From 03c11a61ed300850da1ba69a42e5c0d6aeb6507e Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Tue, 26 Mar 2024 11:22:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=88=B1=E5=8D=95=E5=8F=91=E9=80=81=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrderSeaeEdiService.cs | 103 ++++++++++-------- 1 file changed, 59 insertions(+), 44 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrderSeaeEdi/BookingOrderSeaeEdiService.cs b/Myshipping.Application/Service/BookingOrderSeaeEdi/BookingOrderSeaeEdiService.cs index a6eb9e8d..ff0644cd 100644 --- a/Myshipping.Application/Service/BookingOrderSeaeEdi/BookingOrderSeaeEdiService.cs +++ b/Myshipping.Application/Service/BookingOrderSeaeEdi/BookingOrderSeaeEdiService.cs @@ -377,12 +377,20 @@ namespace Myshipping.Application // 舱单主单 var mainSeaOrder = waitCheckSeaList.FirstOrDefault(x => string.IsNullOrWhiteSpace(x.HBLNO)); - if (mainSeaOrder != null) + + // 是否检验舱单主单 + var isCheckMainSea = true; + if (mainSeaOrder == null) { - // 舱单分单 - var subSeaOrderList = waitCheckSeaList.Where(x => !string.IsNullOrWhiteSpace(x.HBLNO)).ToList(); + isCheckMainSea = false; + mainSeaOrder = await _seaeedi.AsQueryable().Filter(null, true).Where(x => x.BookingId == bkOrderId && string.IsNullOrWhiteSpace(x.HBLNO)).FirstAsync(); + } + // 舱单分单 + var subSeaOrderList = waitCheckSeaList.Where(x => !string.IsNullOrWhiteSpace(x.HBLNO)).ToList(); - // 校验1:船名航次,唛头,货描 ,起运港,卸货港,主单提单号 + // 校验1:船名航次,唛头,货描 ,起运港,卸货港,主单提单号 + if (isCheckMainSea) + { if (bkOrder.MBLNO != mainSeaOrder.MBLNO) checkResult.Add("舱单主单与订舱【提单号】不一致"); if (bkOrder.VESSEL != mainSeaOrder.VESSEL) checkResult.Add("舱单主单与订舱【船名】不一致"); if (bkOrder.VOYNO != mainSeaOrder.VOYNO) checkResult.Add("舱单主单与订舱【航次】不一致"); @@ -390,21 +398,25 @@ namespace Myshipping.Application if (bkOrder.DESCRIPTION != mainSeaOrder.DESCRIPTION) checkResult.Add("舱单主单与订舱【货描】不一致"); if (bkOrder.PORTLOADID != mainSeaOrder.PORTLOADID || bkOrder.PORTLOAD != mainSeaOrder.PORTLOAD) checkResult.Add("舱单主单与订舱【起运港】不一致"); if (bkOrder.PORTDISCHARGEID != mainSeaOrder.PORTDISCHARGEID || bkOrder.PORTDISCHARGE != mainSeaOrder.PORTDISCHARGE) checkResult.Add("舱单主单与订舱【卸货港】不一致"); - subSeaOrderList.ForEach(x => - { - if (bkOrder.VESSEL != x.VESSEL) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【船名】不一致"); - if (bkOrder.VOYNO != x.VOYNO) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【航次】不一致"); - if (bkOrder.MARKS != x.MARKS) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【唛头】不一致"); - if (bkOrder.DESCRIPTION != x.DESCRIPTION) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【货描】不一致"); - if (bkOrder.PORTLOADID != x.PORTLOADID || bkOrder.PORTLOAD != x.PORTLOAD) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【起运港】不一致"); - if (bkOrder.PORTDISCHARGEID != x.PORTDISCHARGEID || bkOrder.PORTDISCHARGE != x.PORTDISCHARGE) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【卸货港】不一致"); - }); + } + subSeaOrderList.ForEach(x => + { + if (bkOrder.VESSEL != x.VESSEL) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【船名】不一致"); + if (bkOrder.VOYNO != x.VOYNO) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【航次】不一致"); + if (bkOrder.MARKS != x.MARKS) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【唛头】不一致"); + if (bkOrder.DESCRIPTION != x.DESCRIPTION) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【货描】不一致"); + if (bkOrder.PORTLOADID != x.PORTLOADID || bkOrder.PORTLOAD != x.PORTLOAD) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【起运港】不一致"); + if (bkOrder.PORTDISCHARGEID != x.PORTDISCHARGEID || bkOrder.PORTDISCHARGE != x.PORTDISCHARGE) checkResult.Add($"舱单分单【{x.HBLNO}】与订舱【卸货港】不一致"); + }); - // 校验2:件重尺 - var 主单箱子列表 = waitCheckSeaCtnList.Where(x => x.PId == mainSeaOrder.Id).ToList(); - var 分单箱子列表 = waitCheckSeaCtnList.Where(x => x.PId != mainSeaOrder.Id).ToList(); + // 校验2:件重尺 + var 主单箱子列表 = waitCheckSeaCtnList.Where(x => x.PId == mainSeaOrder.Id).ToList(); + var 分单箱子列表 = waitCheckSeaCtnList.Where(x => x.PId != mainSeaOrder.Id).ToList(); + + if (isCheckMainSea) + { foreach (var item in 主单箱子列表.GroupBy(x => x.CNTRNO)) { if (item.Sum(x => x.PKGS) != 订舱箱子列表.Where(x => x.CNTRNO == item.Key).Sum(x => x.PKGS)) @@ -420,28 +432,31 @@ namespace Myshipping.Application checkResult.Add($"箱号为【{item.Key}】的箱子,在舱单主单中的【尺码】与订舱中同箱号箱子的【尺码】不一致"); } } + } - foreach (var item in 分单箱子列表.GroupBy(x => x.CNTRNO)) + foreach (var item in 分单箱子列表.GroupBy(x => x.CNTRNO)) + { + if (item.Sum(x => x.PKGS) > 订舱箱子列表.Where(x => x.CNTRNO == item.Key).Sum(x => x.PKGS)) { - if (item.Sum(x => x.PKGS) > 主单箱子列表.Where(x => x.CNTRNO == item.Key).Sum(x => x.PKGS)) - { - checkResult.Add($"箱号为【{item.Key}】的箱子,在舱单各分单中的【总件数】大于主单中同箱号箱子的件数"); - } - if (item.Sum(x => x.KGS) > 主单箱子列表.Where(x => x.CNTRNO == item.Key).Sum(x => x.KGS)) - { - checkResult.Add($"箱号为【{item.Key}】的箱子,在舱单各分单中的【总重量】大于主单中同箱号箱子的重量"); - } - if (item.Sum(x => x.CBM) > 主单箱子列表.Where(x => x.CNTRNO == item.Key).Sum(x => x.CBM)) - { - checkResult.Add($"箱号为【{item.Key}】的箱子,在舱单各分单中的【总尺码】大于主单中同箱号箱子的尺码"); - } + checkResult.Add($"箱号为【{item.Key}】的箱子,在舱单各分单中的【总件数】大于订舱中同箱号箱子的件数"); } + if (item.Sum(x => x.KGS) > 订舱箱子列表.Where(x => x.CNTRNO == item.Key).Sum(x => x.KGS)) + { + checkResult.Add($"箱号为【{item.Key}】的箱子,在舱单各分单中的【总重量】大于订舱中同箱号箱子的重量"); + } + if (item.Sum(x => x.CBM) > 订舱箱子列表.Where(x => x.CNTRNO == item.Key).Sum(x => x.CBM)) + { + checkResult.Add($"箱号为【{item.Key}】的箱子,在舱单各分单中的【总尺码】大于订舱中同箱号箱子的尺码"); + } + } - // 校验3:箱号+封号+箱型 - var 订舱箱封号箱型列表 = 订舱箱子列表.Select(x => $"箱号[{x.CNTRNO}] 封号[{x.SEALNO}] 箱型[{x.CTNALL.Replace("'", "")}]").ToList(); - var 主单箱封号箱型列表 = 主单箱子列表.Select(x => $"箱号[{x.CNTRNO}] 封号[{x.SEALNO}] 箱型[{x.CTNALL.Replace("'", "")}]").ToList(); - var 分单箱封号箱型列表 = 分单箱子列表.Select(x => $"箱号[{x.CNTRNO}] 封号[{x.SEALNO}] 箱型[{x.CTNALL.Replace("'", "")}]").Distinct().ToList(); + // 校验3:箱号+封号+箱型 + var 订舱箱封号箱型列表 = 订舱箱子列表.Select(x => $"箱号[{x.CNTRNO}] 封号[{x.SEALNO}] 箱型[{x.CTNALL.Replace("'", "")}]").ToList(); + var 主单箱封号箱型列表 = 主单箱子列表.Select(x => $"箱号[{x.CNTRNO}] 封号[{x.SEALNO}] 箱型[{x.CTNALL.Replace("'", "")}]").ToList(); + var 分单箱封号箱型列表 = 分单箱子列表.Select(x => $"箱号[{x.CNTRNO}] 封号[{x.SEALNO}] 箱型[{x.CTNALL.Replace("'", "")}]").Distinct().ToList(); + if (isCheckMainSea) + { var list1 = 订舱箱封号箱型列表.Except(主单箱封号箱型列表); if (list1.Any()) { @@ -454,19 +469,19 @@ namespace Myshipping.Application { checkResult.Add($"舱单主单中的下列箱信息在订舱中不存在:{string.Join(",", list2)}"); } - - var list3 = 分单箱封号箱型列表.Except(主单箱封号箱型列表); - if (list3.Any()) - { - checkResult.Add($"舱单分单中存在未知的箱信息:{string.Join(",", list3)}"); - } } + } + var list3 = 分单箱封号箱型列表.Except(订舱箱封号箱型列表); + if (list3.Any()) + { + checkResult.Add($"舱单分单中存在未知的箱信息:{string.Join(",", list3)}"); + } - if (checkResult.Count > 0) - { - UnifyContext.Fill(new { checkResult }); - throw new Exception("校验不通过"); - } + + if (checkResult.Count > 0) + { + UnifyContext.Fill(new { checkResult }); + throw new Exception("校验不通过"); } } #endregion