From d8000c33f20bd6fac0af5c66723bea4ef5b7eaf1 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 20 Nov 2024 14:15:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9SITC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingOrderService.cs | 291 ++++++++++++++---- Myshipping.Core/Myshipping.Core.xml | 5 + 2 files changed, 228 insertions(+), 68 deletions(-) diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 22dba39c..4735a2e3 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -8255,121 +8255,245 @@ namespace Myshipping.Application var currPortInfo = ediLoadPortList.FirstOrDefault(a => a.Code.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}的EDI代码未找到"); + if (currPortInfo != null) + { + multiline.FstPortLoadCode = currPortInfo.MapCode?.Trim(); + multiline.FstPortLoad = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - multiline.FstPortLoadCode = currPortInfo.MapCode?.Trim(); - multiline.FstPortLoad = currPortInfo.MapName?.Trim(); + if (currTPortInfo != null) + { + multiline.FstPortLoadCode = currTPortInfo.MapCode?.Trim(); + multiline.FstPortLoad = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"一程装货港{multiline.FstPortLoadCode}基础港口代码未找到"); + } + } } //一程卸货港 if (!string.IsNullOrWhiteSpace(multiline.FstPortDischargeCode)) { - var sameList = portList.Where(a => + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.FstPortDischargeCode, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo != null) + { + multiline.FstPortDischargeCode = currPortInfo.MapCode?.Trim(); + multiline.FstPortDischarge = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => !string.IsNullOrWhiteSpace(a.EdiCode) && a.EdiCode.Equals(multiline.FstPortDischargeCode, StringComparison.OrdinalIgnoreCase)) .Select(a => a.Code).ToList(); - if (sameList == null || sameList.Count == 0) - throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}基础港口代码未找到"); - - var currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code) - && !string.IsNullOrWhiteSpace(a.CarrierCode) - && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - { - currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code)); + if (currTPortInfo != null) + { + multiline.FstPortDischargeCode = currTPortInfo.MapCode?.Trim(); + multiline.FstPortDischarge = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } } - - if (currPortInfo == null) - throw Oops.Bah($"一程卸货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); - - multiline.FstPortDischargeCode = currPortInfo.MapCode?.Trim(); - multiline.FstPortDischarge = currPortInfo.MapName?.Trim(); } - //二程装货港 if (!string.IsNullOrWhiteSpace(multiline.SecPortLoadCode)) { var currPortInfo = ediLoadPortList.FirstOrDefault(a => a.Code.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - throw Oops.Bah($"二程装货港{multiline.SecPortLoadCode}的EDI代码未找到"); + if (currPortInfo != null) + { + multiline.SecPortLoadCode = currPortInfo.MapCode?.Trim(); + multiline.SecPortLoad = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - multiline.SecPortLoadCode = currPortInfo.MapCode?.Trim(); - multiline.SecPortLoad = currPortInfo.MapName?.Trim(); + if (currTPortInfo != null) + { + multiline.SecPortLoadCode = currTPortInfo.MapCode?.Trim(); + multiline.SecPortLoad = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"二程装货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"二程装货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } + } } //二程卸货港 if (!string.IsNullOrWhiteSpace(multiline.SecPortDischargeCode)) { - var sameList = portList.Where(a => + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.SecPortDischargeCode, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo != null) + { + multiline.SecPortDischargeCode = currPortInfo.MapCode?.Trim(); + multiline.SecPortDischarge = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => !string.IsNullOrWhiteSpace(a.EdiCode) && a.EdiCode.Equals(multiline.SecPortDischargeCode, StringComparison.OrdinalIgnoreCase)) .Select(a => a.Code).ToList(); - if (sameList == null || sameList.Count == 0) - throw Oops.Bah($"二程卸货港{multiline.SecPortDischargeCode}基础港口代码未找到"); - - var currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code) - && !string.IsNullOrWhiteSpace(a.CarrierCode) - && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - { - currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code)); + if (currTPortInfo != null) + { + multiline.SecPortDischargeCode = currTPortInfo.MapCode?.Trim(); + multiline.SecPortDischarge = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"二程卸货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"二程卸货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } } - - if (currPortInfo == null) - throw Oops.Bah($"二程卸货港{multiline.SecPortDischargeCode}的映射EDI代码未找到"); - - multiline.SecPortDischargeCode = currPortInfo.MapCode?.Trim(); - multiline.SecPortDischarge = currPortInfo.MapName?.Trim(); } - //三程装货港 if (!string.IsNullOrWhiteSpace(multiline.ThdPortLoadCode)) { var currPortInfo = ediLoadPortList.FirstOrDefault(a => a.Code.Equals(multiline.ThdPortLoadCode, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - throw Oops.Bah($"三程装货港{multiline.ThdPortLoadCode}的EDI代码未找到"); + if (currPortInfo != null) + { + multiline.ThdPortLoadCode = currPortInfo.MapCode?.Trim(); + multiline.ThdPortLoad = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => + !string.IsNullOrWhiteSpace(a.EdiCode) + && a.EdiCode.Equals(multiline.ThdPortLoadCode, StringComparison.OrdinalIgnoreCase)) + .Select(a => a.Code).ToList(); + + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - multiline.ThdPortLoadCode = currPortInfo.MapCode?.Trim(); - multiline.ThdPortLoad = currPortInfo.MapName?.Trim(); + if (currTPortInfo != null) + { + multiline.ThdPortLoadCode = currTPortInfo.MapCode?.Trim(); + multiline.ThdPortLoad = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"三程装货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"三程装货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } + } } //三程卸货港 if (!string.IsNullOrWhiteSpace(multiline.ThdPortDischargeCode)) { - var sameList = portList.Where(a => + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.ThdPortDischargeCode, StringComparison.OrdinalIgnoreCase)); + + if (currPortInfo != null) + { + multiline.ThdPortDischargeCode = currPortInfo.MapCode?.Trim(); + multiline.ThdPortDischarge = currPortInfo.MapName?.Trim(); + } + else + { + var codePortList = portList.Where(a => !string.IsNullOrWhiteSpace(a.EdiCode) && a.EdiCode.Equals(multiline.ThdPortDischargeCode, StringComparison.OrdinalIgnoreCase)) .Select(a => a.Code).ToList(); - if (sameList == null || sameList.Count == 0) - throw Oops.Bah($"三程卸货港{multiline.ThdPortDischargeCode}基础港口代码未找到"); - - var currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code) - && !string.IsNullOrWhiteSpace(a.CarrierCode) - && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + if (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); - if (currPortInfo == null) - { - currPortInfo = ediPortList.FirstOrDefault(a => - sameList.Contains(a.Code)); + if (currTPortInfo != null) + { + multiline.ThdPortDischargeCode = currTPortInfo.MapCode?.Trim(); + multiline.ThdPortDischarge = currTPortInfo.MapName?.Trim(); + } + else + { + throw Oops.Bah($"三程卸货港{multiline.FstPortDischargeCode}的映射EDI代码未找到"); + } + } + else + { + throw Oops.Bah($"三程卸货港{multiline.FstPortDischargeCode}基础港口代码未找到"); + } } - - if (currPortInfo == null) - throw Oops.Bah($"三程卸货港{multiline.ThdPortDischargeCode}的映射EDI代码未找到"); - - multiline.ThdPortDischargeCode = currPortInfo.MapCode?.Trim(); - multiline.ThdPortDischarge = currPortInfo.MapName?.Trim(); } #endregion @@ -12527,6 +12651,37 @@ namespace Myshipping.Application { result.extra2 = record; } + else + { + record = new BookingMultiLineSplitRecord(); + + if (!string.IsNullOrWhiteSpace(order.PORTLOADID)) + { + record.FstPortLoadCode = order.PORTLOADID; + record.FstPortLoad = order.PORTLOAD; + } + + if (!string.IsNullOrWhiteSpace(order.PORTDISCHARGEID)) + { + record.FstPortDischargeCode = order.PORTDISCHARGEID; + record.FstPortDischarge = order.PORTDISCHARGE; + } + + if (!string.IsNullOrWhiteSpace(order.VESSEL)) + { + record.FstVessel = order.VESSEL; + } + + if (!string.IsNullOrWhiteSpace(order.VOYNO)) + { + record.FstVoyno = order.VOYNO; + } + + if (order.ETD.HasValue) + { + record.FstETD = order.ETD.Value; + } + } return result; } diff --git a/Myshipping.Core/Myshipping.Core.xml b/Myshipping.Core/Myshipping.Core.xml index 52acf7a6..8de9c240 100644 --- a/Myshipping.Core/Myshipping.Core.xml +++ b/Myshipping.Core/Myshipping.Core.xml @@ -9750,6 +9750,11 @@ 公开数据:获取箱型映射代码 + + + 起始港和目的港合并查询 + + 代码