From 881df3dced7afa87621e8a51807505c277e81ba6 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Sat, 28 Jan 2023 17:25:50 +0800 Subject: [PATCH] =?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 样本业务提取帮助类