|
|
@ -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,14 +363,18 @@ 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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!model.isAdd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Oh($"预甩货可Load明细信息不能为空");
|
|
|
|
if(string.IsNullOrWhiteSpace(model.nominationBatchId))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw Oops.Oh($"改配调度需要提供预甩货调度批次ID");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!model.isAdd && string.IsNullOrWhiteSpace(model.nominationBatchId))
|
|
|
|
if (model.loadDetailIds == null || model.loadDetailIds.Length == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw Oops.Oh($"改配调度需要提供预甩货调度批次ID");
|
|
|
|
throw Oops.Oh($"预甩货可Load明细信息不能为空");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var detailList = _taskRollingNominationDetailInfoRepository.AsQueryable()
|
|
|
|
var detailList = _taskRollingNominationDetailInfoRepository.AsQueryable()
|
|
|
@ -374,10 +400,6 @@ namespace Myshipping.Application
|
|
|
|
Dictionary<string, string> batchDict = shipmentList.Select(a => new { Key = a, BatchId = IDGen.NextID().ToString() })
|
|
|
|
Dictionary<string, string> batchDict = shipmentList.Select(a => new { Key = a, BatchId = IDGen.NextID().ToString() })
|
|
|
|
.ToDictionary(a => a.Key, b => b.BatchId);
|
|
|
|
.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,25 +501,40 @@ namespace Myshipping.Application
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
var withDispatchList = _taskRollingNominationDetailInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
if (withDispatchList.Any(p => p.Dispatch != null
|
|
|
|
.InnerJoin<TaskRollingNominationDispatchInfo>((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID)
|
|
|
|
&& !string.IsNullOrWhiteSpace(p.Dispatch.PK_ID)))
|
|
|
|
.Where((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID && detail.IsDeleted == false
|
|
|
|
|
|
|
|
&& shipmentList.Contains(detail.SHIPMENT) && detail.NOM_ID == nomId
|
|
|
|
|
|
|
|
&& dispatch.IsDeleted == false)
|
|
|
|
|
|
|
|
.Select((detail, dispatch) => new { Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (withDispatchList.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
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 =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var a = info.Detail;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!a.NOM_STATUS_NOTE.Equals("Load", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TaskRollingNominationDispatchInfo dispatchInfo = new TaskRollingNominationDispatchInfo
|
|
|
|
TaskRollingNominationDispatchInfo dispatchInfo = new TaskRollingNominationDispatchInfo
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -506,18 +543,20 @@ namespace Myshipping.Application
|
|
|
|
UpdatedTime = nowDate,
|
|
|
|
UpdatedTime = nowDate,
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
CreatedUserName = UserManager.Name,
|
|
|
|
DETAIL_ID= a.PK_ID,
|
|
|
|
DETAIL_ID = a.PK_ID,
|
|
|
|
NOM_ID= a.NOM_ID,
|
|
|
|
NOM_ID = a.NOM_ID,
|
|
|
|
NOM_SHIP_ID= a.NOM_SHIP_ID,
|
|
|
|
NOM_SHIP_ID = a.NOM_SHIP_ID,
|
|
|
|
IsDeleted= false,
|
|
|
|
IsDeleted = false,
|
|
|
|
STATUS = "WAIT",
|
|
|
|
STATUS = "WAIT",
|
|
|
|
TASK_ID = nomModel.TASK_ID,
|
|
|
|
TASK_ID = nomiInfo.TASK_ID,
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
TenantId = UserManager.TENANT_ID,
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
TenantName = UserManager.TENANT_NAME,
|
|
|
|
BATCH_ID = batchDict[a.SHIPMENT],
|
|
|
|
BATCH_ID = batchDict[a.SHIPMENT],
|
|
|
|
|
|
|
|
CONFIRM_DEAD_LINE = deadLine
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
_taskRollingNominationDispatchInfoRepository.Insert(dispatchInfo);
|
|
|
|
_taskRollingNominationDispatchInfoRepository.Insert(dispatchInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|