diff --git a/Myshipping.Application/EDI/Dtos/EDIBaseModel.cs b/Myshipping.Application/EDI/Dtos/EDIBaseModel.cs index 85f74849..1e84fe4a 100644 --- a/Myshipping.Application/EDI/Dtos/EDIBaseModel.cs +++ b/Myshipping.Application/EDI/Dtos/EDIBaseModel.cs @@ -91,5 +91,203 @@ namespace Myshipping.Application /// 付费方式代码 /// public string PAYABLE { get; set; } + + /// + /// 海丰扩展信息 + /// + public SITCExtInfo SITCExt { get; set; } + } + + public class SITCExtInfo + { + /// + /// 运程类型(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferType { get; set; } + + /// + /// 运程类型名称(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferTypeName { get; set; } + + /// + /// 一程运力类型(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacity { get; set; } + + /// + /// 一程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacityName { get; set; } + + /// + /// 一程ETD + /// + public Nullable FstETD { get; set; } + + /// + /// 一程船名 + /// + public string FstVessel { get; set; } + + /// + /// 一程航次号 + /// + public string FstVoyno { get; set; } + + /// + /// 一程装货港代码 + /// + public string FstPortLoadCode { get; set; } + + /// + /// 一程装货港名称 + /// + public string FstPortLoad { get; set; } + + /// + /// 一程卸货港代码 + /// + public string FstPortDischargeCode { get; set; } + + /// + /// 一程卸货港名称 + /// + public string FstPortDischarge { get; set; } + + /// + /// 一程港属类型(LOCATION-本港) + /// + public string FstTransferLocType { get; set; } + + /// + /// 一程港属类型名称(LOCATION-本港) + /// + public string FstTransferLogTypeName { get; set; } + + /// + /// 一程航线 + /// + public string FstLaneName { get; set; } + + /// + /// 二程运力类型(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacity { get; set; } + + /// + /// 二程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacityName { get; set; } + + /// + /// 二程ETD + /// + public Nullable SecETD { get; set; } + + /// + /// 二程船名 + /// + public string SecVessel { get; set; } + + /// + /// 二程航次号 + /// + public string SecVoyno { get; set; } + + /// + /// 二程装货港代码 + /// + public string SecPortLoadCode { get; set; } + + /// + /// 二程装货港名称 + /// + public string SecPortLoad { get; set; } + + /// + /// 二程卸货港代码 + /// + public string SecPortDischargeCode { get; set; } + + /// + /// 二程卸货港名称 + /// + public string SecPortDischarge { get; set; } + + /// + /// 二程港属类型(LOCATION-本港) + /// + public string SecTransferLocType { get; set; } + + /// + /// 二程港属类型名称(LOCATION-本港) + /// + public string SecTransferLogTypeName { get; set; } + + /// + /// 二程航线 + /// + public string SecLaneName { get; set; } + + /// + /// 三程运力类型(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacity { get; set; } + + /// + /// 三程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacityName { get; set; } + + /// + /// 三程ETD + /// + public Nullable ThdETD { get; set; } + + /// + /// 三程船名 + /// + public string ThdVessel { get; set; } + + /// + /// 三程航次号 + /// + public string ThdVoyno { get; set; } + + /// + /// 三程装货港代码 + /// + public string ThdPortLoadCode { get; set; } + + /// + /// 三程装货港名称 + /// + public string ThdPortLoad { get; set; } + + /// + /// 三程卸货港代码 + /// + public string ThdPortDischargeCode { get; set; } + + /// + /// 三程卸货港名称 + /// + public string ThdPortDischarge { get; set; } + + /// + /// 三程港属类型(LOCATION-本港) + /// + public string ThdTransferLocType { get; set; } + + /// + /// 三程港属类型名称(LOCATION-本港) + /// + public string ThdTransferLogTypeName { get; set; } + + /// + /// 三程航线 + /// + public string ThdLaneName { get; set; } } } diff --git a/Myshipping.Application/EDI/SITCEdiHelper.cs b/Myshipping.Application/EDI/SITCEdiHelper.cs index 5ce06f6f..04b6c42c 100644 --- a/Myshipping.Application/EDI/SITCEdiHelper.cs +++ b/Myshipping.Application/EDI/SITCEdiHelper.cs @@ -1,5 +1,7 @@ using DocumentFormat.OpenXml.ExtendedProperties; using Google.Protobuf.WellKnownTypes; +using Mapster.Utils; +using MathNet.Numerics.LinearAlgebra.Factorization; using Myshipping.Application.EDI.ESL; using MySqlX.XDevAPI.Common; using Newtonsoft.Json; @@ -203,6 +205,101 @@ namespace Myshipping.Application.EDI.SITC }); } + /* + 1.直达无需处理 OUT特殊设置TRA + 2.若有中转,根据一程 二程 三程 处理 json中 clen的值‘1-3’ + 3.干线支线的选择,如接口文档中 支线:0 干线:1 + 4.港口及代码的处理,均按照映射中 船公司为SITC的港口代码进行处理 + 5.运输类型 cCommodity 默认为0 + */ + if (InttrEdi.SITCExt != null && !string.IsNullOrWhiteSpace(InttrEdi.SITCExt.TransferType) && !InttrEdi.SITCExt.TransferType.Equals("DIRECT",StringComparison.OrdinalIgnoreCase)) + { + if (InttrEdi.SITCExt.TransferType.Equals("SECOND", StringComparison.OrdinalIgnoreCase)) + { + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 1, + cnum = InttrEdi.SITCExt.FstShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.FstVoyno?.Trim(), + humdity = InttrEdi.SITCExt.FstVessel?.Trim(), + soc = InttrEdi.SITCExt.FstLaneName?.Trim(), + unit = InttrEdi.SITCExt.FstPortLoad, + tempSetting = InttrEdi.SITCExt.FstPortDischarge, + tempMax = InttrEdi.SITCExt.FstPortLoadCode, + tempMin = InttrEdi.SITCExt.FstPortDischargeCode, + etd = InttrEdi.SITCExt.FstETD.HasValue? InttrEdi.SITCExt.FstETD.Value.ToString("yyyy-MM-dd"):"", + cCommodity = "0" + }); + + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 2, + cnum = InttrEdi.SITCExt.SecShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.SecVoyno?.Trim(), + humdity = InttrEdi.SITCExt.SecVessel?.Trim(), + soc = InttrEdi.SITCExt.SecLaneName?.Trim(), + unit = InttrEdi.SITCExt.SecPortLoad, + tempSetting = InttrEdi.SITCExt.SecPortDischarge, + tempMax = InttrEdi.SITCExt.SecPortLoadCode, + tempMin = InttrEdi.SITCExt.SecPortDischargeCode, + etd = InttrEdi.SITCExt.SecETD.HasValue ? InttrEdi.SITCExt.SecETD.Value.ToString("yyyy-MM-dd") : "", + cCommodity = "0" + }); + } + else if (InttrEdi.SITCExt.TransferType.Equals("THIRD", StringComparison.OrdinalIgnoreCase)) + { + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 1, + cnum = InttrEdi.SITCExt.FstShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.FstVoyno?.Trim(), + humdity = InttrEdi.SITCExt.FstVessel?.Trim(), + soc = InttrEdi.SITCExt.FstLaneName?.Trim(), + unit = InttrEdi.SITCExt.FstPortLoad, + tempSetting = InttrEdi.SITCExt.FstPortDischarge, + tempMax = InttrEdi.SITCExt.FstPortLoadCode, + tempMin = InttrEdi.SITCExt.FstPortDischargeCode, + etd = InttrEdi.SITCExt.FstETD.HasValue ? InttrEdi.SITCExt.FstETD.Value.ToString("yyyy-MM-dd") : "", + cCommodity = "0" + }); + + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 2, + cnum = InttrEdi.SITCExt.SecShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.SecVoyno?.Trim(), + humdity = InttrEdi.SITCExt.SecVessel?.Trim(), + soc = InttrEdi.SITCExt.SecLaneName?.Trim(), + unit = InttrEdi.SITCExt.SecPortLoad, + tempSetting = InttrEdi.SITCExt.SecPortDischarge, + tempMax = InttrEdi.SITCExt.SecPortLoadCode, + tempMin = InttrEdi.SITCExt.SecPortDischargeCode, + etd = InttrEdi.SITCExt.SecETD.HasValue ? InttrEdi.SITCExt.SecETD.Value.ToString("yyyy-MM-dd") : "", + cCommodity = "0" + }); + + postModel.extras.Add(new SitcApiPostModelExtra + { + ctype = "TRA", + clen = 3, + cnum = InttrEdi.SITCExt.ThdShipCapacity == "MAIN" ? 1 : 0, + vent = InttrEdi.SITCExt.ThdVoyno?.Trim(), + humdity = InttrEdi.SITCExt.ThdVessel?.Trim(), + soc = InttrEdi.SITCExt.ThdLaneName?.Trim(), + unit = InttrEdi.SITCExt.ThdPortLoad, + tempSetting = InttrEdi.SITCExt.ThdPortDischarge, + tempMax = InttrEdi.SITCExt.ThdPortLoadCode, + tempMin = InttrEdi.SITCExt.ThdPortDischargeCode, + etd = InttrEdi.SITCExt.ThdETD.HasValue ? InttrEdi.SITCExt.ThdETD.Value.ToString("yyyy-MM-dd") : "", + cCommodity = "0" + }); + } + } + string json = JsonConvert.SerializeObject(postModel, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore @@ -573,6 +670,31 @@ namespace Myshipping.Application.EDI.SITC /// 类型 /// public string ctype { get; set; } + + /// + /// 程次(TRA) + /// + public Nullable clen { get; set; } + + /// + /// 支线:0;干线:1(TRA) + /// + public Nullable cnum { get; set; } + + /// + /// 航线代码 + /// + public string soc { get; set; } + + /// + /// 开航日 + /// + public string etd { get; set; } + + /// + /// 运输类型 + /// + public string cCommodity { get; set; } } public class SitcApiPostModelDangerInfo diff --git a/Myshipping.Application/Entity/BookingMultiLineSplitRecord.cs b/Myshipping.Application/Entity/BookingMultiLineSplitRecord.cs index 6081a167..f56d313d 100644 --- a/Myshipping.Application/Entity/BookingMultiLineSplitRecord.cs +++ b/Myshipping.Application/Entity/BookingMultiLineSplitRecord.cs @@ -75,5 +75,195 @@ namespace Myshipping.Application.Entity /// 付费方式代码 /// public string PAYABLE { get; set; } + + /// + /// 运程类型(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferType { get; set; } + + /// + /// 运程类型名称(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferTypeName { get; set; } + + /// + /// 一程运力类型(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacity { get; set; } + + /// + /// 一程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacityName { get; set; } + + /// + /// 一程ETD + /// + public Nullable FstETD { get; set; } + + /// + /// 一程船名 + /// + public string FstVessel { get; set; } + + /// + /// 一程航次号 + /// + public string FstVoyno { get; set; } + + /// + /// 一程装货港代码 + /// + public string FstPortLoadCode { get; set; } + + /// + /// 一程装货港名称 + /// + public string FstPortLoad { get; set; } + + /// + /// 一程卸货港代码 + /// + public string FstPortDischargeCode { get; set; } + + /// + /// 一程卸货港名称 + /// + public string FstPortDischarge { get; set; } + + /// + /// 一程港属类型(LOCATION-本港) + /// + public string FstTransferLocType { get; set; } + + /// + /// 一程港属类型名称(LOCATION-本港) + /// + public string FstTransferLogTypeName { get; set; } + + /// + /// 一程航线 + /// + public string FstLaneName { get; set; } + + /// + /// 二程运力类型(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacity { get; set; } + + /// + /// 二程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacityName { get; set; } + + /// + /// 二程ETD + /// + public Nullable SecETD { get; set; } + + /// + /// 二程船名 + /// + public string SecVessel { get; set; } + + /// + /// 二程航次号 + /// + public string SecVoyno { get; set; } + + /// + /// 二程装货港代码 + /// + public string SecPortLoadCode { get; set; } + + /// + /// 二程装货港名称 + /// + public string SecPortLoad { get; set; } + + /// + /// 二程卸货港代码 + /// + public string SecPortDischargeCode { get; set; } + + /// + /// 二程卸货港名称 + /// + public string SecPortDischarge { get; set; } + + /// + /// 二程港属类型(LOCATION-本港) + /// + public string SecTransferLocType { get; set; } + + /// + /// 二程港属类型名称(LOCATION-本港) + /// + public string SecTransferLogTypeName { get; set; } + + /// + /// 二程航线 + /// + public string SecLaneName { get; set; } + + /// + /// 三程运力类型(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacity { get; set; } + + /// + /// 三程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacityName { get; set; } + + /// + /// 三程ETD + /// + public Nullable ThdETD { get; set; } + + /// + /// 三程船名 + /// + public string ThdVessel { get; set; } + + /// + /// 三程航次号 + /// + public string ThdVoyno { get; set; } + + /// + /// 三程装货港代码 + /// + public string ThdPortLoadCode { get; set; } + + /// + /// 三程装货港名称 + /// + public string ThdPortLoad { get; set; } + + /// + /// 三程卸货港代码 + /// + public string ThdPortDischargeCode { get; set; } + + /// + /// 三程卸货港名称 + /// + public string ThdPortDischarge { get; set; } + + /// + /// 三程港属类型(LOCATION-本港) + /// + public string ThdTransferLocType { get; set; } + + /// + /// 三程港属类型名称(LOCATION-本港) + /// + public string ThdTransferLogTypeName { get; set; } + + /// + /// 三程航线 + /// + public string ThdLaneName { get; set; } } } diff --git a/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecord.cs b/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecord.cs new file mode 100644 index 00000000..bb905731 --- /dev/null +++ b/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecord.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using SqlSugar; +using Myshipping.Core.Entity; +using System.ComponentModel; + +namespace Myshipping.Application +{ + /// + /// 舱位管理主信息 + /// + [SugarTable("booking_slot_base", TableDescription = "舱位管理主信息")] + public class BookingSlotChangeRecord : DBEntityTenant + { + /// + /// 舱位主键 + /// + [SugarColumn(ColumnName = "SLOT_ID")] + [Description("舱位主键")] + public Nullable SLOT_ID { get; set; } + + /// + /// 订单主键 + /// + [SugarColumn(ColumnName = "BOOKING_ID")] + [Description("订单主键")] + public Nullable BOOKING_ID { get; set; } + + /// + /// 变更类型标记 BEFORE-变更前,CURRENT-变更后 + /// + [SugarColumn(ColumnName = "CHANGE_FLAG")] + [Description("变更类型标记")] + public string CHANGE_FLAG { get; set; } + + /// + /// 变更范围类型 SINGLE-单票变更,ALLSHIP-整船变更(例如截止时间变更) + /// + [SugarColumn(ColumnName = "CHANGE_RANGE")] + [Description("变更类型标记")] + public string CHANGE_RANGE { get; set; } + + /// + /// 主提单号 + /// + [SugarColumn(ColumnName = "MBL_NO")] + [Description("主提单号")] + public string MBL_NO { get; set; } + + /// + /// 真提单号 + /// + [SugarColumn(ColumnName = "REAL_MBL_NO")] + [Description("真提单号")] + public string REAL_MBL_NO { get; set; } + + /// + /// 合约号 + /// + [SugarColumn(ColumnName = "CONTRACT_NO")] + [Description("合约号")] + public string CONTRACT_NO { get; set; } + + /// + /// 订舱抬头 + /// + [SugarColumn(ColumnName = "BOOKING_PARTY")] + [Description("订舱抬头")] + public string BOOKING_PARTY { get; set; } + } +} diff --git a/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecordNotify.cs b/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecordNotify.cs new file mode 100644 index 00000000..9ca963ed --- /dev/null +++ b/Myshipping.Application/Entity/BookingSlotChange/BookingSlotChangeRecordNotify.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class BookingSlotChangeRecordNotify + { + } +} diff --git a/Myshipping.Application/Myshipping.Application.csproj b/Myshipping.Application/Myshipping.Application.csproj index b636ec8f..77e3a3ba 100644 --- a/Myshipping.Application/Myshipping.Application.csproj +++ b/Myshipping.Application/Myshipping.Application.csproj @@ -26,6 +26,7 @@ + diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index e7c64160..9576eb24 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -39,6 +39,7 @@ using Myshipping.Core.Service; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NPOI.HSSF.UserModel; +using NPOI.POIFS.Properties; using NPOI.SS.UserModel; using RabbitMQ.Client; using SqlSugar; @@ -8246,6 +8247,497 @@ namespace Myshipping.Application primaryModel.FEETYPE = multiline.FEETYPE; primaryModel.PAYABLEEXT = multiline.PAYABLE; + + #region 必填校验 + //校验所有填写项必填,ETD必须顺序填写 + if (string.IsNullOrWhiteSpace(multiline.TransferType) && multiline.TransferType.Equals("SECOND", StringComparison.OrdinalIgnoreCase)) + { + List checkSITCList = new List(); + + if(!multiline.FstETD.HasValue) + { + checkSITCList.Add("一程开船日期"); + } + + if (!multiline.SecETD.HasValue) + { + checkSITCList.Add("二程开船日期"); + } + + if (multiline.FstETD.Value >= multiline.SecETD.Value) + { + checkSITCList.Add("一程开船日期不能大于等于二程开船日期"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortLoadCode)) + { + checkSITCList.Add("一程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortLoad)) + { + checkSITCList.Add("一程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortDischargeCode)) + { + checkSITCList.Add("一程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortDischarge)) + { + checkSITCList.Add("一程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstVessel)) + { + checkSITCList.Add("一程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstVoyno)) + { + checkSITCList.Add("一程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstLaneName)) + { + checkSITCList.Add("一程航线"); + } + + + if (string.IsNullOrWhiteSpace(multiline.SecPortLoadCode)) + { + checkSITCList.Add("二程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortLoad)) + { + checkSITCList.Add("二程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortDischargeCode)) + { + checkSITCList.Add("二程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortDischarge)) + { + checkSITCList.Add("二程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecVessel)) + { + checkSITCList.Add("二程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecVoyno)) + { + checkSITCList.Add("二程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecLaneName)) + { + checkSITCList.Add("二程航线"); + } + + if (checkSITCList.Count > 0) + { + throw Oops.Oh(string.Join(",", checkSITCList.ToArray()) + " 必填"); + } + } + + if (string.IsNullOrWhiteSpace(multiline.TransferType) && multiline.TransferType.Equals("THIRD", StringComparison.OrdinalIgnoreCase)) + { + List checkSITCList = new List(); + + if (!multiline.FstETD.HasValue) + { + checkSITCList.Add("一程开船日期必填"); + } + + if (!multiline.SecETD.HasValue) + { + checkSITCList.Add("二程开船日期必填"); + } + + if (!multiline.ThdETD.HasValue) + { + checkSITCList.Add("三程开船日期必填"); + } + + if (multiline.FstETD.Value >= multiline.SecETD.Value) + { + checkSITCList.Add("一程开船日期不能大于等于二程开船日期"); + } + + if (multiline.SecETD.Value >= multiline.ThdETD.Value) + { + checkSITCList.Add("二程开船日期不能大于等于三程开船日期"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortLoadCode)) + { + checkSITCList.Add("一程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortLoad)) + { + checkSITCList.Add("一程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortDischargeCode)) + { + checkSITCList.Add("一程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstPortDischarge)) + { + checkSITCList.Add("一程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstVessel)) + { + checkSITCList.Add("一程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstVoyno)) + { + checkSITCList.Add("一程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.FstLaneName)) + { + checkSITCList.Add("一程航线"); + } + + + if (string.IsNullOrWhiteSpace(multiline.SecPortLoadCode)) + { + checkSITCList.Add("二程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortLoad)) + { + checkSITCList.Add("二程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortDischargeCode)) + { + checkSITCList.Add("二程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecPortDischarge)) + { + checkSITCList.Add("二程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecVessel)) + { + checkSITCList.Add("二程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecVoyno)) + { + checkSITCList.Add("二程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.SecLaneName)) + { + checkSITCList.Add("二程航线"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdPortLoadCode)) + { + checkSITCList.Add("三程装货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdPortLoad)) + { + checkSITCList.Add("三程装货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdPortDischargeCode)) + { + checkSITCList.Add("三程卸货港代码"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdPortDischarge)) + { + checkSITCList.Add("三程卸货港"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdVessel)) + { + checkSITCList.Add("三程船名"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdVoyno)) + { + checkSITCList.Add("三程航次"); + } + + if (string.IsNullOrWhiteSpace(multiline.ThdLaneName)) + { + checkSITCList.Add("三程航线"); + } + + if (checkSITCList.Count > 0) + { + throw Oops.Oh(string.Join(",", checkSITCList.ToArray()) + " 必填"); + } + } + #endregion + + #region 映射港口 + //一程装货港 + if (!string.IsNullOrWhiteSpace(multiline.FstPortLoadCode)) + { + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.FstPortLoadCode, StringComparison.OrdinalIgnoreCase)); + + 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)); + + 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 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 (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + + 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 (!string.IsNullOrWhiteSpace(multiline.SecPortLoadCode)) + { + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.SecPortLoadCode, StringComparison.OrdinalIgnoreCase)); + + 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)); + + 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 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 (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + + 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 (!string.IsNullOrWhiteSpace(multiline.ThdPortLoadCode)) + { + var currPortInfo = ediLoadPortList.FirstOrDefault(a => + a.Code.Equals(multiline.ThdPortLoadCode, StringComparison.OrdinalIgnoreCase)); + + 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)); + + 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 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 (codePortList.Count > 0) + { + var currTPortInfo = ediPortList.FirstOrDefault(a => + codePortList.Contains(a.Code) + && !string.IsNullOrWhiteSpace(a.CarrierCode) + && a.CarrierCode.Equals(order.CARRIERID, StringComparison.OrdinalIgnoreCase)); + + 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}基础港口代码未找到"); + } + } + } + #endregion + + ediModel.SITCExt = multiline.Adapt(); } } @@ -11017,7 +11509,10 @@ namespace Myshipping.Application } } - List statusList = new List(); + //是否已截单 + bool hasJDStatus = false; + + List statusList = new List(); if (App.Configuration["ServiceStatusOpenAuto"] == "1") { @@ -11042,6 +11537,11 @@ namespace Myshipping.Application { dto.CtnDayNum = statusList.FirstOrDefault(x => x.StatusSKUCode == "SQXS" && x.IsYield)?.ActVal; } + + if (statusList != null && statusList.Any(x => x.StatusSKUCode == "JD" && x.IsYield)) + { + hasJDStatus = statusList.FirstOrDefault(x => x.StatusSKUCode == "JD" && x.IsYield).IsYield; + } } else { @@ -11075,7 +11575,7 @@ namespace Myshipping.Application { List allOrderList = new List(); - if (!string.IsNullOrWhiteSpace(oddCode) && oddCode.Equals("SIReceipt", StringComparison.OrdinalIgnoreCase)) + if ((!string.IsNullOrWhiteSpace(oddCode) && oddCode.Equals("SIReceipt", StringComparison.OrdinalIgnoreCase)) || hasJDStatus) { allOrderList = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == item.Id && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); @@ -12386,6 +12886,91 @@ namespace Myshipping.Application result.succ = true; result.extra = sitcModel; + var record = _repBookingMultiLineSplitRecord.AsQueryable().Where(a => a.BOOKING_ID == model.Id).OrderByDescending(a => a.CreatedTime).First(); + if (record != null) + { + if(string.IsNullOrWhiteSpace(record.TransferType) || record.TransferType.Equals("SECOND",StringComparison.OrdinalIgnoreCase) + || record.TransferType.Equals("THIRD", StringComparison.OrdinalIgnoreCase)) + { + if(string.IsNullOrWhiteSpace(record.FstPortLoadCode) && !string.IsNullOrWhiteSpace(order.PORTLOADID)) + { + record.FstPortLoadCode = order.PORTLOADID; + record.FstPortLoad = order.PORTLOAD; + } + + if(record.TransferType.Equals("SECOND", StringComparison.OrdinalIgnoreCase)) + { + if (string.IsNullOrWhiteSpace(record.SecPortDischargeCode) && !string.IsNullOrWhiteSpace(order.PORTDISCHARGEID)) + { + record.SecPortDischargeCode = order.PORTDISCHARGEID; + record.SecPortDischarge = order.PORTDISCHARGE; + } + } + else if (record.TransferType.Equals("THIRD", StringComparison.OrdinalIgnoreCase)) + { + if (string.IsNullOrWhiteSpace(record.ThdPortDischargeCode) && !string.IsNullOrWhiteSpace(order.PORTDISCHARGEID)) + { + record.ThdPortDischargeCode = order.PORTDISCHARGEID; + record.ThdPortDischarge = order.PORTDISCHARGE; + } + } + + + if (string.IsNullOrWhiteSpace(record.FstVessel) && !string.IsNullOrWhiteSpace(order.VESSEL)) + { + record.FstVessel = order.VESSEL; + } + + if (string.IsNullOrWhiteSpace(record.FstVoyno) && !string.IsNullOrWhiteSpace(order.VOYNO)) + { + record.FstVoyno = order.VOYNO; + } + + if (!record.FstETD.HasValue && order.ETD.HasValue) + { + record.FstETD = order.ETD.Value; + } + } + + 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.SecPortDischargeCode = order.PORTDISCHARGEID; + record.SecPortDischarge = order.PORTDISCHARGE; + + record.ThdPortDischargeCode = order.PORTDISCHARGEID; + record.ThdPortDischarge = 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; + } + + result.extra2 = record; + } + return result; } diff --git a/Myshipping.Application/Service/BookingOrder/Dto/MultilineSplit/BookingMultiLineSplitDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/MultilineSplit/BookingMultiLineSplitDto.cs index 9ffff857..5037d13f 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/MultilineSplit/BookingMultiLineSplitDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/MultilineSplit/BookingMultiLineSplitDto.cs @@ -70,5 +70,195 @@ namespace Myshipping.Application /// 付费方式代码 /// public string PAYABLE { get; set; } + + /// + /// 运程类型(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferType { get; set; } + + /// + /// 运程类型名称(DIRECT-直达,SECOND-二程,THIRD-三程) + /// + public string TransferTypeName { get; set; } + + /// + /// 一程运力类型(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacity { get; set; } + + /// + /// 一程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string FstShipCapacityName { get; set; } + + /// + /// 一程ETD + /// + public Nullable FstETD { get; set; } + + /// + /// 一程船名 + /// + public string FstVessel { get; set; } + + /// + /// 一程航次号 + /// + public string FstVoyno { get; set; } + + /// + /// 一程装货港代码 + /// + public string FstPortLoadCode { get; set; } + + /// + /// 一程装货港名称 + /// + public string FstPortLoad { get; set; } + + /// + /// 一程卸货港代码 + /// + public string FstPortDischargeCode { get; set; } + + /// + /// 一程卸货港名称 + /// + public string FstPortDischarge { get; set; } + + /// + /// 一程港属类型(LOCATION-本港) + /// + public string FstTransferLocType { get; set; } + + /// + /// 一程港属类型名称(LOCATION-本港) + /// + public string FstTransferLogTypeName { get; set; } + + /// + /// 一程航线 + /// + public string FstLaneName { get; set; } + + /// + /// 二程运力类型(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacity { get; set; } + + /// + /// 二程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string SecShipCapacityName { get; set; } + + /// + /// 二程ETD + /// + public Nullable SecETD { get; set; } + + /// + /// 二程船名 + /// + public string SecVessel { get; set; } + + /// + /// 二程航次号 + /// + public string SecVoyno { get; set; } + + /// + /// 二程装货港代码 + /// + public string SecPortLoadCode { get; set; } + + /// + /// 二程装货港名称 + /// + public string SecPortLoad { get; set; } + + /// + /// 二程卸货港代码 + /// + public string SecPortDischargeCode { get; set; } + + /// + /// 二程卸货港名称 + /// + public string SecPortDischarge { get; set; } + + /// + /// 二程港属类型(LOCATION-本港) + /// + public string SecTransferLocType { get; set; } + + /// + /// 二程港属类型名称(LOCATION-本港) + /// + public string SecTransferLogTypeName { get; set; } + + /// + /// 二程航线 + /// + public string SecLaneName { get; set; } + + /// + /// 三程运力类型(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacity { get; set; } + + /// + /// 三程运力类型名称(MAIN-干线,BRANCH-支线) + /// + public string ThdShipCapacityName { get; set; } + + /// + /// 三程ETD + /// + public Nullable ThdETD { get; set; } + + /// + /// 三程船名 + /// + public string ThdVessel { get; set; } + + /// + /// 三程航次号 + /// + public string ThdVoyno { get; set; } + + /// + /// 三程装货港代码 + /// + public string ThdPortLoadCode { get; set; } + + /// + /// 三程装货港名称 + /// + public string ThdPortLoad { get; set; } + + /// + /// 三程卸货港代码 + /// + public string ThdPortDischargeCode { get; set; } + + /// + /// 三程卸货港名称 + /// + public string ThdPortDischarge { get; set; } + + /// + /// 三程港属类型(LOCATION-本港) + /// + public string ThdTransferLocType { get; set; } + + /// + /// 三程港属类型名称(LOCATION-本港) + /// + public string ThdTransferLogTypeName { get; set; } + + /// + /// 三程航线 + /// + public string ThdLaneName { get; set; } } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs index 6b84eb05..99a029e1 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskPOLContainerNotPickUpService.cs @@ -376,7 +376,18 @@ namespace Myshipping.Application if (opEmailList.Count > 0) opEmail = string.Join(";", opEmailList.Distinct().ToArray()); - string emailTitle = $"{model.MBL_NO}-{model.VESSEL}/{model.VOYNO}/ 未提箱订舱取消确认"; + var fstOrder = bookingOrderList.FirstOrDefault(); + + string emailTitle = string.Empty; + + if (fstOrder != null && !string.IsNullOrWhiteSpace(fstOrder.VESSEL)) + { + emailTitle = $"{model.MBL_NO}-{fstOrder.VESSEL}/{fstOrder.VOYNO}/ 未提箱订舱取消确认"; + } + else + { + emailTitle = $"{model.MBL_NO}-{model.VESSEL}/{model.VOYNO}/ 未提箱订舱取消确认"; + } //提取当前公共邮箱的配置 DjyUserMailAccount publicMailAccount = _djyUserMailAccount.AsQueryable().Filter(null, true).First(x => x.TenantId == UserManager.TENANT_ID && x.ShowName == "PublicSend" @@ -530,7 +541,14 @@ namespace Myshipping.Application baseHtml = baseHtml.Replace("#BillNo#", ""); } - if (!string.IsNullOrWhiteSpace(model.VESSEL)) + var fstOrderInfo = bookingOrderList.FirstOrDefault(); + + if (!string.IsNullOrWhiteSpace(fstOrderInfo.VESSEL)) + { + string s = $"{fstOrderInfo.VESSEL}/{fstOrderInfo.VOYNO}"; + baseHtml = baseHtml.Replace("#VesselVoyno#", s); + } + else if (!string.IsNullOrWhiteSpace(model.VESSEL)) { string s = $"{model.VESSEL}/{model.VOYNO}"; baseHtml = baseHtml.Replace("#VesselVoyno#", s); 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 @@ 公开数据:获取箱型映射代码 + + + 起始港和目的港合并查询 + + 代码 diff --git a/Myshipping.Core/Service/CommonDB/CommonDBService.cs b/Myshipping.Core/Service/CommonDB/CommonDBService.cs index fd41684b..ce6179a0 100644 --- a/Myshipping.Core/Service/CommonDB/CommonDBService.cs +++ b/Myshipping.Core/Service/CommonDB/CommonDBService.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging; using Myshipping.Core.Entity.CommonDB; using Microsoft.AspNetCore.Authorization; using System.Reflection.Metadata.Ecma335; +using StackExchange.Profiling.Internal; namespace Myshipping.Core.Service; /// @@ -2430,4 +2431,53 @@ public class CommonDBService : ICommonDBService, IDynamicApiController, ITransie } #endregion + #region 起始港和目的港合并查询 + /// + /// 起始港和目的港合并查询 + /// + [HttpGet("/commondb/portmixlist")] + public async Task PortMixList([FromQuery] NameQueryDto input) + { + List resultList = new List(); + + List codePortLoadlist = await _sysCacheService.GetAllCodePortLoad(); + List codePortDischargelist = await _sysCacheService.GetAllCodePort(); + + var queryList = codePortLoadlist.WhereIF(!string.IsNullOrEmpty(input.KeyWord), + x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) + || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || + x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) || + x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) + .Take(input.Limit).OrderBy(x => x.Sort).ToList(); + + if (queryList.Count > 0) + { + resultList = queryList.Select(a => new CodePort + { + Code = a.Code, + CnName = a.CnName, + EnName = a.EnName, + EdiCode = a.EdiCode, + }).ToList(); + } + + if (queryList.Count < input.Limit) + { + int lessNum = input.Limit - queryList.Count; + + var queryList2 = codePortDischargelist + .WhereIF(!string.IsNullOrEmpty(input.KeyWord), x => x.Code.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) + || x.EnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) + || x.CnName.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase) + || x.EdiCode.Contains(input.KeyWord, System.StringComparison.CurrentCultureIgnoreCase)) + + .Take(lessNum).OrderBy(x => x.Sort).ToList(); + + if (queryList2.Count > 0) + resultList.AddRange(queryList2); + } + + return resultList; + } + #endregion } diff --git a/ServiceProjectSyncWin/Program.cs b/ServiceProjectSyncWin/Program.cs index 8239c339..6ae4ce9c 100644 --- a/ServiceProjectSyncWin/Program.cs +++ b/ServiceProjectSyncWin/Program.cs @@ -27,6 +27,8 @@ using static System.Net.Mime.MediaTypeNames; using RabbitMQ.Client.Events; using Org.BouncyCastle.Utilities.Bzip2; using ICSharpCode.SharpZipLib.BZip2; +using StackExchange.Profiling.Internal; +using System.Drawing; Serve.RunGeneric(additional: services => { @@ -796,6 +798,694 @@ public class SyncHisRecord: ISyncHisRecord,ITransient /* 按照舱位提取未识别合约号的记录,重新调取 */ + string mailFilePath = "C:\\Users\\Administrator\\Desktop\\日志\\Your Transport Plan has Changed - Maersk241111.eml"; + //string mailFilePath = "C:\\Users\\Administrator\\Desktop\\日志\\Your Transport Plan has Changed - Maersk-带reason.eml"; + + + //读取邮件,解析邮件正文 + MimeMessage mimeMsg = MimeMessage.Load(mailFilePath); + + + HtmlDocument html = new HtmlDocument(); + html.LoadHtml(mimeMsg.HtmlBody); + + var divWrapperList = html.DocumentNode.SelectNodes("//div[@class='wrapper']"); + + int perNum = divWrapperList.Count / 4; + + List list = new List(); + + int start = 1; + int currListIdx = 0; + + for (int i = 0; i < divWrapperList.Count; i++) + { + /* + 每隔4行算一票数据 + 1、第一行 BILLNO, 原因 + 2、第二行 装货港、ETD、卸货港、ETA、船名 + 3、第三行 集装箱 + */ + if (start == 1) + { + #region 第一行 BILLNO, 原因 + TransPlanHasChangeDto dto = new TransPlanHasChangeDto + { + From = new TransPlanHasChangeDetailDto + { + portList = new List(), + dateList = new List(), + vesselList = new List() + }, + To = new TransPlanHasChangeDetailDto + { + portList = new List(), + dateList = new List(), + vesselList = new List() + }, + Carrier = "MSK", + ContaNoList = new List() + }; + + list.Add(dto); + + currListIdx = list.Count - 1; + + var billnoNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[1]/td[1]/div"); + + if (billnoNode != null && !string.IsNullOrWhiteSpace(billnoNode.InnerText)) + { + var s = billnoNode.InnerText; + + if (Regex.IsMatch(s, "Bill\\s+of\\s+Lading\\s{0,}:")) + { + var name = Regex.Match(s, "Bill\\s+of\\s+Lading\\s{0,}:").Value; + + list[currListIdx].BillNo = Regex.Match(s, "(?<=" + name + ")\\s{0,}\\w+").Value?.Trim(); + } + } + + var bookNoNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td[1]/div"); + + if (bookNoNode != null && !string.IsNullOrWhiteSpace(bookNoNode.InnerText)) + { + var s = bookNoNode.InnerText; + + if (Regex.IsMatch(s, "Booking\\s+Number\\s{0,}:")) + { + var name = Regex.Match(s, "Booking\\s+Number\\s{0,}:").Value; + + list[currListIdx].BookingNo = Regex.Match(s, "(?<=" + name + ")\\s{0,}\\w+").Value?.Trim(); + } + } + + var reasonNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[1]/td[1]/div"); + + if (reasonNode != null && !string.IsNullOrWhiteSpace(reasonNode.InnerText) && + Regex.IsMatch(reasonNode.InnerText, "Reason\\s+for\\s+the\\s+change:")) + { + var reasonTxtNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td[1]/div"); + + if (reasonTxtNode != null && !string.IsNullOrWhiteSpace(reasonTxtNode.InnerText)) + { + list[currListIdx].ChangeReasonNotes = reasonTxtNode.InnerText; + } + } + #endregion + } + else if (start == 3) + { + #region 处理装货港 + TransPlanHasChangePortDto from = null; + TransPlanHasChangePortDto from2 = null; + + var loadPortNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div/b"); + + if (loadPortNode != null && !string.IsNullOrWhiteSpace(loadPortNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(loadPortNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + from = new TransPlanHasChangePortDto + { + Indx = 1, + PortName = s.Trim(), + IsRemoved = false, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + from.PortName = sArg[0].Trim(); + from.TerminalName = sArg[1].Trim(); + } + } + } + else + { + loadPortNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div"); + + if (loadPortNode != null && !string.IsNullOrWhiteSpace(loadPortNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(loadPortNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + from = new TransPlanHasChangePortDto + { + Indx = 1, + PortName = s.Trim(), + IsRemoved = false, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + from.PortName = sArg[0].Trim(); + from.TerminalName = sArg[1].Trim(); + } + } + } + } + + if (from != null) + { + list[currListIdx].From.portList.Add(from); + } + + var wasLoadPortNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div/div"); + + if (wasLoadPortNode != null && !string.IsNullOrWhiteSpace(wasLoadPortNode.InnerText)) + { + var s = wasLoadPortNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + + from2 = new TransPlanHasChangePortDto + { + Indx = 2, + PortName = s.Trim(), + IsRemoved = true, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + from2.PortName = sArg[0].Trim(); + from2.TerminalName = sArg[1].Trim(); + } + } + } + } + + if (from2 != null) + { + list[currListIdx].From.portList.Add(from2); + } + #endregion + + #region 处理ETD + TransPlanHasChangeDateDto fromETD = null; + TransPlanHasChangeDateDto fromETD2 = null; + + var etdNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div/b"); + + if (etdNode != null && !string.IsNullOrWhiteSpace(etdNode.InnerText)) + { + var s = etdNode.InnerText; + + s = Regex.Replace(s, "\r\n", " ").Trim(); + s = Regex.Replace(s, "\\(\\s{0,}ETD\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s,","," "), "\\s{2,}", " ").Trim(); + + DateTime etd = DateTime.Parse(s); + + fromETD = new TransPlanHasChangeDateDto + { + Indx = 1, + DateVal = etd, + OrigDateTxt = Regex.Replace(etdNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = false, + }; + } + else + { + etdNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div"); + + if (etdNode != null && !string.IsNullOrWhiteSpace(etdNode.InnerText)) + { + var s = etdNode.InnerText; + + s = Regex.Replace(s, "\r\n", " ").Trim(); + s = Regex.Replace(s, "\\(\\s{0,}ETD\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime etd = DateTime.Parse(s); + + fromETD = new TransPlanHasChangeDateDto + { + Indx = 1, + DateVal = etd, + OrigDateTxt = Regex.Replace(etdNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = false, + }; + } + } + + if (fromETD != null) + { + list[currListIdx].From.dateList.Add(fromETD); + } + + var wasETDNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div/div"); + + if (wasETDNode != null && !string.IsNullOrWhiteSpace(wasETDNode.InnerText)) + { + var s = wasETDNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + s = Regex.Replace(s, "\\(\\s{0,}ETD\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime etd = DateTime.Parse(s); + + fromETD2 = new TransPlanHasChangeDateDto + { + Indx = 2, + DateVal = etd, + OrigDateTxt = Regex.Replace(wasETDNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = true, + }; + } + } + + if (fromETD2 != null) + { + list[currListIdx].From.dateList.Add(fromETD2); + } + #endregion + + #region 处理船名 + TransPlanHasChangeVesselVoynoDto vessel = null; + TransPlanHasChangeVesselVoynoDto vessel2 = null; + + var vesselNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div/b"); + + if (vesselNode != null && !string.IsNullOrWhiteSpace(vesselNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(vesselNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + vessel = new TransPlanHasChangeVesselVoynoDto + { + Indx = 1, + Vessel = s.Trim(), + IsRemoved = false, + }; + } + else + { + vesselNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div"); + + if (vesselNode != null && !string.IsNullOrWhiteSpace(vesselNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(vesselNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + vessel = new TransPlanHasChangeVesselVoynoDto + { + Indx = 1, + Vessel = s.Trim(), + IsRemoved = false, + }; + } + } + + if (vessel != null) + { + list[currListIdx].From.vesselList.Add(vessel); + } + + var wasVesselNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[1]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div/div"); + + if (wasVesselNode != null && !string.IsNullOrWhiteSpace(wasVesselNode.InnerText)) + { + var s = wasVesselNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + + vessel2 = new TransPlanHasChangeVesselVoynoDto + { + Indx = 2, + Vessel = s.Trim(), + IsRemoved = true, + }; + } + } + + if (vessel2 != null) + { + list[currListIdx].From.vesselList.Add(vessel2); + } + #endregion + + + #region 处理卸货港 + TransPlanHasChangePortDto to = null; + TransPlanHasChangePortDto to2 = null; + + var dischargeNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div/b"); + + if (dischargeNode != null && !string.IsNullOrWhiteSpace(dischargeNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(dischargeNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + to = new TransPlanHasChangePortDto + { + Indx = 1, + PortName = s.Trim(), + IsRemoved = false, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + to.PortName = sArg[0].Trim(); + to.TerminalName = sArg[1].Trim(); + } + } + } + else + { + dischargeNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div"); + + if (dischargeNode != null && !string.IsNullOrWhiteSpace(dischargeNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(dischargeNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + to = new TransPlanHasChangePortDto + { + Indx = 1, + PortName = s.Trim(), + IsRemoved = false, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + to.PortName = sArg[0].Trim(); + to.TerminalName = sArg[1].Trim(); + } + } + } + } + + if (to != null) + { + list[currListIdx].To.portList.Add(to); + } + + var wasDischargeNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td/div/div/div"); + + if (wasDischargeNode != null && !string.IsNullOrWhiteSpace(wasDischargeNode.InnerText)) + { + var s = wasDischargeNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + + to2 = new TransPlanHasChangePortDto + { + Indx = 2, + PortName = s.Trim(), + IsRemoved = true, + }; + + if (s.IndexOf(",") >= 0) + { + var sArg = s.Split(new char[] { ',' }); + + if (sArg.Length == 2) + { + to2.PortName = sArg[0].Trim(); + to2.TerminalName = sArg[1].Trim(); + } + } + } + } + + if (to2 != null) + { + list[currListIdx].To.portList.Add(to2); + } + #endregion + + #region 处理ETD + TransPlanHasChangeDateDto toETA = null; + TransPlanHasChangeDateDto toETA2 = null; + + var etaNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div/b"); + + if (etaNode != null && !string.IsNullOrWhiteSpace(etaNode.InnerText)) + { + var s = etaNode.InnerText; + + s = Regex.Replace(s, "\r\n", " ").Trim(); + s = Regex.Replace(s, "\\(\\s{0,}ETA\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime eta = DateTime.Parse(s); + + toETA = new TransPlanHasChangeDateDto + { + Indx = 1, + DateVal = eta, + OrigDateTxt = Regex.Replace(etaNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = false, + }; + } + else + { + etaNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div"); + + if (etaNode != null && !string.IsNullOrWhiteSpace(etaNode.InnerText)) + { + var s = etaNode.InnerText; + + s = Regex.Replace(s, "\r\n", " ").Trim(); + s = Regex.Replace(s, "\\(\\s{0,}ETA\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime eta = DateTime.Parse(s); + + toETA = new TransPlanHasChangeDateDto + { + Indx = 1, + DateVal = eta, + OrigDateTxt = Regex.Replace(etaNode.InnerText, "\r\n", " ").Trim(), + IsRemoved = false, + }; + } + } + + if (toETA != null) + { + list[currListIdx].To.dateList.Add(toETA); + } + + var wasETANode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[3]/td/div/div/div"); + + if (wasETANode != null && !string.IsNullOrWhiteSpace(wasETANode.InnerText)) + { + var s = wasETANode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + s = Regex.Replace(s, "\\(\\s{0,}ETA\\s{0,}\\)", " ").Trim(); + s = Regex.Replace(Regex.Replace(s, ",", " "), "\\s{2,}", " ").Trim(); + + DateTime eta = DateTime.Parse(s); + + toETA2 = new TransPlanHasChangeDateDto + { + Indx = 2, + DateVal = eta, + OrigDateTxt = Regex.Replace(wasETANode.InnerText, "\r\n", " ").Trim(), + IsRemoved = true, + }; + } + } + + if (toETA2 != null) + { + list[currListIdx].To.dateList.Add(toETA2); + } + #endregion + + #region 处理船名 + TransPlanHasChangeVesselVoynoDto vesselPOD = null; + TransPlanHasChangeVesselVoynoDto vesselPOD2 = null; + + var vesselPODNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div/b"); + + if (vesselPODNode != null && !string.IsNullOrWhiteSpace(vesselPODNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(vesselPODNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + vesselPOD = new TransPlanHasChangeVesselVoynoDto + { + Indx = 1, + Vessel = s.Trim(), + IsRemoved = false, + }; + } + else + { + vesselNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div"); + + if (vesselNode != null && !string.IsNullOrWhiteSpace(vesselNode.InnerText)) + { + var s = Regex.Replace(Regex.Replace(vesselNode.InnerText, "\r\n", " "), "\\s{2,}", " ").Trim(); + + vesselPOD = new TransPlanHasChangeVesselVoynoDto + { + Indx = 1, + Vessel = s.Trim(), + IsRemoved = false, + }; + } + } + + if (vesselPOD != null) + { + list[currListIdx].To.vesselList.Add(vesselPOD); + } + + var wasVesselPODNode = divWrapperList[i].SelectSingleNode("./table/tbody/tr[1]/td[1]/div/table/tbody/tr[1]/td[1]/div[2]/table/tbody/tr[1]/td[1]/table/tbody/tr[4]/td/div/div/div"); + + if (wasVesselPODNode != null && !string.IsNullOrWhiteSpace(wasVesselPODNode.InnerText)) + { + var s = wasVesselPODNode.InnerText; + + if (Regex.IsMatch(s, "\\bwas\\s+")) + { + s = Regex.Replace(Regex.Replace(s, "\r\n", " "), "\\s{2,}", " ").Trim(); + s = Regex.Match(s, "(?<=\\bwas\\s).*").Value; + + vesselPOD2 = new TransPlanHasChangeVesselVoynoDto + { + Indx = 2, + Vessel = s.Trim(), + IsRemoved = true, + }; + } + } + + if (vesselPOD2 != null) + { + list[currListIdx].To.vesselList.Add(vesselPOD2); + } + #endregion + } + + + //每4行处理一次 + if ((start + 1) == 5) + { + start = 1; + } + else + { + start++; + } + } + + + var jsonRlt = JSON.Serialize(list); + + } + + public string SplitSubjectValue(string subjectText, string strStart, string strEnd = null) + { + var startIdx = subjectText.IndexOf(strStart); + if (startIdx > -1) + { + subjectText = subjectText.Substring(startIdx + strStart.Length); + + if (!string.IsNullOrEmpty(strEnd)) + { + startIdx = subjectText.IndexOf(strEnd); + if (startIdx > -1) + { + subjectText = subjectText.Substring(0, startIdx); + } + } + + return subjectText.Trim(); + } + + return string.Empty; + } + + /// + /// 文本类型的正文,根据条件提取字段内容 + /// + /// 邮件正文(文本类型) + /// 行起始关键字文本 + /// 行结束关键字文本 + /// 从指定行之后提取 + /// + public string SplitFieldValue(string bodyText, string strStart, string strEnd = null, string afterLine = null) + { + var lines = bodyText.Split("\r\n".ToArray(), StringSplitOptions.RemoveEmptyEntries); + var findArr = new List(lines); + if (!string.IsNullOrEmpty(afterLine)) + { + var strList = findArr.Where(l => l.Trim().StartsWith(afterLine)).ToList(); + if (strList.Count > 0) + { + var idx = findArr.IndexOf(strList[0]); + if (idx > -1) + { + findArr.RemoveRange(0, idx + 1); + } + } + } + + //没有开始标志,取afterLine的下一行 + if (string.IsNullOrEmpty(strStart) && !string.IsNullOrEmpty(afterLine)) + { + return findArr[0].Trim(); + } + else + { + var lineFind = findArr.FirstOrDefault(x => x.Trim().StartsWith(strStart)); + if (lineFind != null) + { + if (string.IsNullOrEmpty(strEnd)) + { + return lineFind.Replace(strStart, "").Trim(); + } + else + { + var tmp = lineFind.Substring(strStart.Length); + var endIdx = tmp.IndexOf(strEnd); + if (endIdx == -1) + { + return tmp.Trim(); + } + else + { + return tmp.Substring(0, endIdx).Trim(); + } + } + } + } + + return string.Empty; } public void SyncServiceProjectRecord5()