From f5755a4cf01e03f6c99d0b6e34934e2fae4b5367 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Sat, 28 Jan 2023 10:17:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9SI=E4=B8=8E=E8=AE=A2=E8=88=B1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=AF=94=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManagePlat/Dtos/TaskManageMapper.cs | 10 + .../TaskManagePlat/TaskManageService.cs | 238 ++++++++++++------ 2 files changed, 172 insertions(+), 76 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs index d23d9d13..f1bcd3d1 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs @@ -377,6 +377,16 @@ namespace Myshipping.Application .Map(dest => dest.KindPKGS, src => src.KIND_PKGS) .Map(dest => dest.PKGS, src => src.PKGS) .Map(dest => dest.ThirdPayAddr, src => src.THIRDPAYADDR); + + + config.ForType() + .Map(dest => dest.ContaNo, src => src.CONTA_NO) + .Map(dest => dest.SealNo, src => src.SEAL_NO) + .Map(dest => dest.PKGS, src => src.PKGS) + .Map(dest => dest.KGS, src => src.KGS) + .Map(dest => dest.CBM, src => src.CBM) + .Map(dest => dest.ContaType, src => src.CONTA_TYPE) + .Map(dest => dest.ContaTypeName, src => src.CONTA_TYPE_NAME); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 3a33f458..d8f0f0b4 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -26,6 +26,7 @@ using Npoi.Mapper; using NPOI.HPSF; using NPOI.HSSF.UserModel; using NPOI.POIFS.Crypt.Dsig; +using NPOI.SS.Formula.Eval; using NPOI.SS.Formula.Functions; using NPOI.SS.UserModel; using NPOI.XSSF.Model; @@ -2578,8 +2579,13 @@ namespace Myshipping.Application if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString()) Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); - var orderInfo = _bookingOrderRepository.AsQueryable() - .First(t => t.Id == long.Parse(taskInfo.BOOK_ORDER_NO)); + + var bookOrderList = _bookingOrderRepository.EntityContext.Queryable() + .InnerJoin((bk, ctn) => bk.Id == ctn.BILLID) + .Where((bk, ctn) => bk.Id == long.Parse(taskInfo.BOOK_ORDER_NO) && bk.TenantId == UserManager.TENANT_ID) + .Select((bk, ctn) => new { bk = bk, ctn = ctn }).ToList(); + + var orderInfo = bookOrderList.FirstOrDefault().bk; model.TaskId = taskInfo.PK_ID; @@ -2591,11 +2597,13 @@ namespace Myshipping.Application if (siFeedBackList.Count == 0) Oops.Oh($"SI反馈信息不存在"); - var siFeedBackInfo = siFeedBackList.FirstOrDefault().si.Adapt(); + var siFeedBackInfo = siFeedBackList.FirstOrDefault().si; + + var resultInfo = siFeedBackInfo.Adapt(); - siFeedBackInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt()).ToList(); + resultInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt()).ToList(); - model.BusiInfo = siFeedBackInfo; + model.BusiInfo = resultInfo; if (orderInfo != null) { @@ -2604,6 +2612,14 @@ namespace Myshipping.Application } //进行数据比对确认差异字段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) { @@ -2612,77 +2628,125 @@ namespace Myshipping.Application return model; } -// private async Task InnerCompareDiff() -// { -// var compareField = new string[] { "SHIPPER", "CONSIGNEE", "NOTIFYPARTY", "MARKS", "DESCRIPTION", "BLFRT", "SERVICE", "ISSUETYPE", "PORTLOAD", "PORTDISCHARGE", "TRANSPORT", "DESTINATION", "PKGS", "KGS", "CBM", "KINDPKGS", "THIRDPAYADDR" }; -// var listDiffField = new List(); -// var bookProps = typeof(OP_SEAE_ORDER).GetProperties(); -// var feedProps = typeof(OP_SEAE_SI_FEEDBACK).GetProperties(); -// foreach (var prop in compareField) -// { -// var pBook = bookProps.First(p => p.Name == prop); -// var bookVal = pBook.GetValue(bill.order); -// var pFeed = feedProps.First(p => p.Name == prop); -// var feedVal = pFeed.GetValue(siFeedback); -// if (pBook.PropertyType == typeof(string)) -// { -// string st1 = bookVal as string; -// string st2 = feedVal as string; -// st1 = ProcessString(st1); -// st2 = ProcessString(st2); - -// if (st1 != st2) -// { -// listDiffField.Add(prop); -// } -// } -// else if (pBook.PropertyType == typeof(int?)) -// { -// var dt1 = bookVal as int?; -// var dt2 = feedVal as int?; -// if (dt1 != dt2) -// { -// listDiffField.Add(prop); -// } -// } -// else if (pBook.PropertyType == typeof(decimal?)) -// { -// var dt1 = bookVal as decimal?; -// var dt2 = feedVal as decimal?; -// if (dt1 != dt2) -// { -// listDiffField.Add(prop); -// } -// } -// } - -// ViewData["DiffFields"] = listDiffField; -//#endregion - -// #region 箱信息对比 -// var listDiffCtn = new List(); -// var ctns = bookingDB.Ctns.Where(c => c.ORDNO == bill.order.ORDNO).ToList(); -// foreach (var cc in feedbackCtn) -// { -// var ctnB = ctns.FirstOrDefault(c => c.CNTRNO == cc.CNTRNO); -// if (ctnB == null) -// { -// listDiffCtn.Add(cc.CNTRNO); -// } -// else -// { -// if (cc.KGS != ctnB.KGS -// || cc.PKGS != ctnB.PKGS -// || cc.SEALNO != ctnB.SEALNO -// || cc.CTNALL != ctnB.CTNALL -// || cc.CBM != ctnB.CBM) -// { -// listDiffCtn.Add(cc.CNTRNO); -// } -// } -// } -// ViewData["DiffCtns"] = listDiffCtn; -// } + #region 比较主信息 + /// + /// 比较主信息 + /// + /// 订舱详情 + /// SI反馈详情 + /// 返回差异 + private async Task> InnerCompareMainInfoDiff(BookingOrder bookingOrder, TaskSIFeedBackInfo 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(); + + siContaList.GroupJoin(bookContaList, l => l.CONTA_NO, 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.SEAL_NO.Equals(bkCtn.SEALNO) + || !l.CONTA_TYPE.Equals(bkCtn.CTNALL) + || !l.CBM.Equals(bkCtn.CBM)) + { + return l.CONTA_NO; + } + } + + return l.CONTA_NO; + }); + + return resultList; + } + #endregion } #region 样本业务提取帮助类 @@ -2709,4 +2773,26 @@ namespace Myshipping.Application } } #endregion + + public static class CompareObjExtension + { + /// + /// 整理文本数据 + /// + /// 文本 + /// + public static string AdjustString(this string str) + { + if (string.IsNullOrWhiteSpace(str)) + return str; + + var rtn = str.Replace("\r\n", "\n").Trim(); + if (rtn.EndsWith("\n")) + { + rtn = rtn.Substring(0, rtn.Length - 1); + } + + return rtn; + } + } }