diff --git a/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/Dtos/CompareDraftDataInfo.cs b/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/Dtos/CompareDraftDataInfo.cs
index c5ee576..ace628a 100644
--- a/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/Dtos/CompareDraftDataInfo.cs
+++ b/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/Dtos/CompareDraftDataInfo.cs
@@ -216,6 +216,12 @@ namespace DAJYun.Application.TaskManagePlatDomain
[Description("冻:湿度")]
public string Humidity { get; set; }
+ ///
+ /// 合约号
+ ///
+ [Description("合约号")]
+ public string ContractNo { get; set; }
+
///
/// 箱明细
///
diff --git a/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/Interface/ITaskVerifyCopyBLParserService.cs b/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/Interface/ITaskVerifyCopyBLParserService.cs
new file mode 100644
index 0000000..2c0e018
--- /dev/null
+++ b/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/Interface/ITaskVerifyCopyBLParserService.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DAJYun.Application.TaskManagePlatDomain
+{
+ public interface ITaskVerifyCopyBLParserService
+ {
+ ///
+ /// 执行Verify Copy BL文件解析读取
+ ///
+ /// Verify Copy BL文件
+ /// Verify Copy BL请求报文
+ /// 返回回执
+ Task ExcuteFileReadAsync(IFormFile file, string jsonMessage);
+
+ ///
+ /// 变更Verify Copy BL文件内容
+ ///
+ /// Verify Copy BL文件
+ /// Verify Copy BL请求报文
+ /// 返回修改后的文件流
+ Task ModifyFileAsync(IFormFile file, string jsonMessage);
+ }
+}
diff --git a/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/TaskVerifyCopyBLParserService.cs b/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/TaskVerifyCopyBLParserService.cs
new file mode 100644
index 0000000..89059ce
--- /dev/null
+++ b/DAJYunPlat/DAJYun.Application/TaskManagePlatDomain/TaskVerifyCopyBLParserService.cs
@@ -0,0 +1,4177 @@
+using Furion;
+using Furion.DistributedIDGenerator;
+using Furion.Extensions;
+using Furion.JsonSerialization;
+using Furion.RemoteRequest;
+using Furion.RemoteRequest.Extensions;
+using Furion.VirtualFileServer;
+using Mapster;
+using Microsoft.Extensions.FileProviders;
+using Microsoft.Extensions.Logging;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Linq.Dynamic.Core;
+using System.Reflection.Emit;
+using System.Text;
+using System.Text.Json;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Web;
+using StackExchange.Profiling.Internal;
+using DAJYun.Application.Enums;
+using DAJYun.Core.Entities.TaskManagePlat;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
+using System.Collections;
+using System.Runtime.Intrinsics.X86;
+using Microsoft.Extensions.Configuration.EnvironmentVariables;
+using System.Xml.Linq;
+using Furion.TimeCrontab;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
+using Furion.DependencyInjection;
+using System.ComponentModel;
+using Microsoft.Extensions.DependencyModel;
+using Newtonsoft.Json.Linq;
+using Microsoft.CodeAnalysis.Operations;
+using System.Net.WebSockets;
+using System.Reflection.Metadata.Ecma335;
+using Locacore.TextComparer;
+using System.Data;
+
+namespace DAJYun.Application.TaskManagePlatDomain
+{
+ ///
+ /// 任务BC解析服务
+ ///
+ [AllowAnonymous, ApiDescriptionSettings(Name = "TaskVerifyCopyBLParser", LowercaseRoute = false, SplitCamelCase = false)]
+ public class TaskVerifyCopyBLParserService : ITaskVerifyCopyBLParserService, IDynamicApiController
+ {
+ private readonly ILogger _logger;
+
+ const string CONST_EVG_POD_FMT = "(16)PortofDischarge";
+ const string CONST_EVG_PLD_FMT = "(17)PlaceofDelivery";
+
+ ///
+ ///
+ ///
+ ///
+ public TaskVerifyCopyBLParserService(ILoggerFactory logger)
+ {
+ _logger = logger.CreateLogger(nameof(TaskVerifyCopyBLParserService));
+ }
+
+ #region 执行Verify Copy BL文件解析读取
+ ///
+ /// 执行Verify Copy BL文件解析读取
+ ///
+ /// Verify Copy BL文件
+ /// Verify Copy BL请求报文
+ /// 返回回执
+ [HttpPost]
+ public async Task ExcuteFileReadAsync(IFormFile file, [FromForm] string jsonMessage)
+ {
+ DJYunWebApiResult result = new DJYunWebApiResult();
+
+ string batchNo = IDGen.NextID().ToString();
+
+ try
+ {
+ if (file == null)
+ {
+ _logger.LogInformation("批次号{0} 未提供请求的文件信息", batchNo);
+
+ throw Oops.Oh($"未提供请求的文件信息,请求参数错误");
+ }
+
+ byte[] bytes = file.ToByteArray();
+
+ //请求格式单PDF解析
+ DateTime transBeginDate = DateTime.Now;
+
+ var realQueryRlt = await TransmitFile(App.Configuration["DraftPDFParseUrl"], new
+ {
+ file = "file",
+ fileName = file.FileName,
+ fileBytes = bytes
+ });
+
+ DateTime transEndDate = DateTime.Now;
+ TimeSpan ts = transEndDate.Subtract(transBeginDate);
+ var timetransDiff = ts.TotalMilliseconds;
+
+
+ string originText = string.Empty;
+
+ var ds = PDFReaderHelper.GetPDFTables(bytes, out originText);
+
+ //解析成功开始清洗数据(主要针对已测试出的问题,比如未空格的情况,日期格式转换)
+ var targetInfo = WashData(realQueryRlt, originText, batchNo);
+
+ result.succ = true;
+ result.extra = targetInfo;
+ }
+ catch (Exception ex)
+ {
+ result.succ = false;
+ result.msg = ex.Message;
+
+ _logger.LogError(ex, "批次号{0}异常 ", batchNo);
+ }
+
+ return result;
+ }
+ #endregion
+
+ #region 清洗数据
+ ///
+ /// 清洗数据(主要针对解析数据返回结果不准确来增加校对)
+ ///
+ /// PDF解析返回结果
+ /// 附页识别原始文本
+ /// 批次号
+ /// 返回清洗后准备比对的数据
+ private CompareDraftDataInfo WashData(DraftPDFParseFileResultDto resultDto, string attchedSheetText, string batchNo)
+ {
+ CompareDraftDataInfo model = null;
+
+ string modelName = string.Empty;
+
+ //key=顺序号 value1=件数 value2=包装 value3=箱型
+ Dictionary, string, string>> contaBaskDict =
+ new Dictionary, string, string>>();
+
+ //key=顺序号 value1=重量 value2=体积
+ Dictionary, Nullable>> contaKgsDict =
+ new Dictionary, Nullable>>();
+ try
+ {
+ if (resultDto.data != null && resultDto.data.DraftDetails != null)
+ {
+ model = new CompareDraftDataInfo
+ {
+ VesselName = resultDto.data.DraftDetails.Vessel,
+ VoyNo = resultDto.data.DraftDetails.VoyageNo,
+ MasterBlNo = resultDto.data.DraftDetails.BillNo,
+ BookingNo = resultDto.data.DraftDetails.SONo,
+ Shipper = resultDto.data.DraftDetails.Shipper?.Trim(),
+ Consignee = resultDto.data.DraftDetails.Consignee?.Trim(),
+ NotifyParty = resultDto.data.DraftDetails.NotifyParty?.Trim(),
+ PlaceReceipt = resultDto.data.DraftDetails.PlaceReceipt?.Trim(),
+ PortLoad = resultDto.data.DraftDetails.PortLoad?.Trim(),
+ PortDischarge = resultDto.data.DraftDetails.PortDischarge?.Trim(),
+ PlaceDelivery = resultDto.data.DraftDetails.PlaceDelivery?.Trim(),
+ Marks = resultDto.data.DraftDetails.Marks,
+ IssuePlace = resultDto.data.DraftDetails.IssuePlace,
+ GoodsDescription = resultDto.data.DraftDetails.GoodsDescription,
+ };
+
+ if (!string.IsNullOrWhiteSpace(resultDto.data.ModelName))
+ {
+ if (Regex.IsMatch(resultDto.data.ModelName, "\\bCNC\\b"))
+ {
+ modelName = "CNC"; //CMA CGM
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\bTSL\\b"))
+ {
+ modelName = "TSL"; //德翔
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\bCSL\\b"))
+ {
+ modelName = "CSL"; //可达利船务
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\bMCC\\b"))
+ {
+ modelName = "MCC"; //马士基海陆
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\bChangRong\\b"))
+ {
+ modelName = "EVG"; //长荣
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\bONE\\b"))
+ {
+ modelName = "ONE"; //ONE
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\bTaiPing|太平\\b"))
+ {
+ modelName = "PIL"; //PIL
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\bMSC\\b"))
+ {
+ modelName = "MSC"; //MSC
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\bMSK\\b"))
+ {
+ modelName = "MSK"; //MSK
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\b赫伯罗特\\b"))
+ {
+ modelName = "HPL"; //HPL 赫伯罗特
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\b海丰\\b"))
+ {
+ modelName = "SITC"; //SITC 海丰
+ }
+ else if (Regex.IsMatch(resultDto.data.ModelName, "\\b现代\\b"))
+ {
+ modelName = "HMM"; //HMM 现代
+ }
+ }
+
+ model.CarrierCompany = modelName;
+
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.IssueDate))
+ {
+ DateTime pDate = DateTime.MinValue;
+
+ if (DateTime.TryParse(resultDto.data.DraftDetails.IssueDate, out pDate))
+ {
+ model.IssueDate = pDate.ToString("yyyy-MM-dd");
+ }
+ }
+
+ var newCheck = App.Configuration["PackageArg"].Replace(",", "|");
+
+ //有2个以上空格自动替换成一个
+ if (!string.IsNullOrWhiteSpace(model.Shipper))
+ {
+ if (Regex.IsMatch(model.Shipper, "\\s{2,}"))
+ model.Shipper = Regex.Replace(model.Shipper, "\\s{2,}", " ");
+
+ //如果有CO.,LTD. 跟后面字符粘连,需要增加空格分割开
+ if (Regex.IsMatch(model.Shipper, "\\bCO\\.\\,LTD\\.") && Regex.IsMatch(model.Shipper, "(\\bCO\\.\\,LTD\\.(?!\\s))"))
+ {
+ var s = Regex.Match(model.Shipper, "(\\bCO\\.\\,LTD\\.(?!\\s))").Value + " ";
+
+ model.Shipper = Regex.Replace(model.Shipper, "(\\bCO\\.\\,LTD\\.(?!\\s))", s);
+ }
+ else if (Regex.IsMatch(model.Shipper, "\\bCO\\.\\,LTD(?!\\.)"))
+ {
+ var s = Regex.Match(model.Shipper, "\\bCO\\.\\,LTD(?!\\s)").Value + " ";
+
+ model.Shipper = Regex.Replace(model.Shipper, "\\bCO\\.\\,LTD(?!\\s)", s);
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.Consignee))
+ {
+ if (Regex.IsMatch(model.Consignee, "\\s{2,}"))
+ model.Consignee = Regex.Replace(model.Consignee, "\\s{2,}", " ");
+
+ if (Regex.IsMatch(model.Consignee, "\\.\\\\n"))
+ model.Consignee = Regex.Replace(model.Consignee, "\\.\\\\n", " ");
+
+ //??
+ if (Regex.IsMatch(model.Consignee, "[a-zA-Z]{1}\\n[a-zA-Z]{1}"))
+ model.Consignee = Regex.Replace(model.Consignee, "[a-zA-Z]{1}\\n[a-zA-Z]{1}", "");
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.Consignee) && Regex.IsMatch(model.Consignee, "\\s{2,}"))
+ model.Consignee = Regex.Replace(model.Consignee, "\\s{2,}", " ");
+
+ if (!string.IsNullOrWhiteSpace(model.NotifyParty) && Regex.IsMatch(model.NotifyParty, "\\s{2,}"))
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\s{2,}", " ");
+
+ #region IssuePlace
+ if (!string.IsNullOrWhiteSpace(model.IssuePlace))
+ {
+ //替换掉空格
+ if (Regex.IsMatch(model.IssuePlace, "\\s{2,}"))
+ model.IssuePlace = Regex.Replace(model.IssuePlace, "\\s{2,}", " ");
+
+ //替换掉空格
+ if (Regex.IsMatch(model.IssuePlace, "\\,\\s{1,}"))
+ model.IssuePlace = Regex.Replace(model.IssuePlace, "\\,\\s{1,}", ",");
+
+ //替换掉空格
+ if (Regex.IsMatch(model.IssuePlace, "\\s{1,}\\,"))
+ model.IssuePlace = Regex.Replace(model.IssuePlace, "\\s{1,}\\,", ",");
+ }
+ #endregion
+
+ #region PortLoad
+ if (!string.IsNullOrWhiteSpace(model.PortLoad))
+ {
+ //替换掉空格
+ if (Regex.IsMatch(model.PortLoad, "\\s{2,}"))
+ model.PortLoad = Regex.Replace(model.PortLoad, "\\s{2,}", " ");
+
+ //替换掉空格
+ if (Regex.IsMatch(model.PortLoad, "\\,\\s{1,}"))
+ model.PortLoad = Regex.Replace(model.PortLoad, "\\,\\s{1,}", ",");
+
+ //替换掉空格
+ if (Regex.IsMatch(model.PortLoad, "\\s{1,}\\,"))
+ model.PortLoad = Regex.Replace(model.PortLoad, "\\s{1,}\\,", ",");
+ }
+ #endregion
+
+ #region PortDischarge
+ if (!string.IsNullOrWhiteSpace(model.PortDischarge))
+ {
+ if (modelName != "CNC")
+ {
+ //替换掉空格
+ if (Regex.IsMatch(model.PortDischarge, "\\s{2,}"))
+ model.PortDischarge = Regex.Replace(model.PortDischarge, "\\s{2,}", " ");
+ }
+
+ //替换掉空格
+ if (Regex.IsMatch(model.PortDischarge, "\\,\\s{1,}"))
+ model.PortDischarge = Regex.Replace(model.PortDischarge, "\\,\\s{1,}", ",");
+
+ //替换掉空格
+ if (Regex.IsMatch(model.PortDischarge, "\\s{1,}\\,"))
+ model.PortDischarge = Regex.Replace(model.PortDischarge, "\\s{1,}\\,", ",");
+ }
+ #endregion
+
+ #region PlaceReceipt
+ if (!string.IsNullOrWhiteSpace(model.PlaceReceipt))
+ {
+ //替换掉空格
+ if (Regex.IsMatch(model.PlaceReceipt, "\\s{2,}"))
+ model.PlaceReceipt = Regex.Replace(model.PlaceReceipt, "\\s{2,}", " ");
+
+ //替换掉空格
+ if (Regex.IsMatch(model.PlaceReceipt, "\\,\\s{1,}"))
+ model.PlaceReceipt = Regex.Replace(model.PlaceReceipt, "\\,\\s{1,}", ",");
+
+ //替换掉空格
+ if (Regex.IsMatch(model.PlaceReceipt, "\\s{1,}\\,"))
+ model.PlaceReceipt = Regex.Replace(model.PlaceReceipt, "\\s{1,}\\,", ",");
+ }
+ #endregion
+
+ #region PlaceDelivery
+ if (!string.IsNullOrWhiteSpace(model.PlaceDelivery))
+ {
+ //替换掉空格
+ if (Regex.IsMatch(model.PlaceDelivery, "\\bPORT\\s+KEL\\s+ANG\\s+NORTH\\b"))
+ model.PlaceDelivery = Regex.Replace(model.PlaceDelivery, "\\bPORT\\s+KEL\\s+ANG\\s+NORTH\\b", "PORT KELANG NORTH");
+ }
+ #endregion
+
+ if (modelName == "CNC")
+ {
+ string orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ #region CNC 调整
+
+ if (!string.IsNullOrWhiteSpace(model.Shipper))
+ {
+ //发货人有可能带上HIPPER或者SHIPPER,需要清除掉
+ if (Regex.IsMatch(model.Shipper, "^(S)?HIPPER"))
+ {
+ model.Shipper = Regex.Replace(model.Shipper, "^(S)?HIPPER", "");
+ }
+
+ if (Regex.IsMatch(model.Shipper, "[a-zA-Z]+\\.\\s[a-zA-Z]"))
+ {
+ model.Shipper = Regex.Replace(model.Shipper, "[a-zA-Z]+\\.\\s[a-zA-Z]", rlp => {
+ if (Regex.IsMatch(rlp.Value, "LTD\\."))
+ return rlp.Value;
+ return Regex.Replace(rlp.Value, "\\s+", "");
+ });
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.Consignee))
+ {
+ /* 感觉替换\\.\\s+意义不大,所以这里暂时关闭
+ if (Regex.IsMatch(model.Consignee, "[a-zA-Z]+\\.\\s[a-zA-Z]"))
+ {
+ model.Consignee = Regex.Replace(model.Consignee, "[a-zA-Z]+\\.\\s[a-zA-Z]", rlp => {
+ if (Regex.IsMatch(rlp.Value, "LTD\\."))
+ return rlp.Value;
+ return Regex.Replace(rlp.Value,"\\s+","");
+ });
+ }
+ */
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.NotifyParty))
+ {
+ /* 感觉替换\\.\\s+意义不大,所以这里暂时关闭
+ if (Regex.IsMatch(model.NotifyParty, "[a-zA-Z]+\\.\\s[a-zA-Z]"))
+ {
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "[a-zA-Z]+\\.\\s[a-zA-Z]", rlp => {
+ if (Regex.IsMatch(rlp.Value, "LTD\\."))
+ return rlp.Value;
+ return Regex.Replace(rlp.Value, "\\s+", "");
+ });
+ }
+ */
+ }
+
+ if (model.VoyNo.IndexOf("/") >= 0)
+ {
+ model.VoyNo = model.VoyNo.Split(new char[] { '/' }).LastOrDefault()?.Trim();
+ }
+
+ //包含重量
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.WeightInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}"))
+ {
+ var weightColles = Regex.Matches(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}");
+
+ model.KGs = decimal.Parse(weightColles[0].Value);
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(model.Marks) || !Regex.IsMatch(model.Marks, "\\w+"))
+ {
+ model.Marks = Regex.Match(orgText, "N\\/M").Value;
+ }
+
+ var cncGoodsRegexPattern = $"[0-9]+(\\.[0-9]+){{0,}}\\s+({newCheck})(\\((s|S)\\))?";
+
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ //Continued on Next Sheet出现这个文字标识货描有分页的信息,需要拼接上
+ if (Regex.IsMatch(orgText, "Continued\\s+on\\s+Next\\s+Sheet"))
+ {
+ string s = Regex.Match(orgText, "(?<=Continued\\s+on\\s+Next\\s+Sheet).*(?=Continued\\s+From\\s+Previous\\s+Sheet)").Value;
+
+ s = Regex.Match(s, "(?<=CONTAINER\\sAND\\sSEALS\\sOF\\sPACKAGES\\sSHIPPER'S\\sLOAD\\sSTOW\\sAND\\sCOUNT).*").Value;
+ s = Regex.Replace(s, "\\\\\\\\n", " ");
+ s = Regex.Replace(s, "SAID\\s+TO\\s+CONTAIN", "");
+ s = Regex.Replace(s, "CARGO\\s+KGS\\s+KGS\\s+CBM", "");
+ s = Regex.Replace(s, "Weight in Kgs", "")?.Trim();
+ s = Regex.Replace(s, "Total\\:[0-9]+\\s+CONTAINER\\(S\\)", "")?.Trim();
+ s = Regex.Replace(s, "SAY\\b\\:?.*", "")?.Trim();
+ s = Regex.Replace(s, "[0-9]+\\s?(x|X|\\*)\\s?\\w+", "")?.Trim();
+ s = Regex.Replace(s, cncGoodsRegexPattern, "")?.Trim();
+
+ model.GoodsDescription += s;
+ }
+
+ //清除掉不需要的信息
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "Cargo\\s+is\\s+stowed\\s+in\\s+a\\s+refrigerated\\s+container\\s+set\\s+at\\s+the\\s+shipper's\\s+requested\\s+carrying\\s+temperature\\s+of\\s+.*?degrees\\s+Celsius", " ");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "Cargo\\s+is\\s+stowed\\s+in\\s+a\\s+refrigerated\\s+container\\s+set\\s+at\\s+the\\s+shipper", " ");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "Cargo\\s+is\\s+stowed\\s+in\\s+a\\s+refrigerated\\s+container\\s+set", " ");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "'s\\s+requested\\s+carrying\\s+temperature\\s+of\\s+(\\-|\\+)?[0-9]+\\s+degrees\\s+Celsius", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "'s\\s+requested\\s+carrying\\s+temperature\\s+of\\s+[0-9]+", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\bon\\s+Board\\b.*", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "atthe\\s+shipper\\s+degrees\\s+Celsius", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "at\\s+the\\s+shipper\\s+degrees\\s+Celsius", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "atthe\\s+shipper", "");
+
+ //如果有件数的大写信息 SAY FIVE THOUSAND SIX HUNDRED SEVENTY-THREE,直接清除掉
+ if (Regex.IsMatch(model.GoodsDescription, "\\bSAY\\b"))
+ {
+ string sayRgxPattern = $"SAY(({App.Configuration["EnglishNumberalCaps"].Replace(",", "|")})|\\s)+";
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, sayRgxPattern, "");
+ }
+
+ //如果货描混入箱型箱量也需要直接清除 例:4 X 40RH
+ if (Regex.IsMatch(model.GoodsDescription, "([0-9]+\\s?(x|X|\\*)\\s?[0-9]{1,}[a-zA-Z]{2})"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "([0-9]+\\s?(x|X|\\*)\\s?[0-9]{1,}[a-zA-Z]{2})", "");
+ }
+
+ if (!Regex.IsMatch(model.Marks, "N\\/M") && !string.IsNullOrWhiteSpace(model.Marks))
+ {
+ var marksMcVal = Regex.Matches(orgText, $"(?<=\\\\n{model.Marks.Trim().Replace("(", "\\(").Replace(")", "\\)")}).*?\\\\n\\w+")
+ .LastOrDefault()?.Value;
+
+ if (!string.IsNullOrWhiteSpace(marksMcVal))
+ {
+ var origMcVal = Regex.Matches(orgText, $"(?<=\\\\n{model.Marks.Trim().Replace("(", "\\(").Replace(")", "\\)")}).*?(?<=\\\\n).*?\\\\\\\\n")
+ .LastOrDefault()?.Value;
+
+ string checkMcVal = Regex.Match(origMcVal, "(?<=\\\\n).*?(?=\\\\n)").Value;
+
+ if (!checkMcVal.StartsWith("H.S") && !checkMcVal.StartsWith("HS")! && checkMcVal.StartsWith("H"))
+ model.Marks += " " + Regex.Match(marksMcVal, "(?<=\\\\n).*").Value?.Trim();
+ }
+
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, cncGoodsRegexPattern))
+ {
+ var picsPkgMatchCols = Regex.Matches(model.GoodsDescription, cncGoodsRegexPattern);
+
+ var lastMatch = picsPkgMatchCols.LastOrDefault();
+ string gPicsPackage = lastMatch.Value;
+
+ model.PKGs = (int)decimal.Parse(Regex.Match(gPicsPackage
+ , "[0-9]+(\\.[0-9]+){0,}").Value);
+
+ gPicsPackage = Regex.Match(gPicsPackage, $"({newCheck})(\\((s|S)\\))?").Value;
+
+ string origgPicsPackage = gPicsPackage;
+
+ if (Regex.IsMatch(gPicsPackage, "\\((s|S)\\)"))
+ {
+ var s2 = Regex.Match(gPicsPackage, "\\((s|S)\\)").Value;
+ gPicsPackage = gPicsPackage.Replace(s2, "S");
+ }
+
+ model.KindPKGs = gPicsPackage.Trim().ToUpper();
+
+ string tempExplainPackage = string.Empty;
+
+ if (Regex.IsMatch(model.GoodsDescription, $"{gPicsPackage}\\s?=(\\w|\\s)+{gPicsPackage}"))
+ {
+ tempExplainPackage = Regex.Match(model.GoodsDescription, $"{gPicsPackage}\\s?=(\\w|\\s)+{gPicsPackage}").Value;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"{gPicsPackage}\\s?=(\\w|\\s)+{gPicsPackage}", "THIS IS EXPLAIN PACK");
+ }
+ else if (Regex.IsMatch(model.GoodsDescription, $"{gPicsPackage}\\s?=\\s?{gPicsPackage}"))
+ {
+ tempExplainPackage = Regex.Match(model.GoodsDescription, $"{gPicsPackage}\\s?=\\s?{gPicsPackage}").Value;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"{gPicsPackage}\\s?=\\s?{gPicsPackage}", "THIS IS EXPLAIN PACK");
+ }
+
+
+ Dictionary pkgTempDict = new Dictionary();
+
+ //货描里会出现商品的详细包装信息,不能直接替换包装,先提取走,替换完反填回来
+ if (Regex.IsMatch(model.GoodsDescription, $"[0-9]+({newCheck})\\s+\\(([0-9]|\\w)+.*?\\)"))
+ {
+ int idx = 1;
+ //var cols = Regex.Matches(model.GoodsDescription, $"[0-9]+({newCheck})\\s+\\(([0-9]|\\w)+.*?\\)");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"[0-9]+({newCheck})\\s+\\(([0-9]|\\w)+.*?\\)", rlp => {
+ string key = $"#MyHidden_{idx}#";
+ pkgTempDict.Add($"#MyHidden_{idx}#", rlp.Value);
+ idx++;
+ return key;
+ });
+ }
+
+ Dictionary qtyDict = new Dictionary();
+ //string qtyStr = string.Empty;
+ if (Regex.IsMatch(model.GoodsDescription, $"QUANTITY\\:[0-9]+({newCheck})"))
+ {
+ var matches = Regex.Matches(model.GoodsDescription, $"QUANTITY\\:[0-9]+({newCheck})");
+
+ int startIdx = 1;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"QUANTITY\\:[0-9]+({newCheck})", rlp => {
+ qtyDict.Add(startIdx, rlp.Value);
+ int curr = startIdx;
+ startIdx++;
+ return $"#MyQtyHidden#{curr}";
+ });
+ //qtyStr = Regex.Match(model.GoodsDescription, $"QUANTITY\\:[0-9]+({newCheck})").Value;
+
+ //
+ }
+ Dictionary qtyDict2 = new Dictionary();
+ if (Regex.IsMatch(model.GoodsDescription, $"QUANTITY\\s+[0-9]+({newCheck})"))
+ {
+ //qtyStr2 = Regex.Match(model.GoodsDescription, $"QUANTITY\\s+[0-9]+({newCheck})").Value;
+
+ int startIdx = 1;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"QUANTITY\\s+[0-9]+({newCheck})", rlp => {
+ qtyDict2.Add(startIdx, rlp.Value);
+ int curr = startIdx;
+ startIdx++;
+ return $"#MyQty2Hidden#{curr}";
+ });
+
+ //model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"QUANTITY\\s+[0-9]+({newCheck})", "#MyQtyHidden2# ");
+ }
+ Dictionary qtyDict3 = new Dictionary();
+ //string qtyStr = string.Empty;
+ if (Regex.IsMatch(model.GoodsDescription, $"QUANTITY\\s+OF\\s+GOODS\\:[0-9]+\\s?({newCheck})"))
+ {
+ var matches = Regex.Matches(model.GoodsDescription, $"QUANTITY\\s+OF\\s+GOODS\\:[0-9]+\\s?({newCheck})");
+
+ int startIdx = 1;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"QUANTITY\\s+OF\\s+GOODS\\:[0-9]+\\s?({newCheck})", rlp => {
+ qtyDict3.Add(startIdx, rlp.Value);
+ int curr = startIdx;
+ startIdx++;
+ return $"#MyQty3Hidden#{curr}";
+ });
+ //qtyStr = Regex.Match(model.GoodsDescription, $"QUANTITY\\:[0-9]+({newCheck})").Value;
+
+ //
+ }
+ string united = string.Empty;
+ if (Regex.IsMatch(model.GoodsDescription, $"\\bUNITED\\b"))
+ {
+ united = Regex.Match(model.GoodsDescription, $"\\bUNITED\\b").Value;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"\\bUNITED\\b", "#MyUnitedHidden# ");
+ }
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, cncGoodsRegexPattern, rlp =>
+ {
+ if (!Regex.IsMatch(Regex.Match(rlp.Value, "[0-9]+(\\.[0-9]+){0,}").Value, "^[1-9]")
+ || rlp.Value.IndexOf(origgPicsPackage) < 0)
+ return rlp.Value;
+
+ return "";
+ })?.Trim();
+
+ Dictionary chkPkgsDict = Regex.Matches(model.GoodsDescription, $"({newCheck})(\\((s|S)\\))?").Select(mc =>
+ {
+ return new { Key = mc.Index, Name = mc.Value };
+ }).ToDictionary(a => a.Key, b => b.Name);
+
+ foreach (KeyValuePair kvp in chkPkgsDict)
+ {
+ if (Regex.IsMatch(model.GoodsDescription.Substring(kvp.Key), "\\s+\\bTEMPERATURE\\b") ||
+ Regex.IsMatch(model.GoodsDescription.Substring(kvp.Key), "\\s+\\bVENT\\b"))
+ {
+ chkPkgsDict.Remove(kvp.Key);
+ }
+ }
+
+ //这里SET会被包装匹配,这里向后判断如果出现TEMPERATURE则不被替换
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"({newCheck})(\\((s|S)\\))?", rlp => {
+ if (!chkPkgsDict.Any(t => t.Key == rlp.Index))
+ {
+ return rlp.Value;
+ }
+
+ return "";
+ })?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "THIS IS EXPLAIN PACK", tempExplainPackage);
+
+ if (pkgTempDict.Count > 0)
+ {
+ foreach (KeyValuePair kvp in pkgTempDict)
+ {
+ model.GoodsDescription = model.GoodsDescription.Replace(kvp.Key, kvp.Value);
+ }
+ }
+
+ if (qtyDict.Count > 0)
+ {
+ foreach (KeyValuePair kvp in qtyDict)
+ {
+ model.GoodsDescription = model.GoodsDescription.Replace($"#MyQtyHidden#{kvp.Key}", kvp.Value);
+ }
+ }
+
+ if (qtyDict2.Count > 0)
+ {
+ foreach (KeyValuePair kvp in qtyDict2)
+ {
+ model.GoodsDescription = model.GoodsDescription.Replace($"#MyQty2Hidden#{kvp.Key}", kvp.Value);
+ }
+ }
+
+ if (qtyDict3.Count > 0)
+ {
+ foreach (KeyValuePair kvp in qtyDict3)
+ {
+ model.GoodsDescription = model.GoodsDescription.Replace($"#MyQty3Hidden#{kvp.Key}", kvp.Value);
+ }
+ }
+ /*
+ if (!string.IsNullOrWhiteSpace(qtyStr))
+ {
+ model.GoodsDescription = model.GoodsDescription.Replace("#MyQtyHidden#", qtyStr);
+ }
+
+ if (!string.IsNullOrWhiteSpace(qtyStr2))
+ {
+ model.GoodsDescription = model.GoodsDescription.Replace("#MyQtyHidden2#", qtyStr);
+ }
+ */
+
+ if (!string.IsNullOrWhiteSpace(united))
+ {
+ model.GoodsDescription = model.GoodsDescription.Replace("#MyUnitedHidden#", united);
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, "[0-9]{2}[a-zA-Z]{2}X[0-9]{1,}"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[0-9]{2}[a-zA-Z]{2}X[0-9]{1,}", " ");
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, $"[0-9]+\\s+{gPicsPackage}\\s+{gPicsPackage}"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"[0-9]+\\s+{gPicsPackage}\\s+{gPicsPackage}", " ");
+ }
+
+ //这里判断如果有货描重复多次的情况,去掉重复
+ if (Regex.Matches(model.GoodsDescription, "EMAIL\\:\\s?\\S+").Count > 1)
+ {
+ string s = Regex.Match(model.GoodsDescription, "EMAIL\\:\\s?\\S+").Value;
+
+ if (!string.IsNullOrWhiteSpace(s))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, $"(?<={s.Replace(":", "\\:").Replace(" ", "\\s")}).*(?=EMAIL)", " ");
+
+ int rIdx = 1;
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, s, rlp =>
+ {
+ if (rIdx == 2)
+ {
+ return " ";
+ }
+ rIdx++;
+ return rlp.Value;
+ });
+ }
+
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, "[0-9]{2}[a-zA-Z]{2}\\s+\\bSUBSTITUTION\\s+AS\\s+[0-9]{2}[a-zA-Z]{2}"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[0-9]{2}[a-zA-Z]{2}\\s+\\bSUBSTITUTION\\s+AS\\s+[0-9]{2}[a-zA-Z]{2}", " ");
+ }
+
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[a-zA-Z]+[0-9]+\\s+[0-9]+(\\.[0-9]+){0,}\\s+[0-9]+(\\.[0-9]+){0,}\\s+[0-9]+(\\.[0-9]+){0,}\\s+(SEAL)?\\s+[a-zA-Z]+[0-9]+", " ");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "^\\.\\s+", " ");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\s+\\,", ",");
+ }
+
+
+ //判断如果货描里含有1320 CARTONS(件数 包装)
+
+ //如果发货人的结尾是“*”符号,则标识发货人过长内容被阶段截断内容在货描获取
+ #region 发货人拼接字符
+ if (model.Shipper.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+"))
+ {
+ string s = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+").Value;
+ //去掉包装单位
+ s = Regex.Replace(s, newCheck, "");
+ //这里拼接字符
+ model.Shipper += s;
+
+ model.Shipper = Regex.Replace(model.Shipper, "\\*{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ #endregion
+
+ string cneeCombined = string.Empty;
+ string cneeEndStr = string.Empty;
+ string notifyEndStr = string.Empty;
+
+ #region 收货人拼接字符
+ if (model.Consignee.EndsWith("**"))
+ {
+ cneeEndStr = "**";
+
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\*{4}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ else if (model.Consignee.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+ cneeEndStr = "*";
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\*{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+
+ model.Consignee = model.Consignee.Trim();
+ #endregion
+
+ #region 通知人拼接字符
+ if (model.NotifyParty.EndsWith("**"))
+ {
+ notifyEndStr = "**";
+
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined) && cneeEndStr == "**")
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ");
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+").Value;
+
+ string checkNewPkgs = $"\\b{App.Configuration["PackageArg"].Replace(",", "\\b|\\b")}\\b";
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, checkNewPkgs, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ }
+ else if (model.NotifyParty.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined) && cneeEndStr == "*")
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ");
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+|\\/|\\#)+", rlp =>
+ {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ }
+
+ model.NotifyParty = model.NotifyParty.Trim();
+ #endregion
+
+
+ if (Regex.Matches(model.GoodsDescription, "VENT\\s?\\:\\w+(\\/)?\\w+").Count > 1)
+ {
+ int startIdx = 1;
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "VENT\\s?\\:\\w+(\\/)?\\w+", rlp => {
+ if (startIdx == 1)
+ {
+ startIdx++;
+
+ return rlp.Value;
+ }
+
+
+ return " ";
+ });
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\s{2,}", " ");
+ }
+
+ if (Regex.Matches(model.GoodsDescription, "[^\\w]'C").Count > 1)
+ {
+ int startIdx = 1;
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[^\\w]'C", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\s{2,}", " ");
+ }
+
+ //这里如果最后唛头没有记录,尝试货描跟收货人匹配,有相同记录直接取为货描
+ if (string.IsNullOrWhiteSpace(model.Marks))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "SEAL\\s+\\w+"))
+ {
+ string s = Regex.Match(model.GoodsDescription, "(?<=SEAL\\s+\\w+)\\s+.*").Value;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "SEAL\\s+\\w+?\\s", " ");
+ var marks = GetMarksFromCnee(s, model.Consignee)?.Trim();
+
+ if (!string.IsNullOrWhiteSpace(marks))
+ {
+ model.Marks = marks;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, marks, " ");
+ }
+
+ }
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\s{2,}", "");
+ }
+
+
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\s{1,}\\,\\s{1,}", "")?.Trim();
+ }
+
+ //如果唛头还是为空需要尝试从铅封号后取值
+ if (string.IsNullOrWhiteSpace(model.Marks))
+ {
+ var sealRegCols = Regex.Matches(orgText, "SEAL\\s+\\w+(\\\\\\\\n).*?(\\\\\\\\n)");
+
+ for (int i = 0; i < sealRegCols.Count; i++)
+ {
+ var match = (Match)sealRegCols[i];
+
+ if (!Regex.IsMatch(match.Value, "\\\\\\\\n?\\w+\\s+([0-9]+\\s?(x|X|\\*)\\s?[0-9]{1,}[a-zA-Z]{2})\\s?[0-9]+(\\.[0-9]+){0,}\\s?[a-zA-Z]+(\\((s|S)\\))?\\s?[0-9]+(\\.[0-9]+){0,}\\s?[0-9]+(\\.[0-9]+){0,}\\s?[0-9]+(\\.[0-9]+){0,}"))
+ {
+ if (!Regex.IsMatch(match.Value, "Cargo\\s+is\\s+stowed"))
+ {
+ if (!Regex.IsMatch(match.Value, "Continued\\s+on\\s+Next"))
+ {
+ string s = Regex.Replace(match.Value, "\\\\\\\\n", " ");
+
+ s = Regex.Match(s, "(?<=SEAL\\s[0-9a-zA-Z]+\\s).*").Value;
+
+ if (Regex.IsMatch(s, "\\bFRESH\\b"))
+ {
+ model.Marks = Regex.Match(s, ".*(?=\\bFRESH\\b)").Value?.Trim();
+
+ break;
+ }
+ else
+ {
+ model.Marks = Regex.Match(s, "(\\w+\\s){2}").Value?.Trim();
+
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ model.Shipper = model.Shipper?.Trim();
+ model.Consignee = model.Consignee?.Trim();
+ model.NotifyParty = model.NotifyParty?.Trim();
+
+ if (model.Shipper.EndsWith("Shipped"))
+ {
+ model.Shipper = model.Shipper.Substring(0, model.Shipper.LastIndexOf("Shipped"))?.Trim();
+ }
+
+ if (model.Shipper.EndsWith(","))
+ {
+ model.Shipper = model.Shipper.Substring(0, model.Shipper.LastIndexOf(","))?.Trim();
+ }
+
+ if (model.Consignee.EndsWith("Shipped"))
+ {
+ model.Consignee = model.Consignee.Substring(0, model.Consignee.LastIndexOf("Shipped"))?.Trim();
+ }
+
+ if (model.Consignee.EndsWith(","))
+ {
+ model.Consignee = model.Consignee.Substring(0, model.Consignee.LastIndexOf(","))?.Trim();
+ }
+
+ //这里会有收货人掺杂着货描信息,这里尝试取货描前2个单词能匹配就直接清理到,相似单词后的内容
+ string chkGoods = Regex.Matches(model.GoodsDescription, "(\\w+\\s?){2}").FirstOrDefault()?.Value;
+
+ if (!string.IsNullOrWhiteSpace(chkGoods) && model.Consignee.IndexOf(chkGoods) >= 0)
+ {
+ model.Consignee = model.Consignee.Substring(0, model.Consignee.IndexOf(chkGoods));
+ }
+
+ if (model.NotifyParty.EndsWith("Shipped"))
+ {
+ model.NotifyParty = model.NotifyParty.Substring(0, model.NotifyParty.LastIndexOf("Shipped"))?.Trim();
+ }
+
+ if (model.NotifyParty.EndsWith(","))
+ {
+ model.NotifyParty = model.NotifyParty.Substring(0, model.NotifyParty.LastIndexOf(","))?.Trim();
+ }
+
+ if (!string.IsNullOrWhiteSpace(chkGoods) && model.NotifyParty.IndexOf(chkGoods) >= 0)
+ {
+ model.NotifyParty = model.NotifyParty.Substring(0, model.NotifyParty.IndexOf(chkGoods));
+ }
+
+ //model.GoodsDescription = Regex.Replace(model.GoodsDescription, newCheck, "");
+
+ if (model.GoodsDescription.EndsWith("Shipped"))
+ {
+ model.GoodsDescription = model.GoodsDescription.Substring(0, model.GoodsDescription.LastIndexOf("Shipped"))?.Trim();
+ }
+
+ if (model.GoodsDescription.EndsWith(","))
+ {
+ model.GoodsDescription = model.GoodsDescription.Substring(0, model.GoodsDescription.LastIndexOf(","))?.Trim();
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, "[0-9]+OF"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[0-9]+OF", rlp =>
+ {
+ string digit = Regex.Match(rlp.Value, "[0-9]+").Value;
+
+ return $"{digit} OF";
+ });
+ }
+
+
+ model.Consignee = Regex.Replace(model.Consignee, "[a-zA-Z]+[0-9]+\\s+[0-9]+(\\.[0-9]+){0,}\\s+[0-9]+(\\.[0-9]+){0,}\\s+[0-9]+(\\.[0-9]+){0,}\\s+(SEAL)?\\s+[a-zA-Z]+[0-9]+", " ");
+ model.Consignee = Regex.Replace(model.Consignee, "\\s{2,}", " ")?.Trim();
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "[a-zA-Z]+[0-9]+\\s+[0-9]+(\\.[0-9]+){0,}\\s+[0-9]+(\\.[0-9]+){0,}\\s+[0-9]+(\\.[0-9]+){0,}\\s+(SEAL)?\\s+[a-zA-Z]+[0-9]+", " ");
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\s{2,}", " ")?.Trim();
+
+ #endregion
+ }
+ else if (modelName == "CSL")
+ {
+ #region CSL 调整
+ if (!string.IsNullOrWhiteSpace(model.VesselName))
+ {
+ if (model.VesselName.IndexOf("/") >= 0)
+ {
+ model.VesselName = model.VesselName.Split(new char[] { '/' }).FirstOrDefault().Trim();
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.VoyNo))
+ {
+ if (model.VoyNo.IndexOf("/") >= 0)
+ {
+ model.VoyNo = model.VoyNo.Split(new char[] { '/' }).LastOrDefault().Trim();
+ }
+ }
+
+ var cncGoodsRegexPattern = $"[0-9]+(\\.[0-9]+){{0,}}\\s+({newCheck})";
+
+ //包含件数和包装
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.ContaPicsPackageInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.ContaPicsPackageInfo, cncGoodsRegexPattern))
+ {
+ string currContaType = string.Empty;
+
+ if (Regex.IsMatch(resultDto.data.DraftDetails.ContaPicsPackageInfo, "[0-9]{1,}\\s?(X|x)\\s?[0-9a-zA-Z]{4}"))
+ {
+ currContaType = Regex.Match(resultDto.data.DraftDetails.ContaPicsPackageInfo, "[0-9]{1,}\\s?(X|x)\\s?[0-9a-zA-Z]{4}").Value;
+
+ if (!string.IsNullOrWhiteSpace(currContaType))
+ {
+ currContaType = Regex.Matches(currContaType, "[0-9a-zA-Z]{4}").LastOrDefault().Value.ToUpper();
+ }
+ }
+
+ var currMatches = Regex.Matches(resultDto.data.DraftDetails.ContaPicsPackageInfo, cncGoodsRegexPattern);
+
+ contaBaskDict = currMatches.Select((m, idx) =>
+ {
+ var s = m.Value;
+
+ var currPKGs = (int)decimal.Parse(Regex.Match(s, "[0-9]+(\\.[0-9]+){0,}").Value);
+
+ var currKindPKGs = Regex.Match(s, newCheck).Value.Trim().ToUpper();
+
+ return new { Key = idx + 1, Tur = new Tuple, string, string>(currPKGs, currKindPKGs, currContaType) };
+
+ }).ToDictionary(a => a.Key,
+ b => b.Tur);
+
+
+ if (contaBaskDict.Count == 1)
+ {
+ model.KindPKGs = contaBaskDict.FirstOrDefault().Value.Item2;
+
+ if (contaBaskDict.FirstOrDefault().Value.Item1.HasValue)
+ model.PKGs = contaBaskDict.FirstOrDefault().Value.Item1.Value;
+
+ }
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.WeightInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}"))
+ {
+ var currMatches = Regex.Matches(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}");
+
+ var perNum = Math.Ceiling(currMatches.Count / 2m);
+
+ for (var i = 0; i < perNum; i++)
+ {
+ var currKgs = decimal.Parse(currMatches[i * 2].Value);
+ var currCBM = decimal.Parse(currMatches[i * 2 + 1].Value);
+
+ contaKgsDict.Add(i + 1, new Tuple(currKgs, currCBM));
+ }
+
+ if (contaKgsDict.Count == 1)
+ {
+ if (contaKgsDict.FirstOrDefault().Value.Item1.HasValue)
+ model.KGs = contaKgsDict.FirstOrDefault().Value.Item1.Value;
+
+ if (contaKgsDict.FirstOrDefault().Value.Item2.HasValue)
+ model.CBM = contaKgsDict.FirstOrDefault().Value.Item2.Value;
+
+ }
+ }
+ }
+
+ //清除已知的货描不想关信息
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ //清理SAID TO CONTAIN和之前的字符
+ if (Regex.IsMatch(model.GoodsDescription, "\\bSAID\\b\\s+\\bTO\\b\\s+\\bCONTAIN\\b"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, ".*?(\\bSAID\\b\\s+\\bTO\\b\\s+\\bCONTAIN\\b)", "");
+ }
+
+ //清理SHIPPED ON BOARD和之后的字符
+ if (Regex.IsMatch(model.GoodsDescription, "\\bSHIPPED\\b\\s+\\bON\\b\\s+\\bBOARD\\b"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "(\\bSHIPPED\\b\\s+\\bON\\b\\s+\\bBOARD\\b).*", "");
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.PlaceDelivery))
+ {
+ model.PlaceDelivery = Regex.Replace(model.PlaceDelivery, "\\,\\s{1,}", ",");
+ model.PlaceDelivery = Regex.Replace(model.PlaceDelivery, "\\s{1,}\\,", ",");
+ }
+
+ #endregion
+ }
+ else if (modelName == "MCC")
+ {
+ #region MCC 调整
+
+ //包含重量
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.WeightInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}?(KGS)"))
+ {
+ var s = Regex.Match(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}?(KGS)").Value;
+
+ model.KGs = decimal.Parse(Regex.Match(s, "[0-9]+(\\.[0-9]+){0,}").Value);
+ }
+ }
+
+ //清除已知的货描不想关信息
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ #region 发货人拼接字符
+ if (model.Shipper.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ string s = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+ //去掉包装单位
+ s = Regex.Replace(s, newCheck, "");
+ //这里拼接字符
+ model.Shipper += s;
+
+ model.Shipper = Regex.Replace(model.Shipper, "\\*{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ #endregion
+
+ string cneeCombined = string.Empty;
+
+ #region 收货人拼接字符
+ if (model.Consignee.EndsWith("**"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+[^N\\/M]").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\*{4}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+[^N\\/M]", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ else if (model.Consignee.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+[^N\\/M]").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\*{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+[^N\\/M]", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ #endregion
+
+ #region 通知人拼接字符
+ if (model.NotifyParty.EndsWith("**"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined))
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ")?.Trim();
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+[^N\\/M]").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+[^N\\/M]", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ }
+ else if (model.NotifyParty.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined))
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ")?.Trim();
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+[^N\\/M]").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+[^N\\/M]", rlp =>
+ {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ }
+ #endregion
+
+
+ if (Regex.IsMatch(model.GoodsDescription, "\\bThis\\s+shipment\\s+is\\s+subject\\s+to\\s+compliance\\s+with\\b"))
+ {
+ //清理N/M和之后的字符
+ if (Regex.IsMatch(model.GoodsDescription, "(\\bThis\\s+shipment\\s+is\\s+subject\\s+to\\s+compliance\\s+with\\b).*"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "(\\bThis\\s+shipment\\s+is\\s+subject\\s+to\\s+compliance\\s+with\\b).*", "")?.Trim();
+ }
+ }
+ }
+
+ #endregion
+ }
+ else if (modelName == "EVG")
+ {
+ string orgText = string.Empty;
+
+ #region EVG 调整
+ //长荣的卸货港和收货地名称需要解决字母混淆
+ if (!string.IsNullOrWhiteSpace(model.PortDischarge))
+ {
+ string s = ReformatStr(model.PortDischarge, CONST_EVG_POD_FMT);
+
+ //清除所有空格
+ if (!string.IsNullOrWhiteSpace(s))
+ model.PortDischarge = Regex.Replace(s, "\\s+", "");
+ }
+
+ //长荣的卸货港和收货地名称需要解决字母混淆
+ if (!string.IsNullOrWhiteSpace(model.PlaceDelivery))
+ {
+ string s = ReformatStr(model.PlaceDelivery, CONST_EVG_PLD_FMT);
+
+ //清除所有空格
+ if (!string.IsNullOrWhiteSpace(s))
+ model.PlaceDelivery = Regex.Replace(s, "\\s+", "");
+ }
+
+ //件数
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.ContaPicsPackageInfo))
+ {
+ //这里会混入箱型箱量信息,所以这里如果是箱型箱量时不从这里去总件数
+ if (!Regex.IsMatch(resultDto.data.DraftDetails.ContaPicsPackageInfo,
+ "[0-9]+\\s?(x|X|\\*)\\s?[0-9]{1,2}[a-zA-z]{2}"))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.ContaPicsPackageInfo, "[0-9]+(\\.[0-9]+){0,}"))
+ {
+ model.PKGs = (int)decimal.Parse(Regex.Match(resultDto.data.DraftDetails.ContaPicsPackageInfo, "[0-9]+(\\.[0-9]+){0,}").Value);
+ }
+ }
+ }
+
+ //包含重量
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.WeightInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\,[0-9]+){0,}(\\.[0-9]+){0,}(KGS)?"))
+ {
+ var s = Regex.Match(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\,[0-9]+){0,}(\\.[0-9]+){0,}(KGS)?").Value;
+
+ model.KGs = decimal.Parse(Regex.Replace(Regex.Match(s, "[0-9]+(\\,[0-9]+){0,}(\\.[0-9]+){0,}").Value, "\\s+|\\,", ""));
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.CBM))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.CBM, "[0-9]+(\\,[0-9]+){0,}(\\.[0-9]+){0,}"))
+ {
+ var s = Regex.Match(resultDto.data.DraftDetails.CBM, "[0-9]+(\\,[0-9]+){0,}(\\.[0-9]+){0,}").Value;
+
+ model.CBM = decimal.Parse(Regex.Replace(Regex.Match(s, "[0-9]+(\\,[0-9]+){0,}(\\.[0-9]+){0,}").Value, "\\s+|\\,", ""));
+ }
+ }
+
+ string otherStr = string.Empty;
+ var packageArg = App.Configuration["PackageArg"].Split(new char[] { ',' });
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ //对内容中 B AGS 字母被分割进行去空格
+ if (Regex.IsMatch(model.GoodsDescription, "((^[a-zA-Z]{1})|(\\s+\\b[a-zA-Z]{1}\\b))\\s+\\b[a-zA-Z]+\\b"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "((^[a-zA-Z]{1})|(\\s+\\b[a-zA-Z]{1}\\b))\\s+\\b[a-zA-Z]+\\b", m => Regex.Replace(m.Value, "(?<=(^[a-zA-Z]{1}))\\s|(?<=\\b[a-zA-Z]{1}\\b)\\s", ""));
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, "SHIPPER'S\\s+LOAD\\s+\\&\\s+COUNT"))
+ {
+ string s = Regex.Match(model.GoodsDescription, "SHIPPER'S\\s+LOAD\\s+\\&\\s+COUNT.*").Value;
+
+ s = Regex.Match(s, newCheck).Value;
+
+ if (!string.IsNullOrWhiteSpace(s))
+ model.KindPKGs = s;
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, App.Configuration["GoodsDescTempCheckRegex"]))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, App.Configuration["GoodsDescTempTakeRegex"]).Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.TempSet = currStr.Replace("#", "");
+ }
+
+ /*
+ 船公司给的格式单会将设定问题如下展示 例:REEFER CONTAINER TEMPERATURE SET AT 3.0 C.
+ 跟录入的差距比较大 例:TEMP:+3'C
+ 所以这里只提取了温度数值,等整个比对完成修正时重新判断温度是否一致。
+ */
+
+ string temperatureStr = string.Empty;
+
+ if (Regex.IsMatch(model.GoodsDescription, "\\bREEFER\\s+CONTAINER\\s+TEMPERATURE\\s+SET\\s+AT\\s+([0-9]+(\\.[0-9]+)){0,}\\s+(c|C)\\.?"))
+ {
+ temperatureStr = Regex.Match(model.GoodsDescription, "\\bREEFER\\s+CONTAINER\\s+TEMPERATURE\\s+SET\\s+AT\\s+([0-9]+(\\.[0-9]+)){0,}\\s+(c|C)\\.?").Value;
+
+ if (string.IsNullOrWhiteSpace(model.TempSet))
+ model.TempSet = Regex.Match(model.GoodsDescription
+ , "\\bREEFER\\s+CONTAINER\\s+TEMPERATURE\\s+SET\\s+AT\\s+([0-9]+(\\.[0-9]+)){0,}\\s+(c|C)\\.?").Value?.Trim();
+ }
+ else if (Regex.IsMatch(model.GoodsDescription, "\\bTEMPERATURE\\s+SET\\s+AT\\s+([0-9]+(\\.[0-9]+)){0,}\\s+(c|C)\\.?"))
+ {
+ temperatureStr = Regex.Match(model.GoodsDescription, "\\bTEMPERATURE\\s+SET\\s+AT\\s+([0-9]+(\\.[0-9]+)){0,}\\s+(c|C)\\.?").Value;
+
+ if (string.IsNullOrWhiteSpace(model.TempSet))
+ model.TempSet = Regex.Match(model.GoodsDescription
+ , "\\bTEMPERATURE\\s+SET\\s+AT\\s+([0-9]+(\\.[0-9]+)){0,}\\s+(c|C)\\.?").Value?.Trim();
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, App.Configuration["GoodsDescVentCheckRegex"]))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, App.Configuration["GoodsDescVentTakeRegex"]).Value;
+
+ if (Regex.IsMatch(currStr, "\\bREEFER\\s+CONTAINER\\s+TEMPERATURE\\s+SET\\s+AT"))
+ {
+ currStr = Regex.Match(currStr, ".*(?=\\bREEFER\\s+CONTAINER\\s+TEMPERATURE\\s+SET\\s+AT)").Value;
+ }
+ else if (Regex.IsMatch(currStr, "\\bTEMPERATURE\\s+SET\\s+AT"))
+ {
+ currStr = Regex.Match(currStr, ".*(?=\\bTEMPERATURE\\s+SET\\s+AT)").Value;
+ }
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Reeferf = currStr.Replace("#", "");
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, App.Configuration["GoodsDescHumiCheckRegex"]))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, App.Configuration["GoodsDescHumiTakeRegex"]).Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Humidity = currStr.Replace("#", "");
+ }
+
+ //OCEAN FREIGHT
+ if (Regex.IsMatch(model.GoodsDescription, "\\bOCEAN\\s+FREIGHT\\b"))
+ {
+ otherStr = Regex.Match(model.GoodsDescription, "\\bOCEAN\\s+FREIGHT\\b.*").Value;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, otherStr, "");
+
+ string s = Regex.Match(otherStr, newCheck).Value;
+
+ if (!string.IsNullOrWhiteSpace(s))
+ model.KindPKGs = s;
+ }
+
+ //REEFER CONTAINER
+ if (!string.IsNullOrWhiteSpace(temperatureStr))
+ {
+ string s = model.GoodsDescription.Substring(model.GoodsDescription.IndexOf(temperatureStr) + temperatureStr.Length);
+
+ if (Regex.IsMatch(s, "\\bREEFER\\s+CONTAINER\\b"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, Regex.Match(s, "\\bREEFER\\s+CONTAINER\\b.*").Value, "");
+ }
+ }
+
+ if (packageArg.Any(a => a.Contains(Regex.Match(model.GoodsDescription, "^[a-zA-Z]+").Value)))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "^[a-zA-Z]+", "").Trim();
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, "\\(\\s?REEFER"))
+ {
+ var gArg = Regex.Split(model.GoodsDescription, "\\(\\s?REEFER");
+
+ if (gArg.Length > 0)
+ {
+ model.GoodsDescription = gArg.LastOrDefault().Trim();
+ }
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.Shipper))
+ {
+ //对内容中 K AMPUNG 字母被分割进行去空格
+ if (Regex.IsMatch(model.Shipper, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b"))
+ {
+ model.Shipper = Regex.Replace(model.Shipper, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b", m => Regex.Replace(m.Value, "\\s+", ""));
+ }
+
+ model.Shipper = Regex.Replace(model.Shipper, "\\n", " ");
+ model.Shipper = Regex.Replace(model.Shipper, "\\s{2,}", " ");
+ model.Shipper = Regex.Replace(model.Shipper, "\\,\\s{1,}", ",");
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.Consignee))
+ {
+ //对内容中 K AMPUNG 字母被分割进行去空格
+ if (Regex.IsMatch(model.Consignee, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b"))
+ {
+ model.Consignee = Regex.Replace(model.Consignee, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b", m => Regex.Replace(m.Value, "\\s+", ""));
+ }
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\n", " ");
+ model.Consignee = Regex.Replace(model.Consignee, "\\s{2,}", " ");
+ //model.Consignee = Regex.Replace(model.Consignee, "\\,\\s{1,}", ",");
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.NotifyParty))
+ {
+ //对内容中 K AMPUNG 字母被分割进行去空格
+ if (Regex.IsMatch(model.NotifyParty, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b"))
+ {
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b", m => Regex.Replace(m.Value, "\\s+", ""));
+ }
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\n", " ");
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\s{2,}", " ");
+ //model.NotifyParty = Regex.Replace(model.NotifyParty, "\\,\\s{1,}", ",");
+ }
+
+ //如果收货人文字长度和通知人文字长度不一样,并且收货人包含通知人或者通知人包含收货人,
+ //则需要从大文本自行读取
+ if (model.Consignee.Length != model.NotifyParty.Length &&
+ model.Consignee.Length > 0 && model.NotifyParty.Length > 0)
+ {
+ if (model.NotifyParty.Contains(model.Consignee))
+ {
+ orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+ var s = Regex.Match(orgText
+ , "(?<=\\(3\\)\\sConsignee\\(complete\\sname\\sand\\saddress\\)).*?(?=\\(4\\)\\s+Notify\\s+Party\\s+\\(complete\\s+name\\s+and\\s+address\\))").Value;
+
+ if (!string.IsNullOrWhiteSpace(s))
+ {
+ s = Regex.Replace(s, "\\(7\\)\\s+Forwarding\\s+Agent-References", "");
+ s = Regex.Replace(s, "\\\\\\\\n", " ");
+
+ if (Regex.IsMatch(s, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b"))
+ {
+ s = Regex.Replace(s, "\\b[a-zA-Z]{1}\\b\\s+\\b[a-zA-Z]+\\b", m => Regex.Replace(m.Value, "\\s+", ""));
+ }
+
+ model.Consignee = s.Trim();
+ }
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(model.Marks))
+ {
+ if (string.IsNullOrWhiteSpace(orgText))
+ orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ if (Regex.IsMatch(orgText, "N\\s?\\/\\s?M"))
+ model.Marks = Regex.Replace(Regex.Match(orgText, "N\\s?\\/\\s?M").Value, "\\s", "");
+ }
+ else
+ {
+ if (!Regex.IsMatch(model.Marks, "N\\s?\\/\\s?M") && Regex.IsMatch(model.Marks, "N\\s?\\/\\s?N"))
+ model.Marks = Regex.Replace(Regex.Match(model.Marks, "N\\s?\\/\\s?N").Value, "\\s", "");
+ }
+
+ if (string.IsNullOrWhiteSpace(model.IssuePlace))
+ {
+ if (string.IsNullOrWhiteSpace(orgText))
+ orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ if (Regex.IsMatch(orgText, "\\(28\\)\\s+Place\\sof\\sB\\(s\\)\\/L"))
+ {
+ string s = Regex.Match(orgText, "\\(28\\)\\s+Place\\sof\\sB\\(s\\)\\/L.*?\\\\n.*?\\\\n").Value;
+
+ if (!string.IsNullOrWhiteSpace(s))
+ {
+ model.IssuePlace = Regex.Match(s, "(?<=\\\\n)(\\s|\\w|\\,)+").Value;
+ model.IssuePlace = Regex.Replace(model.IssuePlace, "\\s+", "");
+ }
+ }
+ }
+ #endregion
+ }
+ else if (modelName == "TSL")
+ {
+ string orgText = string.Empty;
+
+ #region TSL 调整
+
+ orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+ //货描调整
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\bSHIPPERS\\s+PACK\\s+LOAD\\s+COUNT\\s+\\&\\s+SEAL\\b", "");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\b[a-zA-Z]{1}?SAID\\s+TO\\s+CONTAIN\\b", "");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\bTelex\\s+Release\\s+BL\\b", "");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\\"", "");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\s+\\bT\\b\\s+", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\bSAY\\b\\:.*", "");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\bF([a-zA-Z]{1})RESH\\b", "FRESH");
+
+ if (Regex.IsMatch(model.GoodsDescription, "\\bDESCRIPTION\\s+AS\\s+ATTACHED\\s+LIST\\b")
+ && !string.IsNullOrWhiteSpace(attchedSheetText))
+ {
+ string txt = Regex.Replace(attchedSheetText, "\\n", "\\\\n");
+ string s = Regex.Match(txt, "(?<=(<>)).*").Value?.Trim();
+
+ if (!string.IsNullOrWhiteSpace(s))
+ {
+ s = Regex.Replace(s, "\\\\\\\\n", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\bDESCRIPTION\\s+AS\\s+ATTACHED\\s+LIST\\b", s);
+ }
+ }
+
+ //经测试有时货描的温度无法读取到,需要从原文读取温度问题
+ if (!Regex.IsMatch(model.GoodsDescription, "\\bTEMP(ERATURE)?\\b(\\:|\\;|\\s)")
+ && Regex.IsMatch(orgText, "([a-zA-Z]{1})?TEMP(ERATURE)?\\b(\\:|\\;|\\s)"))
+ {
+ string s = Regex.Match(orgText, "TEMP(ERATURE)?\\b(\\:|\\;|\\s).*?\\\\n").Value;
+
+ s = Regex.Replace(s, "\\\\\\\\n", "");
+
+ if (Regex.IsMatch(model.GoodsDescription, "\\bVENT\\b(\\:|\\;|\\s)"))
+ {
+ string vent = Regex.Match(model.GoodsDescription, "\\bVENT\\b(\\:|\\;|\\s).*").Value;
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, vent, $"{s} {vent}");
+ }
+ }
+
+
+ if (string.IsNullOrWhiteSpace(model.TempSet))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bTEMP(ERATURE)?\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bTEMP(ERATURE)?\\b(\\:|\\;|\\s)\\s?.*?\\s"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "((?<=\\bTEMP\\b(\\:|\\;|\\s))\\s?.*?\\s)|((?<=\\bTEMPERATURE\\b(\\:|\\;|\\s))\\s?.*?\\s)").Value?.Trim();
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.TempSet = currStr.Replace("#", "");
+ }
+ else if (Regex.IsMatch(model.GoodsDescription, "\\bTEMP(ERATURE)?\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "((?<=\\bTEMP\\b(\\:|\\;|\\s))\\s?.*)|((?<=\\bTEMPERATURE\\b(\\:|\\;|\\s))\\s?.*)").Value?.Trim();
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.TempSet = currStr.Replace("#", "");
+ }
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(model.Reeferf))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bVENT\\b(\\:|\\;|\\s)"))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bVENT\\b(\\:|\\;|\\s)\\s?.*?\\s"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "(?<=\\bVENT\\b(\\:|\\;|\\s))\\s?.*?\\s").Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Reeferf = currStr.Replace("#", "");
+ }
+ else if (Regex.IsMatch(model.GoodsDescription, "\\bVENT\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "(?<=\\bVENT\\b(\\:|\\;|\\s))\\s?.*").Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Reeferf = currStr.Replace("#", "");
+ }
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(model.Humidity))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bHUMI\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bHUMI\\b(\\:|\\;|\\s)\\s?.*?\\s"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "\\bHUMI\\b(\\:|\\;|\\s)\\s?.*?\\s").Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Humidity = currStr.Replace("#", "");
+ }
+ else if (Regex.IsMatch(model.GoodsDescription, "\\bHUMI\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "\\bHUMI\\b(\\:|\\;|\\s)\\s?.*").Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Humidity = currStr.Replace("#", "");
+ }
+ }
+ }
+ }
+
+ //包含重量
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.WeightInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}?(KGS)"))
+ {
+ var s = Regex.Match(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}?(KGS)").Value;
+
+ model.KGs = decimal.Parse(Regex.Match(s, "[0-9]+(\\.[0-9]+){0,}").Value);
+ }
+ }
+
+ model.GoodsDescription = model.GoodsDescription?.Trim();
+
+
+ if (Regex.IsMatch(model.Consignee, "\\w+\\.\\s+\\w+"))
+ {
+ model.Consignee = Regex.Replace(model.Consignee, "\\w+\\.\\s+\\w+", rlp =>
+ {
+ return Regex.Replace(rlp.Value, "\\s+", "");
+ });
+ }
+
+ if (Regex.IsMatch(model.NotifyParty, "\\w+\\.\\s+\\w+"))
+ {
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\w+\\.\\s+\\w+", rlp =>
+ {
+ return Regex.Replace(rlp.Value, "\\s+", "");
+ });
+ }
+
+ #endregion
+
+ //包含件数和包装
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.ContaPicsPackageInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.ContaPicsPackageInfo, "[0-9]+(\\.[0-9]+){0,}"))
+ {
+ model.PKGs = (int)decimal.Parse(Regex.Match(resultDto.data.DraftDetails.ContaPicsPackageInfo
+ , "[0-9]+(\\.[0-9]+){0,}").Value);
+ }
+
+ var packageArg = App.Configuration["PackageArg"].Split(new char[] { ',' });
+
+ var package = packageArg.FirstOrDefault(c => resultDto.data.DraftDetails.ContaPicsPackageInfo.Contains(c));
+ if (!string.IsNullOrWhiteSpace(package))
+ {
+ model.KindPKGs = package;
+ }
+ }
+ }
+ else if (modelName == "ONE")
+ {
+ string orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ #region ONE 调整
+ /*
+ 测试ONE的格式单货描太长会有需要拼接的情况
+ 发货人有拼接货描 SH> 链接
+ */
+ #region 发货人拼接字符
+ if (Regex.IsMatch(model.Shipper, "SH>"))
+ {
+ string lastStr = string.Empty;
+
+ if (Regex.IsMatch(orgText, "(?<=SH>).*?(?=-)"))
+ {
+ string s = Regex.Matches(orgText, "(?<=SH>).*?(?=-)").LastOrDefault().Value.Trim();
+
+ s = Regex.Replace(s, "\\\\\\\\n", " ").Trim();
+ //这里拼接字符
+ model.Shipper += s;
+
+ model.Shipper = Regex.Replace(model.Shipper, "SH>", " ")?.Trim();
+
+ model.Shipper = Regex.Replace(model.Shipper, "\\s{2,}", " ")?.Trim();
+ }
+ }
+ #endregion
+
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "((\\w|\\s)+\\/)|^\\/", "")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, ".*\\bIN\\s+TOTAL\\b", "")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, ".*(?=\\bSAID\\s+TO\\s+CONTAIN\\b)", "")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "CARGO\\s+IS\\s+STOWED\\s+IN.*\\bCONTAINER.*(?=\\bTEMPERATURE\\b)", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\bSAID\\s+TO\\s+CONTAIN\\:", "");
+
+ if (Regex.IsMatch(orgText, "\\bTO\\s+BE\\s+CONTINUED\\s+ON\\s+ATTACHED\\s+LIST\\b"))
+ {
+ string otherGoods = Regex.Match(orgText, "(?<=\\bDESCRIPTION\\s+OF\\s+GOODS\\s+(\\bGROSS\\s+WEIGHT)?\\s+\\bMEASUREMENT\\b).*?(?=-)").Value;
+
+ if (Regex.IsMatch(otherGoods, "SH>"))
+ otherGoods = Regex.Replace(otherGoods, "SH>.*", "");
+
+ otherGoods = Regex.Replace(otherGoods, "\\\\\\\\n", " ").Trim();
+
+ otherGoods = Regex.Replace(otherGoods, "\\bCARRIAGE\\s+PER\\s+CLAUSE.*", "");
+
+ model.GoodsDescription += " " + otherGoods;
+
+ model.GoodsDescription = model.GoodsDescription.Trim();
+ }
+ string temperatureStr = string.Empty;
+ string ventStr = string.Empty;
+
+ if (Regex.IsMatch(model.GoodsDescription, "\\bTEMPERATURE\\s+OF\\s+(\\+|-)?([0-9]+(\\.[0-9]+){0,})\\s+(c|C|(DEGREES CELSIUS))\\.?"))
+ {
+ temperatureStr = Regex.Match(model.GoodsDescription, "\\bTEMPERATURE\\s+OF\\s+(\\+|-)?([0-9]+(\\.[0-9]+){0,})\\s+(c|C|(DEGREES CELSIUS))\\.?").Value;
+
+ if (string.IsNullOrWhiteSpace(model.TempSet))
+ model.TempSet = Regex.Match(model.GoodsDescription
+ , "\\bTEMPERATURE\\s+OF\\s+(\\+|-)?([0-9]+(\\.[0-9]+){0,})\\s+(c|C|(DEGREES CELSIUS))\\.?").Value?.Trim();
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, "\\bVENTILATION\\s+REQUIRED\\s+.*\\bSET\\s+AT\\b\\s+([0-9]+(\\.[0-9]+){0,})\\s+(CBM\\s+PER\\s+HOUR)\\.?"))
+ {
+ ventStr = Regex.Match(model.GoodsDescription, "\\bVENTILATION\\s+REQUIRED\\s+.*\\bSET\\s+AT\\b\\s+([0-9]+(\\.[0-9]+){0,})\\s+(CBM\\s+PER\\s+HOUR)\\.?").Value;
+
+ if (string.IsNullOrWhiteSpace(model.Reeferf))
+ model.Reeferf = Regex.Match(model.GoodsDescription
+ , "\\bVENTILATION\\s+REQUIRED\\s+.*\\bSET\\s+AT\\b\\s+([0-9]+(\\.[0-9]+){0,})\\s+(CBM\\s+PER\\s+HOUR)\\.?").Value?.Trim();
+ }
+ }
+ #endregion
+ }
+ else if (modelName == "PIL")
+ {
+ #region PIL 调整
+
+ var cncGoodsRegexPattern = $"[0-9]+(\\.[0-9]+){{0,}}\\s+({newCheck})(\\((s|S)\\))?";
+
+ //包含重量
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.WeightInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}"))
+ {
+ var weightColles = Regex.Matches(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}");
+
+ model.KGs = decimal.Parse(weightColles[0].Value);
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\.{2}", " ");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "SAID\\s+TO\\s+CONTAIN\\:?", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "CONTAINER\\(S\\)", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "IN\\s+TOTAL\\:?", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[0-9]+\\s?(x|X|\\*)\\s?\\w+", "")?.Trim();
+
+ if (!Regex.IsMatch(model.GoodsDescription, "\\s(?=VENT\\:)") && Regex.IsMatch(model.GoodsDescription, "VENT\\:"))
+ {
+ string s = Regex.Match(model.GoodsDescription, "VENT\\:").Value;
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "VENT\\:", " " + s);
+ }
+
+ if (Regex.IsMatch(model.GoodsDescription, cncGoodsRegexPattern))
+ {
+ var picsPkgMatchCols = Regex.Matches(model.GoodsDescription, cncGoodsRegexPattern);
+
+ var lastMatch = picsPkgMatchCols.LastOrDefault();
+ string gPicsPackage = lastMatch.Value;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, cncGoodsRegexPattern, "")?.Trim();
+ //model.GoodsDescription = new Regex(cMatch.Value).Replace(model.GoodsDescription, "", 1, cMatch.Index).Trim();
+
+
+ model.PKGs = (int)decimal.Parse(Regex.Match(gPicsPackage
+ , "[0-9]+(\\.[0-9]+){0,}").Value);
+
+ gPicsPackage = Regex.Match(gPicsPackage, $"({newCheck})(\\((s|S)\\))?").Value;
+
+ if (Regex.IsMatch(gPicsPackage, "\\((s|S)\\)"))
+ {
+ var s2 = Regex.Match(gPicsPackage, "\\((s|S)\\)").Value;
+ gPicsPackage = gPicsPackage.Replace(s2, "S");
+ }
+
+ model.KindPKGs = gPicsPackage.Trim().ToUpper();
+ }
+
+
+
+ //判断如果货描里含有1320 CARTONS(件数 包装)
+
+ //如果发货人的结尾是“*”符号,则标识发货人过长内容被阶段截断内容在货描获取
+ #region 发货人拼接字符
+ if (model.Shipper.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ string s = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+ //去掉包装单位
+ s = Regex.Replace(s, newCheck, "");
+ //这里拼接字符
+ model.Shipper += s;
+
+ model.Shipper = Regex.Replace(model.Shipper, "\\*{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ #endregion
+
+ string cneeCombined = string.Empty;
+ string cneeEndStr = string.Empty;
+ string notifyEndStr = string.Empty;
+
+ #region 收货人拼接字符
+ if (model.Consignee.EndsWith("**"))
+ {
+ cneeEndStr = "**";
+
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\*{4}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ else if (model.Consignee.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+ cneeEndStr = "*";
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\*{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+
+ model.Consignee = model.Consignee.Trim();
+ #endregion
+
+ #region 通知人拼接字符
+ if (model.NotifyParty.EndsWith("**"))
+ {
+ notifyEndStr = "**";
+
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined) && cneeEndStr == "**")
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ");
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ }
+ else if (model.NotifyParty.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined) && cneeEndStr == "*")
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ");
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp =>
+ {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ }
+
+ model.NotifyParty = model.NotifyParty.Trim();
+ #endregion
+
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, newCheck, "");
+
+
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\s{1,}\\,\\s{1,}", "")?.Trim();
+ }
+
+ #endregion
+ }
+ else if (modelName == "MSC")
+ {
+ #region MSC 调整
+
+
+ #endregion
+ }
+ else if (modelName == "MSK")
+ {
+ string orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ //是否不可转让海运单
+ bool nonNegotiableSWB = Regex.IsMatch(attchedSheetText, "NON\\-NEGOTIABLE\\s+WAYBILL");
+ //海运提单或者多式联运提单
+ bool blForOceanTransport = Regex.IsMatch(attchedSheetText, "BILL\\s+OF\\s+LADING\\s+FOR\\s+OCEAN\\s+TRANSPORT");
+
+ #region MSK 调整
+
+ if (string.IsNullOrWhiteSpace(model.BookingNo))
+ {
+ if (Regex.IsMatch(attchedSheetText, "Booking\\s+No\\."))
+ {
+ string name = Regex.Match(attchedSheetText, ".*Booking\\s+No\\..*(\\r\\n)").Value;
+
+ string regex = "(?<=" + name.RegexSymbolFormat() + ").*(\\r\\n)";
+
+ var currMatch = Regex.Match(attchedSheetText, regex).Value;
+
+ if (!string.IsNullOrWhiteSpace(currMatch))
+ {
+ var currArg = Regex.Split(currMatch.Trim(), "\\s{6,}");
+
+ if (currArg.Length > 1)
+ {
+ model.BookingNo = currArg.LastOrDefault(x => !string.IsNullOrWhiteSpace(x)).Trim();
+ }
+ }
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(model.ContractNo))
+ {
+ if (Regex.IsMatch(attchedSheetText, "Svc\\s+Contract"))
+ {
+ string name = Regex.Match(attchedSheetText, ".*Svc\\s+Contract.*(\\r\\n)").Value;
+
+ string regex = "(?<=" + name.RegexSymbolFormat() + ").*(\\r\\n)";
+
+ var currMatch = Regex.Match(attchedSheetText, regex).Value;
+
+ if (!string.IsNullOrWhiteSpace(currMatch))
+ {
+ var currArg = Regex.Split(currMatch.Trim(), "\\s{6,}");
+
+ if (currArg.Length > 1)
+ {
+ model.ContractNo = currArg.LastOrDefault(x => !string.IsNullOrWhiteSpace(x)).Trim();
+ }
+ else if (currArg.Length == 1)
+ {
+ model.ContractNo = currArg.FirstOrDefault();
+ }
+ }
+ }
+ }
+
+ //重新取航次号
+ if (Regex.IsMatch(attchedSheetText, "Voyage\\s+No\\."))
+ {
+ string name = Regex.Match(attchedSheetText, ".*Voyage\\s+No\\..*(\\r\\n)").Value;
+
+ string regex = "(?<=" + name.RegexSymbolFormat() + ").*(\\r\\n)";
+
+ var currMatch = Regex.Match(attchedSheetText, regex).Value;
+
+ if (!string.IsNullOrWhiteSpace(currMatch))
+ {
+ var currArg = Regex.Split(currMatch.Trim(), "\\s{6,}");
+
+ if (currArg.Length > 1)
+ {
+ model.VoyNo = currArg.LastOrDefault(x => !string.IsNullOrWhiteSpace(x)).Trim();
+ }
+ }
+ }
+
+ //如果航次号错误需要重新提取
+ if (string.IsNullOrWhiteSpace(model.VoyNo) || model.VoyNo.IndexOf(",") >= 0)
+ {
+ if (!string.IsNullOrWhiteSpace(model.VesselName))
+ {
+ model.VoyNo = Regex.Match(orgText, $"(?<={model.VesselName})\\s+\\w+").Value;
+ }
+ }
+
+ if (Regex.IsMatch(attchedSheetText, "Port\\s+of\\s+Loading"))
+ {
+ string name = Regex.Match(attchedSheetText, "Port\\s+of\\s+Loading.*(\\r\\n)").Value;
+
+ string regex = "(?<=" + name.RegexSymbolFormat() + ").*(\\r\\n)";
+
+ var currMatch = Regex.Match(attchedSheetText, regex).Value;
+
+ if (!string.IsNullOrWhiteSpace(currMatch))
+ {
+ var currArg = Regex.Split(currMatch.Trim(), "\\s{6,}");
+
+ if (currArg.Length > 1)
+ {
+ model.PortLoad = currArg.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)).Trim();
+ }
+ }
+ }
+
+ if (Regex.IsMatch(attchedSheetText, "Port\\s+of\\s+Discharge"))
+ {
+ string name = Regex.Match(attchedSheetText, "Port\\s+of\\s+Discharge.*(\\r\\n)").Value;
+
+ string regex = "(?<=" + name.RegexSymbolFormat() + ").*(\\r\\n)";
+
+ var currMatch = Regex.Match(attchedSheetText, regex).Value;
+
+ if (!string.IsNullOrWhiteSpace(currMatch))
+ {
+ var currArg = Regex.Split(currMatch.Trim(), "\\s{6,}");
+
+ if (currArg.Length > 1)
+ {
+ model.PortDischarge = currArg.LastOrDefault(x => !string.IsNullOrWhiteSpace(x)).Trim();
+ }
+ }
+ }
+
+ //货描信息取的不正确,需要重新从大文本获取
+ model.GoodsDescription = Regex.Match(orgText, "(?<=Seal\\s+No\\.\\s+Weight\\s+Measurement).*(?=This\\s+shipment\\s+is\\s+subject\\s+to\\s+compliance\\s+with\\s+Maersk)").Value;
+
+ if (string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ model.GoodsDescription = Regex.Match(orgText, "(?<=Seal\\sNo\\.\\sWeight\\sMeasurement).*(?=The\\sMerchant\\(s\\)\\swarrant\\sand\\srepresent\\sthat\\sthis\\sshipment)").Value;
+ }
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "SHIPPER'S\\s+LOAD.*", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\b(CO)?PY\\b", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\bRUEEF\\b", "REEF");
+
+ if (Regex.IsMatch(model.GoodsDescription, "TEMP(ERATURE)?\\b(\\:|\\;|\\s)"))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "Temperature\\:.*", "");
+ }
+
+ string beforeCheck = string.Empty;
+
+ if (Regex.IsMatch(model.GoodsDescription, "[0-9]+CBM"))
+ {
+ beforeCheck = Regex.Match(model.GoodsDescription, "[0-9]+CBM").Value;
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[0-9]+CBM", "BBBX");
+ }
+
+ //去掉COPY 混淆的内容
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[0-9](C|O|P|Y)(\\.[0-9]+){0,}", rlp => {
+ return Regex.Replace(rlp.Value, "(C|O|P|Y)", "");
+ });
+
+ //去掉TRUE 混淆的内容
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[0-9](T|R|U|E)(\\.[0-9]+){0,}", rlp => {
+ return Regex.Replace(rlp.Value, "(T|R|U|E)", "");
+ });
+
+ if (!string.IsNullOrWhiteSpace(beforeCheck))
+ {
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "BBBX", beforeCheck);
+ }
+
+ //总重、总体积 1 Container Said to Contain 1450 BAGS
+ if (Regex.IsMatch(model.GoodsDescription, "[0-9]+\\s+\\bContainer\\s+Said\\s+to\\s+Contain\\s+[0-9]+(\\.[0-9]+){0,}\\s+\\w+"))
+ {
+ var s = Regex.Match(model.GoodsDescription,
+ ".*?(?=[0-9]+\\s+\\bContainer\\s+Said\\s+to\\s+Contain)").Value;
+
+ if (!string.IsNullOrWhiteSpace(s))
+ {
+ string kgs = Regex.Match(s, "[0-9]+(\\.[0-9]+){0,}.*(?=KGS)").Value?.Trim();
+
+ if (!string.IsNullOrWhiteSpace(kgs))
+ model.KGs = decimal.Parse(kgs);
+
+ string cbm = Regex.Match(s, "(?<=KGS)\\s+[0-9]+(\\.[0-9]+){0,}.*(?=CBM)").Value?.Trim();
+
+ if (!string.IsNullOrWhiteSpace(cbm))
+ model.CBM = decimal.Parse(cbm);
+ }
+
+ var s1 = Regex.Match(model.GoodsDescription,
+ "[0-9]+\\s+\\bContainer\\s+Said\\s+to\\s+Contain\\s+[0-9]+(\\.[0-9]+){0,}\\s+\\w+").Value;
+
+ if (!string.IsNullOrWhiteSpace(s1))
+ {
+ string pics = Regex.Match(s1, "(?<=\\bContainer\\s+Said\\s+to\\s+Contain)\\s+[0-9]+(\\.[0-9]+){0,}").Value;
+
+ model.PKGs = (int)decimal.Parse(pics);
+
+ s1 = Regex.Replace(s1, "[0-9]+\\s+\\bContainer\\s+Said\\s+to\\s+Contain\\s+[0-9]+(\\.[0-9]+){0,}", "");
+
+ string pkgs = Regex.Match(s1, $"({newCheck})").Value;
+
+ if (!string.IsNullOrWhiteSpace(pkgs))
+ {
+ model.KindPKGs = pkgs;
+ }
+ }
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, ".*(?=[0-9]+\\s+\\bContainer\\s+Said\\s+to\\s+Contain)", "");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[0-9]+\\s+\\bContainer\\s+Said\\s+to\\s+Contain\\s+[0-9]+(\\.[0-9]+){0,}\\s+\\w+", "");
+ }
+
+ //如果发货人的结尾是“+”符号,则标识发货人过长内容被阶段截断内容在货描获取
+ #region 发货人拼接字符
+ if (model.Shipper.EndsWith("+"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\+(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ string s = Regex.Match(model.GoodsDescription, "\\+(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+ //去掉包装单位
+ s = Regex.Replace(s, newCheck, "");
+ //这里拼接字符
+ model.Shipper += s;
+
+ model.Shipper = Regex.Replace(model.Shipper, "\\+{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\+{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp => {
+ if (rlp.Value.StartsWith("++"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ #endregion
+
+
+
+ string cneeCombined = string.Empty;
+ string cneeEndStr = string.Empty;
+ string notifyEndStr = string.Empty;
+
+ //收货人去掉标题混淆内容
+ string cneeErrRegx = "As\\s+principal,\\s+where\\s+“care\\s+of”,\\s+“c\\/o”,\\s+or\\s+other\\s+variants\\s+used\\.\\)";
+
+ if (Regex.IsMatch(model.Consignee, cneeErrRegx))
+ {
+ model.Consignee = Regex.Replace(Regex.Replace(model.Consignee, cneeErrRegx, " "), "\\s{2,}", " ").Trim();
+ }
+
+ #region 收货人拼接字符
+ if (model.Consignee.EndsWith("**"))
+ {
+ cneeEndStr = "**";
+
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\*{4}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ else if (model.Consignee.EndsWith("+"))
+ {
+ string lastStr = string.Empty;
+ cneeEndStr = "+";
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\+(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\+(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\+{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\+{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+", rlp => {
+ if (rlp.Value.StartsWith("++"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+
+ model.Consignee = model.Consignee.Trim();
+ #endregion
+
+ string notifyErrRegx1 = "This\\s+contract\\s+is\\s+subject\\s+to\\s+the\\s+terms.*reasonable\\s+notice\\s+in\\s+writing\\.";
+ string notifyErrRegx2 = "This\\s+contract\\s+is\\s+subject\\s+to\\s+the\\s+terms.*so\\.\\s+The\\s+shipper";
+
+ if (Regex.IsMatch(model.NotifyParty, notifyErrRegx1))
+ {
+ model.NotifyParty = Regex.Replace(Regex.Replace(model.NotifyParty, notifyErrRegx1, " "), "\\s{2,}", " ").Trim();
+ }
+ else if (Regex.IsMatch(model.NotifyParty, notifyErrRegx2))
+ {
+ model.NotifyParty = Regex.Replace(Regex.Replace(model.NotifyParty, notifyErrRegx2, " "), "\\s{2,}", " ").Trim();
+ }
+
+ if(string.IsNullOrWhiteSpace(model.NotifyParty))
+ {
+ //通知人不同VC文件会显示位置不同
+ if (Regex.IsMatch(attchedSheetText, "NON\\-NEGOTIABLE\\s+WAYBILL"))
+ {
+ if (Regex.IsMatch(attchedSheetText, "Notify\\s+Party\\s+\\(see\\s+clause\\s+22\\)"))
+ {
+ var baseMatch = Regex.Match(attchedSheetText, "Notify\\s+Party\\s+\\(see\\s+clause\\s+22\\).*(\\r\\n)");
+ string name1 = baseMatch.Value;
+ int startIdx = baseMatch.Index;
+
+ StringBuilder notifyBuilder = new StringBuilder();
+
+ while (true)
+ {
+ string regex = "(?<=" + name1.RegexSymbolFormat() + ").*(\\r\\n)";
+
+ var currMatch = Regex.Matches(attchedSheetText, regex).FirstOrDefault(a => a.Index > startIdx);
+
+ var currLine = currMatch?.Value;
+
+ if (Regex.IsMatch(currLine, "Vessel\\s+Voyage\\s+No\\."))
+ {
+ break;
+ }
+ else if (currLine.Trim() == "")
+ {
+ break;
+ }
+
+ string currLineCopy = currLine;
+
+ if (!string.IsNullOrWhiteSpace(currLineCopy))
+ //currLineCopy = currLine.Trim();
+
+ startIdx = currMatch.Index;
+
+ if (!Regex.IsMatch(currLineCopy, "^\\s{12,}"))
+ {
+ var currArg = Regex.Split(currLineCopy, "\\s{12,}");
+
+ if (currArg.Length > 1)
+ {
+ notifyBuilder.AppendLine(currArg.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)));
+ }
+ else
+ {
+ notifyBuilder.AppendLine(currLineCopy.Trim());
+ }
+ }
+
+ name1 = currLine;
+ }
+
+ model.NotifyParty = notifyBuilder.ToString();
+ }
+ }
+ else if (Regex.IsMatch(attchedSheetText, "BILL\\s+OF\\s+LADING\\s+FOR\\s+OCEAN\\s+TRANSPORT"))
+ {
+
+ }
+ }
+
+ #region 通知人拼接字符
+ if (model.NotifyParty.EndsWith("**"))
+ {
+ notifyEndStr = "**";
+
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined) && cneeEndStr == "**")
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ");
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ }
+ else if (model.NotifyParty.EndsWith("+"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined) && cneeEndStr == "+")
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ");
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\+(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\+{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp =>
+ {
+ if (rlp.Value.StartsWith("++"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ }
+
+ model.NotifyParty = model.NotifyParty.Trim();
+ #endregion
+ #endregion
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "[0-9]+\\s+[0-9]+(\\.[0-9]+){0,}\\s+KGS", rlp =>
+ {
+ string s = Regex.Match(rlp.Value, "[0-9]+\\s+[0-9]+").Value;
+ return Regex.Replace(rlp.Value, "[0-9]+\\s+[0-9]+", s.Replace(" ", ""));
+ });
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "N\\/M", "");
+ model.GoodsDescription = Regex.Replace(Regex.Replace(model.GoodsDescription, "\\bVERIFY\\b", " "), "\\s{2,}", " ");
+ model.GoodsDescription = Regex.Replace(Regex.Replace(model.GoodsDescription, "\\\\\\\\n", " "), "\\s{2,}", " ")?.Trim();
+
+
+
+ }
+ else if (modelName == "HPL")
+ {
+ #region HPL 调整
+
+ //这里货描不准确,需要从全文重新取
+ string orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ string startStr = Regex.Match(orgText, "Description of Goods Gross Weight\\:.*Measurement\\:").Value;
+
+ if (!string.IsNullOrWhiteSpace(startStr))
+ {
+ string endStr = Regex.Match(orgText, "(S|s)h(\\s)?ip(\\s)?pe(\\s)?r’s(\\s)?de(\\s)?cl(\\s)?ar(\\s)?ed").Value;
+
+ string goodsStr = Regex.Match(orgText, $"(?<={startStr}).*(?={endStr})").Value;
+
+ //货描里有后缀是*的,需要从货描中拼接 SLAC*
+ if (Regex.IsMatch(goodsStr, "\\w+?\\*"))
+ {
+ string gdsMerge = Regex.Match(goodsStr, "\\w+?\\*").Value;
+ string gdsMerge2 = Regex.Match(goodsStr, $"\\*{gdsMerge.Replace("*", "")}.*?\\\\\\\\n").Value;
+
+ goodsStr = Regex.Replace(goodsStr, $"{gdsMerge.Replace("*", "")}?\\*", rlp =>
+ {
+ return Regex.Replace(rlp.Value, $"{gdsMerge.Replace("*", "")}?\\*", gdsMerge2.Replace("*", ""));
+ });
+
+ goodsStr = Regex.Replace(goodsStr, $"\\*{gdsMerge.Replace("*", "")}.*?\\\\\\\\n", "");
+ }
+
+ model.GoodsDescription = goodsStr;
+ }
+
+ //如果发货人的结尾是“*”符号,则标识发货人过长内容被阶段截断内容在货描获取
+ #region 发货人拼接字符
+ if (model.Shipper.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ string s = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+ //去掉包装单位
+ s = Regex.Replace(s, newCheck, "");
+ //这里拼接字符
+ model.Shipper += s;
+
+ model.Shipper = Regex.Replace(model.Shipper, "\\*{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ #endregion
+
+ string cneeCombined = string.Empty;
+ string cneeEndStr = string.Empty;
+ string notifyEndStr = string.Empty;
+
+ #region 收货人拼接字符
+ if (model.Consignee.EndsWith("**"))
+ {
+ cneeEndStr = "**";
+
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\*{4}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ else if (model.Consignee.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+ cneeEndStr = "*";
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.Consignee += cneeCombined;
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\*{2}", " ")?.Trim();
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;|\\+)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+
+ model.Consignee = model.Consignee.Trim();
+ #endregion
+
+ #region 通知人拼接字符
+ if (model.NotifyParty.EndsWith("**"))
+ {
+ notifyEndStr = "**";
+
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined) && cneeEndStr == "**")
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ");
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*{2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{4}", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp => {
+ if (rlp.Value.StartsWith("**"))
+ return string.Empty;
+ return rlp.Value;
+ })?.Trim();
+ }
+ }
+ }
+ }
+ else if (model.NotifyParty.EndsWith("*"))
+ {
+ string lastStr = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (!string.IsNullOrWhiteSpace(cneeCombined) && cneeEndStr == "*")
+ {
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ");
+ }
+ else
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+"))
+ {
+ cneeCombined = Regex.Match(model.GoodsDescription, "\\*(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+").Value;
+
+ //去掉包装单位
+ cneeCombined = Regex.Replace(cneeCombined, newCheck, "");
+ //这里拼接字符
+ model.NotifyParty += cneeCombined;
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\*{2}", " ");
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription,
+ "\\*{1,2}(\\s|\\w|\\:|\\.|\\-|\\(|\\)|\\,|\\@|\\;)+", rlp =>
+ {
+ if (rlp.Value.StartsWith("**"))
+ return rlp.Value;
+ return string.Empty;
+ })?.Trim();
+ }
+ }
+ }
+ }
+
+ model.NotifyParty = model.NotifyParty.Trim();
+ #endregion
+
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "N\\/M", " ");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "MARKS\\s+\\&\\s+NOS\\:", " ");
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\s{2,}", " ");
+
+ string temperatureStr = string.Empty;
+
+ if (Regex.IsMatch(model.GoodsDescription, "TEMPERATURE\\s+TO\\s+BE\\s+SET\\s+AT\\s+(\\-|\\+)?([0-9]+(\\.[0-9]+)){0,}\\s+(c|C)\\.?"))
+ {
+ temperatureStr = Regex.Match(model.GoodsDescription, "TEMPERATURE\\s+TO\\s+BE\\s+SET\\s+AT\\s+(\\-|\\+)?([0-9]+(\\.[0-9]+)){0,}\\s+(c|C)\\.?").Value;
+
+ if (string.IsNullOrWhiteSpace(model.TempSet))
+ model.TempSet = Regex.Match(model.GoodsDescription
+ , "TEMPERATURE\\s+TO\\s+BE\\s+SET\\s+AT\\s+(\\-|\\+)?([0-9]+(\\.[0-9]+)){0,}\\s+(c|C)\\.?").Value?.Trim();
+ }
+
+ if (Regex.IsMatch(orgText, "FRESH\\s+AIR\\s+EXCHANGE\\s+\\(OR\\s+VENT\\s+SETTING\\)\\s+TO\\s+BE\\s+SET\\s+AT\\s+([0-9]+(\\.[0-9]+){0,})\\s+CUBIC\\s+METERS(\\\\\\\\n|\\s)?PER\\s+HOUR"))
+ {
+ if (string.IsNullOrWhiteSpace(model.Reeferf))
+ model.Reeferf = Regex.Replace(Regex.Match(orgText
+ , "FRESH\\s+AIR\\s+EXCHANGE\\s+\\(OR\\s+VENT\\s+SETTING\\)\\s+TO\\s+BE\\s+SET\\s+AT\\s+([0-9]+(\\.[0-9]+){0,})\\s+CUBIC\\s+METERS(\\\\\\\\n|\\s)?PER\\s+HOUR").Value?.Trim(), "\\\\\\\\n", " ");
+ }
+
+ if (string.IsNullOrWhiteSpace(model.PortDischarge))
+ {
+ var pod = Regex.Match(orgText, "Port\\s+of\\s+Discharge\\:(\\\\\\\\n)?(\\w|\\,|\\s)+(?=\\\\\\\\n)").Value;
+
+ if (!string.IsNullOrWhiteSpace(pod))
+ {
+ model.PortDischarge = Regex.Replace(Regex.Match(pod, "(?<=Port\\s+of\\s+Discharge\\:).*").Value, "\\\\\\\\n", "")?.Trim();
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(model.PortLoad))
+ {
+ var pl = Regex.Match(orgText, "Port\\s+of\\s+Loading\\:(\\\\\\\\n)?(\\w|\\,|\\s)+(?=\\\\\\\\n)").Value;
+
+ if (!string.IsNullOrWhiteSpace(pl))
+ {
+ model.PortLoad = Regex.Replace(Regex.Match(pl, "(?<=Port\\s+of\\s+Loading\\:).*").Value, "\\\\\\\\n", "")?.Trim();
+ }
+ }
+
+ #endregion
+ }
+ else if (modelName == "SITC")
+ {
+ #region SITC 调整
+ #endregion
+ }
+ else
+ {
+ //包含重量
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.WeightInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}?(KGS)"))
+ {
+ var s = Regex.Match(resultDto.data.DraftDetails.WeightInfo, "[0-9]+(\\.[0-9]+){0,}?(KGS)").Value;
+
+ model.KGs = decimal.Parse(Regex.Match(s, "[0-9]+(\\.[0-9]+){0,}").Value);
+ }
+ }
+
+ //包含件数和包装
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.ContaPicsPackageInfo))
+ {
+ if (Regex.IsMatch(resultDto.data.DraftDetails.ContaPicsPackageInfo, "[0-9]+(\\.[0-9]+){0,}"))
+ {
+ model.PKGs = (int)decimal.Parse(Regex.Match(resultDto.data.DraftDetails.ContaPicsPackageInfo
+ , "[0-9]+(\\.[0-9]+){0,}").Value);
+ }
+
+ var packageArg = App.Configuration["PackageArg"].Split(new char[] { ',' });
+
+ var package = packageArg.FirstOrDefault(c => resultDto.data.DraftDetails.ContaPicsPackageInfo.Contains(c));
+ if (!string.IsNullOrWhiteSpace(package))
+ {
+ model.KindPKGs = package;
+ }
+ }
+ }
+
+ /*
+ model.Shipper = Regex.Replace(model.Shipper, "\\,\\s{2,}", ",");
+ model.Shipper = Regex.Replace(model.Shipper, "\\s{1,}\\,", ",");
+ model.Shipper = Regex.Replace(model.Shipper, "\\.\\s{1,}", ".");
+
+ model.Consignee = Regex.Replace(model.Consignee, "\\,\\s{1,}", ",");
+ model.Consignee = Regex.Replace(model.Consignee, "\\s{1,}\\,", ",");
+ model.Consignee = Regex.Replace(model.Consignee, "\\.\\s{1,}", ".");
+
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\,\\s{1,}", ",");
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\s{1,}\\,", ",");
+ model.NotifyParty = Regex.Replace(model.NotifyParty, "\\.\\s{1,}", ".");
+ */
+
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.CBM))
+ {
+ //替换掉空格
+ if (Regex.IsMatch(resultDto.data.DraftDetails.CBM, "[0-9]+(\\.[0-9]+){0,}"))
+ model.CBM = decimal.Parse(Regex.Match(resultDto.data.DraftDetails.CBM, "[0-9]+(\\.[0-9]+){0,}").Value);
+ }
+
+ if (!string.IsNullOrWhiteSpace(resultDto.data.DraftDetails.Marks))
+ {
+ //如果唛头里面有N/M就只取这个值,其他的自动忽略掉
+ if (Regex.IsMatch(resultDto.data.DraftDetails.Marks, "\\bN\\/M\\b"))
+ model.Marks = Regex.Match(resultDto.data.DraftDetails.Marks, "\\bN\\/M\\b").Value;
+ }
+
+ //这里判断了温度、湿度、通风是否有值,没有从货描获取
+ if (!string.IsNullOrWhiteSpace(model.GoodsDescription))
+ {
+ if (string.IsNullOrWhiteSpace(model.TempSet))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bTEMP(ERATURE)?\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bTEMP(ERATURE)?\\b(\\:|\\;|\\s)\\s?.*?\\s"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "((?<=\\bTEMP\\b(\\:|\\;|\\s))\\s?.*?\\s)|((?<=\\bTEMPERATURE\\b(\\:|\\;|\\s))\\s?.*?\\s)").Value?.Trim();
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.TempSet = currStr.Replace("#", "");
+ }
+ else if (Regex.IsMatch(model.GoodsDescription, "\\bTEMP(ERATURE)?\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "((?<=\\bTEMP\\b(\\:|\\;|\\s))\\s?.*)|((?<=\\bTEMPERATURE\\b(\\:|\\;|\\s))\\s?.*)").Value?.Trim();
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.TempSet = currStr.Replace("#", "");
+ }
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(model.Reeferf))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bVENT(ILATION)?\\b(\\:|\\:|\\;|\\s)"))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bVENT(ILATION)?\\b(\\:|\\;|\\s)\\s?.*?\\s"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription,
+ "((?<=\\bVENT\\b\\s(\\:|\\;))\\s.*?\\s)|((?<=\\bVENT\\b(\\:|\\;))\\s.*?\\s)|((?<=\\bVENT\\b(\\:|\\;|\\s))\\s?.*?\\s)|((?<=\\bVENTILATION\\b(\\:|\\;|\\s))\\s?.*?\\s)|((?<=\\bVENTILATION\\b(\\:|\\;|\\s))\\s?.*?\\s)")
+ .Value.Replace(":", "").Replace(";", "");
+
+ //这里不确定为啥验证能过,但是取不到数据,这里又补充了提取
+ if (string.IsNullOrWhiteSpace(currStr))
+ currStr = Regex.Match(model.GoodsDescription, "(?<=\\bVENT(ILATION)?\\b(\\:|\\;|\\s))\\s?.*").Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Reeferf = currStr.Replace("#", "");
+ }
+ else if (Regex.IsMatch(model.GoodsDescription, "\\bVENT(ILATION)?\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "((?<=\\bVENT\\b\\s(\\:|\\;))\\s.*)|((?<=\\bVENT\\b(\\:|\\;))\\s.*)|((?<=\\bVENT\\b(\\:|\\;|\\s))\\s?.*)|((?<=\\bVENTILATION\\b\\s(\\:|\\;|\\s))\\s?.*)|((?<=\\bVENTILATION\\b(\\:|\\;|\\s))\\s?.*)")
+ .Value.Replace(":", "").Replace(";", "");
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Reeferf = currStr.Replace("#", "");
+ }
+ }
+ }
+
+ if (string.IsNullOrWhiteSpace(model.Humidity))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bHUMI\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ if (Regex.IsMatch(model.GoodsDescription, "\\bHUMI\\b(\\:|\\;|\\s)\\s?.*?\\\\\\\\n"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "(?<=\\bHUMI\\b(\\:|\\;|\\s))\\s?.*?(?=\\\\\\\\n)").Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Humidity = currStr.Replace("#", "");
+ }
+ else if (Regex.IsMatch(model.GoodsDescription, "\\bHUMI\\b(\\:|\\;|\\s)\\s?.*?\\s"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "(?<=\\bHUMI\\b(\\:|\\;|\\s))\\s?.*?\\s").Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Humidity = currStr.Replace("#", "");
+ }
+ else if (Regex.IsMatch(model.GoodsDescription, "\\bHUMI\\b(\\:|\\;|\\s)\\s?.*"))
+ {
+ var currStr = Regex.Match(model.GoodsDescription, "(?<=\\bHUMI\\b(\\:|\\;|\\s))\\s?.*").Value;
+
+ if (!string.IsNullOrWhiteSpace(currStr))
+ model.Humidity = currStr.Replace("#", "");
+ }
+ }
+ }
+ }
+
+ model.ContaList = new List();
+
+ if (resultDto.data.DraftDetails.ContainerDetails != null &&
+ resultDto.data.DraftDetails.ContainerDetails.Count > 0)
+ {
+ int startNum = 1;
+ resultDto.data.DraftDetails.ContainerDetails.ForEach(d => {
+ var conta = new CompareDraftDataContaInfo();
+
+ if (modelName == "CNC")
+ {
+ if (!string.IsNullOrWhiteSpace(d.ContaNo))
+ {
+ conta.ContaNo = d.ContaNo.Trim().ToUpper();
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.ContaType))
+ {
+ conta.ContaType = d.ContaType.Trim().ToUpper();
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.SealNo))
+ {
+ if (Regex.IsMatch(d.SealNo, "\\bSEAL\\b"))
+ {
+ conta.SealNo = Regex.Replace(d.SealNo, "\\bSEAL\\b", "").Trim().ToUpper();
+ }
+ }
+ }
+ else if (modelName == "CSL")
+ {
+ if (contaBaskDict.Any(dc => dc.Key == startNum))
+ {
+ conta.KindPKGs = contaBaskDict[startNum].Item2;
+ conta.ContaType = contaBaskDict[startNum].Item3;
+
+ if (contaBaskDict[startNum].Item1.HasValue)
+ conta.PKGs = contaBaskDict[startNum].Item1.Value;
+
+ }
+ else
+ {
+ if (!string.IsNullOrWhiteSpace(d.ContaType))
+ {
+ conta.ContaType = d.ContaType.Trim().ToUpper();
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.ContaNo))
+ {
+ conta.ContaNo = d.ContaNo.Trim().ToUpper();
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.SealNo))
+ {
+ conta.SealNo = d.SealNo.Trim().ToUpper();
+ }
+
+ if (contaKgsDict.Any(dc => dc.Key == startNum))
+ {
+ conta.KGs = contaKgsDict[startNum].Item1;
+ conta.CBM = contaKgsDict[startNum].Item2;
+ }
+ }
+ else if (modelName == "EVG")
+ {
+ if (!string.IsNullOrWhiteSpace(d.ContaNo))
+ {
+ conta.ContaNo = d.ContaNo.Trim().ToUpper();
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.SealNo))
+ {
+ conta.SealNo = d.SealNo.Trim().ToUpper();
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.ContaType) && Regex.IsMatch(d.ContaType, "[0-9]{1}[a-zA-Z]{2}"))
+ {
+ conta.ContaType = $"{Regex.Match(d.ContaType, "[0-9]{1}").Value}0{Regex.Match(d.ContaType, "[a-zA-Z]{2}").Value}";
+ }
+
+ //29 00 BAGS 29000.000 KGS (REEFER HI-CUBE)
+ if (!string.IsNullOrWhiteSpace(d.Other))
+ {
+ string kgs = Regex.Match(d.Other, "[0-9]+(\\.[0-9]+){0,}?\\s?(KGS)").Value;
+
+ if (Regex.IsMatch(d.Other, "[0-9]+(\\.[0-9]+){0,}?\\s?(KGS)"))
+ {
+ conta.KGs = decimal.Parse(Regex.Match(kgs, "[0-9]+(\\.[0-9]+){0,}").Value);
+ }
+
+ string s = Regex.Match(d.Other, $"(\\s|\\w)+(?={kgs})").Value;
+ string kindpkg = Regex.Match(s, newCheck).Value;
+
+ s = Regex.Replace(s.Replace(kindpkg, ""), "\\s+", "");
+
+ conta.PKGs = (int)decimal.Parse(Regex.Match(s, "[0-9]+(\\.[0-9]+){0,}").Value);
+ conta.KindPKGs = kindpkg;
+ }
+ }
+ else if (modelName == "MCC")
+ {
+ if (!string.IsNullOrWhiteSpace(d.ContaNo))
+ {
+ conta.ContaNo = d.ContaNo.Trim().ToUpper();
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.ContaType))
+ {
+ conta.ContaType = d.ContaType.Trim().ToUpper();
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.SealNo))
+ {
+ conta.SealNo = d.SealNo.Trim().ToUpper();
+ }
+
+ string otherTxt = d.Other;
+
+ //if()
+ }
+ else if (modelName == "PIL")
+ {
+ if (!string.IsNullOrWhiteSpace(d.ContaNo))
+ {
+ conta.ContaNo = d.ContaNo.Trim().ToUpper();
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.SealNo))
+ {
+ conta.SealNo = d.SealNo.Trim().ToUpper();
+ }
+
+ if (!string.IsNullOrWhiteSpace(d.ContaType))
+ {
+ conta.ContaType = d.ContaType.Trim().ToUpper();
+ }
+
+ //2148 BAGS 29000 55 (CY/CY)
+ if (!string.IsNullOrWhiteSpace(d.Other))
+ {
+ string otherTxt = d.Other;
+
+ string pics = Regex.Match(otherTxt, "[0-9]+(\\.[0-9]+){0,}?\\s").Value?.Trim();
+
+ if (!string.IsNullOrWhiteSpace(pics))
+ {
+ conta.PKGs = (int)decimal.Parse(pics);
+
+ otherTxt = Regex.Replace(otherTxt, "^([0-9]+(\\.[0-9]+){0,}?)", " ")?.Trim();
+ }
+
+ string kindpkg = Regex.Match(otherTxt, newCheck).Value;
+
+ if (!string.IsNullOrWhiteSpace(kindpkg))
+ {
+ conta.KindPKGs = kindpkg;
+
+ otherTxt = Regex.Replace(otherTxt, newCheck, " ")?.Trim();
+ }
+
+ string kgs = Regex.Match(otherTxt, "^([0-9]+(\\.[0-9]+){0,}?)").Value;
+
+ if (!string.IsNullOrWhiteSpace(kgs))
+ {
+ conta.KGs = decimal.Parse(kgs);
+
+ otherTxt = Regex.Replace(otherTxt, "^([0-9]+(\\.[0-9]+){0,}?)", " ")?.Trim();
+ }
+
+ string cbm = Regex.Match(otherTxt, "^([0-9]+(\\.[0-9]+){0,}?)").Value;
+
+ if (!string.IsNullOrWhiteSpace(cbm))
+ {
+ conta.CBM = decimal.Parse(cbm);
+
+ otherTxt = Regex.Replace(otherTxt, "^([0-9]+(\\.[0-9]+){0,}?)", " ")?.Trim();
+ }
+ }
+ }
+ else
+ {
+ if (((string.IsNullOrWhiteSpace(d.ContaNo) || string.IsNullOrWhiteSpace(d.ContaType)
+ || string.IsNullOrWhiteSpace(d.SealNo))) && !string.IsNullOrWhiteSpace(d.Other))
+ {
+ conta.ContaNo = Regex.Match(d.Other, "(?<=(\\-FCL)).*?(?=\\/)").Value?.Trim();
+ conta.ContaType = Regex.Match(d.Other, "(?<=\\/)[0-9a-zA-Z]{4}").Value?.Trim();
+ conta.SealNo = Regex.Match(d.Other, "(?<=\\/[0-9a-zA-Z]{4})\\s[0-9a-zA-Z]{5,}").Value?.Trim();
+ }
+ }
+
+ if (resultDto.data.DraftDetails.ContainerDetails.Count == 1)
+ {
+ if (conta.PKGs == 0)
+ conta.PKGs = model.PKGs;
+
+ if (!conta.KGs.HasValue)
+ conta.KGs = model.KGs;
+
+ if (string.IsNullOrWhiteSpace(conta.KindPKGs))
+ conta.KindPKGs = model.KindPKGs;
+
+ if (!conta.CBM.HasValue)
+ conta.CBM = model.CBM;
+ }
+
+ model.ContaList.Add(conta);
+
+ startNum++;
+ });
+ }
+
+
+ if (modelName == "EVG")
+ {
+ //如果集装箱列表为空,需要重新从大文本提取
+ if (model.ContaList == null || (model.ContaList != null && model.ContaList.Count == 0))
+ {
+ var orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ var ctnInfo = Regex.Match(orgText, "(?<=\\\\n)(\\s|\\w)+\\/\\w+\\/(\\s|\\w)+").Value;
+
+ if (!string.IsNullOrWhiteSpace(ctnInfo))
+ {
+ if (Regex.IsMatch(ctnInfo, "((^[a-zA-Z]{1})|(\\s+\\b[a-zA-Z]{1}\\b))\\s+\\w+"))
+ {
+ ctnInfo = Regex.Replace(ctnInfo, "((^[a-zA-Z]{1})|(\\s+\\b[a-zA-Z]{1}\\b))\\s+\\w+", m => Regex.Replace(m.Value, "(?<=(^[a-zA-Z]{1}))\\s|(?<=\\b[a-zA-Z]{1}\\b)\\s", ""));
+ }
+ }
+
+ //\n(22) TOTAL NUMBER OF 1 X 4RH
+ var contaTypeInfo = Regex.Match(orgText, "\\(22\\)\\sTOTAL\\sNUMBER\\sOF\\b(\\s|\\w)+").Value;
+
+ int contaTotal = 0;
+ string contaType = string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(contaTypeInfo))
+ {
+ var currType = Regex.Match(contaTypeInfo, "(?<=\\(22\\)\\sTOTAL\\sNUMBER\\sOF\\b)(\\s|\\w)+").Value;
+
+ if (!string.IsNullOrWhiteSpace(currType))
+ {
+ currType = Regex.Replace(currType, "\\s+", "");
+ contaTotal = int.Parse(Regex.Match(currType, "[0-9]+(?=X)").Value);
+
+ var name = Regex.Match(currType, "(?<=X)[0-9]{1,2}[a-zA-Z]{2}").Value;
+
+ if (Regex.IsMatch(name, "[0-9]{1}[a-zA-Z]{2}"))
+ {
+ contaType = $"{Regex.Match(name, "[0-9]{1}").Value}0{Regex.Match(name, "[a-zA-Z]{2}").Value}";
+ }
+ }
+ }
+
+ var currArg = ctnInfo.Split(new char[] { '/' });
+
+ int pics = 0;
+ string kindpkgs = string.Empty;
+
+ if (currArg.Length > 2)
+ {
+ pics = (int)decimal.Parse(Regex.Match(currArg[2], "[0-9]+(\\.[0-9]+){0,}").Value);
+
+ kindpkgs = Regex.Match(currArg[2], newCheck).Value.Trim().ToUpper();
+ }
+
+ CompareDraftDataContaInfo contaInfo = new CompareDraftDataContaInfo
+ {
+ ContaNo = currArg.Length > 0 ? currArg[0]?.Trim() : "",
+ SealNo = currArg.Length > 1 ? currArg[1]?.Trim() : "",
+ PKGs = pics,
+ KindPKGs = kindpkgs,
+ ContaType = contaType,
+ KGs = model.KGs,
+ CBM = model.CBM,
+ };
+
+ model.ContaList.Add(contaInfo);
+ }
+
+ }
+ else if (modelName == "CNC")
+ {
+ string orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ //箱列表从大文本重新取
+ var ctnRegexCols = Regex.Matches(orgText,
+ "\\\\\\\\n?\\w+\\s+([0-9]+\\s?(x|X|\\*)\\s?[0-9]{1,}[a-zA-Z]{2})\\s?[0-9]+(\\.[0-9]+){0,}\\s?[a-zA-Z]+(\\((s|S)\\))?\\s?[0-9]+(\\.[0-9]+){0,}\\s?[0-9]+(\\.[0-9]+){0,}\\s?[0-9]+(\\.[0-9]+){0,}\\\\\\\\n?(SEAL)\\s?\\w+");
+
+ List matchList = ctnRegexCols.Select(a => a.Value).ToList();
+
+ //这里处理一下箱明细被分页断开的问题
+ var checkCtnRegexCol = Regex.Match(orgText,
+ "\\\\\\\\n?\\w+\\s+([0-9]+\\s?(x|X|\\*)\\s?[0-9]{1,}[a-zA-Z]{2})\\s?[0-9]+(\\.[0-9]+){0,}\\s?[a-zA-Z]+(\\((s|S)\\))?\\s?[0-9]+(\\.[0-9]+){0,}\\s?[0-9]+(\\.[0-9]+){0,}\\s?[0-9]+(\\.[0-9]+){0,}\\\\\\\\n?(Continued\\s+on\\s+Next\\s+Sheet)").Value;
+
+ if (!string.IsNullOrWhiteSpace(checkCtnRegexCol))
+ {
+ checkCtnRegexCol = Regex.Replace(checkCtnRegexCol, "\\\\\\\\n?(Continued\\s+on\\s+Next\\s+Sheet)", "");
+
+
+ Match checkMatch = Regex.Match(orgText, "(?<=Continued on Next Sheet).*(?=SEAL\\s\\w+)");
+ //尝试提取分页的铅封信息
+ string s = checkMatch.Value;
+
+
+ if (!string.IsNullOrWhiteSpace(s))
+ {
+ s = Regex.Matches(s, "SEAL\\s+\\w+").FirstOrDefault()?.Value;
+
+ //如果未取到有效值,重新提取
+ if (string.IsNullOrWhiteSpace(s))
+ {
+ string tempS = orgText.Substring(checkMatch.Index + checkMatch.Length);
+ s = Regex.Matches(tempS, "SEAL\\s+\\w+").FirstOrDefault()?.Value;
+ }
+ }
+
+ matchList.Add($"{checkCtnRegexCol}\\\\n{s}");
+
+ }
+ #region 箱明细
+ //集装箱明细原文格式 \\nSZLU9204029 1 x 40RH 1320 CARTONS 24156.000 4700 50.000\\nSEAL C9731053
+ if (matchList.Count > 0)
+ {
+ model.ContaList = new List();
+
+ foreach (var match in matchList)
+ {
+ CompareDraftDataContaInfo ctn = new CompareDraftDataContaInfo();
+ string s = match;
+
+ s = Regex.Replace(s, "\\\\\\\\n", " ").Trim();
+
+ ctn.ContaNo = Regex.Match(s, "\\w+(?=\\s)").Value?.Trim();
+
+ //处理完去掉箱号信息
+ s = Regex.Replace(s, ctn.ContaNo, "")?.Trim();
+
+ string ctnType = Regex.Match(s, "[0-9]+\\s?(x|X|\\*)\\s?[0-9]{1,}[a-zA-Z]{2}").Value;
+
+ if (!string.IsNullOrWhiteSpace(ctnType))
+ {
+ string tempCtnType = Regex.Match(ctnType, "(?<=(x|X|\\*))\\s?[0-9]{1,}[a-zA-Z]{2}").Value?.Trim();
+
+ if (Regex.IsMatch(tempCtnType, "[0-9]{1}[a-zA-Z]{2}"))
+ {
+ ctn.ContaType = $"{Regex.Match(tempCtnType, "[0-9]{1}").Value}0{Regex.Match(tempCtnType, "[a-zA-Z]{2}").Value}";
+ }
+ else
+ {
+ ctn.ContaType = tempCtnType;
+ }
+
+ //CNC和CMA 会有箱型代码40RA/40RK 统一认为是40RH
+ if (ctn.ContaType == "40RA" || ctn.ContaType == "40RK")
+ {
+ ctn.ContaType = "40RH";
+ }
+
+ //处理完去掉箱型信息
+ s = Regex.Replace(s, ctnType, "")?.Trim();
+ }
+
+ //件数
+ string pics = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})").Value;
+
+ if (!string.IsNullOrWhiteSpace(pics))
+ {
+ ctn.PKGs = (int)decimal.Parse(pics);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+
+ //包装
+ string pkg = Regex.Match(s, $"^({newCheck})(\\((s|S)\\))?").Value;
+
+ if (!string.IsNullOrWhiteSpace(pkg))
+ {
+ pkg = Regex.Replace(pkg, "(\\((s|S)\\))", "S");
+
+ ctn.KindPKGs = pkg;
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, $"^({newCheck})(\\((s|S)\\))?", "")?.Trim();
+ }
+
+ //重量
+ string weight = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})").Value;
+
+ if (!string.IsNullOrWhiteSpace(weight))
+ {
+ ctn.KGs = decimal.Parse(weight);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+ //箱重
+ string tareWt = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})").Value;
+
+ if (!string.IsNullOrWhiteSpace(tareWt))
+ {
+ ctn.TareWeight = decimal.Parse(tareWt);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+ //CBM
+ string cbm = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})").Value;
+
+ if (!string.IsNullOrWhiteSpace(cbm))
+ {
+ ctn.CBM = decimal.Parse(cbm);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+ //铅封号
+ string seal = Regex.Match(s, "(?<=(SEAL)).*").Value;
+
+ if (!string.IsNullOrWhiteSpace(seal))
+ {
+ ctn.SealNo = seal.Trim();
+ }
+
+ model.ContaList.Add(ctn);
+ }
+ }
+ #endregion
+
+
+
+ if (model.ContaList.Count > 0)
+ {
+ model.PKGs = model.ContaList.Sum(a => a.PKGs);
+ model.KGs = model.ContaList.Sum(a => a.KGs.HasValue ? a.KGs.Value : 0);
+ model.CBM = model.ContaList.Sum(a => a.CBM.HasValue ? a.CBM.Value : 0);
+ }
+ }
+ else if (modelName == "ONE")
+ {
+ string orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ //箱列表从大文本重新取
+ var ctnRegexCols = Regex.Matches(orgText,
+ "\\\\\\\\n?\\w+(\\s+|\\s?)\\/(\\s+|\\s?)\\w+(\\s+|\\s?)\\/(\\s+|\\s?)[0-9]+(\\s+|\\s?)\\w+(\\s+|\\s?)\\/(\\s+|\\s?)\\w+(\\s+|\\s?)\\/(\\s+|\\s?)\\w+(\\s+|\\s?)\\/(\\s+|\\s?)\\w+(\\s+|\\s?)\\/(\\s+|\\s?)[0-9]+(\\.[0-9]+){0,}(KGS)?\\/(\\s+|\\s?)[0-9]+(\\.[0-9]+){0,}(M3)?");
+
+ #region 箱明细
+ //集装箱明细原文格式 \\nSZLU9204029 1 x 40RH 1320 CARTONS 24156.000 4700 50.000\\nSEAL C9731053
+ if (ctnRegexCols.Count > 0)
+ {
+ model.ContaList = new List();
+
+ foreach (Match match in ctnRegexCols)
+ {
+ CompareDraftDataContaInfo ctn = new CompareDraftDataContaInfo();
+ string s = match.Value;
+
+ s = Regex.Replace(s, "\\\\\\\\n", " ").Trim();
+
+ string ctnNo = Regex.Match(s, "(\\w|\\s)+\\/").Value;
+ ctn.ContaNo = ctnNo.Replace("/", "").Trim();
+
+ //处理完去掉箱号信息
+ s = Regex.Replace(s, ctnNo, "")?.Trim();
+
+ //铅封号
+ string seal = Regex.Match(s, "(\\w|\\s)+\\/").Value;
+
+ if (!string.IsNullOrWhiteSpace(seal))
+ {
+ ctn.SealNo = seal.Replace("/", "").Trim();
+
+ s = Regex.Replace(s, seal, "")?.Trim();
+ }
+
+ //件数
+ string picsAndPackage = Regex.Match(s, "(\\w|\\s)+\\/").Value;
+
+ if (!string.IsNullOrWhiteSpace(picsAndPackage))
+ {
+ string pics = Regex.Match(picsAndPackage, "([0-9]+(\\.[0-9]+){0,})").Value;
+ ctn.PKGs = (int)decimal.Parse(pics);
+
+ string pkg = Regex.Match(picsAndPackage, $"({newCheck})").Value;
+
+ if (!string.IsNullOrWhiteSpace(pkg))
+ {
+ ctn.KindPKGs = pkg;
+ }
+ //处理完去掉件数信息
+ s = Regex.Replace(s, picsAndPackage, "")?.Trim();
+ }
+
+ //连续去2个去掉 FCL /
+ s = Regex.Replace(s, "^(\\w|\\s)+\\/", "");
+ //去掉 FCL /
+ s = Regex.Replace(s, "^(\\w|\\s)+\\/", "");
+
+ string ctnType = Regex.Match(s, "\\s?[0-9]{2}[a-zA-Z]{2}\\s?\\/").Value;
+
+ if (!string.IsNullOrWhiteSpace(ctnType))
+ {
+ ctn.ContaType = Regex.Match(s, "[0-9]{2}[a-zA-Z]{2}").Value.Trim();
+
+ if (ctn.ContaType == "40RQ")
+ {
+ ctn.ContaType = "40RH";
+ }
+
+ //处理完去掉箱型信息
+ s = Regex.Replace(s, ctnType, "")?.Trim();
+ }
+
+ //重量
+ string weight = Regex.Match(s, "\\s?([0-9]+(\\.[0-9]+){0,})\\s?(KGS)?\\/").Value;
+
+ if (!string.IsNullOrWhiteSpace(weight))
+ {
+ ctn.KGs = decimal.Parse(Regex.Match(weight, "([0-9]+(\\.[0-9]+){0,})").Value);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "\\s?([0-9]+(\\.[0-9]+){0,})\\s?(KGS)?\\/", "")?.Trim();
+ }
+
+ //CBM
+ string cbm = Regex.Match(s, "\\s?([0-9]+(\\.[0-9]+){0,})\\s?(M3)?").Value;
+
+ if (!string.IsNullOrWhiteSpace(cbm))
+ {
+ ctn.CBM = decimal.Parse(Regex.Match(cbm, "([0-9]+(\\.[0-9]+){0,})").Value);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "\\s?([0-9]+(\\.[0-9]+){0,})\\s?(M3)?", "")?.Trim();
+ }
+
+ model.ContaList.Add(ctn);
+ }
+ }
+ #endregion
+
+ if (model.ContaList.Count > 0)
+ {
+ model.PKGs = model.ContaList.Sum(a => a.PKGs);
+ model.KGs = model.ContaList.Sum(a => a.KGs.HasValue ? a.KGs.Value : 0);
+ model.CBM = model.ContaList.Sum(a => a.CBM.HasValue ? a.CBM.Value : 0);
+ }
+ }
+ else if (modelName == "PIL")
+ {
+ string orgText = Regex.Replace(resultDto.data.DraftDetails.OriginText?.Trim(), "\\n", "\\\\n");
+
+ //箱列表从大文本重新取 FBIU5330174 CQ0227891 40RH 2148 BAGS 29000 55
+ var ctnRegexCols = Regex.Matches(orgText,
+ "\\\\\\\\n?\\w+\\s+\\w+\\s+[0-9]{2}[a-zA-Z]{2}\\s+[0-9]+(\\.[0-9]+){0,}\\s+\\w+\\s+[0-9]+(\\.[0-9]+){0,}\\s+[0-9]+(\\.[0-9]+){0,}");
+
+ #region 箱明细
+ //集装箱明细原文格式 \\nFBIU5330174 CQ0227891 40RH 2148 BAGS 29000 55
+ if (ctnRegexCols.Count > 0)
+ {
+ model.ContaList = new List();
+
+ foreach (Match match in ctnRegexCols)
+ {
+ CompareDraftDataContaInfo ctn = new CompareDraftDataContaInfo();
+ string s = match.Value;
+
+ s = Regex.Replace(s, "\\\\\\\\n", " ").Trim();
+
+ string ctnNo = Regex.Match(s, "\\w+\\s+").Value;
+ ctn.ContaNo = ctnNo.Trim();
+
+ //处理完去掉箱号信息
+ s = Regex.Replace(s, ctnNo, "")?.Trim();
+
+ //铅封号
+ string seal = Regex.Match(s, "\\w+\\s+").Value;
+
+ if (!string.IsNullOrWhiteSpace(seal))
+ {
+ ctn.SealNo = seal.Trim();
+
+ s = Regex.Replace(s, seal, "")?.Trim();
+ }
+
+ string ctnType = Regex.Match(s, "[0-9]{2}[a-zA-Z]{2}\\s+").Value;
+
+ if (!string.IsNullOrWhiteSpace(ctnType))
+ {
+ ctn.ContaType = Regex.Match(ctnType, "[0-9]{2}[a-zA-Z]{2}").Value.Trim();
+
+ //处理完去掉箱型信息
+ s = Regex.Replace(s, ctnType, "")?.Trim();
+ }
+
+ //件数
+ string pics = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})\\s+").Value;
+
+ if (!string.IsNullOrWhiteSpace(pics))
+ {
+ ctn.PKGs = (int)decimal.Parse(Regex.Match(pics, "([0-9]+(\\.[0-9]+){0,})").Value.Trim());
+
+ //处理完去掉箱型信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})\\s+", "")?.Trim();
+ }
+
+ //包装
+ string pkgs = Regex.Match(s, $"({newCheck})").Value;
+
+ if (!string.IsNullOrWhiteSpace(pkgs))
+ {
+ ctn.KindPKGs = pkgs;
+ //处理完去掉件数信息
+ s = Regex.Replace(s, $"({newCheck})", "")?.Trim();
+ }
+
+ //重量
+ string weight = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})\\s+").Value;
+
+ if (!string.IsNullOrWhiteSpace(weight))
+ {
+ ctn.KGs = decimal.Parse(Regex.Match(weight, "([0-9]+(\\.[0-9]+){0,})").Value);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+ //CBM
+ string cbm = Regex.Match(s, "([0-9]+(\\.[0-9]+){0,})").Value;
+
+ if (!string.IsNullOrWhiteSpace(cbm))
+ {
+ ctn.CBM = decimal.Parse(Regex.Match(cbm, "([0-9]+(\\.[0-9]+){0,})").Value);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+ model.ContaList.Add(ctn);
+ }
+ }
+ #endregion
+
+ if (model.ContaList.Count > 0)
+ {
+ model.PKGs = model.ContaList.Sum(a => a.PKGs);
+ model.KGs = model.ContaList.Sum(a => a.KGs.HasValue ? a.KGs.Value : 0);
+ model.CBM = model.ContaList.Sum(a => a.CBM.HasValue ? a.CBM.Value : 0);
+ }
+ }
+ else if (modelName == "MSK")
+ {
+ string ctnRegPattern = "\\w+\\s+\\w+(-)\\w+\\s+[0-9]{2}\\s+\\w+\\s+[0-9]{1}'?[0-9]{1}\\s+[0-9]+\\s+\\w+\\s+[0-9]+(\\.[0-9]+){0,}\\s+KGS+\\s+[0-9]+(\\.[0-9]+){0,}\\s+CBM";
+
+ var ctnRegexCols = Regex.Matches(model.GoodsDescription, ctnRegPattern);
+
+ #region 箱明细
+ //集装箱明细原文格式 \\nMNBU4310137 ML-CN0231567 40 REEF 9'6 1870 CARTONS 20570.000 KGS 50.0000 CBM
+ if (ctnRegexCols.Count > 0)
+ {
+ model.ContaList = new List();
+
+ foreach (Match match in ctnRegexCols)
+ {
+ CompareDraftDataContaInfo ctn = new CompareDraftDataContaInfo();
+ string s = match.Value;
+
+ s = Regex.Replace(s, "\\\\\\\\n", " ").Trim();
+
+ string ctnNo = Regex.Match(s, "\\w+\\s+").Value;
+ ctn.ContaNo = ctnNo.Trim();
+
+ //处理完去掉箱号信息
+ s = Regex.Replace(s, ctnNo, "")?.Trim();
+
+ //铅封号
+ string seal = Regex.Match(s, "\\w+(-)\\w+\\s").Value;
+
+ if (!string.IsNullOrWhiteSpace(seal))
+ {
+ ctn.SealNo = seal.Trim();
+
+ s = Regex.Replace(s, seal, "")?.Trim();
+ }
+
+ string ctnType = Regex.Match(s, "[0-9]{2}\\s+\\w+\\s+[0-9]{1}'?[0-9]{1}\\s").Value;
+
+ if (!string.IsNullOrWhiteSpace(ctnType))
+ {
+ if (Regex.Match(ctnType, "^[0-9]{2}").Value == "40" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "REEF 9'6")
+ {
+ ctn.ContaType = "40RH";
+ }
+ else if (Regex.Match(ctnType, "^[0-9]{2}").Value == "40" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "DRY 8'6")
+ {
+ ctn.ContaType = "40GP";
+ }
+ else if (Regex.Match(ctnType, "^[0-9]{2}").Value == "40" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "DRY 9'6")
+ {
+ ctn.ContaType = "40HC";
+ }
+ else if (Regex.Match(ctnType, "^[0-9]{2}").Value == "40" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "OPEN 8'6")
+ {
+ ctn.ContaType = "40OT";
+ }
+ else if (Regex.Match(ctnType, "^[0-9]{2}").Value == "40" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "OPEN 9'6")
+ {
+ ctn.ContaType = "40OH";
+ }
+ else if (Regex.Match(ctnType, "^[0-9]{2}").Value == "40" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "REEF 9'6")
+ {
+ ctn.ContaType = "40RF";
+ }
+ else if (Regex.Match(ctnType, "^[0-9]{2}").Value == "40" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "FLAT 9'6")
+ {
+ ctn.ContaType = "40FR";
+ }
+ else if (Regex.Match(ctnType, "^[0-9]{2}").Value == "20" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "DRY 8'6")
+ {
+ //20 DRY 8'6
+ ctn.ContaType = "20GP";
+ }
+ else if (Regex.Match(ctnType, "^[0-9]{2}").Value == "20" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "OPEN 8'6")
+ {
+ //20 OPEN 8'6
+ ctn.ContaType = "20OT";
+ }
+ else if (Regex.Match(ctnType, "^[0-9]{2}").Value == "20" && Regex.Match(ctnType, "\\w+\\s+[0-9]{1}'?[0-9]{1}").Value == "REEF 8'6")
+ {
+ //20 DRY 8'6
+ ctn.ContaType = "20RF";
+ }
+
+ //处理完去掉箱型信息
+ s = Regex.Replace(s, ctnType, "")?.Trim();
+ }
+
+ //件数
+ string pics = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})\\s+").Value;
+
+ if (!string.IsNullOrWhiteSpace(pics))
+ {
+ ctn.PKGs = (int)decimal.Parse(Regex.Match(pics, "([0-9]+(\\.[0-9]+){0,})").Value.Trim());
+
+ //处理完去掉箱型信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})\\s+", "")?.Trim();
+ }
+
+ //包装
+ string pkgs = Regex.Match(s, $"({newCheck})").Value;
+
+ if (!string.IsNullOrWhiteSpace(pkgs))
+ {
+ ctn.KindPKGs = pkgs;
+ //处理完去掉件数信息
+ s = Regex.Replace(s, $"({newCheck})", "")?.Trim();
+ }
+
+ //重量
+ string weight = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})\\s+").Value;
+
+ if (!string.IsNullOrWhiteSpace(weight))
+ {
+ ctn.KGs = decimal.Parse(Regex.Match(weight, "([0-9]+(\\.[0-9]+){0,})").Value);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+ //CBM
+ string cbm = Regex.Match(s, "([0-9]+(\\.[0-9]+){0,})").Value;
+
+ if (!string.IsNullOrWhiteSpace(cbm))
+ {
+ ctn.CBM = decimal.Parse(Regex.Match(cbm, "([0-9]+(\\.[0-9]+){0,})").Value);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+ model.ContaList.Add(ctn);
+ }
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, ctnRegPattern, "")?.Trim();
+ }
+ #endregion
+
+ if (model.ContaList.Count > 0)
+ {
+ model.PKGs = model.ContaList.Sum(a => a.PKGs);
+ model.KGs = model.ContaList.Sum(a => a.KGs.HasValue ? a.KGs.Value : 0);
+ model.CBM = model.ContaList.Sum(a => a.CBM.HasValue ? a.CBM.Value : 0);
+ }
+ }
+ else if (modelName == "HPL")
+ {
+ string ctnRegPattern = "[0-9]+\\s+CONT\\.\\s+[0-9]{2}'X9'6\\\"\\s+.*?\\\\\\\\n";
+
+ var ctnRegexCols = Regex.Matches(model.GoodsDescription, ctnRegPattern)
+ .Select(a => a.Value).ToList();
+
+ var itemList = Regex.Split(model.GoodsDescription, ctnRegPattern)
+ .Where(a => a != "\\\\n").ToList();
+
+ //货描列表,单箱解析过程中提取提取货描,最后合并相同项
+ List cargoList = new List();
+
+ #region 箱明细
+ //集装箱明细原文格式 \\nMNBU4310137 ML-CN0231567 40 REEF 9'6 1870 CARTONS 20570.000 KGS 50.0000 CBM
+ if (ctnRegexCols.Count > 0)
+ {
+ model.ContaList = new List();
+
+ for (int i = 0; i < itemList.Count; i++)
+ {
+ CompareDraftDataContaInfo ctn = new CompareDraftDataContaInfo();
+
+ string s = itemList[i];
+
+ s = Regex.Replace(s, "\\\\\\\\n", " ").Trim();
+
+ string ctnNo = Regex.Match(s, "\\w+\\s?\\w+\\s+").Value;
+ ctn.ContaNo = Regex.Replace(ctnNo, "\\s+", "").Trim();
+
+ //处理完去掉箱号信息
+ s = Regex.Replace(s, ctnNo, "")?.Trim();
+
+ //件数
+ string pics = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})\\s+").Value;
+
+ if (!string.IsNullOrWhiteSpace(pics))
+ {
+ ctn.PKGs = (int)decimal.Parse(Regex.Match(pics, "([0-9]+(\\.[0-9]+){0,})").Value.Trim());
+
+ //处理完去掉箱型信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})\\s+", "")?.Trim();
+ }
+
+ //包装
+ string pkgs = Regex.Match(s, $"({newCheck})").Value;
+
+ if (!string.IsNullOrWhiteSpace(pkgs))
+ {
+ ctn.KindPKGs = pkgs;
+ //处理完去掉件数信息
+ s = Regex.Replace(s, $"({newCheck})", "")?.Trim();
+ }
+
+ //重量
+ string weight = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})\\s+").Value;
+
+ if (!string.IsNullOrWhiteSpace(weight))
+ {
+ ctn.KGs = decimal.Parse(Regex.Match(weight, "([0-9]+(\\.[0-9]+){0,})").Value);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+ //CBM
+ string cbm = Regex.Match(s, "^([0-9]+(\\.[0-9]+){0,})").Value;
+
+ if (!string.IsNullOrWhiteSpace(cbm))
+ {
+ ctn.CBM = decimal.Parse(Regex.Match(cbm, "^([0-9]+(\\.[0-9]+){0,})").Value);
+
+ //处理完去掉件数信息
+ s = Regex.Replace(s, "^([0-9]+(\\.[0-9]+){0,})", "")?.Trim();
+ }
+
+ //铅封号
+ string seal = Regex.Match(s, "(?<=KGM\\s+MTQ)\\s?\\w+?\\s").Value;
+
+ if (!string.IsNullOrWhiteSpace(seal))
+ {
+ ctn.SealNo = seal.Trim();
+
+ s = Regex.Replace(s, seal, " ")?.Trim();
+ }
+
+ string ctnType = Regex.Match(ctnRegexCols[i], "[0-9]{2}'X9'6\\\"\\s").Value;
+
+ if (!string.IsNullOrWhiteSpace(ctnType))
+ {
+ if (Regex.Match(ctnType, "[0-9]{2}'X9'6").Value == "40'X9'6")
+ {
+ ctn.ContaType = "40RH";
+ }
+ }
+
+ string goodsDesp = Regex.Match(s, "(?<=SEAL\\:).*(?=KGM\\s+MTQ)").Value;
+ string goodsDesp2 = Regex.Match(s, "(?<=KGM\\s+MTQ).*").Value;
+
+ cargoList.Add(goodsDesp + goodsDesp2);
+
+ model.ContaList.Add(ctn);
+ }
+
+ if (cargoList.Count == 1 || cargoList.Distinct().Count() == 1)
+ {
+ model.GoodsDescription = cargoList.FirstOrDefault()?.Trim();
+ }
+ else
+ {
+ model.GoodsDescription = string.Join(" ", cargoList.ToArray())?.Trim();
+ }
+
+ model.GoodsDescription = Regex.Replace(model.GoodsDescription, "\\s{2,}", " ");
+ }
+ #endregion
+
+ if (model.ContaList.Count > 0)
+ {
+ model.PKGs = model.ContaList.Sum(a => a.PKGs);
+ model.KGs = model.ContaList.Sum(a => a.KGs.HasValue ? a.KGs.Value : 0);
+ model.CBM = model.ContaList.Sum(a => a.CBM.HasValue ? a.CBM.Value : 0);
+ }
+ }
+
+ if (model.CBM.HasValue && model.CBM.Value > 0 && model.ContaList != null &&
+ model.ContaList.Any(a => !a.CBM.HasValue))
+ {
+ decimal pCBM = model.CBM.Value / model.ContaList.Count;
+
+ model.ContaList.ForEach(contaInfo =>
+ {
+ contaInfo.CBM = pCBM;
+ });
+ }
+
+ if (model.PKGs == 0 && model.ContaList != null &&
+ !model.ContaList.Any(a => a.PKGs == 0))
+ {
+ model.PKGs = model.ContaList.Sum(a => a.PKGs);
+ }
+
+ if(modelName == "MSK")
+ {
+ //重新取货描
+ if (Regex.IsMatch(attchedSheetText, "[0-9]{1,}\\s+container(s)?\\s+said\\s+to\\s+contain\\s+[0-9]+\\s+\\w+", RegexOptions.IgnoreCase))
+ {
+ var baseMatch = Regex.Match(attchedSheetText, "[0-9]{1,}\\s+container(s)?\\s+said\\s+to\\s+contain\\s+[0-9]+\\s+\\w+.*(\\r\\n)", RegexOptions.IgnoreCase);
+
+ string name1 = baseMatch.Value;
+ int startIdx = baseMatch.Index;
+
+ StringBuilder descriptionBuilder = new StringBuilder();
+
+ while (true)
+ {
+ string regex = "(?<=" + name1.RegexSymbolFormat() + ").*(\\r\\n)";
+
+ var currMatch = Regex.Matches(attchedSheetText, regex).FirstOrDefault(a => a.Index > startIdx);
+
+ var currLine = currMatch?.Value;
+
+ if (Regex.IsMatch(currLine, "\\w+\\s+\\w+(-)\\w+\\s+[0-9]{2}\\s+\\w+\\s+[0-9]{1}'?[0-9]{1}\\s+[0-9]+\\s+\\w+\\s+[0-9]+(\\.[0-9]+){0,}\\s+KGS+\\s+[0-9]+(\\.[0-9]+){0,}\\s+CBM"))
+ {
+ break;
+ }
+
+ string currLineCopy = currLine;
+
+ if (Regex.IsMatch(currLineCopy, "\\bVERIFY\\b"))
+ {
+ currLineCopy = Regex.Replace(Regex.Replace(currLineCopy, "\\bVERIFY\\b", " "), "\\s{2,}", " ");
+ }
+
+ startIdx = currMatch.Index;
+
+ if (!string.IsNullOrWhiteSpace(currLineCopy) && !Regex.IsMatch(currLineCopy, "N\\/M"))
+ {
+ descriptionBuilder.AppendLine(currLineCopy.Trim());
+ }
+
+ name1 = currLine;
+ }
+
+ model.GoodsDescription = descriptionBuilder.ToString();
+ }
+ }
+ }
+ }
+ catch
+ {
+ _logger.LogInformation("批次号{0} 清洗数据PDF解析数据异常", batchNo);
+
+ throw Oops.Oh($"清洗数据PDF解析数据异常");
+ }
+
+ return model;
+ }
+ #endregion
+
+ #region 重新格式化数据
+ ///
+ /// 重新格式化数据
+ ///
+ /// 请求字符串
+ /// 格式化字符
+ /// 返回除去格式化字符后剩余的字符串
+ [NonAction]
+ public string ReformatStr(string name, string formatStr)
+ {
+ var fmtList = formatStr.Select(a => a).ToList();
+
+ List array = new List();
+ List array2 = new List();
+
+ for (var i = 0; i < name.Length; i++)
+ {
+ bool isExists = false;
+
+ if (fmtList.Count > 0)
+ {
+ if (name[i] == fmtList.First())
+ {
+ array.Add(name[i]);
+
+ fmtList.Remove(fmtList[0]);
+
+ isExists = true;
+ }
+ }
+
+ if (!isExists)
+ array2.Add(name[i]);
+ }
+
+ return string.Join("", array2);
+ }
+ #endregion
+
+ #region 货描与收货人匹配唛头
+ ///
+ /// 货描与收货人匹配唛头
+ ///
+ /// 货描详情
+ /// 收货人详情
+ /// 返回首个匹配一致的字符
+ private string GetMarksFromCnee(string checkVal, string cnee)
+ {
+ string result = string.Empty;
+
+ try
+ {
+ TextComparer txtCompare = new TextComparer();
+
+ var list = txtCompare.CompareTexts(cnee, checkVal);
+
+ if (list.Count > 0 && list.Any(a => a.ComparisonType == ComparisonResultType.Equals))
+ result = list.FirstOrDefault(a => a.ComparisonType == ComparisonResultType.Equals).Text2;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "货描与收货人匹配唛头异常 ");
+ }
+
+ return result;
+ }
+ #endregion
+
+ #region 请求Draft的PDF解析
+ ///
+ /// 请求Draft的PDF解析
+ ///
+ /// 请求地址
+ /// 文件详情
+ /// 返回BC解析详情
+ private async Task TransmitFile(string requestUrl, dynamic fileInfo)
+ {
+ DraftPDFParseFileResultDto model = null;
+
+ try
+ {
+ var response = await requestUrl.SetContentType("multipart/form-data")
+ .SetFiles(HttpFile.Create(fileInfo.file.ToString(),
+ fileInfo.fileBytes,
+ HttpUtility.UrlEncode(fileInfo.fileName.ToString())))
+ .PostAsync();
+
+ if (response.StatusCode == System.Net.HttpStatusCode.OK)
+ {
+ var result = response.Content.ReadAsStringAsync().Result;
+
+ if (string.IsNullOrWhiteSpace(result))
+ {
+ throw Oops.Bah($"请求格式单PDF文件解析失败,未获取到有效信息");
+ }
+
+ /*
+ System.Text.Json.JsonSerializerOptions jsonOptions = new JsonSerializerOptions();
+ jsonOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
+ jsonOptions.Converters.Add(new IntegerJsonConverter());
+ jsonOptions.Converters.Add(new DecimalJsonConverter());
+ */
+
+ model = JSON.Deserialize(result);
+ }
+ }
+ catch (Exception ex)
+ {
+ //_logger.LogInformation("{name} 发送BC文件解析请求 url={url} 异常,原因={error}", nameof(TransmitFile),
+ //requestUrl, ex.Message);
+
+ throw Oops.Bah($"{nameof(TransmitFile)} {requestUrl} 请求格式单PDF文件解析异常,{ex.Message}");
+ }
+ return model;
+ }
+ #endregion
+
+ #region 变更Verify Copy BL文件内容
+ ///
+ /// 变更Verify Copy BL文件内容
+ ///
+ /// Verify Copy BL文件
+ /// Verify Copy BL请求报文
+ /// 返回修改后的文件流
+ public async Task ModifyFileAsync(IFormFile file, [FromForm] string jsonMessage)
+ {
+ return null;
+ }
+ #endregion
+ }
+}