|
|
@ -1,4 +1,6 @@
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
using Mapster;
|
|
|
|
using Mapster;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
@ -22,7 +24,7 @@ namespace Myshipping.Application
|
|
|
|
/// 预甩货通知
|
|
|
|
/// 预甩货通知
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
[ApiDescriptionSettings("Application", Name = "TaskManageRollingNomination", Order = 10)]
|
|
|
|
[ApiDescriptionSettings("Application", Name = "TaskManageRollingNomination", Order = 10)]
|
|
|
|
public class TaskManageRollingNominationService : ITaskManageRollingNominationService, IDynamicApiController
|
|
|
|
public class TaskManageRollingNominationService : ITaskManageRollingNominationService, IDynamicApiController, ITransient
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
private readonly ILogger<TaskManageRollingNominationService> _logger;
|
|
|
|
private readonly ILogger<TaskManageRollingNominationService> _logger;
|
|
|
@ -177,6 +179,8 @@ namespace Myshipping.Application
|
|
|
|
&& (string.IsNullOrWhiteSpace(dispatch.PK_ID) || (!string.IsNullOrWhiteSpace(dispatch.PK_ID) && dispatch.IsDeleted == false)))
|
|
|
|
&& (string.IsNullOrWhiteSpace(dispatch.PK_ID) || (!string.IsNullOrWhiteSpace(dispatch.PK_ID) && dispatch.IsDeleted == false)))
|
|
|
|
.Select((detail, dispatch) => new { Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
.Select((detail, dispatch) => new { Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Tuple<string,int>> tuples = new List<Tuple<string,int>>();
|
|
|
|
|
|
|
|
|
|
|
|
model.PreBillList = withDispatchList.Where(a=>
|
|
|
|
model.PreBillList = withDispatchList.Where(a=>
|
|
|
|
a.Dispatch != null || ((a.Dispatch == null || string.IsNullOrWhiteSpace(a.Dispatch.PK_ID))
|
|
|
|
a.Dispatch != null || ((a.Dispatch == null || string.IsNullOrWhiteSpace(a.Dispatch.PK_ID))
|
|
|
|
&& !a.Detail.NOM_STATUS_NOTE.Equals("Load",StringComparison.OrdinalIgnoreCase)))
|
|
|
|
&& !a.Detail.NOM_STATUS_NOTE.Equals("Load",StringComparison.OrdinalIgnoreCase)))
|
|
|
@ -192,9 +196,14 @@ namespace Myshipping.Application
|
|
|
|
var preBillDetail = preBillArg.FirstOrDefault().Detail;
|
|
|
|
var preBillDetail = preBillArg.FirstOrDefault().Detail;
|
|
|
|
var preBillDispatch = preBillArg.FirstOrDefault().Dispatch;
|
|
|
|
var preBillDispatch = preBillArg.FirstOrDefault().Dispatch;
|
|
|
|
|
|
|
|
|
|
|
|
string ctnStat = string.Join(",", preBillArg.GroupBy(x => x.Detail.CTNALL)
|
|
|
|
var cStaticlst = preBillArg.GroupBy(x => x.Detail.CTNALL)
|
|
|
|
.Select(x =>
|
|
|
|
.Select(x =>
|
|
|
|
$"{x.Key}*{x.Sum(t => t.Detail.CTNNUM)}").ToArray());
|
|
|
|
new { Key = x.Key, Num = x.Sum(t => t.Detail.CTNNUM) }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string ctnStat = string.Join(",", cStaticlst.Select(x =>
|
|
|
|
|
|
|
|
$"{x.Key}*{x.Num}").ToArray());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cStaticlst.ForEach(y => tuples.Add(new Tuple<string, int>(y.Key, y.Num)));
|
|
|
|
|
|
|
|
|
|
|
|
TaskRollingNominationShipPreBillShowDto preBillInfo = new TaskRollingNominationShipPreBillShowDto
|
|
|
|
TaskRollingNominationShipPreBillShowDto preBillInfo = new TaskRollingNominationShipPreBillShowDto
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -219,7 +228,7 @@ namespace Myshipping.Application
|
|
|
|
UserOpinionTxt = preBillDispatch?.USER_OPINION_TXT,
|
|
|
|
UserOpinionTxt = preBillDispatch?.USER_OPINION_TXT,
|
|
|
|
BatchId = preBillDispatch?.BATCH_ID,
|
|
|
|
BatchId = preBillDispatch?.BATCH_ID,
|
|
|
|
BookingId = preBillDetail.BOOKING_ID,
|
|
|
|
BookingId = preBillDetail.BOOKING_ID,
|
|
|
|
GroupName = $"CUST_{idx + 1}",
|
|
|
|
GroupName = preBillDetail.CUSTOMERID.HasValue?$"CUST_{idx + 1}":"",
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return preBillInfo;
|
|
|
|
return preBillInfo;
|
|
|
@ -234,6 +243,20 @@ namespace Myshipping.Application
|
|
|
|
&& a.Detail.NOM_STATUS_NOTE.Equals("Load", StringComparison.OrdinalIgnoreCase))
|
|
|
|
&& a.Detail.NOM_STATUS_NOTE.Equals("Load", StringComparison.OrdinalIgnoreCase))
|
|
|
|
.Select(a => a.Detail.Adapt<TaskRollingNominationShipDetailShowDto>()).ToList();
|
|
|
|
.Select(a => a.Detail.Adapt<TaskRollingNominationShipDetailShowDto>()).ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(tuples.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
model.TotalPreBillCtnStat = string.Join(",", tuples.GroupBy(x => x.Item1)
|
|
|
|
|
|
|
|
.Select(x =>
|
|
|
|
|
|
|
|
$"{x.Key}*{x.Sum(t => t.Item2)}").ToArray());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (model.LoadDetailList.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
model.TotalLoadCtnStat = string.Join(",", model.LoadDetailList.GroupBy(x => x.CtnAll)
|
|
|
|
|
|
|
|
.Select(x =>
|
|
|
|
|
|
|
|
$"{x.Key}*{x.Sum(t => t.CtnNum)}").ToArray());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -249,13 +272,23 @@ namespace Myshipping.Application
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 生成预甩货客户访问链接
|
|
|
|
/// 生成预甩货客户访问链接
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="taskPkIds">预甩货任务主键组</param>
|
|
|
|
/// <param name="nominationDispatchIds">预甩货调度主键组</param>
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
[HttpPost("/TaskManageRollingNomination/CreateShareLink")]
|
|
|
|
[HttpPost("/TaskManageRollingNomination/CreateShareLink")]
|
|
|
|
public async Task<TaskManageOrderResultDto> CreateShareLink([FromQuery] string[] taskPkIds)
|
|
|
|
public async Task<TaskManageOrderResultDto> CreateShareLink([FromBody] string[] nominationDispatchIds)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
|
|
|
result.msg = $"生成预甩货客户访问链接异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -264,13 +297,23 @@ namespace Myshipping.Application
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 取消预甩货客户访问链接
|
|
|
|
/// 取消预甩货客户访问链接
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="taskPkIds">预甩货任务主键组</param>
|
|
|
|
/// <param name="nominationDispatchIds">预甩货调度主键组</param>
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
[HttpPost("/TaskManageRollingNomination/CancelShareLink")]
|
|
|
|
[HttpPost("/TaskManageRollingNomination/CancelShareLink")]
|
|
|
|
public async Task<TaskManageOrderResultDto> CancelShareLink(string[] taskPkIds)
|
|
|
|
public async Task<TaskManageOrderResultDto> CancelShareLink([FromBody] string[] nominationDispatchIds)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
|
|
|
result.msg = $"取消预甩货客户访问链接异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -279,13 +322,23 @@ namespace Myshipping.Application
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 推送预甩货客户访问链接
|
|
|
|
/// 推送预甩货客户访问链接
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="taskPkIds">预甩货任务主键组</param>
|
|
|
|
/// <param name="nominationDispatchId">预甩货任务主键组</param>
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
[HttpPost("/TaskManageRollingNomination/PushShareLink")]
|
|
|
|
[HttpPost("/TaskManageRollingNomination/PushShareLink")]
|
|
|
|
public async Task<TaskManageOrderResultDto> PushShareLink(string[] taskPkIds)
|
|
|
|
public async Task<TaskManageOrderResultDto> PushShareLink([FromBody] string[] nominationDispatchId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
|
|
|
result.msg = $"推送预甩货客户访问链接异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -294,14 +347,254 @@ namespace Myshipping.Application
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 生成预甩货调度
|
|
|
|
/// 生成预甩货调度
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="nominationShipId">预甩货船信息主键</param>
|
|
|
|
/// <param name="model">生成预甩货调度请求</param>
|
|
|
|
/// <param name="loadDetailIds">预甩货可Load明细信息主键组</param>
|
|
|
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
[HttpPost("/TaskManageRollingNomination/DispatchRollingNomination")]
|
|
|
|
[HttpPost("/TaskManageRollingNomination/DispatchRollingNomination")]
|
|
|
|
public async Task<TaskManageOrderResultDto> DispatchRollingNomination(string nominationShipId, string[] loadDetailIds)
|
|
|
|
public async Task<TaskManageOrderResultDto> DispatchRollingNomination([FromBody] RollingNominationDispatchRequestDto model)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
1、如果调度ID不为空,标识选择新的明细替换原有的调度。
|
|
|
|
|
|
|
|
(1)首先匹配所选的箱型箱量是否一致,装货港、卸货港必需一致,不满足不能进行生成调度。
|
|
|
|
|
|
|
|
(2)删除原调度,生成新调度。
|
|
|
|
|
|
|
|
2、如果调度ID为空,标识是新增调度。
|
|
|
|
|
|
|
|
3、没有订舱ID或委托单位ID的数据不能生成调度。
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!model.isAdd)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(string.IsNullOrWhiteSpace(model.nominationBatchId))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"改配调度需要提供预甩货调度批次ID");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (model.loadDetailIds == null || model.loadDetailIds.Length == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货可Load明细信息不能为空");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var detailList = _taskRollingNominationDetailInfoRepository.AsQueryable()
|
|
|
|
|
|
|
|
.Where(a => model.loadDetailIds.Contains(a.PK_ID) && a.IsDeleted == false).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (detailList.Count != model.loadDetailIds.Length)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货明细部分获取失败,请重新获取预甩货明细");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (detailList.Any(a => !a.BOOKING_ID.HasValue || !a.CUSTOMERID.HasValue))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货明细存在未对应订舱的记录,不能生成调度");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nomId = detailList.FirstOrDefault().NOM_ID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nomModel = _taskRollingNominationInfoRepository.AsQueryable()
|
|
|
|
|
|
|
|
.First(a => a.PK_ID == nomId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var shipmentList = detailList.Select(a => a.SHIPMENT).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> batchDict = shipmentList.Select(a => new { Key = a, BatchId = IDGen.NextID().ToString() })
|
|
|
|
|
|
|
|
.ToDictionary(a => a.Key, b => b.BatchId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<TaskRollingNominationDispatchInfo> dispatchList = new List<TaskRollingNominationDispatchInfo>();
|
|
|
|
|
|
|
|
List<TaskRollingNominationDetailInfo> withDispatchDetailList = new List<TaskRollingNominationDetailInfo>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var withDispatchList = _taskRollingNominationDetailInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
|
|
|
.InnerJoin<TaskRollingNominationDispatchInfo>((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID)
|
|
|
|
|
|
|
|
.Where((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID && detail.IsDeleted == false
|
|
|
|
|
|
|
|
&& dispatch.IsDeleted == false && dispatch.BATCH_ID == model.nominationBatchId)
|
|
|
|
|
|
|
|
.Select((detail, dispatch) => new { Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (withDispatchList.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
withDispatchDetailList = withDispatchList.Select(a => a.Detail)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dispatchList.Count == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货调度获取失败,无法改配");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果原调度对应的明细含有本次提交的明细,不允许改配调度
|
|
|
|
|
|
|
|
if (withDispatchDetailList.Any(a =>
|
|
|
|
|
|
|
|
model.loadDetailIds.Any(b => b == a.PK_ID)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货调度获取失败,提交明细已生成调度,无法改配");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//需要匹配箱型箱量
|
|
|
|
|
|
|
|
var origCtnStat = string.Join(",", withDispatchDetailList
|
|
|
|
|
|
|
|
.GroupBy(a => a.CTNALL).OrderBy(a => a.Key)
|
|
|
|
|
|
|
|
.Select(a => $"{a.Key}*{a.Sum(b => b.CTNNUM)}").ToArray());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detailList = _taskRollingNominationDetailInfoRepository.AsQueryable()
|
|
|
|
|
|
|
|
.Where(a => shipmentList.Contains(a.SHIPMENT) && a.IsDeleted == false && a.NOM_ID == nomId).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var targetCtnStat = string.Join(",", detailList
|
|
|
|
|
|
|
|
.GroupBy(a => a.CTNALL).OrderBy(a => a.Key)
|
|
|
|
|
|
|
|
.Select(a => $"{a.Key}*{a.Sum(b => b.CTNNUM)}").ToArray());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果箱型箱量不一致不能改配
|
|
|
|
|
|
|
|
if (!origCtnStat.Equals(targetCtnStat))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货调度获取失败,提交明细箱型箱量于被改配调度不一致,无法改配");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var origShip = withDispatchDetailList.FirstOrDefault();
|
|
|
|
|
|
|
|
var targetShip = detailList.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var origKey = $"{origShip.PLACEOF_RECEIPT}_{origShip.LOADPORT_NAME}_{origShip.DISCHARGEPORT_NAME}_{origShip.PLACEOF_DELIVERY}";
|
|
|
|
|
|
|
|
var targeKey = $"{targetShip.PLACEOF_RECEIPT}_{targetShip.LOADPORT_NAME}_{targetShip.DISCHARGEPORT_NAME}_{targetShip.PLACEOF_DELIVERY}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//收货地、装货港、卸货港、交货地必需一致
|
|
|
|
|
|
|
|
if (!origKey.Equals(targeKey))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货调度获取失败,提交明细收货地、装货港、卸货港、交货地被改配调度不一致,无法改配");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//删除原调度
|
|
|
|
|
|
|
|
withDispatchList.ForEach(async a =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
a.Dispatch.IsDeleted = true;
|
|
|
|
|
|
|
|
a.Dispatch.UpdatedTime = nowDate;
|
|
|
|
|
|
|
|
a.Dispatch.UpdatedUserId = UserManager.UserId;
|
|
|
|
|
|
|
|
a.Dispatch.UpdatedUserName = UserManager.Name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _taskRollingNominationDispatchInfoRepository.AsUpdateable(a.Dispatch)
|
|
|
|
|
|
|
|
.UpdateColumns(it => new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
it.IsDeleted,
|
|
|
|
|
|
|
|
it.UpdatedTime,
|
|
|
|
|
|
|
|
it.UpdatedUserId,
|
|
|
|
|
|
|
|
it.UpdatedUserName
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//写入新调度
|
|
|
|
|
|
|
|
detailList.ForEach(a =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TaskRollingNominationDispatchInfo dispatchInfo = new TaskRollingNominationDispatchInfo
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
|
|
|
UpdatedTime = nowDate,
|
|
|
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
|
|
|
DETAIL_ID = a.PK_ID,
|
|
|
|
|
|
|
|
NOM_ID = a.NOM_ID,
|
|
|
|
|
|
|
|
NOM_SHIP_ID = a.NOM_SHIP_ID,
|
|
|
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
|
|
|
STATUS = "WAIT",
|
|
|
|
|
|
|
|
TASK_ID = nomModel.TASK_ID,
|
|
|
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
|
|
|
BATCH_ID = batchDict[a.SHIPMENT],
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_taskRollingNominationDispatchInfoRepository.Insert(dispatchInfo);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var withDispatchList =
|
|
|
|
|
|
|
|
_taskRollingNominationInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
|
|
|
.InnerJoin<TaskRollingNominationDetailInfo>((nom, detail) => nom.PK_ID == detail.NOM_ID)
|
|
|
|
|
|
|
|
.LeftJoin<TaskRollingNominationDispatchInfo>((nom, detail, dispatch) =>
|
|
|
|
|
|
|
|
detail.PK_ID == dispatch.DETAIL_ID && dispatch.IsDeleted == false)
|
|
|
|
|
|
|
|
.Where((nom, detail, dispatch) =>
|
|
|
|
|
|
|
|
detail.IsDeleted == false
|
|
|
|
|
|
|
|
&& detail.NOM_ID == model.nominationId)
|
|
|
|
|
|
|
|
.Select((nom, detail, dispatch) =>
|
|
|
|
|
|
|
|
new { Nom = nom, Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (withDispatchList.Any(p => p.Dispatch != null
|
|
|
|
|
|
|
|
&& !string.IsNullOrWhiteSpace(p.Dispatch.PK_ID)))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货明细已生成调度不能重复");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nomiInfo = withDispatchList.FirstOrDefault().Nom;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var shipmentList = withDispatchList
|
|
|
|
|
|
|
|
.Select(a => a.Detail.SHIPMENT)
|
|
|
|
|
|
|
|
.Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> batchDict = shipmentList.Select(a => new { Key = a, BatchId = IDGen.NextID().ToString() })
|
|
|
|
|
|
|
|
.ToDictionary(a => a.Key, b => b.BatchId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime deadLine = nomiInfo.CONFIRM_DEAD_LINE.Value.AddHours(2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//开始写入调度
|
|
|
|
|
|
|
|
withDispatchList.ForEach(info =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var a = info.Detail;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!a.NOM_STATUS_NOTE.Equals("Load", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TaskRollingNominationDispatchInfo dispatchInfo = new TaskRollingNominationDispatchInfo
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
|
|
|
CreatedTime = nowDate,
|
|
|
|
|
|
|
|
UpdatedTime = nowDate,
|
|
|
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
|
|
|
|
DETAIL_ID = a.PK_ID,
|
|
|
|
|
|
|
|
NOM_ID = a.NOM_ID,
|
|
|
|
|
|
|
|
NOM_SHIP_ID = a.NOM_SHIP_ID,
|
|
|
|
|
|
|
|
IsDeleted = false,
|
|
|
|
|
|
|
|
STATUS = "WAIT",
|
|
|
|
|
|
|
|
TASK_ID = nomiInfo.TASK_ID,
|
|
|
|
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
|
|
|
|
BATCH_ID = batchDict[a.SHIPMENT],
|
|
|
|
|
|
|
|
CONFIRM_DEAD_LINE = deadLine
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_taskRollingNominationDispatchInfoRepository.Insert(dispatchInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
|
|
|
result.msg = "成功";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
|
|
|
result.msg = $"生成预甩货调度异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 刷新预甩货对应订舱
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 刷新预甩货对应订舱
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="detailPkIds">预甩货明细任务主键组</param>
|
|
|
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
|
|
|
[HttpPost("/TaskManageRollingNomination/RefreshBookingOrder")]
|
|
|
|
|
|
|
|
public async Task<TaskManageOrderResultDto> RefreshBookingOrder([FromBody] string[] detailPkIds)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
|
|
|
result.msg = $"刷新预甩货对应订舱异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -317,6 +610,16 @@ namespace Myshipping.Application
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
|
|
|
result.msg = $"推送预甩货客户访问链接异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -332,6 +635,30 @@ namespace Myshipping.Application
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var withDispatchList =
|
|
|
|
|
|
|
|
_taskRollingNominationInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
|
|
|
.InnerJoin<TaskRollingNominationDetailInfo>((nom,detail)=> nom.PK_ID == detail.NOM_ID)
|
|
|
|
|
|
|
|
.LeftJoin<TaskRollingNominationDispatchInfo>((nom,detail, dispatch) =>
|
|
|
|
|
|
|
|
detail.PK_ID == dispatch.DETAIL_ID && dispatch.IsDeleted == false)
|
|
|
|
|
|
|
|
.Where((nom,detail, dispatch) =>
|
|
|
|
|
|
|
|
nom.TASK_ID == taskPkId && detail.IsDeleted == false && string.IsNullOrWhiteSpace(dispatch.TASK_ID))
|
|
|
|
|
|
|
|
.Select((nom, detail, dispatch) => new { Detail = detail}).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (withDispatchList.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.ext = withDispatchList.Select(a => a.Detail.Adapt<TaskRollingNominationShipDetailShowDto>()).ToList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
|
|
|
result.msg = $"推送预甩货客户访问链接异常,原因:{ex.Message}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|