diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageSISubmittedService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageSISubmittedService.cs index 463ce967..ddf25e37 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageSISubmittedService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageSISubmittedService.cs @@ -46,5 +46,19 @@ namespace Myshipping.Application /// 截单回执任务主键 /// 返回回执 Task ProcessSISubmitted(string taskPkId); + + /// + /// 获取订舱详情 + /// + /// 任务主键 + /// 返回结果 + Task GetBookingOrderInfo(string taskPKId); + + /// + /// 获取SI反馈信息 + /// + /// 任务主键 + /// 返回结果 + Task GetSIFeedBackInfo(string taskPKId); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index f048a461..fe996c9c 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -2531,7 +2531,14 @@ namespace Myshipping.Application if (bcOrder == null) throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息"); - return await _bookingSlotService.GetSlotCompareResult(bcOrder.BOOKING_SLOT_ID.Value, bcOrder.BATCH_NO); + if(bcOrder.BOOKING_SLOT_ID.HasValue) + { + return await _bookingSlotService.GetSlotCompareResult(bcOrder.BOOKING_SLOT_ID.Value, bcOrder.BATCH_NO); + } + else + { + return new List(); + } } #endregion diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManagePODDischargeGateoutFullService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManagePODDischargeGateoutFullService.cs index faaab653..7b8ac5d5 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManagePODDischargeGateoutFullService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManagePODDischargeGateoutFullService.cs @@ -144,6 +144,7 @@ namespace Myshipping.Application dto.CompleteTime = taskBase.COMPLETE_DATE; dto.NoticeType = dischargeFull.NOTICE_TYPE; dto.NoticeTypeName = dischargeFull.NOTICE_TYPE_NAME; + dto.Carrier = dischargeFull.CARRIER; return dto; }).ToList(); diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageSISubmittedService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageSISubmittedService.cs index bf64d8c2..c25ccd32 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageSISubmittedService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageSISubmittedService.cs @@ -16,6 +16,7 @@ using Myshipping.Application.Service; using Myshipping.Core; using Myshipping.Core.Service; using NPOI.OpenXmlFormats.Dml.Diagram; +using Org.BouncyCastle.Asn1.X9; using RabbitMQ.Client; using System; using System.Collections.Generic; @@ -40,6 +41,7 @@ namespace Myshipping.Application private readonly SqlSugarRepository _taskBaseRepository; private readonly SqlSugarRepository _bookingOrderRepository; private readonly SqlSugarRepository _bookingCtnRepository; + private readonly SqlSugarRepository _bookingOrderContaCargoRepository; private readonly SqlSugarRepository _businessCompareDiffRecordRepository; private readonly SqlSugarRepository _taskFileRepository; private readonly SqlSugarRepository _bookingFileRepository; @@ -61,6 +63,7 @@ namespace Myshipping.Application SqlSugarRepository taskSISubmittedCtnRepository, SqlSugarRepository taskFileRepository, SqlSugarRepository bookingFileRepository, + SqlSugarRepository bookingOrderContaCargoRepository, IBookingValueAddedService bookingValueAddedService, IDjyTenantParamService djyTenantParamService, IBookingOrderService bookingOrderService) { @@ -77,6 +80,7 @@ namespace Myshipping.Application _taskFileRepository = taskFileRepository; _bookingFileRepository = bookingFileRepository; + _bookingOrderContaCargoRepository = bookingOrderContaCargoRepository; } #region 获取截单回执详情 @@ -300,7 +304,8 @@ namespace Myshipping.Application var siCtnList = _taskSISubmittedCtnRepository.AsQueryable().Filter(null, true).Where(a => a.P_PKID == siSubmitted.PK_ID && a.TenantId == UserManager.TENANT_ID).ToList(); var orderInfo = _bookingOrderRepository.AsQueryable().Filter(null, true) - .First(a => a.MBLNO == siSubmitted.MBL_NO && a.IsDeleted == false && a.TenantId == UserManager.TENANT_ID && a.ParentId == 0); + .First(a => ((a.MBLNO == siSubmitted.MBL_NO) || (a.SPLIT_OR_MERGE_FLAG != null && a.SPLIT_OR_MERGE_FLAG == 1 && a.CUSTNO == siSubmitted.MBL_NO)) && a.IsDeleted == false + && a.TenantId == UserManager.TENANT_ID && (a.ParentId == 0 || a.ParentId == null)); if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE",StringComparison.OrdinalIgnoreCase)) { @@ -1064,70 +1069,70 @@ namespace Myshipping.Application } #endregion - /// - /// 获取SI反馈信息 - /// - /// 任务主键 - /// 返回结果 - [HttpGet("/TaskManageSISubmitted/GetSIFeedBackInfo")] - public async Task GetSIFeedBackInfo(string taskPKId) - { - TaskSISubmittedShowDto dto = new TaskSISubmittedShowDto(); + ///// + ///// 获取SI反馈信息 + ///// + ///// 任务主键 + ///// 返回结果 + //[HttpGet("/TaskManageSISubmitted/GetSIFeedBackInfo")] + //public async Task GetSIFeedBackInfo(string taskPKId) + //{ + // TaskSISubmittedShowDto dto = new TaskSISubmittedShowDto(); - var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPKId); + // var taskBase = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPKId); - if (taskBase == null) - throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); + // if (taskBase == null) + // throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); - var siSubmitted = _taskSISubmittedRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID); + // var siSubmitted = _taskSISubmittedRepository.AsQueryable().First(a => a.TASK_ID == taskBase.PK_ID); - if (siSubmitted == null) - throw Oops.Oh($"截单回执主键{taskPKId}无法获取业务信息"); + // if (siSubmitted == null) + // throw Oops.Oh($"截单回执主键{taskPKId}无法获取业务信息"); - var bookOrderList = _bookingOrderRepository.AsQueryable().Filter(null, true) - .InnerJoin((bk, ctn) => bk.Id == ctn.BILLID) - .Where((bk, ctn) => bk.Id == siSubmitted.BOOKING_ID.Value && bk.TenantId == UserManager.TENANT_ID) - .Select((bk, ctn) => new { bk = bk, ctn = ctn }).ToList(); + // var bookOrderList = _bookingOrderRepository.AsQueryable().Filter(null, true) + // .InnerJoin((bk, ctn) => bk.Id == ctn.BILLID) + // .Where((bk, ctn) => bk.Id == siSubmitted.BOOKING_ID.Value && bk.TenantId == UserManager.TENANT_ID) + // .Select((bk, ctn) => new { bk = bk, ctn = ctn }).ToList(); - var orderInfo = bookOrderList.FirstOrDefault().bk; + // var orderInfo = bookOrderList.FirstOrDefault().bk; - //var siFeedBackList = _taskSISubmittedRepository.EntityContext.Queryable() - // .InnerJoin((si, ctn) => si.PK_ID == ctn.P_PKID) - // .Where((si, ctn) => si.TASK_PKID == model.TaskId && si.TenantId == UserManager.TENANT_ID) - // .Select((si, ctn) => new { si = si, ctn = ctn }).ToList(); + // //var siFeedBackList = _taskSISubmittedRepository.EntityContext.Queryable() + // // .InnerJoin((si, ctn) => si.PK_ID == ctn.P_PKID) + // // .Where((si, ctn) => si.TASK_PKID == model.TaskId && si.TenantId == UserManager.TENANT_ID) + // // .Select((si, ctn) => new { si = si, ctn = ctn }).ToList(); - //if (siFeedBackList.Count == 0) - // throw Oops.Oh($"SI反馈信息不存在"); + // //if (siFeedBackList.Count == 0) + // // throw Oops.Oh($"SI反馈信息不存在"); - //var siFeedBackInfo = siFeedBackList.FirstOrDefault().si; + // //var siFeedBackInfo = siFeedBackList.FirstOrDefault().si; - //var resultInfo = siFeedBackInfo.Adapt(); + // //var resultInfo = siFeedBackInfo.Adapt(); - //resultInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt()).ToList(); + // //resultInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt()).ToList(); - //model.BusiInfo = resultInfo; + // //model.BusiInfo = resultInfo; - //if (orderInfo != null) - //{ - // //订舱 - // model.BookingOrder = orderInfo.Adapt(); - //} + // //if (orderInfo != null) + // //{ + // // //订舱 + // // model.BookingOrder = orderInfo.Adapt(); + // //} - ////进行数据比对确认差异字段KEY - //var mainDiff = await InnerCompareMainInfoDiff(orderInfo, siFeedBackInfo); + // ////进行数据比对确认差异字段KEY + // //var mainDiff = await InnerCompareMainInfoDiff(orderInfo, siFeedBackInfo); - //model.SICompareOrderKeyList = mainDiff; + // //model.SICompareOrderKeyList = mainDiff; - //var contaDiff = await InnerCompareContaInfoDiff(bookOrderList.Select(t => t.ctn).ToList(), - // siFeedBackList.Select(t => t.ctn).ToList()); + // //var contaDiff = await InnerCompareContaInfoDiff(bookOrderList.Select(t => t.ctn).ToList(), + // // siFeedBackList.Select(t => t.ctn).ToList()); - //model.SICompareOrderContaKeyList = contaDiff; + // //model.SICompareOrderContaKeyList = contaDiff; - return dto; - } + // return dto; + //} #region 推送BC变更比对 @@ -1299,5 +1304,300 @@ namespace Myshipping.Application return model; } #endregion + + #region 获取订舱详情 + /// + /// 获取订舱详情 + /// + /// 任务主键 + /// 返回结果 + [HttpGet("/TaskManageSISubmitted/GetBookingOrderInfo")] + public async Task GetBookingOrderInfo(string taskPKId) + { + TaskBookingOrderDto model = new TaskBookingOrderDto(); + + string batchNo = IDGen.NextID().ToString(); + try + { + var taskBase = _taskBaseRepository.AsQueryable().Filter(null, true).First(a => a.PK_ID == taskPKId && a.TenantId == UserManager.TENANT_ID); + + if (taskBase == null) + throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); + + var siSubmitted = _taskSISubmittedRepository.AsQueryable().Filter(null, true).First(a => a.TASK_ID == taskBase.PK_ID && a.TenantId == UserManager.TENANT_ID); + + if (siSubmitted == null) + throw Oops.Oh($"截单回执主键{taskPKId}无法获取业务信息"); + + BookingOrder orderInfo = null; + + if (!siSubmitted.BOOKING_ID.HasValue) + { + orderInfo = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => ((a.MBLNO == siSubmitted.MBL_NO) || (a.SPLIT_OR_MERGE_FLAG != null && a.SPLIT_OR_MERGE_FLAG == 1 && a.CUSTNO == siSubmitted.MBL_NO)) && a.IsDeleted == false + && a.TenantId == UserManager.TENANT_ID && (a.ParentId == 0 || a.ParentId == null)); + + if (orderInfo != null) + { + siSubmitted.BOOKING_ID = orderInfo.Id; + + await _taskSISubmittedRepository.AsUpdateable(siSubmitted).UpdateColumns(x => new + { + x.BOOKING_ID + }).ExecuteCommandAsync(); + } + } + else + { + var bookingId = siSubmitted.BOOKING_ID.Value; + orderInfo = _bookingOrderRepository.AsQueryable().Filter(null, true) + .First(a => a.Id == bookingId && a.IsDeleted == false + && a.TenantId == UserManager.TENANT_ID && (a.ParentId == 0 || a.ParentId == null)); + } + + if (orderInfo != null) + { + //订舱 + model = orderInfo.Adapt(); + + var contaList = await _bookingCtnRepository.AsQueryable().Where(x => x.BILLID == orderInfo.Id).ToListAsync(); + + //获取集装箱的主键 + var ctnArg = contaList.Select(t => t.Id).ToArray(); + + //查询集装箱所有的货物信息 + var cargoList = await _bookingOrderContaCargoRepository.AsQueryable() + .Where(x => ctnArg.Contains(x.CTNID.Value)).ToListAsync(); + + _logger.LogInformation("批次={no} 提取货物明细完成 数量={total}", batchNo, cargoList.Count); + + if (cargoList.Count > 0) + { + model.ContaList = contaList.GroupJoin(cargoList, l => l.Id, r => r.CTNID, (l, r) => { + var currList = r.ToList(); + + if (currList.Count > 0) + { + var info = l.Adapt(); + info.CargoList = currList.Adapt>(); + + return info; + } + + return l.Adapt(); + + }).ToList(); + } + else + { + model.ContaList = contaList.Adapt>(); + } + + //任务 + model.TaskBaseInfo = taskBase.Adapt(); + } + + } + catch (Exception ex) + { + throw Oops.Bah("获取订舱详情异常,{0}", ex.Message); + } + return model; + + } + #endregion + + + #region 获取SI反馈信息 + /// + /// 获取SI反馈信息 + /// + /// 任务主键 + /// 返回结果 + [HttpGet("/TaskManageSISubmitted/GetSIFeedBackInfo")] + public async Task GetSIFeedBackInfo(string taskPKId) + { + TaskSIFeedBackResultDto model = new TaskSIFeedBackResultDto(); + + try + { + var taskBase = _taskBaseRepository.AsQueryable().Filter(null, true).First(a => a.PK_ID == taskPKId && a.TenantId == UserManager.TENANT_ID); + + if (taskBase == null) + throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); + + var siFeedBackList = _taskSISubmittedRepository.AsQueryable().Filter(null, true) + .InnerJoin((si, ctn) => si.PK_ID == ctn.P_PKID) + .Where((si, ctn) => si.TASK_ID == model.TaskId && si.TenantId == UserManager.TENANT_ID) + .Select((si, ctn) => new { si = si, ctn = ctn }).ToList(); + + if (siFeedBackList.Count == 0) + throw Oops.Oh($"SI反馈信息不存在"); + + var bookingId = siFeedBackList.FirstOrDefault().si.BOOKING_ID.Value; + + var bookOrderList = _bookingOrderRepository.EntityContext.Queryable() + .InnerJoin((bk, ctn) => bk.Id == ctn.BILLID) + .Where((bk, ctn) => bk.Id == bookingId && bk.TenantId == UserManager.TENANT_ID) + .Select((bk, ctn) => new { bk = bk, ctn = ctn }).ToList(); + + var orderInfo = bookOrderList.FirstOrDefault().bk; + + model.TaskId = taskBase.PK_ID; + + var siFeedBackInfo = siFeedBackList.FirstOrDefault().si; + + var resultInfo = siFeedBackInfo.Adapt(); + + resultInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt()).ToList(); + + model.BusiInfo = resultInfo; + + if (orderInfo != null) + { + //订舱 + model.BookingOrder = orderInfo.Adapt(); + } + + //进行数据比对确认差异字段KEY + var mainDiff = await InnerCompareMainInfoDiff(orderInfo, siFeedBackInfo); + + model.SICompareOrderKeyList = mainDiff; + + var contaDiff = await InnerCompareContaInfoDiff(bookOrderList.Select(t => t.ctn).ToList(), + siFeedBackList.Select(t => t.ctn).ToList()); + + model.SICompareOrderContaKeyList = contaDiff; + } + catch (Exception ex) + { + throw Oops.Bah("获取获取单票账单详情异常,{0}", ex.Message); + } + return model; + } + #endregion + + #region 比较主信息 + /// + /// 比较主信息 + /// + /// 订舱详情 + /// SI反馈详情 + /// 返回差异 + private async Task> InnerCompareMainInfoDiff(BookingOrder bookingOrder, TaskSISubmitted taskSIFeedBackInfo) + { + List resultList = new List(); + + //需要比对的字段 + var compareField = new string[] { "SHIPPER", "CONSIGNEE", "NOTIFYPARTY", "MARKS", "DESCRIPTION", "BLFRT", "SERVICE", "ISSUETYPE", "PORTLOAD", "PORTDISCHARGE", + "TRANSPORT", "DESTINATION", "PKGS", "KGS", "CBM", "KINDPKGS", "THIRDPAYADDR" }; + + var bookProps = typeof(BookingOrder).GetProperties(); + var feedProps = typeof(TaskSIFeedBackInfo).GetProperties(); + + resultList = bookProps.GroupJoin(feedProps, l => l.Name.ToUpper(), + r => r.Name.ToUpper(), (l, r) => + { + if (compareField.Any(x => x.Equals(l.Name, StringComparison.OrdinalIgnoreCase))) + { + var currList = r.ToList(); + + if (currList.Count > 0) + { + var si = r.FirstOrDefault(); + + var bkVal = l.GetValue(bookingOrder); + var siVal = si.GetValue(taskSIFeedBackInfo); + + if (l.PropertyType == typeof(string)) + { + string st1 = (bkVal as string).AdjustString(); + string st2 = (siVal as string).AdjustString(); + + if (!st1.Equals(st2)) + { + return l.Name.ToUpper(); + } + + return string.Empty; + } + else if (l.PropertyType == typeof(int?)) + { + var dt1 = bkVal as int?; + var dt2 = siVal as int?; + + if (!dt1.Equals(dt2)) + { + return l.Name.ToUpper(); + } + + return string.Empty; + } + else if (l.PropertyType == typeof(decimal?)) + { + var dt1 = bkVal as decimal?; + var dt2 = siVal as decimal?; + + if (!dt1.Equals(dt2)) + { + return l.Name.ToUpper(); + } + + return string.Empty; + } + } + + return string.Empty; + } + + return string.Empty; + + }).Where(t => !string.IsNullOrWhiteSpace(t)).ToList(); + + return resultList; + } + #endregion + + #region 比较箱信息 + /// + /// 比较箱信息 + /// + /// 订舱箱信息 + /// SI反馈箱信息 + /// 返回差异 + private async Task> InnerCompareContaInfoDiff(List bookContaList, List siContaList) + { + List resultList = new List(); + + var bookProps = typeof(BookingCtn).GetProperties(); + var feedProps = typeof(TaskSIFeedBackContaInfo).GetProperties(); + + resultList = siContaList.GroupJoin(bookContaList, l => l.CNTRNO, r => r.CNTRNO, (l, r) => + { + var currList = r.ToList(); + + if (currList.Count > 0) + { + var bkCtn = currList.FirstOrDefault(); + + if (!l.KGS.Equals(bkCtn.KGS) + || !l.PKGS.Equals(bkCtn.PKGS) + || !l.SEALNO.Equals(bkCtn.SEALNO) + || !l.CTNALL.Equals(bkCtn.CTNALL) + || !l.CBM.Equals(bkCtn.CBM)) + { + return l.CNTRNO; + } + + return String.Empty; + } + + return l.CNTRNO; + }).Where(t => !string.IsNullOrWhiteSpace(t)).ToList(); + + return resultList; + } + #endregion + } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 1c8d969b..02fb7de1 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -4897,9 +4897,6 @@ namespace Myshipping.Application if (taskInfo == null) Oops.Oh($"任务信息获取失败"); - if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) - Oops.Oh($"任务信息的订舱主键不存在"); - var orderInfo = _bookingOrderRepository.AsQueryable() .First(t => t.Id == long.Parse(taskInfo.BOOK_ORDER_NO));