From ddf73c2315cc23db86c500501e52ea12114f3be6 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 19 Jan 2023 14:34:19 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=91=E7=9A=84?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=EF=BC=8C=E6=9F=A5=E8=AF=A2=E6=88=91=E7=9A=84?= =?UTF-8?q?SI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManagePlat/Dtos/TaskManageMapper.cs | 24 +++ .../Dtos/TaskSIFeedBackResultBusiDto.cs | 111 +++++++++++++ .../Dtos/TaskSIFeedBackResultContaDto.cs | 56 +++++++ .../Dtos/TaskSIFeedBackResultDto.cs | 40 +++++ .../Interface/ITaskManageService.cs | 18 ++ .../TaskManagePlat/TaskManageService.cs | 156 +++++++++++++++++- 6 files changed, 404 insertions(+), 1 deletion(-) create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultBusiDto.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultContaDto.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultDto.cs diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs index 99328ed7..d23d9d13 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs @@ -354,6 +354,30 @@ namespace Myshipping.Application .Map(dest => dest.CreatedUserName, src => src.CreatedUserName) .Map(dest => dest.UpdatedUserId, src => src.UpdatedUserId.ToString()) .Map(dest => dest.UpdatedUserName, src => src.UpdatedUserName); + + + config.ForType() + .Map(dest => dest.Shipper, src => src.SHIPPER) + .Map(dest => dest.Consignee, src => src.CONSIGNEE) + .Map(dest => dest.NotifyParty, src => src.NOTIFYPARTY) + .Map(dest => dest.Marks, src => src.MARKS) + .Map(dest => dest.Description, src => src.DESCRIPTION) + .Map(dest => dest.Remark, src => src.REMARK) + .Map(dest => dest.BLFRT, src => src.BLFRT) + .Map(dest => dest.Service, src => src.SERVICE) + .Map(dest => dest.IssueType, src => src.ISSUETYPE) + .Map(dest => dest.PortLoadId, src => src.PORT_LOADID) + .Map(dest => dest.PortLoad, src => src.PORT_LOAD) + .Map(dest => dest.PortDischargeId, src => src.PORT_DISCHARGEID) + .Map(dest => dest.PortDischarge, src => src.PORT_DISCHARGE) + .Map(dest => dest.PortTransId, src => src.PORT_TRANSID) + .Map(dest => dest.PortTrans, src => src.PORT_TRANS) + .Map(dest => dest.DestinationId, src => src.DESTINATION_ID) + .Map(dest => dest.Destination, src => src.DESTINATION) + .Map(dest => dest.KindPKGS, src => src.KIND_PKGS) + .Map(dest => dest.PKGS, src => src.PKGS) + .Map(dest => dest.ThirdPayAddr, src => src.THIRDPAYADDR); } + } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultBusiDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultBusiDto.cs new file mode 100644 index 00000000..cdb77a0d --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultBusiDto.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class TaskSIFeedBackResultBusiDto + { + /// + /// 发货人 + /// + public string Shipper { get; set; } + /// + /// 收货人 + /// + public string Consignee { get; set; } + /// + /// 通知人 + /// + public string NotifyParty { get; set; } + /// + /// 唛头 + /// + public string Marks { get; set; } + /// + /// 货描 + /// + public string Description { get; set; } + /// + /// 截单备注 + /// + public string Remark { get; set; } + /// + /// 付费方式 + /// + public string BLFRT { get; set; } + /// + /// 运输条款 + /// + /// CY-CY + public string Service { get; set; } + /// + /// 签单方式 + /// + /// TELEX + public string IssueType { get; set; } + /// + /// 装货港代码 + /// + /// CNTAO + public string PortLoadId { get; set; } + /// + /// 装货港 + /// + public string PortLoad { get; set; } + /// + /// 卸货港代码 + /// + /// GUPIT + public string PortDischargeId { get; set; } + /// + /// 卸货港 + /// + public string PortDischarge { get; set; } + /// + /// 中转港代码 + /// + /// GUPIT + public string PortTransId { get; set; } + /// + /// 中转港 + /// + public string PortTrans { get; set; } + /// + /// 目的地代码 + /// + /// GUPIT + public string DestinationId { get; set; } + /// + /// 目的地 + /// + public string Destination { get; set; } + /// + /// 件数 + /// + public int? PKGS { get; set; } + /// + /// 包装 + /// + public string KindPKGS { get; set; } + /// + /// 毛重 + /// + public decimal? KGS { get; set; } + /// + /// 尺寸 + /// + public decimal? CBM { get; set; } + /// + /// 第三付款地 + /// + public string ThirdPayAddr { get; set; } + + /// + /// 箱信息 + /// + public List ContaList { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultContaDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultContaDto.cs new file mode 100644 index 00000000..63728170 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultContaDto.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// SI集装箱 + /// + public class TaskSIFeedBackResultContaDto + { + /// + /// 集装箱号 + /// + /// RFCU2088064 + public string ContaNo { get; set; } + + /// + /// 铅封号 + /// + /// T090518 + public string SealNo { get; set; } + + /// + /// 件数 + /// + /// 222 + public int PKGS { get; set; } + + /// + /// 重量 + /// + /// 1651 + public decimal? KGS { get; set; } + + /// + /// 尺寸 + /// + /// 9.67 + public decimal? CBM { get; set; } + + /// + /// 箱型代码 + /// + /// 20GP + public string ContaType { get; set; } + + /// + /// 箱型 + /// + /// 20GP + public string ContaTypeName { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultDto.cs new file mode 100644 index 00000000..5ad1b027 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIFeedBackResultDto.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// SI详情 + /// + public class TaskSIFeedBackResultDto + { + // + /// 任务主键 + /// + public string TaskId { get; set; } + + /// + /// 订舱详情 + /// + public TaskBookingOrderDto BookingOrder { get; set; } + + /// + /// SI详情 + /// + public TaskSIFeedBackResultBusiDto BusiInfo { get; set; } + + /// + /// SI与订舱主信息比对差异字段列表 + /// + public List SICompareOrderKeyList { get; set; } + + /// + /// SI与订舱集装箱比对差异字段列表 + /// + public List SICompareOrderContaKeyList { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs index cde968b6..51196ee6 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs @@ -174,5 +174,23 @@ namespace Myshipping.Application /// 排序方法,默认降序 /// 返回结果 Task LaraPaperRecordExport(string sortField, int pageNo = 1, int pageSize = 30, bool descSort = true); + + /// + /// 保存SI信息 + /// + /// 订舱信息 + /// 返回结果 + Task SaveBookingSI(BookingOrderDto model); + + + /// + /// 获取SI反馈信息 + /// + /// 任务主键 + /// 返回结果 + Task GetSIFeedBackInfo(string taskPKId); + + + } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 5aa6e6c2..86933370 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -2435,7 +2435,7 @@ namespace Myshipping.Application /// 页码容量 /// 排序方法,默认降序 /// 返回结果 - [HttpGet("/TaskManage/GetLaraPaperRecordPage")] + [HttpGet("/TaskManage/LaraPaperRecordExport")] public async Task LaraPaperRecordExport([FromQuery] string sortField,[FromQuery] int pageNo = 1, [FromQuery] int pageSize = 30, [FromQuery] bool descSort = true) { QueryTaskManageBaseDto querySearch = new QueryTaskManageBaseDto @@ -2465,6 +2465,7 @@ namespace Myshipping.Application return new FileStreamResult(ms, "application/vnd.ms-excel") { FileDownloadName = $"{DateTime.Now.ToString("yyyyMMddHHmmss")}_LaraPaperRecord.xls" }; } + #region 导出提单纸登记记录生成Excel /// /// 导出提单纸登记记录生成Excel /// @@ -2529,6 +2530,159 @@ namespace Myshipping.Application return ms; } + #endregion + + /// + /// 保存SI信息 + /// + /// 订舱信息 + /// 返回结果 + [HttpPost("/TaskManage/GetSIFeedBackInfo")] + public async Task SaveBookingSI(BookingOrderDto model) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + + } + catch(Exception ex) + { + + } + + return result; + } + + + /// + /// 获取SI反馈信息 + /// + /// 任务主键 + /// 返回结果 + [HttpGet("/TaskManage/GetSIFeedBackInfo")] + public async Task GetSIFeedBackInfo(string taskPKId) + { + TaskSIFeedBackResultDto model = new TaskSIFeedBackResultDto(); + + try + { + var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId); + + if (taskInfo == null) + Oops.Oh($"任务信息获取失败"); + + if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) + Oops.Oh($"任务信息的订舱主键不存在"); + + 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)); + + model.TaskId = taskInfo.PK_ID; + + var siFeedBackList = _taskSIFeedBackInfoRepository.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) + Oops.Oh($"SI反馈信息不存在"); + + var siFeedBackInfo = siFeedBackList.FirstOrDefault().si.Adapt(); + + siFeedBackInfo.ContaList = siFeedBackList.Select(t => t.ctn.Adapt()).ToList(); + + model.BusiInfo = siFeedBackInfo; + + if (orderInfo != null) + { + //订舱 + model.BookingOrder = orderInfo.Adapt(); + } + + //进行数据比对确认差异字段KEY + } + catch (Exception ex) + { + throw Oops.Bah($"获取获取单票账单详情异常,{0}", ex.Message); + } + 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 样本业务提取帮助类 From eb88d749b24819c26c1f026ad4b188a51adbaf2b Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 19 Jan 2023 14:38:05 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=91=E7=9A=84?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TaskManagePlat/TaskManageService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 86933370..3a33f458 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -2537,7 +2537,7 @@ namespace Myshipping.Application /// /// 订舱信息 /// 返回结果 - [HttpPost("/TaskManage/GetSIFeedBackInfo")] + [HttpPost("/TaskManage/SaveBookingSI")] public async Task SaveBookingSI(BookingOrderDto model) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); From f5755a4cf01e03f6c99d0b6e34934e2fae4b5367 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Sat, 28 Jan 2023 10:17:06 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9SI=E4=B8=8E=E8=AE=A2?= =?UTF-8?q?=E8=88=B1=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; + } + } } From 0606c4dfb892aa3d9109d662182721023f9a9cd8 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Sat, 28 Jan 2023 11:06:15 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9SI=E6=AF=94=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TaskManagePlat/TaskManageService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index d8f0f0b4..9f9d7f05 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -2723,7 +2723,7 @@ namespace Myshipping.Application var bookProps = typeof(BookingCtn).GetProperties(); var feedProps = typeof(TaskSIFeedBackContaInfo).GetProperties(); - siContaList.GroupJoin(bookContaList, l => l.CONTA_NO, r => r.CNTRNO, (l, r) => + resultList = siContaList.GroupJoin(bookContaList, l => l.CONTA_NO, r => r.CNTRNO, (l, r) => { var currList = r.ToList(); @@ -2739,10 +2739,12 @@ namespace Myshipping.Application { return l.CONTA_NO; } + + return String.Empty; } return l.CONTA_NO; - }); + }).Where(t => !string.IsNullOrWhiteSpace(t)).ToList(); return resultList; } @@ -2774,6 +2776,7 @@ namespace Myshipping.Application } #endregion + #region 整理文本数据 public static class CompareObjExtension { /// @@ -2795,4 +2798,5 @@ namespace Myshipping.Application return rtn; } } + #endregion } From d8101c1233a94584dd2ba0003e041ad75a4811ba Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Sat, 28 Jan 2023 13:58:19 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9SI=E4=BF=9D=E5=AD=98=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/TaskCompareResultDto.cs | 39 ++++++ .../TaskManagePlat/Dtos/TaskSIModifyDto.cs | 16 +++ .../Interface/ITaskManageService.cs | 2 +- .../TaskManagePlat/TaskManageService.cs | 129 +++++++++++++++++- 4 files changed, 179 insertions(+), 7 deletions(-) create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskCompareResultDto.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIModifyDto.cs diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskCompareResultDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskCompareResultDto.cs new file mode 100644 index 00000000..6a225e00 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskCompareResultDto.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// + /// + public class TaskCompareResultDto + { + /// + /// 字段代码 + /// + public string Code { get; set; } + + /// + /// 原值 + /// + public object SrcVal { get; set; } + + /// + /// 修改值 + /// + public object TargetVal { get; set; } + + /// + /// 是否不一致 + /// + public bool IsDiff { get; set; } = false; + + /// + /// 字段类型 + /// + public Type ValType { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIModifyDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIModifyDto.cs new file mode 100644 index 00000000..2b4cae48 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskSIModifyDto.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class TaskSIModifyDto: TaskBookingOrderDto + { + /// + /// 任务主键 + /// + public string TaskPKId { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs index 51196ee6..b8d2af73 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs @@ -180,7 +180,7 @@ namespace Myshipping.Application /// /// 订舱信息 /// 返回结果 - Task SaveBookingSI(BookingOrderDto model); + Task SaveBookingSI(TaskBookingOrderDto model); /// diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 9f9d7f05..c311e2e7 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -4,6 +4,7 @@ using Furion.DistributedIDGenerator; using Furion.DynamicApiController; using Furion.FriendlyException; using Furion.JsonSerialization; +using Furion.Localization; using Furion.RemoteRequest; using Furion.RemoteRequest.Extensions; using Mapster; @@ -2533,29 +2534,79 @@ namespace Myshipping.Application } #endregion + #region 保存SI信息 /// /// 保存SI信息 /// /// 订舱信息 /// 返回结果 [HttpPost("/TaskManage/SaveBookingSI")] - public async Task SaveBookingSI(BookingOrderDto model) + public async Task SaveBookingSI(TaskBookingOrderDto model) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + /* + 1、比较原始数据和修改数据内容,记录差异。 + 2、更新订舱主信息和集装箱信息。 + 3、写入本地历史记录表。 + */ try { + var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == model.TaskBaseInfo.PKId); + + if (taskInfo == null) + throw Oops.Oh($"任务信息获取失败"); + + if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) + throw Oops.Oh($"任务信息的订舱主键不存在"); + + if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString()) + throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); + + 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; + + //比对差异,更新订舱主信息 + var mdBookingOrder = model.Adapt(); + + await _bookingOrderRepository.AsUpdateable(mdBookingOrder).IgnoreColumns(it => new + { + it.ParentId, + it.TenantId, + it.CreatedTime, + it.CreatedUserId, + it.CreatedUserName + }).ExecuteCommandAsync(); + + var ctnlist = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == mdBookingOrder.Id).ToListAsync(); + + //更新订舱的集装箱信息 + ctnlist.ForEach(async ctn => { + + await _bookingOrderContaRepository.AsUpdateable(ctn).IgnoreColumns(it => new + { + it.TenantId, + it.CreatedTime, + it.CreatedUserId, + it.CreatedUserName + }).ExecuteCommandAsync(); + }); } catch(Exception ex) { - + throw Oops.Bah($"保存SI信息,{0}", ex.Message); } return result; } + #endregion - + #region 获取SI反馈信息 /// /// 获取SI反馈信息 /// @@ -2571,13 +2622,13 @@ namespace Myshipping.Application var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId); if (taskInfo == null) - Oops.Oh($"任务信息获取失败"); + throw Oops.Oh($"任务信息获取失败"); if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) - Oops.Oh($"任务信息的订舱主键不存在"); + throw Oops.Oh($"任务信息的订舱主键不存在"); if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString()) - Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); + throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); var bookOrderList = _bookingOrderRepository.EntityContext.Queryable() @@ -2627,6 +2678,72 @@ namespace Myshipping.Application } return model; } + #endregion + + private List InnerCompare(object srcModel,object targetModel) + { + List list = new List(); + + if(srcModel is BookingOrder) + { + var srcBK = (BookingOrder)srcModel; + var targetBK = (BookingOrder)targetModel; + + var bookProps = typeof(BookingOrder).GetProperties(); + + list = bookProps.Select(prop => + { + var bk1Val = prop.GetValue(srcBK); + var bk2Val = prop.GetValue(targetBK); + + if (prop.PropertyType == typeof(string)) + { + string st1 = (bk1Val as string).AdjustString(); + string st2 = (bk2Val as string).AdjustString(); + + if (!st1.Equals(st2)) + { + return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; + } + + return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = false, ValType = prop.PropertyType }; + } + else if (prop.PropertyType == typeof(int?)) + { + var dt1 = bk1Val as int?; + var dt2 = bk2Val as int?; + + if (!dt1.Equals(dt2)) + { + return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; + } + + return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; + } + else if (prop.PropertyType == typeof(decimal?)) + { + var dt1 = bk1Val as decimal?; + var dt2 = bk2Val as decimal?; + + if (!dt1.Equals(dt2)) + { + return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; + } + + return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; + } + + if (!bk1Val.Equals(bk2Val)) + return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; + + + return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = false, ValType = prop.PropertyType }; + }).ToList(); + } + + + return list; + } #region 比较主信息 /// From 881df3dced7afa87621e8a51807505c277e81ba6 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Sat, 28 Jan 2023 17:25:50 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9VGM=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 | 33 +++ .../TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs | 54 +++++ .../Dtos/TaskVgmCompareResultDto.cs | 30 +++ .../Interface/ITaskManageService.cs | 12 + .../TaskManagePlat/TaskManageService.cs | 216 +++++++++++++++++- 5 files changed, 344 insertions(+), 1 deletion(-) create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVgmCompareResultDto.cs diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs index f1bcd3d1..1697ac94 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs @@ -387,6 +387,39 @@ namespace Myshipping.Application .Map(dest => dest.CBM, src => src.CBM) .Map(dest => dest.ContaType, src => src.CONTA_TYPE) .Map(dest => dest.ContaTypeName, src => src.CONTA_TYPE_NAME); + + + config.ForType() + .Map(dest => dest.ContaNo, src => src.CONTA_NO) + .Map(dest => dest.SealNo, src => src.SEAL_NO) + .Map(dest => dest.ContaType, src => src.CONTA_TYPE) + .Map(dest => dest.ContaTypeName, src => src.CONTA_TYPE_NAME) + .Map(dest => dest.KGS, src => src.KGS) + .Map(dest => dest.TareWeight, src => src.TAREWEIGHT) + .Map(dest => dest.WeighKGs, src => src.WEIGHKGS) + .Map(dest => dest.WeighType, src => src.WEIGHTYPE); + + + config.ForType() + .Map(dest => dest.ContaNo, src => src.CONTA_NO) + .Map(dest => dest.SealNo, src => src.SEAL_NO) + .Map(dest => dest.ContaType, src => src.CONTA_TYPE) + .Map(dest => dest.ContaTypeName, src => src.CONTA_TYPE_NAME) + .Map(dest => dest.KGS, src => src.KGS) + .Map(dest => dest.TareWeight, src => src.TAREWEIGHT) + .Map(dest => dest.WeighKGs, src => src.WEIGHKGS) + .Map(dest => dest.WeighType, src => src.WEIGHTYPE); + + + config.ForType() + .Map(dest => dest.ContaNo, src => src.CNTRNO) + .Map(dest => dest.SealNo, src => src.SEALNO) + .Map(dest => dest.ContaType, src => src.CTNCODE) + .Map(dest => dest.ContaTypeName, src => src.CTNALL) + .Map(dest => dest.KGS, src => src.KGS) + .Map(dest => dest.TareWeight, src => src.TAREWEIGHT) + .Map(dest => dest.WeighKGs, src => src.WEIGHKGS) + .Map(dest => dest.WeighType, src => src.WEIGHTYPE); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs new file mode 100644 index 00000000..c83834b2 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// VGM反馈 + /// + public class TaskVGMFeedBackDto + { + /// + /// 集装箱号 + /// + public string ContaNo { get; set; } + + /// + /// 铅封号 + /// + public string SealNo { get; set; } + + /// + /// 箱型代码 + /// + public string ContaType { get; set; } + + /// + /// 箱型 + /// + public string ContaTypeName { get; set; } + + /// + /// 重量 + /// + public decimal? KGS { get; set; } + + /// + /// 皮重 + /// + public decimal? TareWeight { get; set; } + + /// + /// 称重重量 + /// + public decimal? WeighKGs { get; set; } + + /// + /// 称重方式 + /// + public string WeighType { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVgmCompareResultDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVgmCompareResultDto.cs new file mode 100644 index 00000000..1eaa28f7 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVgmCompareResultDto.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class TaskVgmCompareDto : TaskVGMFeedBackDto + { + /// + /// 比对差异字段 + /// + public List compareDiffList { get; set; } + } + + + public class TaskVgmCompareResultDto + { + /// + /// 订舱与VGM反馈差异对比 + /// + public List bookOrderCompareList { get; set; } + + /// + /// VGM反馈与订舱差异比对 + /// + public List vgmCompareList { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs index b8d2af73..4d99ed1f 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageService.cs @@ -190,7 +190,19 @@ namespace Myshipping.Application /// 返回结果 Task GetSIFeedBackInfo(string taskPKId); + /// + /// 获取VGM比较结果 + /// + /// 任务主键 + /// 返回结果 + Task GetVGMCompareResult(string taskPKId); + /// + /// 更新订舱(VGM比较更新) + /// + /// 任务主键 + /// 返回结果 + Task SaveBookingVGM(string taskPKId); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index c311e2e7..20d4f73a 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -2646,7 +2646,7 @@ namespace Myshipping.Application .Select((si, ctn) => new { si = si, ctn = ctn }).ToList(); if (siFeedBackList.Count == 0) - Oops.Oh($"SI反馈信息不存在"); + throw Oops.Oh($"SI反馈信息不存在"); var siFeedBackInfo = siFeedBackList.FirstOrDefault().si; @@ -2866,6 +2866,220 @@ namespace Myshipping.Application return resultList; } #endregion + + /// + /// 获取VGM比较结果 + /// + /// 任务主键 + /// 返回结果 + [HttpGet("/TaskManage/GetVGMCompareResult")] + public async Task GetVGMCompareResult(string taskPKId) + { + TaskVgmCompareResultDto model = new TaskVgmCompareResultDto(); + + List list = new List(); + List list2 = new List(); + try + { + var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId); + + if (taskInfo == null) + throw Oops.Oh($"任务信息获取失败"); + + if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) + throw Oops.Oh($"任务信息的订舱主键不存在"); + + if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.VGM_COMPARE.ToString()) + throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.VGM_COMPARE.GetDescription()}"); + + var vgmList = _taskVGMFeedBackInfoRepository.AsQueryable().Where(t => t.TASK_PKID == taskInfo.PK_ID) + .ToList(); + + if(vgmList.Count == 0) + throw Oops.Oh($"VGM反馈信息不存在"); + + var contaList = _bookingOrderContaRepository.AsQueryable().Where(t => t.BILLID == long.Parse(taskInfo.BOOK_ORDER_NO)).ToList(); + + list = contaList.GroupJoin(vgmList, l => l.CNTRNO?.Trim(), r => r.CONTA_NO?.Trim(), (l, r) => { + var currInfo = r.FirstOrDefault(); + + TaskVgmCompareDto md = l.Adapt(); + + if (currInfo != null) + { + if(!l.SEALNO.Equals(currInfo.SEAL_NO)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo)); + } + if (!l.CTNCODE.Equals(currInfo.CONTA_TYPE)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType)); + } + if (!l.CTNALL.Equals(currInfo.CONTA_TYPE_NAME)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName)); + } + if (!l.KGS.Equals(currInfo.KGS)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS)); + } + if (!l.TAREWEIGHT.Equals(currInfo.TAREWEIGHT)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight)); + } + if (!l.WEIGHKGS.Equals(currInfo.WEIGHKGS)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs)); + } + if (!l.WEIGHTYPE.Equals(currInfo.WEIGHTYPE)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType)); + } + } + else + { + md.compareDiffList = new List { nameof(TaskVgmCompareDto.ContaNo), + nameof(TaskVgmCompareDto.SealNo), + nameof(TaskVgmCompareDto.ContaType), + nameof(TaskVgmCompareDto.ContaTypeName), + nameof(TaskVgmCompareDto.KGS), + nameof(TaskVgmCompareDto.TareWeight), + nameof(TaskVgmCompareDto.WeighKGs), + nameof(TaskVgmCompareDto.WeighType), + }; + } + + return md; + }).ToList(); + + model.bookOrderCompareList = list; + + list2 = vgmList.GroupJoin(contaList, l => l.CONTA_NO?.Trim(), r => r.CNTRNO?.Trim(), (l, r) => { + var currInfo = r.FirstOrDefault(); + + TaskVgmCompareDto md = l.Adapt(); + + if (currInfo != null) + { + if (!l.SEAL_NO.Equals(currInfo.SEALNO)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.SealNo)); + } + if (!l.CONTA_TYPE.Equals(currInfo.CTNCODE)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaType)); + } + if (!l.CONTA_TYPE_NAME.Equals(currInfo.CTNALL)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.ContaTypeName)); + } + if (!l.KGS.Equals(currInfo.KGS)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.KGS)); + } + if (!l.TAREWEIGHT.Equals(currInfo.TAREWEIGHT)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.TareWeight)); + } + if (!l.WEIGHKGS.Equals(currInfo.WEIGHKGS)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighKGs)); + } + if (!l.WEIGHTYPE.Equals(currInfo.WEIGHTYPE)) + { + md.compareDiffList.Add(nameof(TaskVgmCompareDto.WeighType)); + } + } + else + { + md.compareDiffList = new List { nameof(TaskVgmCompareDto.ContaNo), + nameof(TaskVgmCompareDto.SealNo), + nameof(TaskVgmCompareDto.ContaType), + nameof(TaskVgmCompareDto.ContaTypeName), + nameof(TaskVgmCompareDto.KGS), + nameof(TaskVgmCompareDto.TareWeight), + nameof(TaskVgmCompareDto.WeighKGs), + nameof(TaskVgmCompareDto.WeighType), + }; + } + + return md; + }).ToList(); + + model.vgmCompareList = list2; + + } + catch (Exception ex) + { + throw Oops.Bah($"获取VGM比较结果异常,{0}", ex.Message); + } + + return model; + } + + /// + /// 更新订舱(VGM比较更新) + /// + /// 任务主键 + /// 返回结果 + [HttpPost("/TaskManage/SaveBookingVGM")] + public async Task SaveBookingVGM(string taskPKId) + { + TaskManageOrderResultDto result = new TaskManageOrderResultDto(); + + try + { + var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == taskPKId); + + if (taskInfo == null) + throw Oops.Oh($"任务信息获取失败"); + + if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) + throw Oops.Oh($"任务信息的订舱主键不存在"); + + if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString()) + throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); + + 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; + + //比对差异,更新订舱主信息 + var mdBookingOrder = orderInfo.Adapt(); + + await _bookingOrderRepository.AsUpdateable(mdBookingOrder).IgnoreColumns(it => new + { + it.ParentId, + it.TenantId, + it.CreatedTime, + it.CreatedUserId, + it.CreatedUserName + }).ExecuteCommandAsync(); + + var ctnlist = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == mdBookingOrder.Id).ToListAsync(); + + //更新订舱的集装箱信息 + ctnlist.ForEach(async ctn => { + + await _bookingOrderContaRepository.AsUpdateable(ctn).IgnoreColumns(it => new + { + it.TenantId, + it.CreatedTime, + it.CreatedUserId, + it.CreatedUserName + }).ExecuteCommandAsync(); + }); + } + catch(Exception ex) + { + throw Oops.Bah($"更新订舱(VGM比较更新)异常,{0}", ex.Message); + } + + return result; + } } #region 样本业务提取帮助类 From 63cf04434a9377e6a8d6014b6260bbe43cf09096 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Sat, 28 Jan 2023 17:28:14 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TaskManagePlat/TaskManageService.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index 20d4f73a..c47e2a4c 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -2867,6 +2867,7 @@ namespace Myshipping.Application } #endregion + #region 获取VGM比较结果 /// /// 获取VGM比较结果 /// @@ -3016,7 +3017,9 @@ namespace Myshipping.Application return model; } + #endregion + #region 更新订舱(VGM比较更新) /// /// 更新订舱(VGM比较更新) /// @@ -3080,6 +3083,7 @@ namespace Myshipping.Application return result; } + #endregion } #region 样本业务提取帮助类 From 3fba4289888c7a1a4499c35f577a2b1db144a615 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Sun, 29 Jan 2023 15:03:18 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9SI=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/TaskBookingOrderDto.cs | 13 ++ .../TaskManagePlat/Dtos/TaskManageMapper.cs | 153 ++++++++++++++++- .../TaskManagePlat/TaskManageService.cs | 159 +++++++++++++++--- 3 files changed, 300 insertions(+), 25 deletions(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBookingOrderDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBookingOrderDto.cs index 6392da86..dccd35f4 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBookingOrderDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBookingOrderDto.cs @@ -87,30 +87,37 @@ namespace Myshipping.Application /// /// 开船日期 /// + /// 2022-01-01 public string ETD { get; set; } /// /// 实际开船日期 /// + /// 2022-01-01 public string ATD { get; set; } /// /// 预计到港日期 /// + /// 2022-01-01 public string ETA { get; set; } /// /// 截港日期 /// + /// 2022-01-01 public string ClosingDate { get; set; } /// /// 截单日期 /// + /// 2022-01-01 public string CloseDocDate { get; set; } /// /// 截VGM时间 /// + /// 2022-01-01 public string CloseVGMDate { get; set; } /// /// 收货地代码 /// + /// CNTAO public string PlaceReceiptId { get; set; } /// /// 收货地 @@ -119,6 +126,7 @@ namespace Myshipping.Application /// /// 起运港代码 /// + /// CNTAO public string PortLoadId { get; set; } /// /// 起运港 @@ -127,6 +135,7 @@ namespace Myshipping.Application /// /// 卸货港代码 /// + /// USDCB public string PortDischargeId { get; set; } /// /// 卸货港 @@ -135,6 +144,7 @@ namespace Myshipping.Application /// /// 交货地代码 /// + /// USDCB public string PlaceDeliveryId { get; set; } /// /// 交货地 @@ -143,6 +153,7 @@ namespace Myshipping.Application /// /// 目的地代码 /// + /// USDCB public string DestinationId { get; set; } /// /// 目的地 @@ -163,6 +174,7 @@ namespace Myshipping.Application /// /// 签单日期 /// + /// 2022-01-01 public string IssueDate { get; set; } /// /// 签单地点代码 @@ -544,6 +556,7 @@ namespace Myshipping.Application /// /// 中转港代码 /// + /// public string TransportId { get; set; } /// /// 中转港 diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs index 1697ac94..7e89be8b 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs @@ -163,7 +163,7 @@ namespace Myshipping.Application .Map(dest => dest.CloseVGMDate, src => src.CLOSEVGMDATE.HasValue ? src.CLOSEVGMDATE.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") .Map(dest => dest.PlaceReceiptId, src => src.PLACERECEIPTID) .Map(dest => dest.PlaceReceipt, src => src.PLACERECEIPT) - .Map(dest => dest.PortLoadId, src => src.PORTLOAD) + .Map(dest => dest.PortLoadId, src => src.PORTLOADID) .Map(dest => dest.PortLoad, src => src.PORTLOAD) .Map(dest => dest.PortDischargeId, src => src.PORTDISCHARGEID) .Map(dest => dest.PortDischarge, src => src.PORTDISCHARGE) @@ -420,6 +420,157 @@ namespace Myshipping.Application .Map(dest => dest.TareWeight, src => src.TAREWEIGHT) .Map(dest => dest.WeighKGs, src => src.WEIGHKGS) .Map(dest => dest.WeighType, src => src.WEIGHTYPE); + + + config.ForType() + .Map(dest => dest.CTNCODE, src => src.ContaType) + .Map(dest => dest.CTNALL, src => src.ContaTypeName) + .Map(dest => dest.TEU, src => src.TEU) + .Map(dest => dest.CNTRNO, src => src.ContaNo) + .Map(dest => dest.SEALNO, src => src.SealNo) + .Map(dest => dest.PKGS, src => src.PKGs) + .Map(dest => dest.KINDPKGS, src => src.KindPKGs) + .Map(dest => dest.KGS, src => src.KGs) + .Map(dest => dest.CBM, src => src.CBM) + .Map(dest => dest.TAREWEIGHT, src => src.TareWeight) + .Map(dest => dest.CTNSTATUS, src => src.ContaStatus) + .Map(dest => dest.WEIGHTYPE, src => src.WeighType) + .Map(dest => dest.WEIGHKGS, src => src.WeighKGs) + .Map(dest => dest.WEIGHATTN, src => src.WeighAttn) + .Map(dest => dest.VGMCONNCOM, src => src.VGMConnCom) + .Map(dest => dest.WEIGHTEL, src => src.WeighTel) + .Map(dest => dest.WEIGHDATE, src => src.WeighDate) + .Map(dest => dest.VGMADDR, src => src.VGMAddr) + .Map(dest => dest.VGMEMAIL, src => src.VGMEmail) + .Map(dest => dest.REMARK, src => src.Remark); + + + config.ForType() + .Map(dest => dest.MBLNO, src => src.MasterBlNo) + .Map(dest => dest.HBLNO, src => src.HouseBlNo) + .Map(dest => dest.BOOKINGNO, src => src.BookingNo) + .Map(dest => dest.CONTRACTNO, src => src.ContrNo) + .Map(dest => dest.SERVICECONTRACTNO, src => src.ServContrNo) + .Map(dest => dest.SHIPPERID, src => src.ShipperId) + .Map(dest => dest.CONSIGNEEID, src => src.ConsigneeId) + .Map(dest => dest.NOTIFYPARTYID, src => src.NotifyPartyId) + .Map(dest => dest.SHIPPER, src => src.Shipper) + .Map(dest => dest.CONSIGNEE, src => src.Consignee) + .Map(dest => dest.NOTIFYPARTY, src => src.NotifyParty) + .Map(dest => dest.NOTIFYPARTY2, src => src.NotifyPrt2) + .Map(dest => dest.YARDID, src => src.YardId) + .Map(dest => dest.YARD, src => src.Yard) + .Map(dest => dest.VESSELID, src => src.VesselId) + .Map(dest => dest.VESSEL, src => src.Vessel) + .Map(dest => dest.VOYNO, src => src.Voyno) + .Map(dest => dest.VOYNOINNER, src => src.VoynoIn) + .Map(dest => dest.ETD, src => src.ETD) + .Map(dest => dest.ATD, src => src.ATD) + .Map(dest => dest.ETA, src => src.ETA) + .Map(dest => dest.CLOSINGDATE, src => src.ClosingDate) + .Map(dest => dest.CLOSEDOCDATE, src => src.CloseDocDate) + .Map(dest => dest.CLOSEVGMDATE, src => src.CloseVGMDate) + .Map(dest => dest.PLACERECEIPTID, src => src.PlaceReceiptId) + .Map(dest => dest.PLACERECEIPT, src => src.PlaceReceipt) + .Map(dest => dest.PORTLOADID, src => src.PortLoadId) + .Map(dest => dest.PORTLOAD, src => src.PortLoad) + .Map(dest => dest.PORTDISCHARGEID, src => src.PortDischargeId) + .Map(dest => dest.PORTDISCHARGE, src => src.PortDischarge) + .Map(dest => dest.PLACEDELIVERYID, src => src.PlaceDeliveryId) + .Map(dest => dest.PLACEDELIVERY, src => src.PlaceDelivery) + .Map(dest => dest.DESTINATIONID, src => src.DestinationId) + .Map(dest => dest.DESTINATION, src => src.Destination) + .Map(dest => dest.NOBILL, src => src.NoBill) + .Map(dest => dest.COPYNOBILL, src => src.CopyNoBill) + .Map(dest => dest.ISSUETYPE, src => src.IssueType) + .Map(dest => dest.ISSUEDATE, src => src.IssueDate) + .Map(dest => dest.ISSUEPLACEID, src => src.IssuePlaceId) + .Map(dest => dest.ISSUEPLACE, src => src.IssuePlace) + .Map(dest => dest.BLFRT, src => src.Blfrt) + .Map(dest => dest.PREPARDAT, src => src.PrepardAt) + .Map(dest => dest.PAYABLEAT, src => src.PayableAt) + .Map(dest => dest.SERVICE, src => src.Service) + .Map(dest => dest.MARKS, src => src.Marks) + .Map(dest => dest.HSCODE, src => src.HsCode) + .Map(dest => dest.DESCRIPTION, src => src.GoodsDescription) + .Map(dest => dest.PKGS, src => src.PKGs) + .Map(dest => dest.KINDPKGS, src => src.KindPKGs) + .Map(dest => dest.KGS, src => src.KGs) + .Map(dest => dest.CBM, src => src.CBM) + .Map(dest => dest.TOTALNO, src => src.TotalNO) + .Map(dest => dest.CNTRTOTAL, src => src.CntrTotal) + .Map(dest => dest.CARRIERID, src => src.CarrierId) + .Map(dest => dest.CARRIER, src => src.Carrier) + .Map(dest => dest.CARGOID, src => src.CargoId) + .Map(dest => dest.DCLASS, src => src.DClass) + .Map(dest => dest.DUNNO, src => src.DUnno) + .Map(dest => dest.DPAGE, src => src.DPage) + .Map(dest => dest.DLABEL, src => src.DLabel) + .Map(dest => dest.LINKMAN, src => src.DLinkMan) + .Map(dest => dest.TEMPID, src => src.TempId) + .Map(dest => dest.TEMPSET, src => src.TempSet) + .Map(dest => dest.REEFERF, src => src.Reeferf) + .Map(dest => dest.HUMIDITY, src => src.Humidity) + .Map(dest => dest.TEMPMIN, src => src.TempMin) + .Map(dest => dest.TEMPMAX, src => src.TempMax) + .Map(dest => dest.ISCONTAINERSOC, src => src.IsContaSOC) + .Map(dest => dest.SOREMARK, src => src.SORemark) + .Map(dest => dest.SIREMARK, src => src.SIRemark) + .Map(dest => dest.YARDREMARK, src => src.YardRemark) + .Map(dest => dest.SHIPPERNAME, src => src.ShipperName) + .Map(dest => dest.SHIPPERADDR1, src => src.ShipperAddr1) + .Map(dest => dest.SHIPPERADDR2, src => src.ShipperAddr2) + .Map(dest => dest.SHIPPERADDR3, src => src.ShipperAddr3) + .Map(dest => dest.SHIPPERCITY, src => src.ShipperCity) + .Map(dest => dest.SHIPPERPROVINCE, src => src.ShipperProvice) + .Map(dest => dest.SHIPPERPOSTCODE, src => src.ShipperPostCode) + .Map(dest => dest.SHIPPERCOUNTRY, src => src.ShipperCountry) + .Map(dest => dest.SHIPPERATTN, src => src.ShipperAttn) + .Map(dest => dest.SHIPPERTEL, src => src.ShipperTel) + .Map(dest => dest.CONSIGNEENAME, src => src.ConsigneeName) + .Map(dest => dest.CONSIGNEEADDR1, src => src.ConsigneeAddr1) + .Map(dest => dest.CONSIGNEEADDR2, src => src.ConsigneeAddr2) + .Map(dest => dest.CONSIGNEEADDR3, src => src.ConsigneeAddr3) + .Map(dest => dest.CONSIGNEECITY, src => src.ConsigneeCity) + .Map(dest => dest.CONSIGNEEPROVINCE, src => src.ConsigneeProvince) + .Map(dest => dest.CONSIGNEEPOSTCODE, src => src.ConsigneePostCode) + .Map(dest => dest.CONSIGNEERCOUNTRY, src => src.ConsigneeCountry) + .Map(dest => dest.CONSIGNEEATTN, src => src.ConsigneeAttn) + .Map(dest => dest.CONSIGNEETEL, src => src.ConsigneeTel) + .Map(dest => dest.NOTIFYPARTYNAME, src => src.NotifyPartyName) + .Map(dest => dest.NOTIFYPARTYADDR1, src => src.NotifyPartyAddr1) + .Map(dest => dest.NOTIFYPARTYADDR2, src => src.NotifyPartyAddr2) + .Map(dest => dest.NOTIFYPARTYADDR3, src => src.NotifyPartyAddr3) + .Map(dest => dest.NOTIFYPARTYCITY, src => src.NotifyPartyCity) + .Map(dest => dest.NOTIFYPARTYPROVINCE, src => src.NotifyPartyProvince) + .Map(dest => dest.NOTIFYPARTYPOSTCODE, src => src.NotifyPartyPostCode) + .Map(dest => dest.NOTIFYPARTYCOUNTRY, src => src.NotifyPartyCountry) + .Map(dest => dest.NOTIFYPARTYATTN, src => src.NotifyPartyAttn) + .Map(dest => dest.NOTIFYPARTYTEL, src => src.NotifyPartyTel) + .Map(dest => dest.CUSTOMSER, src => src.CustomsER) + .Map(dest => dest.TRUCKER, src => src.TruckER) + .Map(dest => dest.AGENTID, src => src.AgentId) + .Map(dest => dest.FORWARDERID, src => src.ForwarderId) + .Map(dest => dest.SHIPAGENCYID, src => src.ShipAgencyId) + .Map(dest => dest.CUSTOMSERID, src => src.CustomsERId) + .Map(dest => dest.TRUCKERID, src => src.TruckERId) + .Map(dest => dest.AGENTNAME, src => src.AgentName) + .Map(dest => dest.CONSIGNEEDOORADDR, src => src.ConsigneeDoorAddr) + .Map(dest => dest.SHIPPERDOORADDR, src => src.ShipperDoorAddr) + .Map(dest => dest.SCACCODE, src => src.SCACCode) + .Map(dest => dest.ITNCODE, src => src.ITNCode) + .Map(dest => dest.PREPARDATID, src => src.PrePardAtId) + .Map(dest => dest.PAYABLEATID, src => src.PayableAtId) + .Map(dest => dest.CUSTNO, src => src.CustNo) + .Map(dest => dest.TRANSPORTID, src => src.TransportId) + .Map(dest => dest.TRANSPORT, src => src.Transport) + .Map(dest => dest.THIRDPAYADDR, src => src.ThirdPayAddr) + .Map(dest => dest.YARDCONTRACTTEL, src => src.YardContractTel) + .Map(dest => dest.YARDCONTRACTEMAIL, src => src.YardContractEmail) + .Map(dest => dest.FEESELF, src => src.FeeSelf) + .Map(dest => dest.LANECODE, src => src.LaneCode) + .Map(dest => dest.LANENAME, src => src.LaneName) + .Map(dest => dest.FREIGHTPAYER, src => src.FreightPayer); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index c47e2a4c..d1e276c6 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -26,6 +26,7 @@ using Newtonsoft.Json.Linq; using Npoi.Mapper; using NPOI.HPSF; using NPOI.HSSF.UserModel; +using NPOI.OpenXmlFormats; using NPOI.POIFS.Crypt.Dsig; using NPOI.SS.Formula.Eval; using NPOI.SS.Formula.Functions; @@ -2552,6 +2553,9 @@ namespace Myshipping.Application */ try { + if (string.IsNullOrWhiteSpace(model.TaskBaseInfo.PKId)) + throw Oops.Oh($"任务主键TaskBaseInfo.PKId不能为空"); + var taskInfo = _taskBaseInfoRepository.AsQueryable().First(t => t.PK_ID == model.TaskBaseInfo.PKId); if (taskInfo == null) @@ -2563,43 +2567,150 @@ namespace Myshipping.Application if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString()) throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); + //取订舱详情(包含集装箱) var bookOrderList = _bookingOrderRepository.EntityContext.Queryable() - .InnerJoin((bk, ctn) => bk.Id == ctn.BILLID) + .LeftJoin(_bookingOrderRepository.EntityContext.Queryable(),(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; - //比对差异,更新订舱主信息 + List orderCtnList = new List(); + + //这里是左连接查询,解决集装箱为空的情况 + if(bookOrderList.Any(t=>t.ctn.Id > 0)) + orderCtnList = bookOrderList.Select(t => t.ctn).ToList(); + var mdBookingOrder = model.Adapt(); - await _bookingOrderRepository.AsUpdateable(mdBookingOrder).IgnoreColumns(it => new + mdBookingOrder.Id = orderInfo.Id; + mdBookingOrder.UpdatedTime = DateTime.Now; + mdBookingOrder.UpdatedUserId = UserManager.UserId; + mdBookingOrder.UpdatedUserName = UserManager.Name; + + //比对主订舱信息 + var orderDiff = InnerCompare(orderInfo, mdBookingOrder); + + //比对箱信息 + var contaList = model.ContaList.Select(x => x.Adapt()).ToList(); + + /**/ + //这里参考原有的更新逻辑,只更新了SI回执有的字段信息,其他字段不更新,如果后期有调整可以自行增加更新字段 + await _bookingOrderRepository.AsUpdateable(mdBookingOrder).UpdateColumns(it => new { - it.ParentId, - it.TenantId, - it.CreatedTime, - it.CreatedUserId, - it.CreatedUserName + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName, + it.SHIPPER, + it.CONSIGNEE, + it.NOTIFYPARTY, + it.MARKS, + it.DESCRIPTION, + it.BLFRT, + it.SERVICE, + it.ISSUETYPE, + it.PORTLOADID, + it.PORTLOAD, + it.PORTDISCHARGEID, + it.PORTDISCHARGE, + it.TRANSPORTID, + it.TRANSPORT, + it.DESTINATIONID, + it.DESTINATION, + it.PKGS, + it.KINDPKGS, + it.KGS, + it.CBM, + it.THIRDPAYADDR, + it.SIREMARK }).ExecuteCommandAsync(); var ctnlist = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == mdBookingOrder.Id).ToListAsync(); - //更新订舱的集装箱信息 - ctnlist.ForEach(async ctn => { + var si2orderCtnList = contaList.GroupJoin(ctnlist, l => l.CNTRNO?.Trim(), r => r.CNTRNO?.Trim(), (l, r) => { + var currInfo = r.FirstOrDefault(); - await _bookingOrderContaRepository.AsUpdateable(ctn).IgnoreColumns(it => new + if(currInfo == null) { - it.TenantId, - it.CreatedTime, - it.CreatedUserId, - it.CreatedUserName - }).ExecuteCommandAsync(); - }); + l.BILLID = orderInfo.Id; + l.CreatedTime = DateTime.Now; + l.CreatedUserId = UserManager.UserId; + l.CreatedUserName = UserManager.Name; + + l.UpdatedTime = l.CreatedTime; + l.UpdatedUserId = UserManager.UserId; + l.UpdatedUserName = UserManager.Name; + return new { OperType = "insert", obj = l }; + } + else + { + currInfo.Id = l.Id; + currInfo.BILLID = l.BILLID; + currInfo.UpdatedTime = DateTime.Now; + currInfo.UpdatedUserId = UserManager.UserId; + currInfo.UpdatedUserName = UserManager.Name; + + return new { OperType = "update", obj = currInfo }; + } + }).ToList(); + + + var delList = ctnlist.GroupJoin(contaList, l => l.CNTRNO?.Trim(), r => r.CNTRNO?.Trim(), (l, r) => { + var currInfo = r.FirstOrDefault(); + + if (currInfo == null) + { + l.UpdatedTime = DateTime.Now; + l.UpdatedUserId = UserManager.UserId; + l.UpdatedUserName = UserManager.Name; + return new { OperType = "delete", obj = l }; + } + return new { OperType = string.Empty, obj = l }; + }).Where(t=>t.OperType != string.Empty).ToList(); + + + if (delList.Count > 0) + si2orderCtnList.AddRange(delList); + + + if (si2orderCtnList.Count > 0) + { + si2orderCtnList.ForEach(async ctn => + { + if (ctn.OperType == "insert") + { + //插入 + await _bookingOrderContaRepository.InsertAsync(ctn.obj); + } + else if (ctn.OperType == "update") + { + //更新 + await _bookingOrderContaRepository.AsUpdateable(ctn.obj).UpdateColumns(it => new + { + it.CTNALL, + it.SEALNO, + it.PKGS, + it.KGS, + it.CBM, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName, + }).ExecuteCommandAsync(); + } + else if (ctn.OperType == "delete") + { + await _bookingOrderContaRepository.DeleteAsync(x => x.Id == ctn.obj.Id); + } + }); + } + + result.succ = true; + result.msg = "保存SI信息成功"; } catch(Exception ex) { - throw Oops.Bah($"保存SI信息,{0}", ex.Message); + throw Oops.Bah($"保存SI信息异常,{0}", ex.Message); } return result; @@ -2701,7 +2812,7 @@ namespace Myshipping.Application string st1 = (bk1Val as string).AdjustString(); string st2 = (bk2Val as string).AdjustString(); - if (!st1.Equals(st2)) + if (st1 != st2) { return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; } @@ -2713,7 +2824,7 @@ namespace Myshipping.Application var dt1 = bk1Val as int?; var dt2 = bk2Val as int?; - if (!dt1.Equals(dt2)) + if (dt1 != dt2) { return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; } @@ -2725,7 +2836,7 @@ namespace Myshipping.Application var dt1 = bk1Val as decimal?; var dt2 = bk2Val as decimal?; - if (!dt1.Equals(dt2)) + if (dt1 != dt2) { return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; } @@ -2733,7 +2844,7 @@ namespace Myshipping.Application return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; } - if (!bk1Val.Equals(bk2Val)) + if (bk1Val != bk2Val) return new TaskCompareResultDto { Code = prop.Name, SrcVal = bk1Val, TargetVal = bk2Val, IsDiff = true, ValType = prop.PropertyType }; @@ -3040,8 +3151,8 @@ namespace Myshipping.Application if (string.IsNullOrWhiteSpace(taskInfo.BOOK_ORDER_NO)) throw Oops.Oh($"任务信息的订舱主键不存在"); - if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.SI_FEEDBACK.ToString()) - throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.SI_FEEDBACK.GetDescription()}"); + if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.VGM_COMPARE.ToString()) + throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.VGM_COMPARE.GetDescription()}"); var bookOrderList = _bookingOrderRepository.EntityContext.Queryable() .InnerJoin((bk, ctn) => bk.Id == ctn.BILLID) From 5f235fef634779b6daf13c598607a502be9f2073 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Sun, 29 Jan 2023 15:59:02 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E6=88=91=E7=9A=84=E4=BB=BB=E5=8A=A1-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9VGM=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TaskManagePlat/TaskVGMFeedBackInfo.cs | 5 + .../TaskManagePlat/Dtos/TaskManageMapper.cs | 20 +++- .../Dtos/TaskManageOrderVGMFeedBackInfo.cs | 6 + .../TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs | 5 + .../TaskManagePlat/TaskManageService.cs | 110 ++++++++++++++---- 5 files changed, 122 insertions(+), 24 deletions(-) diff --git a/Myshipping.Application/Entity/TaskManagePlat/TaskVGMFeedBackInfo.cs b/Myshipping.Application/Entity/TaskManagePlat/TaskVGMFeedBackInfo.cs index fd9e86a3..969ea4fb 100644 --- a/Myshipping.Application/Entity/TaskManagePlat/TaskVGMFeedBackInfo.cs +++ b/Myshipping.Application/Entity/TaskManagePlat/TaskVGMFeedBackInfo.cs @@ -59,5 +59,10 @@ namespace Myshipping.Application.Entity /// 称重方式 /// public string WEIGHTYPE { get; set; } + + /// + /// 主单号 + /// + public string MBL_NO { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs index 7e89be8b..b11b1565 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageMapper.cs @@ -72,7 +72,8 @@ namespace Myshipping.Application .Map(dest => dest.KGS, src => src.KGS) .Map(dest => dest.TAREWEIGHT, src => src.TAREWEIGHT) .Map(dest => dest.WEIGHKGS, src => src.WEIGHKGS) - .Map(dest => dest.WEIGHTYPE, src => src.WEIGHTYPE); + .Map(dest => dest.WEIGHTYPE, src => src.WEIGHTYPE) + .Map(dest => dest.MBL_NO, src => src.MBLNo); config.ForType() @@ -397,7 +398,8 @@ namespace Myshipping.Application .Map(dest => dest.KGS, src => src.KGS) .Map(dest => dest.TareWeight, src => src.TAREWEIGHT) .Map(dest => dest.WeighKGs, src => src.WEIGHKGS) - .Map(dest => dest.WeighType, src => src.WEIGHTYPE); + .Map(dest => dest.WeighType, src => src.WEIGHTYPE) + .Map(dest => dest.MBLNo, src => src.MBL_NO); config.ForType() @@ -408,7 +410,8 @@ namespace Myshipping.Application .Map(dest => dest.KGS, src => src.KGS) .Map(dest => dest.TareWeight, src => src.TAREWEIGHT) .Map(dest => dest.WeighKGs, src => src.WEIGHKGS) - .Map(dest => dest.WeighType, src => src.WEIGHTYPE); + .Map(dest => dest.WeighType, src => src.WEIGHTYPE) + .Map(dest => dest.MBLNo, src => src.MBL_NO); config.ForType() @@ -571,6 +574,17 @@ namespace Myshipping.Application .Map(dest => dest.LANECODE, src => src.LaneCode) .Map(dest => dest.LANENAME, src => src.LaneName) .Map(dest => dest.FREIGHTPAYER, src => src.FreightPayer); + + + config.ForType() + .Map(dest => dest.CTNCODE, src => src.CONTA_TYPE) + .Map(dest => dest.CTNALL, src => src.CONTA_TYPE_NAME) + .Map(dest => dest.CNTRNO, src => src.CONTA_NO) + .Map(dest => dest.SEALNO, src => src.SEAL_NO) + .Map(dest => dest.KGS, src => src.KGS) + .Map(dest => dest.TAREWEIGHT, src => src.TAREWEIGHT) + .Map(dest => dest.WEIGHTYPE, src => src.WEIGHTYPE) + .Map(dest => dest.WEIGHKGS, src => src.WEIGHKGS); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderVGMFeedBackInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderVGMFeedBackInfo.cs index 97562128..cfd411c9 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderVGMFeedBackInfo.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskManageOrderVGMFeedBackInfo.cs @@ -50,5 +50,11 @@ namespace Myshipping.Application /// 称重方式 /// public string WEIGHTYPE { get; set; } + + + /// + /// 主单号 + /// + public string MBLNo { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs index c83834b2..1ffd201f 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskVGMFeedBackDto.cs @@ -50,5 +50,10 @@ namespace Myshipping.Application /// 称重方式 /// public string WeighType { get; set; } + + /// + /// 主单号 + /// + public string MBLNo { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index d1e276c6..e98de14b 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -31,6 +31,7 @@ using NPOI.POIFS.Crypt.Dsig; using NPOI.SS.Formula.Eval; using NPOI.SS.Formula.Functions; using NPOI.SS.UserModel; +using NPOI.Util; using NPOI.XSSF.Model; using Org.BouncyCastle.Asn1.X500; using SixLabors.ImageSharp.Processing.Processors.Transforms; @@ -3154,38 +3155,105 @@ namespace Myshipping.Application if (taskInfo.TASK_TYPE != TaskBusiTypeEnum.VGM_COMPARE.ToString()) throw Oops.Oh($"当前任务类型不是{TaskBusiTypeEnum.VGM_COMPARE.GetDescription()}"); + //取订舱详情(包含集装箱) var bookOrderList = _bookingOrderRepository.EntityContext.Queryable() - .InnerJoin((bk, ctn) => bk.Id == ctn.BILLID) + .LeftJoin(_bookingOrderRepository.EntityContext.Queryable(), (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; - //比对差异,更新订舱主信息 - var mdBookingOrder = orderInfo.Adapt(); + List orderCtnList = new List(); - await _bookingOrderRepository.AsUpdateable(mdBookingOrder).IgnoreColumns(it => new - { - it.ParentId, - it.TenantId, - it.CreatedTime, - it.CreatedUserId, - it.CreatedUserName - }).ExecuteCommandAsync(); + //这里是左连接查询,解决集装箱为空的情况 + if (bookOrderList.Any(t => t.ctn.Id > 0)) + orderCtnList = bookOrderList.Select(t => t.ctn).ToList(); - var ctnlist = await _bookingOrderContaRepository.AsQueryable().Where(x => x.BILLID == mdBookingOrder.Id).ToListAsync(); + var contaList = _taskVGMFeedBackInfoRepository.AsQueryable().Where(t => t.TASK_PKID == taskInfo.PK_ID).ToList(); + + var si2orderCtnList = contaList.GroupJoin(orderCtnList, l => l.CONTA_NO?.Trim(), r => r.CNTRNO?.Trim(), (l, r) => { + var currInfo = r.FirstOrDefault(); - //更新订舱的集装箱信息 - ctnlist.ForEach(async ctn => { + var contaInfo = l.Adapt(); - await _bookingOrderContaRepository.AsUpdateable(ctn).IgnoreColumns(it => new + if (currInfo == null) { - it.TenantId, - it.CreatedTime, - it.CreatedUserId, - it.CreatedUserName - }).ExecuteCommandAsync(); - }); + contaInfo.BILLID = orderInfo.Id; + contaInfo.CreatedTime = DateTime.Now; + contaInfo.CreatedUserId = UserManager.UserId; + contaInfo.CreatedUserName = UserManager.Name; + + contaInfo.UpdatedTime = contaInfo.CreatedTime; + contaInfo.UpdatedUserId = UserManager.UserId; + contaInfo.UpdatedUserName = UserManager.Name; + + return new { OperType = "insert", obj = contaInfo }; + } + else + { + currInfo.Id = contaInfo.Id; + currInfo.BILLID = contaInfo.BILLID; + currInfo.UpdatedTime = DateTime.Now; + currInfo.UpdatedUserId = UserManager.UserId; + currInfo.UpdatedUserName = UserManager.Name; + + return new { OperType = "update", obj = currInfo }; + } + }).ToList(); + + + var delList = orderCtnList.GroupJoin(contaList, l => l.CNTRNO?.Trim(), r => r.CONTA_NO?.Trim(), (l, r) => { + var currInfo = r.FirstOrDefault(); + + if (currInfo == null) + { + l.UpdatedTime = DateTime.Now; + l.UpdatedUserId = UserManager.UserId; + l.UpdatedUserName = UserManager.Name; + return new { OperType = "delete", obj = l }; + } + + return new { OperType = string.Empty, obj = l }; + }).Where(t => t.OperType != string.Empty).ToList(); + + + if (delList.Count > 0) + si2orderCtnList.AddRange(delList); + + + if (si2orderCtnList.Count > 0) + { + si2orderCtnList.ForEach(async ctn => + { + if (ctn.OperType == "insert") + { + //插入 + await _bookingOrderContaRepository.InsertAsync(ctn.obj); + } + else if (ctn.OperType == "update") + { + //更新 + await _bookingOrderContaRepository.AsUpdateable(ctn.obj).UpdateColumns(it => new + { + it.CTNALL, + it.SEALNO, + it.PKGS, + it.KGS, + it.CBM, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName, + }).ExecuteCommandAsync(); + } + else if (ctn.OperType == "delete") + { + await _bookingOrderContaRepository.DeleteAsync(x => x.Id == ctn.obj.Id); + } + }); + } + + result.succ = true; + result.msg = "更新订舱成功"; } catch(Exception ex) {