|
|
@ -1,4 +1,5 @@
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
|
|
|
using Furion.DistributedIDGenerator;
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
using Mapster;
|
|
|
|
using Mapster;
|
|
|
@ -23,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;
|
|
|
@ -178,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)))
|
|
|
@ -193,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
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -220,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;
|
|
|
@ -235,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)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -341,43 +363,43 @@ namespace Myshipping.Application
|
|
|
|
2、如果调度ID为空,标识是新增调度。
|
|
|
|
2、如果调度ID为空,标识是新增调度。
|
|
|
|
3、没有订舱ID或委托单位ID的数据不能生成调度。
|
|
|
|
3、没有订舱ID或委托单位ID的数据不能生成调度。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (model.loadDetailIds == null || model.loadDetailIds.Length == 0)
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货可Load明细信息不能为空");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!model.isAdd && string.IsNullOrWhiteSpace(model.nominationBatchId))
|
|
|
|
if (!model.isAdd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Oh($"改配调度需要提供预甩货调度批次ID");
|
|
|
|
if(string.IsNullOrWhiteSpace(model.nominationBatchId))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"改配调度需要提供预甩货调度批次ID");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var detailList = _taskRollingNominationDetailInfoRepository.AsQueryable()
|
|
|
|
if (model.loadDetailIds == null || model.loadDetailIds.Length == 0)
|
|
|
|
.Where(a => model.loadDetailIds.Contains(a.PK_ID) && a.IsDeleted == false).ToList();
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货可Load明细信息不能为空");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (detailList.Count != model.loadDetailIds.Length)
|
|
|
|
var detailList = _taskRollingNominationDetailInfoRepository.AsQueryable()
|
|
|
|
{
|
|
|
|
.Where(a => model.loadDetailIds.Contains(a.PK_ID) && a.IsDeleted == false).ToList();
|
|
|
|
throw Oops.Oh($"预甩货明细部分获取失败,请重新获取预甩货明细");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (detailList.Any(a => !a.BOOKING_ID.HasValue || !a.CUSTOMERID.HasValue))
|
|
|
|
if (detailList.Count != model.loadDetailIds.Length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Oh($"预甩货明细存在未对应订舱的记录,不能生成调度");
|
|
|
|
throw Oops.Oh($"预甩货明细部分获取失败,请重新获取预甩货明细");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var nomId = detailList.FirstOrDefault().NOM_ID;
|
|
|
|
if (detailList.Any(a => !a.BOOKING_ID.HasValue || !a.CUSTOMERID.HasValue))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"预甩货明细存在未对应订舱的记录,不能生成调度");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var nomModel = _taskRollingNominationInfoRepository.AsQueryable()
|
|
|
|
var nomId = detailList.FirstOrDefault().NOM_ID;
|
|
|
|
.First(a => a.PK_ID == nomId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var shipmentList = detailList.Select(a => a.SHIPMENT).Distinct().ToList();
|
|
|
|
var nomModel = _taskRollingNominationInfoRepository.AsQueryable()
|
|
|
|
|
|
|
|
.First(a => a.PK_ID == nomId);
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> batchDict = shipmentList.Select(a => new { Key = a, BatchId = IDGen.NextID().ToString() })
|
|
|
|
var shipmentList = detailList.Select(a => a.SHIPMENT).Distinct().ToList();
|
|
|
|
.ToDictionary(a => a.Key, b => b.BatchId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, string> batchDict = shipmentList.Select(a => new { Key = a, BatchId = IDGen.NextID().ToString() })
|
|
|
|
|
|
|
|
.ToDictionary(a => a.Key, b => b.BatchId);
|
|
|
|
|
|
|
|
|
|
|
|
DateTime nowDate = DateTime.Now;
|
|
|
|
|
|
|
|
if (!model.isAdd)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<TaskRollingNominationDispatchInfo> dispatchList = new List<TaskRollingNominationDispatchInfo>();
|
|
|
|
List<TaskRollingNominationDispatchInfo> dispatchList = new List<TaskRollingNominationDispatchInfo>();
|
|
|
|
List<TaskRollingNominationDetailInfo> withDispatchDetailList = new List<TaskRollingNominationDetailInfo>();
|
|
|
|
List<TaskRollingNominationDetailInfo> withDispatchDetailList = new List<TaskRollingNominationDetailInfo>();
|
|
|
|
|
|
|
|
|
|
|
@ -479,45 +501,62 @@ namespace Myshipping.Application
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var withDispatchList =
|
|
|
|
var withDispatchList = _taskRollingNominationDetailInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
_taskRollingNominationInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
.InnerJoin<TaskRollingNominationDispatchInfo>((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID)
|
|
|
|
.InnerJoin<TaskRollingNominationDetailInfo>((nom, detail) => nom.PK_ID == detail.NOM_ID)
|
|
|
|
.Where((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID && detail.IsDeleted == false
|
|
|
|
.LeftJoin<TaskRollingNominationDispatchInfo>((nom, detail, dispatch) =>
|
|
|
|
&& shipmentList.Contains(detail.SHIPMENT) && detail.NOM_ID == nomId
|
|
|
|
detail.PK_ID == dispatch.DETAIL_ID && dispatch.IsDeleted == false)
|
|
|
|
&& dispatch.IsDeleted == false)
|
|
|
|
.Where((nom, detail, dispatch) =>
|
|
|
|
.Select((detail, dispatch) => new { Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
detail.IsDeleted == false
|
|
|
|
|
|
|
|
&& detail.NOM_ID == model.nominationId)
|
|
|
|
if (withDispatchList.Count > 0)
|
|
|
|
.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($"预甩货明细已生成调度不能重复");
|
|
|
|
throw Oops.Oh($"预甩货明细已生成调度不能重复");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
detailList = _taskRollingNominationDetailInfoRepository.AsQueryable()
|
|
|
|
var nomiInfo = withDispatchList.FirstOrDefault().Nom;
|
|
|
|
.Where(a => shipmentList.Contains(a.SHIPMENT) && a.IsDeleted == false && a.NOM_ID == nomId).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//开始写入调度
|
|
|
|
//开始写入调度
|
|
|
|
detailList.ForEach(a =>
|
|
|
|
withDispatchList.ForEach(info =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskRollingNominationDispatchInfo dispatchInfo = new TaskRollingNominationDispatchInfo
|
|
|
|
var a = info.Detail;
|
|
|
|
{
|
|
|
|
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|