修改预甩货任务

optimize
jianghaiqing 10 months ago
parent 2f53f2e7a0
commit a87273b940

@ -67,6 +67,16 @@ namespace Myshipping.Application
/// Load列表 /// Load列表
/// </summary> /// </summary>
public List<TaskRollingNominationShipDetailShowDto> LoadDetailList { get; set; } public List<TaskRollingNominationShipDetailShowDto> LoadDetailList { get; set; }
/// <summary>
/// 合计单票汇总合计箱型箱量
/// </summary>
public string TotalPreBillCtnStat { get; set; }
/// <summary>
/// 合计load汇总合计箱型箱量
/// </summary>
public string TotalLoadCtnStat { get; set; }
} }
/// <summary> /// <summary>
@ -291,5 +301,15 @@ namespace Myshipping.Application
/// 预甩货调度主键 /// 预甩货调度主键
/// </summary> /// </summary>
public string NominationDispatchId { get; set; } public string NominationDispatchId { get; set; }
/// <summary>
/// 箱备注(主要)
/// </summary>
public string CtnNote { get; set; }
/// <summary>
/// 明细主键
/// </summary>
public string PKId { get; set; }
} }
} }

@ -940,7 +940,8 @@ namespace Myshipping.Application
.Map(dest => dest.BBYMAIL, src => src.BBYMAIL) .Map(dest => dest.BBYMAIL, src => src.BBYMAIL)
.Map(dest => dest.CtnCode, src => src.CTNCODE) .Map(dest => dest.CtnCode, src => src.CTNCODE)
.Map(dest => dest.CtnAll, src => src.CTNALL) .Map(dest => dest.CtnAll, src => src.CTNALL)
.Map(dest => dest.CtnNum, src => src.CTNNUM); .Map(dest => dest.CtnNum, src => src.CTNNUM)
.Map(dest => dest.PKId, src => src.PK_ID);
} }
} }

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public interface ITaskManageAccessShareLinkService
{
/// <summary>
/// 访问链接
/// </summary>
/// <param name="Url">请求链接</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> AccessRollingNomination(string shareKey);
}
}

@ -37,11 +37,6 @@ namespace Myshipping.Application
Task<TaskManageOrderResultDto> ValidateShareLink(string Url); Task<TaskManageOrderResultDto> ValidateShareLink(string Url);
/// <summary>
/// 访问链接
/// </summary>
/// <param name="Url">请求链接</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> QueryShareLink(string Url);
} }
} }

@ -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
2ID 2ID
3IDID 3IDID
*/ */
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);
}
}); });
} }

@ -112,6 +112,7 @@ namespace Myshipping.Application
private readonly ISysDataUserMenu _sysDataUserMenuService; private readonly ISysDataUserMenu _sysDataUserMenuService;
private readonly INamedServiceProvider<IBookingOrderService> _namedBookingOrderServiceProvider; private readonly INamedServiceProvider<IBookingOrderService> _namedBookingOrderServiceProvider;
private readonly INamedServiceProvider<ITaskManageRollingNominationService> _namedRollingNominationServiceProvider;
const string CONST_WEB_ACCOUNT_TYPE = "CmaWeb"; const string CONST_WEB_ACCOUNT_TYPE = "CmaWeb";
const string CONST_BOOK_ORIGINAL_DOWN_URL_CODE = "bookOriginalDownUrl"; const string CONST_BOOK_ORIGINAL_DOWN_URL_CODE = "bookOriginalDownUrl";
@ -157,6 +158,7 @@ namespace Myshipping.Application
IDjyWebsiteAccountConfigService webAccountConfig, IDjyWebsiteAccountConfigService webAccountConfig,
ISysCacheService cache, ISysCacheService cache,
ISysDataUserMenu sysDataUserMenuService, ISysDataUserMenu sysDataUserMenuService,
INamedServiceProvider<ITaskManageRollingNominationService> namedRollingNominationServiceProvider,
ILogger<BookingOrderService> logger) ILogger<BookingOrderService> logger)
{ {
_taskBaseInfoRepository = taskBaseInfoRepository; _taskBaseInfoRepository = taskBaseInfoRepository;
@ -190,6 +192,7 @@ namespace Myshipping.Application
_taskRollingNominationDetailInfoRepository = taskRollingNominationDetailInfoRepository; _taskRollingNominationDetailInfoRepository = taskRollingNominationDetailInfoRepository;
_namedBookingOrderServiceProvider = namedBookingOrderServiceProvider; _namedBookingOrderServiceProvider = namedBookingOrderServiceProvider;
_namedRollingNominationServiceProvider = namedRollingNominationServiceProvider;
_sysDataUserMenuService = sysDataUserMenuService; _sysDataUserMenuService = sysDataUserMenuService;
@ -881,7 +884,14 @@ namespace Myshipping.Application
}); });
} }
//异步生成调度
var rollNominationService = _namedRollingNominationServiceProvider
.GetService<ITransient>(nameof(TaskManageRollingNominationService));
var dispatchRlt = await rollNominationService.DispatchRollingNomination(new RollingNominationDispatchRequestDto {
isAdd = true,
nominationId = rollingNomination.PK_ID
});
} }
#endregion #endregion

Loading…
Cancel
Save