From 881dd6a4d27b43ab7acd28830ea0c7ce933fa9ed Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Wed, 3 Apr 2024 10:35:39 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/Entity/BookingCustomerOrder.cs | 5 +++++ .../Entity/BookingSoTemplate/BookingSoTemplate.cs | 9 ++++++++- .../BookingCustomerOrderService.cs | 3 +-- .../Service/BookingCustomerOrder/Dto/Dtos.cs | 10 ++++++++++ .../BookingSoTemplate/Dto/BookingSoTemplateDto.cs | 5 +++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Myshipping.Application/Entity/BookingCustomerOrder.cs b/Myshipping.Application/Entity/BookingCustomerOrder.cs index a3a4ce1a..4bad0842 100644 --- a/Myshipping.Application/Entity/BookingCustomerOrder.cs +++ b/Myshipping.Application/Entity/BookingCustomerOrder.cs @@ -313,6 +313,11 @@ namespace Myshipping.Application.Entity /// 运输条款代码 /// public string SERVICECODE { get; set; } + + /// + /// 船公司航线代码 + /// + public string LANECODE { get; set; } } /// diff --git a/Myshipping.Application/Entity/BookingSoTemplate/BookingSoTemplate.cs b/Myshipping.Application/Entity/BookingSoTemplate/BookingSoTemplate.cs index 9ce672a5..b88dfe3f 100644 --- a/Myshipping.Application/Entity/BookingSoTemplate/BookingSoTemplate.cs +++ b/Myshipping.Application/Entity/BookingSoTemplate/BookingSoTemplate.cs @@ -58,7 +58,14 @@ namespace Myshipping.Application.Entity [SugarColumn(ColumnName = "TemplateName")] [Description("模板名称")] public string TemplateName{ get; set; } - + + /// + /// 分类 + /// + [SugarColumn(ColumnName = "Category")] + [Description("分类")] + public string Category { get; set; } + /// /// 船司ID /// diff --git a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs index c64fb54a..c8ce03e2 100644 --- a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs +++ b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs @@ -517,7 +517,6 @@ namespace Myshipping.Application } #endregion - #region 客户端操作与接口 /// /// 提交订舱 @@ -1769,6 +1768,7 @@ namespace Myshipping.Application var serviceList = await _cache.GetAllCodeService(); var frtList = await _cache.GetAllCodeFrt(); var ctnList = await _cache.GetAllCodeCtn(); + #region 校验 /* 1.必填字段:船公司,开船日期,起运港,目的港,箱型箱量,服务项目,运输条款,付费方式,件数,毛重,包装,货物标识,品名,HSCODE。 @@ -1974,7 +1974,6 @@ namespace Myshipping.Application custOrder.SERVICE = service.Name; custOrder.BLFRT = frt.EnName; - //订舱账号、密码 var jobj = new JObject(); if (!string.IsNullOrEmpty(custOrder.ExtendData)) diff --git a/Myshipping.Application/Service/BookingCustomerOrder/Dto/Dtos.cs b/Myshipping.Application/Service/BookingCustomerOrder/Dto/Dtos.cs index b4b61873..7c30878a 100644 --- a/Myshipping.Application/Service/BookingCustomerOrder/Dto/Dtos.cs +++ b/Myshipping.Application/Service/BookingCustomerOrder/Dto/Dtos.cs @@ -325,6 +325,11 @@ namespace Myshipping.Application /// 运输条款代码 /// public string SERVICECODE { get; set; } + + /// + /// 船公司航线代码 + /// + public string LANECODE { get; set; } } //保存dto @@ -934,5 +939,10 @@ namespace Myshipping.Application /// 订舱密码 /// public string BOOKINGPASSWORD { get; set; } + + /// + /// 航线代码 + /// + public string LINECODE { get; set; } } } diff --git a/Myshipping.Application/Service/BookingSoTemplate/Dto/BookingSoTemplateDto.cs b/Myshipping.Application/Service/BookingSoTemplate/Dto/BookingSoTemplateDto.cs index fa92a42f..3a0c8fa1 100644 --- a/Myshipping.Application/Service/BookingSoTemplate/Dto/BookingSoTemplateDto.cs +++ b/Myshipping.Application/Service/BookingSoTemplate/Dto/BookingSoTemplateDto.cs @@ -47,6 +47,11 @@ namespace Myshipping.Application /// public string TemplateName { get; set; } + /// + /// 分类 + /// + public string Category { get; set; } + /// /// 船司ID /// From 032a6f75f67c6edaf58989559a463e27532fbb42 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 3 Apr 2024 12:02:46 +0800 Subject: [PATCH 2/5] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9BC=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E4=BB=BB=E5=8A=A1=202=E3=80=81=E5=A2=9E=E5=8A=A0INTTR?= =?UTF-8?q?A=E7=9A=84=E8=AE=A2=E8=88=B1=E3=80=81=E6=88=AA=E5=8D=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/EDI/InttraEdiHelper.cs | 2234 +++++++++++++++++ Myshipping.Application/Enum/EDIRouteEnum.cs | 6 +- .../BookingOrder/BookingOrderService.cs | 32 + .../Service/BookingSlot/BookingSlotService.cs | 57 +- .../BookingSlot/Dto/BookingSlotMapper.cs | 30 +- .../BookingSlot/IBookingSlotService.cs | 17 + .../Dtos/EmailBCReadMessageInfo.cs | 29 + .../Dtos/ParserReaderExcuteResultDto.cs | 66 + .../TaskManagePlat/Dtos/TaskBCInfoReadDto.cs | 417 +++ .../Interface/ITaskManageBCService.cs | 7 + .../TaskManagePlat/TaskManageBCService.cs | 318 ++- Myshipping.Web.Core/applicationconfig.json | 4 +- 12 files changed, 3197 insertions(+), 20 deletions(-) create mode 100644 Myshipping.Application/EDI/InttraEdiHelper.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/EmailBCReadMessageInfo.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/ParserReaderExcuteResultDto.cs create mode 100644 Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoReadDto.cs diff --git a/Myshipping.Application/EDI/InttraEdiHelper.cs b/Myshipping.Application/EDI/InttraEdiHelper.cs new file mode 100644 index 00000000..de24c7ab --- /dev/null +++ b/Myshipping.Application/EDI/InttraEdiHelper.cs @@ -0,0 +1,2234 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.EDI +{ + /// + /// INTTRA 订舱、截单帮助类 + /// + public class InttraEdiHelper + { + public InttraEdiHelper() + { + } + + #region 基本函数 + public static string GetCarrierName(string str) + { + if (str == "MAEU") return "MAERSK LINE"; + if (str == "MCCQ") return "MCC TRANSPORT SINGAPORE"; + if (str == "ANNU") return "ANL CONTAINER LINE"; + if (str == "CMDU") return "CMA CGM"; + if (str == "CHNL") return "CNC"; + if (str == "HLCU") return "HAPAG-LLOYD"; + if (str == "SUDU") return "HAMBURG"; + if (str == "MSCU") return "MSC"; + if (str == "DAAE") return "DELMAS"; + if (str == "UASC") return "UASC"; + if (str == "COSU") return "COSCO"; + else return ""; + } + public static string GetBillNum(string str) + { + if (str == "ZERO") return "0"; + if (str == "ONE") return "1"; + if (str == "TWO") return "2"; + if (str == "THREE") return "3"; + if (str == "FOUR") return "4"; + if (str == "FIVE") return "5"; + if (str == "SIX") return "6"; + if (str == "SERVEN") return "7"; + if (str == "EIGHT") return "8"; + if (str == "NINE") return "9"; + if (str == "TEN") return "10"; + else return ""; + } + public static string GetBillNum2(string str) + { + if (str == "ZERO") return "00"; + if (str == "ONE") return "01"; + if (str == "TWO") return "02"; + if (str == "THREE") return "03"; + if (str == "FOUR") return "04"; + if (str == "FIVE") return "05"; + if (str == "SIX") return "06"; + if (str == "SERVEN") return "07"; + if (str == "EIGHT") return "08"; + if (str == "NINE") return "09"; + if (str == "TEN") return "10"; + else return ""; + } + + #region 判断中文字符 + public static bool IsChinese(char c) + { + return (int)c > 0x80; + } + public static bool StringIsChinese(string str) + { + var result = false; + for (int i = 1; i < str.Length; i++) + { + if (IsChinese(str[i])) + { + result = true; + return result; + } + } + for (int i = 0; i < str.Length; i++) + { + string stemp = str.Substring(i, 1); + int ilen = System.Text.Encoding.Default.GetByteCount(stemp); + if (ilen == 2) + { + result = true; + return result; + } + + } + + return result; + } + + #endregion + + #region 文本字段判断每行是否符合 + /// + /// edi 文本格式处理判断(例如:1行35个字符不超过5行) + /// + /// 文件类型(例如:txt、xml) + /// 要处理的数据 + /// 每行长度 + /// 主提单号 + /// 数据类型(例如:发货人内容、货描等) + /// 限制录入的行数(“0”代表不限制) + /// 限录后多出的放到货描中的数据的连接符(例如:“*”发货人内容、“**”收件人等) + /// + public static System.String formatlengthError(string fileType, string str, int length, string sMBLNO, string sType, int rowNum, string sSymbol, bool isHuoMiao) + { + string error = ""; + string Shipping = str; + if (fileType == "txt") + { + Shipping = formatEdiStr("txt", str); + } + else if (fileType == "xml") + { + Shipping = formatEdiStr("txt", str); + } + string[] argAGENT = Shipping.Split(new string[] { "\r\n" }, StringSplitOptions.None); + if (argAGENT.Length > 0) + { + if (argAGENT.Length == 1) + { + argAGENT = Shipping.Split(new string[] { "\n" }, StringSplitOptions.None); + if (argAGENT.Length > 0) + { + if (argAGENT.Length > rowNum && rowNum != 0) + { + if (isHuoMiao) + { + error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!"; + } + else + { + error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)"; + } + } + for (int j = 0; j < argAGENT.Length; j++) + { + //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35); + if (argAGENT[j].ToString().Length > length) + { + error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符"; + } + } + } + } + else + { + if (argAGENT.Length > rowNum && rowNum != 0) + { + if (isHuoMiao) + { + error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据!"; + } + else + { + error = error + "
提单号:" + sMBLNO + " " + sType + " 不允许录入超过" + rowNum + "行数据,多余信息请手动以“" + sSymbol + "”号开头放到货物描述中!(例如:“货描内容" + sSymbol + "超出部分”)"; + } + } + for (int j = 0; j < argAGENT.Length; j++) + { + //List AgentList = formatlengthStr(argAGENT[j].ToString(), 35); + if (argAGENT[j].ToString().Length > length) + { + error = error + "
提单号:" + sMBLNO + " " + sType + " 第" + (j + 1) + "行超过" + length + "个字符"; + } + } + } + } + return error; + } + #endregion + + #region 字符转义 + /// + /// 各种文本转义字符 + /// + /// 文件类型(例如:txt、xml) + /// 文本字符串 + /// + public static string formatEdiStr(string fileType, string str) + { + if (fileType == "txt") + { + return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace("'", "?'"); + } + else if (fileType == "xml") + { + return str.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("\"", """).Replace("'", "'"); + } + else if (fileType == "sitc") + { + return str.Replace("?", "??").Replace(":", "?:").Replace("'", "?'"); + } + else + { + return str; + } + } + #endregion + #region 格式化每行 + public static List formatlengthStr(string str, int length, bool formatstr = false, bool nodelsp = false) + { + str = str.Replace("\r\n", "\\"); + str = str.Replace("\n", "\\"); + str = str.Replace("\r", " "); + string[] StrList = str.Split('\\'); + var strtemp = ""; + var strnewline = ""; + var strtempnewline = ""; + char[] spstring = { ' ', ';', ',', '.', ':', '/', '(', ')', '?', '+', '-' }; + List DestList = new List(); + for (var i = 0; i <= StrList.Length - 1; i++) + { + if (StrList[i].Length <= length) + { + if (formatstr) + DestList.Add(formatEdiStr("txt", StrList[i])); + else + DestList.Add(StrList[i]); + + } + else + { + strtemp = StrList[i] + " "; + strtempnewline = ""; + strnewline = ""; + for (var j = 0; j < strtemp.Length; j++) + { + strtempnewline = strtempnewline + strtemp[j]; + if (strtemp[j] == ' ' || strtemp[j] == ':' || strtemp[j] == ',' || strtemp[j] == '.' || strtemp[j] == ':' || strtemp[j] == '/' + || strtemp[j] == '?' || strtemp[j] == ')' || strtemp[j] == '}' || strtemp[j] == '+' || strtemp[j] == '-') + { + if ((strnewline.Length + strtempnewline.Length) <= length) + strnewline = strnewline + strtempnewline; + else + { + if (formatstr) + DestList.Add(formatEdiStr("txt", strnewline)); + else + DestList.Add(strnewline); + strnewline = strtempnewline; + + } + strtempnewline = ""; + } + } + if (nodelsp) + { + if (formatstr) + DestList.Add(formatEdiStr("txt", strnewline)); + else DestList.Add(strnewline); + } + else if (strnewline.Trim() != "") + { + if (formatstr) + DestList.Add(formatEdiStr("txt", strnewline)); + else DestList.Add(strnewline); + } + } + + } + + return DestList; + } + #endregion + #endregion + + #region 检查 + public static string IsCreateINTTR(EDIBaseModel InttrEdi) + { + var error = ""; + + if (string.IsNullOrEmpty(InttrEdi.SENDCODE)) + { error = error + "
发送方代码不能为空"; } + + if (string.IsNullOrEmpty(InttrEdi.SENDNAME)) + { error = error + "
发送方名称不能为空"; } + + if (string.IsNullOrEmpty(InttrEdi.RECEIVECODE)) + { error = error + "
接收方代码不能为空"; } + + if (InttrEdi.filetype == "B") + { + if (InttrEdi.UseForWarderCode) + { + if (string.IsNullOrEmpty(InttrEdi.ForWarderCode)) + { error = error + "
货代代码不能为空"; } + + if (string.IsNullOrEmpty(InttrEdi.ForWarderName)) + { error = error + "
货代称呼不能为空"; } + } + } + + + foreach (var headData in InttrEdi.BSLIST) + { + + if (InttrEdi.filetype == "B") + { + if (InttrEdi.UseForWarderCode) + { + if (string.IsNullOrEmpty(headData.ORDERNO)) + { error = error + "
订舱编号不能为空"; } + } + } + + + if (headData.CARRIER != "YML") + { + if (string.IsNullOrEmpty(headData.OpEName)) + { error = error + "
操作的英文名不能为空"; } + + if (string.IsNullOrEmpty(headData.OpTel)) + { error = error + "
操作的电话不能为空"; } + + if (string.IsNullOrEmpty(headData.OpEmail)) + { error = error + "
操作的邮箱不能为空"; } + } + if (string.IsNullOrEmpty(headData.MBLNO)) + { error = error + "
主提单号不能为空"; } + + if (string.IsNullOrEmpty(headData.BLFRT)) + { error = error + "
提单号:" + headData.MBLNO + " 付费方式不能为空"; } + + if (string.IsNullOrEmpty(headData.SERVICE)) + { error = error + "
提单号:" + headData.MBLNO + " 运输条款不能为空"; } + + if (string.IsNullOrEmpty(headData.CONTRACTNO)) + { error = error + "
提单号:" + headData.MBLNO + " 运费协议号不能为空"; } + if (string.IsNullOrEmpty(headData.CARGOID)) + { error = error + "
提单号:" + headData.MBLNO + " 货物标识不能为空"; } + + + if (headData.CARGOID == "D" || headData.SERVICE == "DOOR-DOOR" || headData.SERVICE == "DOOR-CY" || headData.SERVICE == "CY-DOOR") + { + if (headData.CARRIER != "YML") + { + if (string.IsNullOrEmpty(headData.EDIATTN)) + { error = error + "
EDI信息联系人不能为空"; } + + if (string.IsNullOrEmpty(headData.EDIATTNTEL)) + { error = error + "
EDI信息联系人电话不能为空"; } + + if (string.IsNullOrEmpty(headData.EDIATTNEMAIL)) + { error = error + "
EDI信息联系人邮箱不能为空"; } + } + } + + + if (InttrEdi.filetype == "E") + { + if (string.IsNullOrEmpty(headData.VESSEL)) + { error = error + "
提单号:" + headData.MBLNO + " 船名不能为空"; } + + if (string.IsNullOrEmpty(headData.VOYNO)) + { error = error + "
提单号:" + headData.MBLNO + " 航次不能为空"; } + } + if (InttrEdi.filetype == "E") + { + if (headData.SIREMARK.IndexOf("PLEASE BOOK OCEAN CARRIER") > -1 || headData.SIREMARK.ToString().Trim() == "") + { + if (headData.CARRIER == "COSU") + { + error = error + "
提单号:" + headData.MBLNO + " 请在SI备注中输入:COSCO 销售的营销代码(此代码船公司会直接提供)"; + } + else + { + //if (carrier != "YML") + //error = error + "
提单号:" + bill.MBLNO + " EDI备注中不能为空"; + } + } + else + { + if (StringIsChinese(headData.SIREMARK)) + { + error = error + "
提单号:" + headData.MBLNO + " SI备注中含有中文或双字节字符"; + } + + } + } + else + { + if (headData.EDIREMARK.IndexOf("PLEASE BOOK OCEAN CARRIER") > -1 || headData.EDIREMARK.ToString().Trim() == "") + { + if (headData.CARRIEREDICODE == "COSU") + { + error = error + "
提单号:" + headData.MBLNO + " 请在EDI备注中输入:COSCO 销售的营销代码(此代码船公司会直接提供)"; + } + else + { + //if (carrier != "YML") + //error = error + "
提单号:" + bill.MBLNO + " EDI备注中不能为空"; + } + } + else + { + if (StringIsChinese(headData.EDIREMARK)) + { + error = error + "
提单号:" + headData.MBLNO + " EDI备注中含有中文或双字节字符"; + } + } + } + //if (string.IsNullOrEmpty(headData.CARRIER)) + //{ error = error + "
提单号:" + headData.MBLNO + " 船公司不能为空"; } + + if (string.IsNullOrEmpty(headData.CARRIEREDICODE)) + { error = error + "
提单号:" + headData.MBLNO + " 船公司EDI代码不能为空"; } + + + if (string.IsNullOrEmpty(headData.SHIPPER)) + { + error = error + "
提单号:" + headData.MBLNO + " 发货人不能为空"; + } + else + { + if (StringIsChinese(headData.SHIPPER)) + { + error = error + "
提单号:" + headData.MBLNO + " 发货人含有中文或双字节字符"; + } + else + { + if (headData.CARRIEREDICODE == "HLCU") + { + error += formatlengthError("txt", headData.SHIPPER, 35, headData.MBLNO, "发货人", 6, "-", false); + } + else + { + error += formatlengthError("txt", headData.SHIPPER, 35, headData.MBLNO, "发货人", 6, "*", false); + } + } + } + //} + + + + if (string.IsNullOrEmpty(headData.CONSIGNEE)) + { + error = error + "
提单号:" + headData.MBLNO + " 收货人不能为空"; + } + else + { + if (StringIsChinese(headData.CONSIGNEE)) + { + error = error + "
提单号:" + headData.MBLNO + " 收货人含有中文或双字节字符"; + } + else + { + if (headData.CARRIEREDICODE == "HLCU") + { + error += formatlengthError("txt", headData.CONSIGNEE, 35, headData.MBLNO, "收货人", 6, "--", false); + } + else + { + error += formatlengthError("txt", headData.CONSIGNEE, 35, headData.MBLNO, "收货人", 6, "**", false); + } + } + } + + + if (headData.SERVICE == "CY-DOOR") + { + if (string.IsNullOrEmpty(headData.CONSIGNEEDOORADDR)) + { + error = error + "
提单号:" + headData.MBLNO + " 运输条款为:CY-DOOR,EDI信息中的DOOR地址不能为空"; + } + else + { + if (StringIsChinese(headData.CONSIGNEEDOORADDR)) + { + error = error + "
提单号:" + headData.MBLNO + " DOOR地址含有中文或双字节字符"; + } + } + } + if (headData.SERVICE == "DOOR-CY") + { + if (string.IsNullOrEmpty(headData.SHIPPERDOORADDR)) + { + error = error + "
提单号:" + headData.MBLNO + " 运输条款为:DOOR-CY,EDI信息中的联系人地址不能为空"; + } + else + { + if (StringIsChinese(headData.SHIPPERDOORADDR)) + { + error = error + "
提单号:" + headData.MBLNO + " 联系人地址含有中文或双字节字符"; + } + } + } + + + if (string.IsNullOrEmpty(headData.NOTIFYPARTY)) + { + error = error + "
提单号:" + headData.MBLNO + " 通知人不能为空"; + } + else + { + if (StringIsChinese(headData.NOTIFYPARTY)) + { + error = error + "
提单号:" + headData.MBLNO + " 通知人含有中文或双字节字符"; + } + else + { + if (headData.CARRIEREDICODE == "HLCU") + { + error += formatlengthError("txt", headData.NOTIFYPARTY, 35, headData.MBLNO, "通知人", 6, "---", false); + } + else + { + error += formatlengthError("txt", headData.NOTIFYPARTY, 35, headData.MBLNO, "通知人", 6, "***", false); + } + } + } + + if (!string.IsNullOrEmpty(headData.NOTIFYPARTY2)) + { + error += formatlengthError("txt", headData.NOTIFYPARTY2, 35, headData.MBLNO, "第二通知人", 5, "", false); + } + + if (string.IsNullOrEmpty(headData.MARKS)) + { + error = error + "
提单号:" + headData.MBLNO + " 唛头不能为空"; + } + else + { + if (StringIsChinese(headData.MARKS)) + { + error = error + "
提单号:" + headData.MBLNO + " 唛头含有中文或双字节字符"; + } + else + { + error += formatlengthError("txt", headData.MARKS, 35, headData.MBLNO, "唛头", 0, "", false); + } + } + + if (string.IsNullOrEmpty(headData.DESCRIPTION)) + { + error = error + "
提单号:" + headData.MBLNO + " 货物描述不能为空"; + } + else + { + if (StringIsChinese(headData.DESCRIPTION)) + { + error = error + "
提单号:" + headData.MBLNO + " 货物描述含有中文或双字节字符"; + } + else + { + //error += formatlengthError("txt", bill.DESCRIPTION, 35, bill.MBLNO, "货物描述", 0, ""); + } + } + if (string.IsNullOrEmpty(headData.PORTLOADID) || headData.PORTLOADID.Length != 5) + { error = error + "
提单号:" + headData.MBLNO + " 装货港代码不能为空或录入不正确(必须是5位代码)"; } + + if (string.IsNullOrEmpty(headData.PORTLOAD)) + { error = error + "
提单号:" + headData.MBLNO + " 装货港不能为空"; } + + if (string.IsNullOrEmpty(headData.ETD)) + { + error = error + "
提单号:" + headData.MBLNO + " 开船日期不能为空"; + return error; + } + if (string.IsNullOrEmpty(headData.PORTDISCHARGEID) || headData.PORTDISCHARGEID.Length != 5) + { error = error + "
提单号:" + headData.MBLNO + " 卸货港代码不能为空或录入不正确(必须是5位代码)"; } + if (string.IsNullOrEmpty(headData.PORTDISCHARGE)) + { error = error + "
提单号:" + headData.MBLNO + " 卸货港不能为空"; } + if (string.IsNullOrEmpty(headData.DESTINATION)) + { + if (string.IsNullOrEmpty(headData.DESTINATIONID) || headData.DESTINATIONID.Length != 5) + { error = error + "
提单号:" + headData.MBLNO + " 目的地代码不能为空或录入不正确(必须是5位代码)"; } + } + if (string.IsNullOrEmpty(headData.KINDPKGS_EDI_CODE)) + { error = error + "
提单号:" + headData.MBLNO + " 包装EDI代码不能为空"; } + if (headData.PKGS == 0) + { error = error + "
提单号:" + headData.MBLNO + " 件数不能为0"; } + if (headData.KGS == 0) + { error = error + "
提单号:" + headData.MBLNO + " 毛重不能为0"; } + if (headData.CBM == 0) + { error = error + "
提单号:" + headData.MBLNO + " 尺码不能为0"; } + + if (headData.CARGOID == "D") + { + if (string.IsNullOrEmpty(headData.DCLASS)) + { error = error + "
提单号:" + headData.MBLNO + " 危险品分类不能为空"; } + + if (string.IsNullOrEmpty(headData.DUNNO)) + { error = error + "
提单号:" + headData.MBLNO + " 危险品编号不能为空"; } + } + if (headData.CARGOID == "R") + { + if (headData.TEMPSET == null || headData.TEMPSET == "") + { error = error + "
提单号:" + headData.MBLNO + " 设置温度不能为空"; } + if (headData.REEFERF == null || headData.REEFERF == "") + { error = error + "
提单号:" + headData.MBLNO + " 通风度不能为空"; } + } + + if (headData.BLFRT != null && headData.BLFRT.IndexOf("PREPAID") >= 0) + { + if (string.IsNullOrEmpty(headData.PREPARDAT)) + { error = error + "
提单号:" + headData.MBLNO + " 预付地点不能为空"; } + if (string.IsNullOrEmpty(headData.PREPARDATID)) + { error = error + "
提单号:" + headData.MBLNO + " 预付地点EDI代码不能为空"; } + } + else if (headData.BLFRT != null && headData.BLFRT.IndexOf("COLLECT") >= 0) + { + if (string.IsNullOrEmpty(headData.PAYABLEAT)) + { error = error + "
提单号:" + headData.MBLNO + " 到付地点不能为空"; } + if (string.IsNullOrEmpty(headData.PAYABLEATID)) + { error = error + "
提单号:" + headData.MBLNO + " 到付地点EDI代码不能为空"; } + } + + if (InttrEdi.filetype == "E") + { + if (string.IsNullOrEmpty(headData.ISSUEPLACEID)) + { error = error + "
提单号:" + headData.MBLNO + " 签单地点或到签单地点EDI代码不能为空"; } + } + var ctnlist = headData.CTNLIST; + if (ctnlist.Count == 0) { error = error + "
提单号:" + headData.MBLNO + " 集装箱信息不能为空"; }; + + if (InttrEdi.filetype == "E") + { + #region 集装箱判断检查 + if (ctnlist.Count != 0) + { + Decimal dlPKGS = 0; + Decimal dlKGS = 0; + Decimal dlCBM = 0; + foreach (var ctn in ctnlist) + { + if (string.IsNullOrEmpty(ctn.CTNALLCODE)) + { error = error + "
提单号:" + headData.MBLNO + " 集装箱箱型EDI代码不能为空"; } + if (string.IsNullOrEmpty(ctn.CNTRNO)) + { error = error + "
提单号:" + headData.MBLNO + " 箱号不能为空"; } + if (string.IsNullOrEmpty(ctn.SEALNO)) + { error = error + "
提单号:" + headData.MBLNO + " 封号不能为空"; } + if (headData.BYCOUNTRY == "BRAZIL") + { + // 20240402 if (string.IsNullOrEmpty(ctn.TAREWEIGHT) || Convert.ToDecimal(ctn.TAREWEIGHT) == 0) + if(ctn.TAREWEIGHT == 0) + { error = error + "
提单号:" + headData.MBLNO + " 箱皮重不能为空"; } + } + if (ctn.KINDPKGS != headData.KINDPKGS) + { error = error + "
提单号:" + headData.MBLNO + " 中的包装类型与集装箱的包装类型不同"; } + dlPKGS += Convert.ToDecimal(ctn.PKGS); + dlKGS += Convert.ToDecimal(ctn.KGS); + dlCBM += Convert.ToDecimal(ctn.CBM); + } + + if (dlPKGS != Convert.ToDecimal(headData.PKGS)) + { error = error + "
提单号:" + headData.MBLNO + " 集装箱件数合计数必须等于委托单总件数"; } + if (dlKGS != Convert.ToDecimal(headData.KGS)) + { error = error + "
提单号:" + headData.MBLNO + " 集装箱重量合计数必须等于委托单总重量数"; } + if (dlCBM != Convert.ToDecimal(headData.CBM)) + { error = error + "
提单号:" + headData.MBLNO + " 集装箱尺码合计数必须等于委托单总尺码数"; } + } + if (headData.CTNGOODSLIST != null && headData.CTNGOODSLIST.Count > 0) + { + foreach (var ctn in ctnlist) + { + var isfind = false; + Int32 ctngoodssumpkgs = 0; + decimal ctngoodssumkgs = 0; + decimal ctngoodssumcbm = 0; + headData.CTNGOODSLIST.ForEach(i => + { + if (i.CNTRNO == ctn.CNTRNO) + { + isfind = true; + ctngoodssumpkgs = ctngoodssumpkgs + i.PKGS; + ctngoodssumkgs = ctngoodssumkgs + i.KGS; + ctngoodssumcbm = ctngoodssumcbm + i.CBM; + } + }); + if (!isfind) + { + error = error + "
提单号:" + headData.MBLNO + "的“" + ctn.CNTRNO + "”未添加分箱明细!"; + } + else + { + if (ctngoodssumpkgs != Convert.ToDecimal(ctn.PKGS)) + { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细件数合计数不等于集装箱件数"; } + if (ctngoodssumkgs != Convert.ToDecimal(ctn.KGS)) + { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细毛重合计数不等于集装箱毛重"; } + if (ctngoodssumcbm != Convert.ToDecimal(ctn.CBM)) + { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctn.CNTRNO + " 分箱明细尺码合计数不等于集装箱毛重"; } + + } + + } + + foreach (var ctngood in headData.CTNGOODSLIST) + { + if (string.IsNullOrEmpty(ctngood.KINDPKGS)) + { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型不能为空"; } + if (string.IsNullOrEmpty(ctngood.DESCRIPTION)) + { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱货物描述不能为空"; } + else + { + error += formatlengthError("txt", ctngood.DESCRIPTION, 70, headData.MBLNO, "的“" + ctngood.CNTRNO + "”箱号的分箱货物描述", 0, "", false); + } + //if (string.IsNullOrEmpty(ctngood.HSCODE)) + //{ error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱HS编码不能为空"; } + if (string.IsNullOrEmpty(ctngood.KINDPKGS_EDI_CODE)) + { error = error + "
提单号:" + headData.MBLNO + ",箱号:" + ctngood.CNTRNO + " 中的分箱明细包装类型代码不能为空"; } + + } + + } + + #endregion + + if (headData.BYCOUNTRY == "USA") + { + if (string.IsNullOrEmpty(headData.CONSIGNEEPOSTCODE)) + { error = error + "
提单号:" + headData.MBLNO + " 收货人邮编不能为空"; } + if (string.IsNullOrEmpty(headData.NOTIFYPARTYPOSTCODE)) + { error = error + "
提单号:" + headData.MBLNO + " 通知人邮编不能为空"; } + } + else if (headData.BYCOUNTRY == "CANADA") + { + if (string.IsNullOrEmpty(headData.CONSIGNEEPOSTCODE)) + { error = error + "
提单号:" + headData.MBLNO + " 收货人邮编不能为空"; } + } + else if (headData.BYCOUNTRY == "BRAZIL") + { + if (string.IsNullOrEmpty(headData.CONSIGNEECOUNTRY)) + { error = error + "
提单号:" + headData.MBLNO + " 收货人国家代码不能为空"; } + if (string.IsNullOrEmpty(headData.CONSIGNEETAXNO)) + { error = error + "
提单号:" + headData.MBLNO + " 收货人税号不能为空"; } + if (string.IsNullOrEmpty(headData.NOTIFYPARTYCOUNTRY)) + { error = error + "
提单号:" + headData.MBLNO + " 通知人国家代码不能为空"; } + if (string.IsNullOrEmpty(headData.NOTIFYPARTYTAXNO)) + { error = error + "
提单号:" + headData.MBLNO + " 通知人税号不能为空"; } + if (string.IsNullOrEmpty(headData.GOODSNCM)) + { error = error + "
提单号:" + headData.MBLNO + " 货物NCM编码不能为空"; } + } + } + + } + return error; + } + #endregion + + #region 订舱 + public static CommonWebApiResult CreateEdiINTTR(EDIBaseModel InttrEdi) + { + CommonWebApiResult result = new CommonWebApiResult { succ = false }; + + string filename = InttrEdi.filerpath + "\\" + InttrEdi.BSLIST[0].MBLNO + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt"; + + //如果是部署linux需要修改路径 + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + filename = filename.Replace("\\", "/"); + + //if (System.IO.File.Exists(filename)) + //{ + // System.IO.File.Delete(filename); + //} + FileStream f = new FileStream(filename, FileMode.Create); + StreamWriter r = new StreamWriter(f, Encoding.Default); + var icount = 0; + var bsno = ""; + foreach (var bill in InttrEdi.BSLIST) + { + bsno = bill.ORDERNO; + r.WriteLine("UNB+UNOC:2+" + InttrEdi.SENDCODE + "SO:ZZZ+" + InttrEdi.RECEIVECODE + ":ZZZ+" + DateTime.Now.ToString("yyMMdd:HHmm") + "+" + bill.ORDERNO + "'"); + r.WriteLine("UNH+" + bill.ORDERNO + "+IFTMBF:D:99B:UN'"); + icount = icount + 2; + + if (bill.CARRIEREDICODE == "HLCU") + { + if (InttrEdi.filerole == "9") + r.WriteLine("BGM+335+" + bill.ORDERNO + "SO+9'"); + else if (InttrEdi.filerole == "1") + r.WriteLine("BGM+335+" + bill.ORDERNO + "SO+1'"); + else + r.WriteLine("BGM+335+" + bill.ORDERNO + "SO+5'"); + + } + else + { + if (InttrEdi.filerole == "9") + r.WriteLine("BGM+335+" + bill.MBLNO + "SO+9'"); + else if (InttrEdi.filerole == "1") + r.WriteLine("BGM+335+" + bill.ORDERNO + "SO+1'"); + else + r.WriteLine("BGM+335+" + bill.MBLNO + "SO+5'"); + + } + + r.WriteLine("DTM+137:" + DateTime.Now.ToString("yyyyMMddHHmm") + ":203'"); + icount = icount + 2; + + if (bill.SERVICE.ToUpper() == "DOOR-DOOR") + { + r.WriteLine("TSR+27+2'"); + } + else if (bill.SERVICE.ToUpper() == "DOOR-CY") + { + r.WriteLine("TSR+28+2'"); + } + else if (bill.SERVICE.ToUpper() == "CY-DOOR") + { + r.WriteLine("TSR+29+2'"); + } + else + { + r.WriteLine("TSR+30+2'"); + } + + var str_pay = ""; + if (bill.BLFRT.IndexOf("PREPAID") >= 0) + str_pay = bill.PREPARDAT; + if (bill.BLFRT.IndexOf("COLLECT") >= 0) + str_pay = bill.PAYABLEAT; + + + if (bill.CARRIEREDICODE == "HLCU") + { + r.WriteLine("FTX+AAI+++" + bill.BLFRT + " Payable at " + str_pay + " " + bill.SERVICE + " " + bill.CONTRACTNO + " " + + bill.PKGS.ToString() + bill.KINDPKGS + " " + formatEdiStr("txt", bill.EDIREMARK.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ")) + "'"); + } + else if (bill.CARRIEREDICODE == "COSU") + { + r.WriteLine("FTX+AAI+++" + bill.BLFRT + " Payable at " + str_pay + " " + formatEdiStr("txt", bill.EDIREMARK.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ")) + "'"); + } + else + { + + r.WriteLine("FTX+AAI+++" + bill.BLFRT + " Payable at " + str_pay + " " + bill.SERVICE + " " + + bill.PKGS.ToString() + bill.KINDPKGS + " " + formatEdiStr("txt", bill.EDIREMARK.Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ")) + "'"); + } + + icount = icount + 2; + /*件重尺*/ + r.WriteLine("CNT+7:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + ":KGM'");//按照四舍五入的国际标准 + r.WriteLine("CNT+11:" + bill.PKGS.ToString() + "'"); + r.WriteLine("CNT+15:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + ":MTQ'"); + + icount = icount + 3; + + + if (bill.CARRIEREDICODE == "UASC") + { + if (bill.CTNLIST.Count > 0) + { + var ctnnum = 0; + foreach (var ctn in bill.CTNLIST) + { + ctnnum = ctnnum + ctn.CTNNUM; + } + r.WriteLine("CNT+16:" + ctnnum.ToString() + "'"); + icount = icount + 1; + } + + } + + if (bill.BLFRT == "FREIGHT COLLECT") + { + if (bill.PAYABLEAT != "") + { + r.WriteLine("LOC+57+" + bill.PREPARDATID + "::6:" + bill.PAYABLEAT + "'"); + icount = icount + 1; + } + } + else + { + r.WriteLine("LOC+57+" + bill.PREPARDATID + "::6:" + bill.PREPARDAT + "'"); + icount = icount + 1; + + } + + if (InttrEdi.UseForWarderCode) + { + r.WriteLine("RFF+FF:" + bill.ORDERNO.Trim() + "'"); + r.WriteLine("RFF+ON:" + bill.ORDERNO.Trim() + "'"); + icount = icount + 2; + } + else + { + if (bill.ORDERNO.Trim() != "") + { + r.WriteLine("RFF+FF:" + bill.ORDERNO.Trim() + "'"); + r.WriteLine("RFF+ON:" + bill.ORDERNO.Trim() + "'"); + icount = icount + 2; + } + } + + if (bill.CARRIEREDICODE != "COSU") + { + if (bill.CARRIEREDICODE == "HLCU") + { + //r.WriteLine("RFF+ON:" + bill.CUSTNO + "'"); + r.WriteLine("RFF+BM:" + bill.MBLNO + "'"); + } + else + { + r.WriteLine("RFF+BN:" + bill.MBLNO + "'"); + r.WriteLine("RFF+BM:" + bill.MBLNO + "'"); + } + icount = icount + 2; + } + r.WriteLine("RFF+CT:" + bill.CONTRACTNO + "'"); + + if (bill.BLFRT.IndexOf("PREPAID") >= 0) + r.WriteLine("CPI+4++P'"); + else if (bill.BLFRT.IndexOf("COLLECT") >= 0) + r.WriteLine("CPI+4++C'"); + else + r.WriteLine("CPI+4++B'"); + icount = icount + 2; + + var voyno = ""; + if (!string.IsNullOrEmpty(bill.NVOYNO)) voyno = bill.NVOYNO; else voyno = bill.VOYNO; + + if (voyno.IndexOf(".") >= 0) + voyno = voyno.Substring(voyno.IndexOf(".") + 1, voyno.Length - voyno.IndexOf(".") - 1); + + + r.WriteLine("TDT+20+" + voyno + "+1++" + bill.CARRIEREDICODE + "+++:::" + bill.VESSEL + "'"); + r.WriteLine("LOC+9+" + bill.PORTLOADID + ":139:6:" + bill.PORTLOAD + "'"); + r.WriteLine("DTM+133:" + Convert.ToDateTime(bill.ETD).ToString("yyyyMMdd") + ":102'");//yyyyMMddHHmm + r.WriteLine("LOC+88+" + bill.PORTLOADID + ":139:6:" + bill.PORTLOAD + "'"); + r.WriteLine("LOC+11+" + bill.PORTDISCHARGEID + ":139:6:" + bill.PORTDISCHARGE + "'"); + icount = icount + 5; + + if (bill.DESTINATION != "") + { + r.WriteLine("LOC+7+" + bill.DESTINATIONID + ":139:6:" + bill.DESTINATION + "'"); + icount = icount + 1; + } + var Shipping = ""; + var DescriptionShipper = ""; + Shipping = formatEdiStr("txt", bill.SHIPPER); + + List ShippingList = formatlengthStr(Shipping, 35); + + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+CZ+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i]; + if (i >= 4 && ShippingList.Count > 5) + { + if (i == 4) + { + if (ShippingList[i].Length > 34) + { + Shipping = Shipping + ":" + ShippingList[i].Substring(0, 34); + DescriptionShipper = ShippingList[i].Substring(34); + } + else + Shipping = Shipping + ":" + ShippingList[i]; + if (bill.CARRIEREDICODE == "HLCU") + { + Shipping = Shipping + "-"; + DescriptionShipper = "-" + DescriptionShipper; + } + else + { + Shipping = Shipping + "*"; + DescriptionShipper = "*" + DescriptionShipper; + } + + } + else if (i > 4) + { + + DescriptionShipper = DescriptionShipper + " " + ShippingList[i]; + } + + } + else + if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; + } + } + + r.WriteLine(Shipping + "'"); + icount = icount + 1; + + Shipping = formatEdiStr("txt", bill.CONSIGNEE); + ShippingList = formatlengthStr(Shipping, 35); + + var DescriptionConsignee = ""; + + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+CN+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i]; + if (i >= 4 && ShippingList.Count > 5) + { + if (i == 4) + { + if (ShippingList[i].Length > 33) + { + Shipping = Shipping + ":" + ShippingList[i].Substring(0, 33); + DescriptionConsignee = ShippingList[i].Substring(33); + } + else + Shipping = Shipping + ":" + ShippingList[i]; + if (bill.CARRIEREDICODE == "HLCU") + { + Shipping = Shipping + "--"; + DescriptionConsignee = "--" + DescriptionConsignee; + } + else + { + Shipping = Shipping + "**"; + DescriptionConsignee = "**" + DescriptionConsignee; + } + + } + else if (i > 4) + { + + DescriptionConsignee = DescriptionConsignee + " " + ShippingList[i]; + } + + } + else + if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; + } + } + + if (bill.BYCOUNTRY == "USA") + { + Shipping = Shipping + "+++" + bill.CONSIGNEEPOSTCODE; + r.WriteLine(Shipping + "'"); + } + else if (bill.BYCOUNTRY == "CANADA") + { + Shipping = Shipping + "+++" + bill.CONSIGNEEPOSTCODE + "+CA"; + r.WriteLine(Shipping + "'"); + } + else if (bill.BYCOUNTRY == "BRAZIL") + { + Shipping = Shipping + "++++" + bill.CONSIGNEECOUNTRY; + r.WriteLine(Shipping + "'"); + r.WriteLine("RFF+GN:" + bill.CONSIGNEETAXNO + "'"); + icount = icount + 1; + + } + else r.WriteLine(Shipping + "'"); + + icount = icount + 1; + + Shipping = formatEdiStr("txt", bill.NOTIFYPARTY); + ShippingList = formatlengthStr(Shipping, 35); + + var DescriptionNotifyparty = ""; + + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+NI+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i]; + if (i >= 4 && ShippingList.Count > 5) + { + if (i == 4) + { + if (ShippingList[i].Length > 32) + { + Shipping = Shipping + ":" + ShippingList[i].Substring(0, 32); + DescriptionNotifyparty = ShippingList[i].Substring(32); + } + else + Shipping = Shipping + ":" + ShippingList[i]; + if (bill.CARRIEREDICODE == "HLCU") + { + Shipping = Shipping + "---"; + DescriptionNotifyparty = "---" + DescriptionNotifyparty; + } + else + { + Shipping = Shipping + "***"; + DescriptionNotifyparty = "***" + DescriptionNotifyparty; + } + + } + else if (i > 4) + { + + DescriptionNotifyparty = DescriptionNotifyparty + " " + ShippingList[i]; + } + + } + else + if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; + } + } + + if (bill.BYCOUNTRY == "USA") + { + Shipping = Shipping + "+++" + bill.NOTIFYPARTYPOSTCODE; + r.WriteLine(Shipping + "'"); + } + else if (bill.BYCOUNTRY == "BRAZIL") + { + if (bill.NOTIFYPARTYCOUNTRY != "") + Shipping = Shipping + "++++" + bill.NOTIFYPARTYCOUNTRY; + r.WriteLine(Shipping + "'"); + if (bill.NOTIFYPARTYTAXNO != "") + { + r.WriteLine("RFF+GN:" + bill.NOTIFYPARTYTAXNO + "'"); + icount = icount + 1; + + } + } + else r.WriteLine(Shipping + "'"); + icount = icount + 1; + + r.WriteLine("NAD+CA+" + bill.CARRIEREDICODE + ":160:86++" + GetCarrierName(bill.CARRIEREDICODE) + "'"); + icount = icount + 1; + + if (bill.SERVICE == "DOOR-DOOR") + { + Shipping = formatEdiStr("txt", bill.SHIPPER); + ShippingList = formatlengthStr(Shipping, 35); + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+SF+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i >= 2) Shipping = Shipping + ":" + ShippingList[i]; + } + } + r.WriteLine(Shipping + "'"); + + r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'"); + r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'"); + r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'"); + icount = icount + 4; + Shipping = formatEdiStr("txt", bill.CONSIGNEE); + if (Shipping.ToUpper().IndexOf("TO ORDER") >= 0 || Shipping.ToUpper().IndexOf("SAME AS") >= 0) + Shipping = formatEdiStr("txt", bill.NOTIFYPARTY); + + ShippingList = formatlengthStr(Shipping, 35); + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+ST+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i >= 2) Shipping = Shipping + ":" + ShippingList[i]; + } + } + r.WriteLine(Shipping + "'"); + + r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'"); + r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'"); + r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'"); + icount = icount + 4; + } + if (bill.SERVICE == "DOOR-CY") + { + Shipping = formatEdiStr("txt", bill.SHIPPERDOORADDR); + ShippingList = formatlengthStr(Shipping, 35); + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+SF+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i >= 2) Shipping = Shipping + ":" + ShippingList[i]; + } + } + r.WriteLine(Shipping + "'"); + + r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'"); + r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'"); + r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'"); + icount = icount + 4; + } + + if (bill.SERVICE == "CY-DOOR") + { + Shipping = formatEdiStr("txt", bill.CONSIGNEEDOORADDR); + ShippingList = formatlengthStr(Shipping, 35); + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+ST+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i >= 2) Shipping = Shipping + ":" + ShippingList[i]; + } + } + r.WriteLine(Shipping + "'"); + + r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'"); + r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'"); + r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'"); + icount = icount + 4; + } + + + if (bill.WEITUO != "") + { + if (bill.WEITUO.Length > 35) + r.WriteLine("NAD+FW+++" + formatEdiStr("txt", bill.WEITUO.Substring(0, 35)) + "+" + formatEdiStr("txt", bill.WEITUO.Substring(35)) + "'"); + else + r.WriteLine("NAD+FW+++" + formatEdiStr("txt", bill.WEITUO) + "'"); + + } + else + { + + if (InttrEdi.UseForWarderCode) + { + r.WriteLine("NAD+FW+" + InttrEdi.ForWarderCode + ":160:86++" + InttrEdi.ForWarderName + "'"); + icount++; + } + else + { + if (InttrEdi.SENDNAME.Length > 35) + r.WriteLine("NAD+FW+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'"); + else + r.WriteLine("NAD+FW+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'"); + } + } + + + if (InttrEdi.SENDNAME.Length > 35) + r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'"); + else + r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'"); + + //r.WriteLine("CTA+IC+:" +billams.ATTN+ "'"); + //r.WriteLine("COM+" +billams.ATTNTEL+ ":TE'"); + //r.WriteLine("COM+" + billams.ATTNEMAIL + ":EM'"); + + + r.WriteLine("CTA+IC+:" + bill.OpEName + "'"); + r.WriteLine("COM+" + bill.OpTel + ":TE'"); + r.WriteLine("COM+" + bill.OpEmail + ":EM'"); + + r.WriteLine("NAD+MR+++" + InttrEdi.SENDNAME + "'"); + //r.WriteLine("CTA+NT+:" +billams.ATTN+ "'"); + //r.WriteLine("COM+" + billams.ATTNEMAIL + ":EM'"); + r.WriteLine("CTA+NT+:" + bill.OpEName + "'"); + r.WriteLine("COM+" + bill.OpEmail + ":EM'"); + + r.WriteLine("GID+1+" + bill.PKGS.ToString() + ":" + bill.KINDPKGS_EDI_CODE + "::6:" + bill.KINDPKGS + "'"); + + icount = icount + 8; + + if (bill.HSCODE != "") + { + r.WriteLine("PIA+5+" + bill.HSCODE + ":HS'"); + icount = icount + 1; + + } + Shipping = formatEdiStr("txt", bill.DESCRIPTION); + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + string[] DescriptionList = Shipping.Split('\\'); + if (DescriptionList.Length != 0) + { + + for (var i = 0; i < DescriptionList.Length; i++) + { + r.WriteLine("FTX+AAA+++" + DescriptionList[i] + "'"); + icount = icount + 1; + + } + } + if (DescriptionShipper != "") + { + r.WriteLine("FTX+AAA+++" + DescriptionShipper + "'"); + icount = icount + 1; + + } + if (DescriptionConsignee != "") + { + r.WriteLine("FTX+AAA+++" + DescriptionConsignee + "'"); + icount = icount + 1; + + } + if (DescriptionNotifyparty != "") + { + r.WriteLine("FTX+AAA+++" + DescriptionNotifyparty + "'"); + icount = icount + 1; + + } + + r.WriteLine("MEA+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + "'"); + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + "'"); + icount = icount + 2; + + Shipping = formatEdiStr("txt", bill.MARKS); + + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + string[] MarksList = Shipping.Split('\\'); + if (MarksList.Length != 0) + { + + for (var i = 0; i < MarksList.Length; i++) + { + r.WriteLine("PCI++" + MarksList[i] + "'"); + icount = icount + 1; + + } + } + if (bill.CARGOID == "D") + { + r.WriteLine("DGS+IMD+" + bill.DCLASS + "+" + bill.DUNNO + "'"); + r.WriteLine("CTA+HG+:" + bill.EDIATTN + "'"); + r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'"); + icount = icount + 3; + } + + var ctnsumlist = new List(); + foreach (var ctn in bill.CTNLIST) + { + var isfind = false; + ctnsumlist.ForEach(i => + { + if (i.CTNALLCODE == ctn.CTNALLCODE) + { + i.CTNNUM = i.CTNNUM + ctn.CTNNUM; + isfind = true; + } + }); + if (!isfind) + { + var ctnnum = new MsOpSeaeCtnEDIBaseModel(); + ctnnum.CTNALLCODE = ctn.CTNALLCODE; + ctnnum.CTNNUM = ctn.CTNNUM; + ctnsumlist.Add(ctnnum); + } + } + foreach (var ctn in ctnsumlist) + { + if (bill.ISCONTAINERSOC) + r.WriteLine("EQD+CN++" + ctn.CTNALLCODE + "+1'"); + else + r.WriteLine("EQD+CN++" + ctn.CTNALLCODE + "+2'"); + r.WriteLine("EQN+" + ctn.CTNNUM.ToString() + "'"); + icount = icount + 2; + + if (bill.CARGOID == "R") + { + if (bill.REEFERF != "") + r.WriteLine("MEA+AAE+AAS+CBM:" + bill.REEFERF + "'"); + if (bill.HUMIDITY != "") + r.WriteLine("MEA+AAE+AAO+HMD:" + bill.HUMIDITY + "'"); + r.WriteLine("TMP+2+" + bill.TEMPSET + ":CEL'"); + icount = icount + 2; + + + } + + } + + } + r.WriteLine("UNT+" + icount.ToString() + "+" + bsno + "'"); + r.WriteLine("UNZ+" + InttrEdi.BSLIST.Count.ToString() + "+" + bsno + "'"); + r.Close(); + f.Close(); + + return result; + } + #endregion + + #region 确认 + public static CommonWebApiResult CreateEdiINTTRSI(EDIBaseModel InttrEdi) + { + CommonWebApiResult result = new CommonWebApiResult { succ = false }; + + string filename = InttrEdi.filerpath + "\\" + InttrEdi.BSLIST[0].MBLNO + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt"; + + if (System.IO.File.Exists(filename)) + { + System.IO.File.Delete(filename); + } + FileStream f = new FileStream(filename, FileMode.Create); + StreamWriter r = new StreamWriter(f, Encoding.Default); + + var icount = 0; + var bsno = ""; + foreach (var bill in InttrEdi.BSLIST) + { + bsno = bill.ORDERNO; + r.WriteLine("UNB+UNOC:2+" + InttrEdi.SENDCODE + ":ZZZ+" + InttrEdi.RECEIVECODE + ":ZZZ+" + DateTime.Now.ToString("yyMMdd:HHmm") + "+" + bill.ORDERNO + "'"); + r.WriteLine("UNH+" + bill.ORDERNO + "+IFTMIN:D:99B:UN'"); + if (InttrEdi.filerole == "9") + r.WriteLine("BGM+340+" + bill.MBLNO + "+9'"); + else + r.WriteLine("BGM+340+" + bill.MBLNO + "+5'"); + + + + if (bill.SERVICE.ToUpper() == "DOOR-DOOR") + { + r.WriteLine("TSR+27+2'"); + } + else if (bill.SERVICE.ToUpper() == "DOOR-CY") + { + r.WriteLine("TSR+28+2'"); + } + else if (bill.SERVICE.ToUpper() == "CY-DOOR") + { + r.WriteLine("TSR+29+2'"); + } + else + { + r.WriteLine("TSR+30+2'"); + } + + var str_pay = ""; + if (bill.BLFRT.IndexOf("PREPAID") >= 0) + str_pay = bill.PREPARDAT; + if (bill.BLFRT.IndexOf("COLLECT") >= 0) + str_pay = bill.PAYABLEAT; + r.WriteLine("FTX+AAI+++" + bill.BLFRT + " Payable at " + str_pay + " " + bill.SERVICE + " " + + bill.PKGS.ToString() + bill.KINDPKGS + "'"); + icount = icount + 5; + + var Shipping = ""; + Shipping = formatEdiStr("txt", bill.SIREMARK); + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + string[] EdiRemarkList = Shipping.Split('\\'); + if (EdiRemarkList.Length != 0) + { + + for (var i = 0; i < EdiRemarkList.Length; i++) + { + r.WriteLine("FTX+AAI+++" + EdiRemarkList[i] + "'"); + icount = icount + 1; + + } + } + + if (bill.BYCOUNTRY == "USA") + { + if (bill.SCACCODE != "") + r.WriteLine("FTX+CCI++MFS+1:US:" + bill.SCACCODE + "'"); + else + r.WriteLine("FTX+CCI++MFS+5:US'"); + icount = icount + 1; + + } + else if (bill.BYCOUNTRY == "CANADA") + { + if (bill.SCACCODE != "") + r.WriteLine("FTX+CCI++MFS+1:CA:" + bill.SCACCODE + "'"); + else + r.WriteLine("FTX+CCI++MFS+5:CA'"); + icount = icount + 1; + + } + r.WriteLine("CNT+7:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + ":KGM'"); + r.WriteLine("CNT+11:" + bill.PKGS.ToString() + "'"); + r.WriteLine("CNT+15:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + ":MTQ'"); + + icount = icount + 3; + + if (bill.CARRIEREDICODE == "UASC") + { + if (bill.CTNLIST.Count > 0) + { + var ctnnum = 0; + foreach (var ctn in bill.CTNLIST) + { + ctnnum = ctnnum + ctn.CTNNUM; + } + r.WriteLine("CNT+16:" + ctnnum.ToString() + "'"); + icount = icount + 1; + } + + } + + if (bill.BLFRT == "FREIGHT COLLECT") + { + if (bill.PAYABLEAT != "") + { + r.WriteLine("LOC+57+" + bill.PREPARDATID + "::6:" + bill.PAYABLEAT + "'"); + icount = icount + 1; + } + } + else + { + r.WriteLine("LOC+57+" + bill.PREPARDATID + "::6:" + bill.PREPARDAT + "'"); + icount = icount + 1; + } + + r.WriteLine("LOC+73+" + bill.ISSUEPLACEID + "::6:" + bill.ISSUEPLACE + "'"); + icount = icount + 1; + + + + if (bill.CARRIEREDICODE == "MASK") + { + Shipping = formatEdiStr("txt", bill.BSNOLIST); + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + EdiRemarkList = Shipping.Split('\\'); + if (EdiRemarkList.Length != 0) + { + + for (var i = 0; i < EdiRemarkList.Length; i++) + { + r.WriteLine("RFF+BN:" + EdiRemarkList[i] + "'"); + icount = icount + 1; + + } + } + else + { + //if (billams.ORDERNO != "") + // r.WriteLine("RFF+BN:" + billams.ORDERNO + "'"); + //else + r.WriteLine("RFF+BN:" + bill.MBLNO + "'"); + icount = icount + 1; + + } + } + else + { + //if (billams.ORDERNO != "") + // r.WriteLine("RFF+BN:" + billams.ORDERNO + "'"); + //else + r.WriteLine("RFF+BN:" + bill.MBLNO + "'"); + icount = icount + 1; + + } + r.WriteLine("RFF+BM:" + bill.MBLNO + "'"); + + + + + r.WriteLine("RFF+CT:" + bill.CONTRACTNO + "'"); + icount = icount + 2; + + + if (bill.CARRIEREDICODE == "UASC") + { + r.WriteLine("RFF+SI:" + bill.ORDERNO + "'"); + icount = icount + 1; + + } + if (bill.BYCOUNTRY == "USA") + { + r.WriteLine("REF+TN:" + bill.ITNCODE + "'"); + icount = icount + 1; + + } + + if (bill.BLFRT.IndexOf("PREPAID") >= 0) + r.WriteLine("CPI+4++P'"); + else if (bill.BLFRT.IndexOf("COLLECT") >= 0) + r.WriteLine("CPI+4++C'"); + else + r.WriteLine("CPI+4++B'"); + icount = icount + 1; + + var voyno = ""; + if (bill.VOYNO.IndexOf(".") >= 0) + { + voyno = bill.VOYNO.Substring(bill.VOYNO.IndexOf(".") + 1, bill.VOYNO.Length - bill.VOYNO.IndexOf(".") - 1); + } + else + { + voyno = bill.VOYNO; + } + r.WriteLine("TDT+20+" + voyno + "+1++" + bill.CARRIEREDICODE + "+++:::" + bill.VESSEL + "'"); + r.WriteLine("LOC+9+" + bill.PORTLOADID + ":139:6:" + bill.PORTLOAD + "'"); + + r.WriteLine("LOC+88+" + bill.PORTLOADID + ":139:6:" + bill.PORTLOAD + "'"); + r.WriteLine("LOC+11+" + bill.PORTDISCHARGEID + ":139:6:" + bill.PORTDISCHARGE + "'"); + icount = icount + 4; + + if (bill.DESTINATION != "") + { + r.WriteLine("LOC+7+" + bill.DESTINATIONID + ":139:6:" + bill.DESTINATION + "'"); + icount = icount + 1; + + } + + + + var DescriptionShipper = ""; + Shipping = formatEdiStr("txt", bill.SHIPPER); + + List ShippingList = formatlengthStr(Shipping, 35); + + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+CZ+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i]; + if (i >= 4 && ShippingList.Count > 5) + { + if (i == 4) + { + if (ShippingList[i].Length > 34) + { + Shipping = Shipping + ":" + ShippingList[i].Substring(0, 34); + DescriptionShipper = ShippingList[i].Substring(34); + } + else + Shipping = Shipping + ":" + ShippingList[i]; + if (bill.CARRIEREDICODE == "HLCU") + { + Shipping = Shipping + "-"; + DescriptionShipper = "-" + DescriptionShipper; + } + else + { + Shipping = Shipping + "*"; + DescriptionShipper = "*" + DescriptionShipper; + } + + } + else if (i > 4) + { + + DescriptionShipper = DescriptionShipper + " " + ShippingList[i]; + } + + } + else + if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; + } + } + + r.WriteLine(Shipping + "'"); + icount = icount + 1; + Shipping = formatEdiStr("txt", bill.CONSIGNEE); + + ShippingList = formatlengthStr(Shipping, 35); + + var DescriptionConsignee = ""; + + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+CN+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i]; + if (i >= 4 && ShippingList.Count > 5) + { + if (i == 4) + { + if (ShippingList[i].Length > 33) + { + Shipping = Shipping + ":" + ShippingList[i].Substring(0, 33); + DescriptionConsignee = ShippingList[i].Substring(33); + } + else + Shipping = Shipping + ":" + ShippingList[i]; + if (bill.CARRIEREDICODE == "HLCU") + { + Shipping = Shipping + "--"; + DescriptionConsignee = "--" + DescriptionConsignee; + } + else + { + Shipping = Shipping + "**"; + DescriptionConsignee = "**" + DescriptionConsignee; + } + + } + else if (i > 4) + { + + DescriptionConsignee = DescriptionConsignee + " " + ShippingList[i]; + } + + } + else + if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; + } + } + + if (bill.BYCOUNTRY == "USA") + { + Shipping = Shipping + "+++" + bill.CONSIGNEEPOSTCODE; + r.WriteLine(Shipping + "'"); + } + else if (bill.BYCOUNTRY == "CANADA") + { + Shipping = Shipping + "+++" + bill.CONSIGNEEPOSTCODE + "+CA"; + r.WriteLine(Shipping + "'"); + } + else if (bill.BYCOUNTRY == "BRAZIL") + { + Shipping = Shipping + "++++" + bill.CONSIGNEECOUNTRY; + r.WriteLine(Shipping + "'"); + r.WriteLine("RFF+GN:" + bill.CONSIGNEETAXNO + "'"); + icount = icount + 1; + + } + else r.WriteLine(Shipping + "'"); + icount = icount + 1; + + if (!string.IsNullOrEmpty(bill.WEITUO)) + { + if (bill.WEITUO.Length > 35) + r.WriteLine("NAD+FW+++" + formatEdiStr("txt", bill.WEITUO.Substring(0, 35)) + "+" + formatEdiStr("txt", bill.WEITUO.Substring(35)) + "'"); + else + r.WriteLine("NAD+FW+++" + formatEdiStr("txt", bill.WEITUO) + "'"); + + } + else + { + + if (InttrEdi.UseForWarderCode) + { + r.WriteLine("NAD+FW+" + InttrEdi.ForWarderCode + ":160:86++" + InttrEdi.ForWarderName + "'"); + icount++; + } + else + { + if (InttrEdi.SENDNAME.Length > 35) + r.WriteLine("NAD+FW+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'"); + else + r.WriteLine("NAD+FW+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'"); + } + } + + + + icount++; + + Shipping = formatEdiStr("txt", bill.NOTIFYPARTY); + + ShippingList = formatlengthStr(Shipping, 35); + + var DescriptionNotifyparty = ""; + + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+NI+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i]; + if (i >= 4 && ShippingList.Count > 5) + { + if (i == 4) + { + if (ShippingList[i].Length > 32) + { + Shipping = Shipping + ":" + ShippingList[i].Substring(0, 32); + DescriptionNotifyparty = ShippingList[i].Substring(32); + } + else + Shipping = Shipping + ":" + ShippingList[i]; + if (bill.CARRIEREDICODE == "HLCU") + { + Shipping = Shipping + "---"; + DescriptionNotifyparty = "---" + DescriptionNotifyparty; + } + else + { + Shipping = Shipping + "***"; + DescriptionNotifyparty = "***" + DescriptionNotifyparty; + } + + } + else if (i > 4) + { + + DescriptionNotifyparty = DescriptionNotifyparty + " " + ShippingList[i]; + } + + } + else + if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; + } + } + + if (bill.BYCOUNTRY == "USA") + { + Shipping = Shipping + "+++" + bill.NOTIFYPARTYPOSTCODE; + r.WriteLine(Shipping + "'"); + } + else if (bill.BYCOUNTRY == "BRAZIL") + { + if (bill.NOTIFYPARTYCOUNTRY != "") + Shipping = Shipping + "++++" + bill.NOTIFYPARTYCOUNTRY; + r.WriteLine(Shipping + "'"); + if (bill.NOTIFYPARTYTAXNO != "") + { + r.WriteLine("RFF+GN:" + bill.NOTIFYPARTYTAXNO + "'"); + icount = icount + 1; + + } + } + else r.WriteLine(Shipping + "'"); + icount = icount + 1; + + Shipping = formatEdiStr("txt", bill.NOTIFYPARTY2); + ShippingList = formatlengthStr(Shipping, 35); + if (ShippingList.Count != 0 && Shipping.Length > 0) + { + for (var i = 0; i < ShippingList.Count; i++) + { + if (i == 0) Shipping = "NAD+N1+++" + ShippingList[0] + "+"; + if (i == 1) Shipping = Shipping + ShippingList[i]; + if (i == 2 || i == 3) Shipping = Shipping + ":" + ShippingList[i]; + if (i == 4) Shipping = Shipping + ":" + ShippingList[i]; + } + r.WriteLine(Shipping + "'"); + } + + + + r.WriteLine("NAD+CA+" + bill.CARRIEREDICODE + ":160:86++" + GetCarrierName(bill.CARRIEREDICODE) + "'"); + + if (InttrEdi.SENDNAME.Length > 35) + r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'"); + else + r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'"); + + r.WriteLine("CTA+IC+:" + bill.EDIATTN + "'"); + r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'"); + r.WriteLine("COM+" + bill.EDIATTNEMAIL + ":EM'"); + icount = icount + 5; + var copynum = GetBillNum(bill.COPYNOBILL); + + if (bill.ISSUETYPE == "正本") + { + r.WriteLine("DOC+706+++" + GetBillNum(bill.NOBILL) + "'"); + icount = icount + 1; + if (copynum != "") + { + r.WriteLine("DOC+707+++" + copynum + "'"); + icount = icount + 1; + } + + } + else if (bill.ISSUETYPE == "海运单" || bill.ISSUETYPE.ToUpper() == "SEAWAY" || bill.ISSUETYPE.ToUpper() == "SEAWAY BILL" || bill.ISSUETYPE.ToUpper() == "WAYBILL" || bill.ISSUETYPE.ToUpper() == "SWB正本" || bill.ISSUETYPE.ToUpper() == "SWB无正本") + { + r.WriteLine("DOC+710+++" + GetBillNum(bill.NOBILL) + "'"); + icount = icount + 1; + + } + else if (bill.ISSUETYPE.ToUpper() == "BILL COPY" || bill.ISSUETYPE == "电放") + { + r.WriteLine("DOC+706+++" + GetBillNum(bill.NOBILL) + "'"); + icount = icount + 1; + if (copynum != "") + { + r.WriteLine("DOC+707+++" + copynum + "'"); + icount = icount + 1; + } + + } + else if (bill.ISSUETYPE == "正副本") + { + r.WriteLine("DOC+706+++" + GetBillNum(bill.NOBILL) + "'"); + icount = icount + 1; + if (copynum != "") + { + r.WriteLine("DOC+707+++" + copynum + "'"); + icount = icount + 1; + } + + } + else if (bill.ISSUETYPE.ToUpper() == "HOUSE BILL") + { + r.WriteLine("DOC+714+++" + GetBillNum(bill.NOBILL) + "'"); + icount = icount + 1; + + } + + //判断集装箱是否包含分箱明细 + + if (bill.CTNGOODSLIST == null || bill.CTNGOODSLIST.Count == 0) + { + #region 取委托单货描、唛头信息 + r.WriteLine("GID+1+" + bill.PKGS.ToString() + ":" + bill.KINDPKGS_EDI_CODE + "::6:" + bill.KINDPKGS + "'"); + + icount = icount + 1; + + if (bill.HSCODE != "") + { + r.WriteLine("PIA+5+" + bill.HSCODE + ":HS'"); + icount = icount + 1; + + } + + Shipping = formatEdiStr("txt", bill.DESCRIPTION); + + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + string[] DescriptionList = Shipping.Split('\\'); + if (DescriptionList.Length != 0) + { + + for (var i = 0; i < DescriptionList.Length; i++) + { + //if (DescriptionList[i] != "") + //{ + r.WriteLine("FTX+AAA+++" + DescriptionList[i] + "'"); + icount = icount + 1; + //} + + } + } + if (DescriptionShipper != "") + { + r.WriteLine("FTX+AAA+++" + DescriptionShipper + "'"); + icount = icount + 1; + + } + if (DescriptionConsignee != "") + { + r.WriteLine("FTX+AAA+++" + DescriptionConsignee + "'"); + icount = icount + 1; + + } + if (DescriptionNotifyparty != "") + { + r.WriteLine("FTX+AAA+++" + DescriptionNotifyparty + "'"); + icount = icount + 1; + + } + r.WriteLine("MEA+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + "'"); + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + "'"); + + icount = icount + 2; + + + if (!string.IsNullOrEmpty(bill.GOODSNCM)) + { + r.WriteLine("RFF+ABT:" + bill.GOODSNCM + "'"); + icount = icount + 1; + + } + Shipping = formatEdiStr("txt", bill.MARKS); + + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + string[] MarksList = Shipping.Split('\\'); + if (MarksList.Length != 0) + { + + for (var i = 0; i < MarksList.Length; i++) + { + + //if (MarksList[i] != "") + //{ + r.WriteLine("PCI++" + MarksList[i] + "'"); + icount = icount + 1; + //} + + } + } + + foreach (var ctn in bill.CTNLIST) + { + r.WriteLine("SGP+" + ctn.CNTRNO + "+" + ctn.PKGS.ToString() + "'"); + r.WriteLine("MEA+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctn.KGS), 3) + "'"); + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(ctn.CBM), 3) + "'"); + icount = icount + 3; + } + #endregion + } + else + { + + if (bill.CARRIEREDICODE == "UASC" || bill.CARRIEREDICODE == "HLCU" || bill.CARRIEREDICODE == "CMDU") + { + #region 取集装箱分箱_货描、唛头信息 + if (bill.CTNGOODSLIST != null) + { + if (bill.CTNGOODSLIST.Count > 0) + { + var i = 0; + foreach (var ctngood in bill.CTNGOODSLIST) + { + //GID+1+400:CT::6:CARTONS' + r.WriteLine("GID+" + (i + 1) + "+" + ctngood.PKGS.ToString() + ":" + ctngood.KINDPKGS_EDI_CODE + "::6:" + ctngood.KINDPKGS + "'"); + icount++; + //PIA+5+HS_CODE1:HS' + r.WriteLine("PIA+5+" + ctngood.HSCODE + ":HS'"); + icount++; + //FTX+AAA+++MATERIAL 1' + //FTX+AAA+++HS-NO 39023012' + Shipping = formatEdiStr("txt", ctngood.DESCRIPTION); + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + string[] DescriptionList = Shipping.Split('\\'); + if (DescriptionList.Length != 0) + { + for (var j = 0; j < DescriptionList.Length; j++) + { + r.WriteLine("FTX+AAA+++" + DescriptionList[j] + "'"); + icount++; + } + } + //MEA+AAE+WT+KGM:3000' + //MEA+AAE+AAW+MTQ:110.11' + r.WriteLine("MEA+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngood.KGS), 3) + "'"); + icount++; + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(ctngood.CBM), 3) + "'"); + icount++; + //PCI++MARKS AND NUMBERS:FOR MATERIAL 1: OUR PONUMBER: PO_123456' + //if (isbill != 1) + //{ + // Shipping = formatEdiStr("txt", bill.MARKS); + //} + //else + //{ + Shipping = formatEdiStr("txt", ctngood.MARKS); + //} + if (string.IsNullOrEmpty(ctngood.MARKS)) Shipping = formatEdiStr("txt", bill.MARKS); + + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + string[] MarksList = Shipping.Split('\\'); + if (MarksList.Length != 0) + { + for (var j = 0; j < MarksList.Length; j++) + { + r.WriteLine("PCI++" + MarksList[j] + "'"); + icount++; + } + } + if (!string.IsNullOrEmpty(bill.GOODSNCM)) + { + r.WriteLine("RFF+ABT:" + bill.GOODSNCM + "'"); + icount++; + } + // + + //SGP+MSCU1234567+100' + r.WriteLine("SGP+" + ctngood.CNTRNO + "+" + ctngood.PKGS.ToString() + "'"); + //MEA+AAE+WT+KGM:1000' + r.WriteLine("MEA+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngood.KGS), 3) + "'"); + //MEA+AAE+AAW+MTQ:50.11' + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(ctngood.CBM), 3) + "'"); + icount = icount + 3; + i = i + 1; + } + } + } + #endregion + + } + else + { + + #region 取集装箱分箱_货描、唛头信息 + + + var ctngoodssumlist = new List(); + foreach (var ctn in bill.CTNGOODSLIST) + { + var isfind = false; + ctngoodssumlist.ForEach(i => + { + if (i.HSCODE == ctn.HSCODE && i.KINDPKGS == ctn.KINDPKGS && i.DESCRIPTION == ctn.DESCRIPTION && i.MARKS == ctn.MARKS) + { + i.PKGS = i.PKGS + ctn.PKGS; + i.KGS = i.KGS + ctn.KGS; + i.CBM = i.CBM + ctn.CBM; + isfind = true; + } + }); + if (!isfind) + { + var ctnnum = new MsOpSeaeCtnDetailEDIBaseModel(); + ctnnum.HSCODE = ctn.HSCODE; + ctnnum.KINDPKGS = ctn.KINDPKGS; + ctnnum.KINDPKGS_EDI_CODE = ctn.KINDPKGS_EDI_CODE; + ctnnum.DESCRIPTION = ctn.DESCRIPTION; + ctnnum.MARKS = ctn.MARKS; + ctnnum.PKGS = ctn.PKGS; + ctnnum.KGS = ctn.KGS; + ctnnum.CBM = ctn.CBM; + ctngoodssumlist.Add(ctnnum); + } + } + + if (ctngoodssumlist != null) + { + if (ctngoodssumlist.Count > 0) + { + var goodct = 0; + foreach (var ctngoodsum in ctngoodssumlist) + { + //GID+1+400:CT::6:CARTONS' + r.WriteLine("GID+" + (goodct + 1) + "+" + ctngoodsum.PKGS.ToString() + ":" + ctngoodsum.KINDPKGS_EDI_CODE + "::6:" + ctngoodsum.KINDPKGS + "'"); + icount++; + //PIA+5+HS_CODE1:HS' + r.WriteLine("PIA+5+" + ctngoodsum.HSCODE + ":HS'"); + icount++; + //FTX+AAA+++MATERIAL 1' + //FTX+AAA+++HS-NO 39023012' + Shipping = formatEdiStr("txt", ctngoodsum.DESCRIPTION); + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + string[] DescriptionList = Shipping.Split('\\'); + if (DescriptionList.Length != 0) + { + for (var j = 0; j < DescriptionList.Length; j++) + { + r.WriteLine("FTX+AAA+++" + DescriptionList[j] + "'"); + icount++; + } + } + //MEA+AAE+WT+KGM:3000' + //MEA+AAE+AAW+MTQ:110.11' + r.WriteLine("MEA+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngoodsum.KGS), 3) + "'"); + icount++; + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(ctngoodsum.CBM), 3) + "'"); + icount++; + //PCI++MARKS AND NUMBERS:FOR MATERIAL 1: OUR PONUMBER: PO_123456' + //if (isbill != 1) + //{ + // Shipping = formatEdiStr("txt", bill.MARKS); + //} + //else + //{ + Shipping = formatEdiStr("txt", ctngoodsum.MARKS); + //} + + if (ctngoodsum.MARKS == "") Shipping = formatEdiStr("txt", bill.MARKS); + + + Shipping = Shipping.Replace("\n", "\\"); + Shipping = Shipping.Replace("\r", " "); + string[] MarksList = Shipping.Split('\\'); + if (MarksList.Length != 0) + { + for (var j = 0; j < MarksList.Length; j++) + { + r.WriteLine("PCI++" + MarksList[j] + "'"); + icount++; + } + } + if (!string.IsNullOrEmpty(bill.GOODSNCM)) + { + r.WriteLine("RFF+ABT:" + bill.GOODSNCM + "'"); + icount++; + } + goodct = goodct + 1; + bill.CTNGOODSLIST.ForEach(i => + { + if (i.HSCODE == ctngoodsum.HSCODE && i.KINDPKGS == ctngoodsum.KINDPKGS && i.DESCRIPTION == ctngoodsum.DESCRIPTION && i.MARKS == ctngoodsum.MARKS) + { + //SGP+MSCU1234567+100' + r.WriteLine("SGP+" + i.CNTRNO + "+" + i.PKGS.ToString() + "'"); + //MEA+AAE+WT+KGM:1000' + r.WriteLine("MEA+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(i.KGS), 3) + "'"); + //MEA+AAE+AAW+MTQ:50.11' + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(i.CBM), 3) + "'"); + icount = icount + 3; + } + }); + } + } + } + #endregion + } + + } + + if (bill.CARGOID == "D") + { + r.WriteLine("DGS+IMD+" + bill.DCLASS + "+" + bill.DUNNO + "'"); + r.WriteLine("CTA+HG+:" + bill.EDIATTN + "'"); + r.WriteLine("COM+" + bill.EDIATTNTEL + ":TE'"); + icount = icount + 3; + } + + #region 集装箱 主箱循环 + + foreach (var ctn in bill.CTNLIST) + { + if (bill.ISCONTAINERSOC) + r.WriteLine("EQD+CN+" + ctn.CNTRNO + "+" + ctn.CTNALLCODE + "+1'"); + else + r.WriteLine("EQD+CN+" + ctn.CNTRNO + "+" + ctn.CTNALLCODE + "+2'"); + r.WriteLine("MEA+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctn.KGS), 3) + "'"); + r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(ctn.CBM), 3) + "'"); + icount = icount + 3; + + if (bill.CARGOID == "R") + { + if (bill.REEFERF != "") + { + r.WriteLine("MEA+AAE+AAS+CBM:" + bill.REEFERF + "'"); + icount = icount + 1; + } + } + r.WriteLine("SEL+" + ctn.SEALNO + "+CA'"); + icount = icount + 1; + + if (bill.CARGOID == "R") + { + r.WriteLine("TMP+2+" + bill.TEMPSET + ":CEL'"); + icount = icount + 1; + } + + } + #endregion + } + r.WriteLine("UNT+" + icount.ToString() + "+" + bsno + "'"); + r.WriteLine("UNZ+" + InttrEdi.BSLIST.Count.ToString() + "+" + bsno + "'"); + r.Close(); + f.Close(); + + return result; + } + #endregion + } +} diff --git a/Myshipping.Application/Enum/EDIRouteEnum.cs b/Myshipping.Application/Enum/EDIRouteEnum.cs index 3d207807..e3a9638f 100644 --- a/Myshipping.Application/Enum/EDIRouteEnum.cs +++ b/Myshipping.Application/Enum/EDIRouteEnum.cs @@ -47,6 +47,10 @@ namespace Myshipping.Application /// /// 沃尔塔航运 /// - VOL + VOL, + /// + /// INTTRA + /// + INTTRA } } diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 48f281d3..23e2e794 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -8626,6 +8626,38 @@ namespace Myshipping.Application result.extra = currRlt.succ ? currRlt.extra.ToString() : ""; result.extra2 = currRlt.succ ? currRlt.extra2.ToString() : ""; } + else if (ediRouteEnum == EDIRouteEnum.INTTRA) + { + #region INTTRA + string strCheck = InttraEdiHelper.IsCreateINTTR(ediModel); + + _logger.LogInformation($"调用SO(SI),校验:{strCheck},数据对象:{JsonConvert.SerializeObject(ediModel)}"); + + if (!string.IsNullOrWhiteSpace(strCheck)) + { + if (Regex.IsMatch(strCheck, "\\")) + { + strCheck = Regex.Replace(strCheck, "\\", "\n"); + } + + throw Oops.Bah($"发送{EDIRouteEnum.ESL.ToString()}校验失败,{strCheck}"); + } + CommonWebApiResult currRlt = new CommonWebApiResult(); + + if (model.sendType == "B") + { + currRlt = InttraEdiHelper.CreateEdiINTTR(ediModel); + } + else if (model.sendType == "E") + { + currRlt = InttraEdiHelper.CreateEdiINTTRSI(ediModel); + } + + #endregion + + result.succ = currRlt.succ; + result.extra = currRlt.succ ? currRlt.extra.ToString() : ""; + } } catch (Exception ex) { diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index b93b4c35..dce4d948 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -1042,7 +1042,8 @@ namespace Myshipping.Application /// 舱位主键 /// 请求批次号用来区分对应的哪个批次任务 /// - private async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo) + [NonAction] + public async Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo) { string batchNo = IDGen.NextID().ToString(); @@ -1061,22 +1062,46 @@ namespace Myshipping.Application DateTime nowDate = DateTime.Now; - BookingSlotCompare entity = new BookingSlotCompare + var hisInfo = _bookingSlotCompareRepository.AsQueryable().First(a => a.COMPARE_BATCHNO == reqBatchNo); + + if (hisInfo == null) { - SLOT_ID = slotId, - COMPARE_BATCHNO = reqBatchNo, - COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff ? compareResult.extra.ShowDetailList.Count : 0, - CreatedTime = nowDate, - UpdatedTime = nowDate, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name, - UpdatedUserId = UserManager.UserId, - UpdatedUserName = UserManager.Name, - COMPARE_TYPE = "BC_MODIFY", - COMPARE_RLT = JSON.Serialize(compareResult.extra.ShowDetailList), - }; + BookingSlotCompare entity = new BookingSlotCompare + { + SLOT_ID = slotId, + COMPARE_BATCHNO = reqBatchNo, + COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff ? compareResult.extra.ShowDetailList.Count : 0, + CreatedTime = nowDate, + UpdatedTime = nowDate, + CreatedUserId = UserManager.UserId, + CreatedUserName = UserManager.Name, + UpdatedUserId = UserManager.UserId, + UpdatedUserName = UserManager.Name, + COMPARE_TYPE = "BC_MODIFY", + COMPARE_RLT = JSON.Serialize(compareResult.extra.ShowDetailList), + }; - await _bookingSlotCompareRepository.InsertAsync(entity); + await _bookingSlotCompareRepository.InsertAsync(entity); + } + else + { + hisInfo.COMPARE_DIFF_NUM = compareResult.extra.IsExistsDiff ? compareResult.extra.ShowDetailList.Count : 0; + hisInfo.UpdatedTime = nowDate; + hisInfo.UpdatedUserId = UserManager.UserId; + hisInfo.UpdatedUserName = UserManager.Name; + + hisInfo.COMPARE_RLT = JSON.Serialize(compareResult.extra.ShowDetailList); + + await _bookingSlotCompareRepository.AsUpdateable(hisInfo).UpdateColumns(it => + new + { + it.COMPARE_DIFF_NUM, + it.COMPARE_RLT, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); + } } #endregion @@ -1089,7 +1114,7 @@ namespace Myshipping.Application /// BC变更后详情 /// 返回回执 [NonAction] - private async Task ExcuteCompare(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto) + public async Task ExcuteCompare(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto) { TaskManageExcuteResultDto model = null; /* diff --git a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs index 81998ebd..1bac5974 100644 --- a/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs +++ b/Myshipping.Application/Service/BookingSlot/Dto/BookingSlotMapper.cs @@ -73,7 +73,35 @@ namespace Myshipping.Application .Map(dest => dest.TransferPort1, src => src.TRANSFER_PORT_1) .Map(dest => dest.TransferPort2, src => src.TRANSFER_PORT_2); - + config.ForType() + .Map(dest => dest.CarrierId, src => src.CarrierId) + .Map(dest => dest.Carrier, src => src.Carrier) + .Map(dest => dest.MBLNo, src => src.MBLNo) + .Map(dest => dest.BookingSlotType, src => src.BookingSlotType) + .Map(dest => dest.BookingSlotTypeName, src => src.BookingSlotTypeName) + .Map(dest => dest.Vessel, src => src.Vessel) + .Map(dest => dest.VoyNo, src => src.VoyNo) + .Map(dest => dest.VGMSubmissionCutDate, src => src.VGMCutoffTime.HasValue ? src.VGMCutoffTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.WeekAt, src => src.WeekAt) + .Map(dest => dest.CarriageType, src => src.CarriageType) + .Map(dest => dest.CarriageTypeName, src => src.CarriageTypeName) + .Map(dest => dest.ContractNo, src => src.ContractNo) + .Map(dest => dest.CtnStat, src => src.CtnStat) + .Map(dest => dest.CYCutoffTime, src => src.CYCutoffTime.HasValue ? src.CYCutoffTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.DetensionFreeDays, src => src.DetensionFreeDays) + .Map(dest => dest.ETD, src => src.ETD.HasValue ? src.ETD.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.ETA, src => src.ETA.HasValue ? src.ETA.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.LaneCode, src => src.LaneCode) + .Map(dest => dest.LaneName, src => src.LaneName) + .Map(dest => dest.ManifestCutDate, src => src.ManifestCutDate.HasValue ? src.ManifestCutDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.MDGFCutDate, src => src.MDGFCutDate.HasValue ? src.MDGFCutDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.SICutDate, src => src.SICutDate.HasValue ? src.SICutDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "") + .Map(dest => dest.PlaceDelivery, src => src.PlaceDelivery) + .Map(dest => dest.PlaceReceipt, src => src.PlaceReceipt) + .Map(dest => dest.PortDischarge, src => src.PortDischarge) + .Map(dest => dest.Portload, src => src.Portload) + .Map(dest => dest.TransferPort1, src => src.TransferPort1) + .Map(dest => dest.TransferPort2, src => src.TransferPort2); } } } diff --git a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs index 3f51f0ab..414a555f 100644 --- a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs @@ -128,5 +128,22 @@ namespace Myshipping.Application /// 返回回执 Task SendEmail(BookingSlotSendEmailDto model); + /// + /// 请求BC比对 + /// + /// BC详情 + /// BC变更后详情 + /// 返回回执 + Task ExcuteCompare(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto); + + /// + /// 推送BC变更比对 + /// + /// 原舱位详情 + /// 变更后舱位详情 + /// 舱位主键 + /// 请求批次号用来区分对应的哪个批次任务 + /// + Task PushCompareBCInfo(TaskBCInfoDto bcSrcDto, TaskBCInfoDto bcTargetDto, long slotId, string reqBatchNo); } } \ No newline at end of file diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/EmailBCReadMessageInfo.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/EmailBCReadMessageInfo.cs new file mode 100644 index 00000000..5e7a651e --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/EmailBCReadMessageInfo.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class EmailBCReadMessageInfo + { + /// + /// 表头 + /// + public TaskMessageHead Head { get; set; } + + /// + /// 表体 + /// + public EmailBCReadMessageMainInfo Main { get; set; } + } + + public class EmailBCReadMessageMainInfo + { + /// + /// 所属租户ID + /// + public string TenantId { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/ParserReaderExcuteResultDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/ParserReaderExcuteResultDto.cs new file mode 100644 index 00000000..e2813f15 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/ParserReaderExcuteResultDto.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class ParserReaderExcuteResultDto + { + /// + /// 是否成功 true=成功 false=失败 + /// + public bool succ { get; set; } = false; + + /// + /// 状态 0-成功 + /// + public int status { get; set; } = 0; + + /// + /// 返回消息 + /// + public string msg { get; set; } + + /// + /// 总记录数 + /// + public int total { get; set; } + + /// + /// 当前页列表数据 + /// + public object rows { get; set; } + + /// + /// 合计信息 + /// + public object summary { get; set; } + + /// + /// 扩展信息 + /// + public object extra { get; set; } + + /// + /// 扩展信息2 + /// + public object extra2 { get; set; } + + /// + /// 扩展信息场站统计 + /// + public object yardStatInfo { get; set; } + + /// + /// 是否异常 + /// + public bool exceptionflag { get; set; } + + /// + /// 生成HTML + /// + public string ResultHtml { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoReadDto.cs b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoReadDto.cs new file mode 100644 index 00000000..bc691466 --- /dev/null +++ b/Myshipping.Application/Service/TaskManagePlat/Dtos/TaskBCInfoReadDto.cs @@ -0,0 +1,417 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// + /// + public class TaskBCInfoReadDto + { + /// + /// 订舱单位 + /// + public string BookingParty { get; set; } + + /// + /// 发货人 + /// + public string Shipper { get; set; } + + /// + /// 收货人 + /// + public string Consignee { get; set; } + + /// + /// 通知人 + /// + public string NotifyParty { get; set; } + + /// + /// BC更新次数 + /// + public Nullable BCModifyTimes { get; set; } + + /// + /// BC更新时间 + /// + public Nullable BCModifyDate { get; set; } + + /// + /// 主单号 + /// + public string MBLNo { get; set; } + + /// + /// 船名 + /// + public string Vessel { get; set; } + + /// + /// 航次 + /// + public string VoyNo { get; set; } + + /// + /// 船公司 + /// + public string Carrier { get; set; } + + /// + /// 收货地 + /// + public string PlaceReceipt { get; set; } + + /// + /// 装货港 + /// + public string Portload { get; set; } + + /// + /// 截关时间 + /// + public Nullable ClosingDate { get; set; } + + /// + /// 截VGM时间 + /// + public Nullable VGMCutoffTime { get; set; } + + /// + /// ETA(预计到港时间) + /// + public Nullable ETA { get; set; } + + /// + /// ETD(预计离港时间) + /// + public Nullable ETD { get; set; } + + /// + /// 目的港ETA + /// + public Nullable PODETA { get; set; } + + /// + /// 截单时间 + /// + public Nullable CutSingleTime { get; set; } + + /// + /// 卸货港 + /// + public string PortDischarge { get; set; } + + /// + /// 交货地 + /// + public string PlaceDelivery { get; set; } + + /// + /// 装运方式 + /// + public string ShippingMethod { get; set; } + + /// + /// 运输条款 + /// + public string Service { get; set; } + + /// + /// 港前运输形态 + /// + public string PreTransMode { get; set; } + + /// + /// 品名 + /// + public string Description { get; set; } + + /// + /// 签单地点 + /// + public string IssuePlace { get; set; } + + /// + /// 集港码头 + /// + public string CollectionTerminal { get; set; } + + /// + /// 约号 + /// + public string ContractNo { get; set; } + + /// + /// 预付地点 + /// + public string PrepardAT { get; set; } + + /// + /// 船代 + /// + public string ShipAgent { get; set; } + + /// + /// 场站 + /// + public string Yard { get; set; } + + /// + /// 场站联系人 + /// + public string YardContactUserName { get; set; } + + /// + /// 场站联系电话 + /// + public string YardContactTel { get; set; } + + /// + /// 一代客服姓名 + /// + public string FstCustomerSerUserName { get; set; } + + /// + /// 一代客服电话 + /// + public string FstCustomerSerUserTel { get; set; } + + /// + /// 一代客服邮箱 + /// + public string FstCustomerSerUserEmail { get; set; } + + /// + /// 备注1 + /// + public string Remark1 { get; set; } + + /// + /// 截港时间 + /// + public Nullable CYCutoffTime { get; set; } + + /// + /// 状态 TEMP-暂存 SUCC-已对应 ERROR-异常 + /// + public string Status { get; set; } + + /// + /// 文件MD5 + /// + public string FileMD5 { get; set; } + + /// + /// 最后对应时间,最后关联到订舱日期 + /// + public Nullable LastToBookingDate { get; set; } + + /// + /// 来源邮箱 + /// + public string FromEmail { get; set; } + + /// + /// 接收邮箱 + /// + public string RecvEmail { get; set; } + + /// + /// 订舱ID,对应成功后,订舱ID写入 + /// + public Nullable BookingOrderId { get; set; } + + /// + /// 集装箱列表 + /// + public List CtnList { get; set; } + + /// + /// 顺序号 + /// + public int Indx { get; set; } + + /// + /// 对应订舱序号 + /// + public int BKOrderIndx { get; set; } + + /// + /// 舱位主键 + /// + public Nullable BookingSlotId { get; set; } + + /// + /// 船公司代号 + /// + public string CarrierId { get; set; } + + /// + /// 航线代码(船公司) + /// + public string LaneCode { get; set; } + + /// + /// 航线名称(船公司) + /// + public string LaneName { get; set; } + + /// + /// 承运方式 DIRECT_SHIP-直达;TRANSFER_SHIP-中转 + /// + public string CarriageType { get; set; } + + /// + /// 承运方式名称 DIRECT_SHIP-直达;TRANSFER_SHIP-中转 + /// + public string CarriageTypeName { get; set; } + + /// + /// 订舱方式 CONTRACT_ORDER-合约订舱;SPOT_ORDER-SPOT订舱 + /// + public string BookingSlotType { get; set; } + + /// + /// 订舱方式名称 CONTRACT_ORDER-合约订舱;SPOT_ORDER-SPOT订舱 + /// + public string BookingSlotTypeName { get; set; } + + /// + /// 箱型箱量 + /// + public string CtnStat { get; set; } + + /// + /// 所在周数 + /// + public string WeekAt { get; set; } + + /// + /// 箱使天数 + /// + public int DetensionFreeDays { get; set; } + + /// + /// 样单截止日期 + /// + public Nullable SICutDate { get; set; } + + + /// + /// 舱单截止时间 + /// + public Nullable ManifestCutDate { get; set; } + + /// + /// MDGF提交截止时间 + /// + public Nullable MDGFCutDate { get; set; } + + /// + /// 中转港1 + /// + public string TransferPort1 { get; set; } + + /// + /// 中转港2 + /// + public string TransferPort2 { get; set; } + + + /// + /// 二程船名 + /// + public string SecondVessel { get; set; } + + /// + /// 二程航次 + /// + public string SecondVoyno { get; set; } + + /// + /// 二程ETD + /// + public Nullable SecondETD { get; set; } + + /// + /// 二程ETA + /// + public Nullable SecondETA { get; set; } + + /// + /// 订舱确认时间 + /// + public Nullable BookingConfirmDate { get; set; } + } + + /// + /// 任务BC集装箱 + /// + public class TaskBCInfoReadCtnDto + { + /// + /// 箱型代码 + /// + public string CtnCode { get; set; } + + /// + /// 箱型 + /// + public string CtnALL { get; set; } + + /// + /// 箱量 + /// + public Nullable CTNNUM { get; set; } + + /// + /// 件数 + /// + public Nullable PKGS { get; set; } + + /// + /// 尺码 + /// + public Nullable CBM { get; set; } + + /// + /// 毛重 + /// + public Nullable KGS { get; set; } + + /// + /// 皮重 + /// + public Nullable TareWeight { get; set; } + + /// + /// 危品票标示 + /// + public string IODGT { get; set; } + + /// + /// 特殊装载需求 + /// + public string SpecialLoadingRequire { get; set; } + + /// + /// 提箱场站 + /// + public string TakeCTNYard { get; set; } + + /// + /// 提箱时间 + /// + public Nullable TakeCTNTime { get; set; } + + /// + /// 还箱场站 + /// + public string ReturnCTNYard { get; set; } + } +} diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs index 062af2bc..1ca0d748 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs @@ -105,5 +105,12 @@ namespace Myshipping.Application /// BC任务主键 /// 返回回执 Task SearchAndConnectBookingInfo(string taskPkId); + + /// + /// 重新比对 + /// + /// BC任务主键 + /// + Task ReCompareResult(string taskPKId); } } diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index a73681f3..65918ab5 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -30,9 +30,11 @@ using SqlSugar; using StackExchange.Profiling.Internal; using System; using System.Collections.Generic; +using System.Collections.Specialized; using System.IO; using System.Linq; using System.Net.Http; +using System.Net.Http.Headers; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Security.Principal; @@ -1664,7 +1666,7 @@ namespace Myshipping.Application if (fileInfo == null) { - throw Oops.Oh($"提取订舱的Booking Confirmation Notice文件失败,不能发送邮件"); + throw Oops.Oh($"提取变更文件失败,不能发送邮件"); } _logger.LogInformation($"获取订舱附件地址,结果:{fileInfo.FILE_PATH}"); @@ -2611,6 +2613,320 @@ namespace Myshipping.Application return result; } #endregion + + /// + /// 重新比对 + /// + /// BC任务主键 + /// + [HttpGet("/TaskManageBC/ReCompareResult")] + public async Task ReCompareResult(string taskPKId) + { + List list = new List(); + /* + 1、判断舱位是否存在,如果舱位不存在终止重新比对。 + 2、获取BookingConfirmation任务,如果不存在终止。 + 3、调取BookingConfirmation文件识别结果,与当前任务的文件识别重新比对。 + 4、更新到对应的舱位 + */ + + var baseTask = _taskBaseRepository.AsQueryable().First(a => a.PK_ID == taskPKId); + + if (baseTask == null) + { + throw Oops.Oh($"未提取有效的任务信息"); + } + + if (baseTask.TASK_TYPE != TaskBaseTypeEnum.BC_MODIFY.ToString()) + { + throw Oops.Oh($"任务类型不是Amendment不能重新比对"); + } + + var bcTaskInfo = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == taskPKId); + + if (bcTaskInfo == null) + { + throw Oops.Oh($"未提取有效的BC任务信息"); + } + + long slotId = 0; + string reqBatchNo = bcTaskInfo.BATCH_NO; + + var server = _namedBookingSlotServiceProvider.GetService(nameof(BookingSlotService)); + + //没有舱位先要匹配舱位,才能比对 + if (!bcTaskInfo.BOOKING_SLOT_ID.HasValue) + { + var searchInfo = await server.SearchBookingSlotWithOrderByNo(bcTaskInfo.MBL_NO); + + if (searchInfo != null) + { + if (searchInfo.HasBookingOrder) + { + bcTaskInfo.BOOKING_SLOT_ID = searchInfo.BookingSlotId; + bcTaskInfo.BOOKING_ORDER_ID = searchInfo.BookingOrderList.FirstOrDefault(); + bcTaskInfo.UpdatedTime = DateTime.Now; + bcTaskInfo.UpdatedUserId = UserManager.UserId; + bcTaskInfo.UpdatedUserName = UserManager.Name; + + await _taskBCInfoRepository.AsUpdateable(bcTaskInfo).UpdateColumns(it => new + { + it.BOOKING_SLOT_ID, + it.BOOKING_ORDER_ID, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); + } + else + { + bcTaskInfo.BOOKING_SLOT_ID = searchInfo.BookingSlotId; + bcTaskInfo.UpdatedTime = DateTime.Now; + bcTaskInfo.UpdatedUserId = UserManager.UserId; + bcTaskInfo.UpdatedUserName = UserManager.Name; + + await _taskBCInfoRepository.AsUpdateable(bcTaskInfo).UpdateColumns(it => new + { + it.BOOKING_SLOT_ID, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); + } + } + } + + var bcInfo = _taskBaseRepository.AsQueryable().Filter(null, true).Where(a => a.MBL_NO == bcTaskInfo.MBL_NO && a.CARRIER_ID == bcTaskInfo.CARRIERID + && a.TASK_TYPE == TaskBaseTypeEnum.BC.ToString() && a.IsDeleted == false && a.TenantId == UserManager.TENANT_ID).First(); + + if (bcInfo == null) + throw Oops.Oh($"未检索到对应的BC任务"); + + var modifyFile = _taskFileRepository.AsQueryable().First(a => a.TASK_PKID == taskPKId && a.FILE_CATEGORY == "BC_MODIFY"); + + if(modifyFile == null) + throw Oops.Oh($"未获取到当前任务的文件信息"); + + var bcFile = _taskFileRepository.AsQueryable().First(a => a.TASK_PKID == bcInfo.PK_ID && a.FILE_CATEGORY == "BC"); + + if (bcFile == null) + throw Oops.Oh($"未获取到当前任务对应BC的文件信息"); + + var modifyFileName = Path.GetFileName(modifyFile.FILE_PATH); + var bcFileName = Path.GetFileName(bcFile.FILE_PATH); + + var opt = App.GetOptions(); + var dirAbs = opt.basePath; + if (string.IsNullOrEmpty(dirAbs)) + { + dirAbs = App.WebHostEnvironment.WebRootPath; + } + + var modifyFileFullPath = Path.Combine(dirAbs, modifyFile.FILE_PATH); + if (!File.Exists(modifyFileFullPath)) + { + throw Oops.Oh("Amendment 文件提取失败"); + } + + var bcFileFullPath = Path.Combine(dirAbs, bcFile.FILE_PATH); + if (!File.Exists(bcFileFullPath)) + { + throw Oops.Oh("BC 文件提取失败"); + } + + TaskBCInfoReadDto modifyBCReadInfo = await GetBCReaderInfo(modifyFileFullPath, modifyFileName, UserManager.TENANT_ID, taskPKId, App.Configuration["BookingAmendReadWebApiUrl"]); + + if (modifyBCReadInfo == null) + throw Oops.Oh($"重新读取BC变更文件详情失败"); + + + + TaskBCInfoReadDto BCReadInfo = await GetBCReaderInfo(bcFileFullPath, bcFileName, UserManager.TENANT_ID, taskPKId, App.Configuration["BCReadWebApiUrl"]); + + if (BCReadInfo == null) + throw Oops.Oh($"重新读取BC文件详情失败"); + + + TaskBCInfoDto bcSrcDto = BCReadInfo.Adapt(); + TaskBCInfoDto bcTargetDto = modifyBCReadInfo.Adapt(); + + if (BCReadInfo.CtnList != null && BCReadInfo.CtnList.Count > 0) + { + bcSrcDto.CtnList = BCReadInfo.CtnList.GroupBy(x => x.CtnALL) + .Select(x => + { + return new TaskBCCTNInfoDto + { + CtnALL = x.Key, + CTNNUM = x.ToList() + .Sum(a => a.CTNNUM) + }; + }).ToList(); + } + + if (modifyBCReadInfo.CtnList != null && modifyBCReadInfo.CtnList.Count > 0) + { + bcTargetDto.CtnList = modifyBCReadInfo.CtnList.GroupBy(x => x.CtnALL) + .Select(x => + { + return new TaskBCCTNInfoDto + { + CtnALL = x.Key, + CTNNUM = x.ToList() + .Sum(a => a.CTNNUM) + }; + }).ToList(); + } + + _logger.LogInformation($"触发比对差异开始,reqBatchNo={reqBatchNo}"); + + //比对差异 + await server.PushCompareBCInfo(bcSrcDto, bcTargetDto, slotId, reqBatchNo); + + _logger.LogInformation($"触发比对差异结束,reqBatchNo={reqBatchNo}"); + } + + #region 读BC详情详情 + /// + /// 读BC详情详情 + /// + /// 文件完整路径 + /// 文件名称 + /// 所属租户 + /// 任务ID + /// 请求URL + /// + private async Task GetBCReaderInfo(string attachFullName, string fileName, long tenantId,string taskPKId,string url) + { + TaskBCInfoReadDto taskBCInfoReadDto = null; + + try + { + DateTime nowDate = DateTime.Now; + + EmailBCReadMessageInfo messageInfo = new EmailBCReadMessageInfo + { + Head = new TaskMessageHead + { + GID = IDGen.NextID().ToString(), + MessageType = "BOOKING_AMENDMENT", + SenderId = "DJY", + SenderName = "新大简云", + ReceiverId = "RulesEngine", + ReceiverName = "大简云规则引擎", + Version = "1.0", + RequestDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss"), + RequestAction = "ReadFile", + }, + Main = new EmailBCReadMessageMainInfo + { + TenantId = tenantId > 0 ? tenantId.ToString() : "" + } + }; + + NameValueCollection par = new NameValueCollection(); + par.Add("jsonData", JSON.Serialize(messageInfo)); + + //解析BookingAmendment + var compareRlt = await ExcuteReadFile(par, url,new + { + file = "file", + fileName = fileName, + fileBytes = File.ReadAllBytes(attachFullName) + }); + + _logger.LogInformation($"读取BC附件详情 taskPKId={taskPKId},compareRlt={JSON.Serialize(compareRlt)}"); + + if (compareRlt.succ) + { + taskBCInfoReadDto = JSON.Deserialize(JSON.Serialize(compareRlt.extra)); + } + } + catch (Exception ex) + { + _logger.LogError($"读取BC附件详情异常,原因:{ex.Message}"); + } + + return taskBCInfoReadDto; + } + #endregion + + #region 请求BookingAmendment解析 + /// + /// 请求BookingAmendment解析 + /// + /// 请求参数 + /// 请求url + /// 文件 + /// 请求类型 + /// 返回回执 + [NonAction] + private async Task ExcuteReadFile(NameValueCollection nameValueCollection, string url,dynamic fileInfo, + string contentType = "application/json") + { + ParserReaderExcuteResultDto model = null; + var result = string.Empty; + + using (var httpClient = new HttpClient()) + { + try + { + using (var reduceAttach = new MultipartFormDataContent()) + { + string[] allKeys = nameValueCollection.AllKeys; + foreach (string key in allKeys) + { + var dataContent = new ByteArrayContent(Encoding.UTF8.GetBytes(nameValueCollection[key])); + + dataContent.Headers.ContentDisposition = new ContentDispositionHeaderValue($"form-data") + { + Name = key + }; + + reduceAttach.Add(dataContent); + } + + #region 文件参数 + if (fileInfo != null) + { + var Content = new ByteArrayContent(fileInfo.fileBytes); + + //Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") + //{ + // Name = fileInfo.file.ToString(), + // FileName = fileInfo.fileName.ToString(), + + //}; + + Content.Headers.Add("Content-Type", contentType); + + reduceAttach.Add(Content, fileInfo.file.ToString(), HttpUtility.UrlEncode(fileInfo.fileName.ToString())); + } + #endregion + + //httpClient.DefaultRequestHeaders.Add("USER_KEY", App.Configuration["ApiUserKey"]); + //httpClient.DefaultRequestHeaders.Add("USER_SECRET", App.Configuration["ApiUserSecret"]); + //请求 + var response = httpClient.PostAsync(url, reduceAttach).Result; + result = response.Content.ReadAsStringAsync().Result; + + model = JSON.Deserialize(result); + } + } + catch (Exception ex) + { + _logger.LogInformation("请求读取BC附件详情读取详情异常,原因:{error}", ex.Message); + + throw Oops.Oh($"请求读取BC附件详情读取详情异常,原因:{ex.Message}"); + + } + + } + return model; + } + #endregion + + } /// diff --git a/Myshipping.Web.Core/applicationconfig.json b/Myshipping.Web.Core/applicationconfig.json index 2355f0cb..fc12bf3d 100644 --- a/Myshipping.Web.Core/applicationconfig.json +++ b/Myshipping.Web.Core/applicationconfig.json @@ -136,5 +136,7 @@ "BCCompareUrl": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentCompare", "MSKAPIDjyUserKey": "wu", "MSKAPIDjyUserSecret": "123456", - "MSKAPIOPEnvironment": "TEST" + "MSKAPIOPEnvironment": "TEST", + "BCReadWebApiUrl": "http://localhost:5110/api/TaskBCParser/ExcuteBCFileRead", + "BookingAmendReadWebApiUrl": "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentRead" } \ No newline at end of file From ed908f11d71e48a5d250957d7894debe5fc2732a Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 3 Apr 2024 12:52:28 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E8=BD=AC=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TaskManagePlat/TaskManageBCService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index 65918ab5..084178d5 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -2193,7 +2193,7 @@ namespace Myshipping.Application emailApiUserDefinedDto.Attaches.Add(new AttachesInfo { - AttachName = Path.GetFileName(filePath), + AttachName = Path.GetFileName(filePath).Replace("_MODIFY",""), AttachContent = base64Str }); From e8615ce4d17b2b8a007fc9c8aa4758edb769038a Mon Sep 17 00:00:00 2001 From: wanghaomei <86whm@163.com> Date: Wed, 3 Apr 2024 14:20:15 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=9B=BD=E5=AE=B6=E5=8C=BA=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EDI/ZhongYuanSoApiHelper.cs | 200 ++++++++++++++++ .../BookingSoTemplate/BookingSoTemplate.cs | 222 ++++++++++-------- .../Dto/BookingSoTemplateDto.cs | 20 ++ 3 files changed, 345 insertions(+), 97 deletions(-) create mode 100644 Myshipping.Application/EDI/ZhongYuanSoApiHelper.cs diff --git a/Myshipping.Application/EDI/ZhongYuanSoApiHelper.cs b/Myshipping.Application/EDI/ZhongYuanSoApiHelper.cs new file mode 100644 index 00000000..f249bb88 --- /dev/null +++ b/Myshipping.Application/EDI/ZhongYuanSoApiHelper.cs @@ -0,0 +1,200 @@ +using Furion; +using Myshipping.Application.Entity; +using Myshipping.Core; +using Myshipping.Core.Service; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.EDI +{ + /// + /// 中远API订舱 + /// + public static class ZhongYuanSoApiHelper + { + public async static Task> DoPost(long bookingId) + { + var repCustOrder = App.GetService>(); + var repOrder = App.GetService>(); + var repCtn = App.GetService>(); + + var cacheService = App.GetService(); + + var order = repOrder.FirstOrDefault(o => o.Id == bookingId); + if (order == null) + { + return new KeyValuePair(false, "订舱信息未找到"); + } + + + + return new KeyValuePair(); + } + } + + public class ZhongYuanSoApiModel + { + /// + /// 用户key + /// + public string userKey { get; set; } + + /// + /// 用户secret + /// + public string userSecret { get; set; } + + /// + /// 网站账户 + /// + public string webAccount { get; set; } + + /// + /// 网站密码 + /// + public string webPassword { get; set; } + + /// + /// 上传类型 + /// + public string uploadType { get; set; } + + /// + /// 在选择草稿及模板时, 保存时填写的名称 + /// + public string saveName { get; set; } + + /// + /// 在选择草稿及模板时的描述 + /// + public string saveDes { get; set; } + + /// + /// 路线信息 + /// + public ZhongYuanSoApiRoute routes { get; set; } + + /// + /// 发货人信息 + /// + public string shipperInfo { get; set; } + + /// + /// 收货人信息 + /// + public string consigneeInfo { get; set; } + + /// + /// 通知人信息 + /// + public string notifyInfo { get; set; } + + /// + /// 货代信息 + /// + public string forwarderInfo { get; set; } + } + + public class ZhongYuanSoApiRoute + { + /// + /// 出发城市 + /// + public string originCity { get; set; } + + /// + /// 目的城市 + /// + public string destinationCity { get; set; } + + /// + /// 船名 + /// + public string vesselName { get; set; } + + /// + /// 航次 + /// + public string voyageNumber { get; set; } + + /// + /// 航线代码 + /// + public string serviceCode { get; set; } + } + + public class ZhongYuanSoApiSFT + { + /// + /// 名字 + /// + public string partyName { get; set; } + + /// + /// 国家 + /// + public string country { get; set; } + + /// + /// 省 + /// + public string state { get; set; } + + /// + /// 城市名 + /// + public string city { get; set; } + + /// + /// 区 + /// + public string county { get; set; } + + /// + /// 详细地址 + /// + public string addressDes { get; set; } + + /// + /// 邮编 + /// + public string postalCode { get; set; } + + /// + /// 姓 + /// + public string firstName { get; set; } + + /// + /// 名 + /// + public string lastName { get; set; } + + /// + /// 电话 + /// + public ZhongYuanSoApiPhone phone { get; set; } + } + + public class ZhongYuanSoApiPhone + { + + /// + /// 国家代码 + /// + public string countryCode { get; set; } + + /// + /// 区号 + /// + public string areaCode { get; set; } + + /// + /// 电话号码 + /// + public string number { get; set; } + } +} diff --git a/Myshipping.Application/Entity/BookingSoTemplate/BookingSoTemplate.cs b/Myshipping.Application/Entity/BookingSoTemplate/BookingSoTemplate.cs index b88dfe3f..d6e9f7c1 100644 --- a/Myshipping.Application/Entity/BookingSoTemplate/BookingSoTemplate.cs +++ b/Myshipping.Application/Entity/BookingSoTemplate/BookingSoTemplate.cs @@ -93,343 +93,371 @@ namespace Myshipping.Application.Entity [SugarColumn(ColumnName = "Priority")] [Description("优先级")] public string Priority{ get; set; } - + /// /// 发货人名称 /// [SugarColumn(ColumnName = "ShipperName")] [Description("发货人名称")] - public string ShipperName{ get; set; } - + public string ShipperName { get; set; } + /// /// 发货人地址 /// [SugarColumn(ColumnName = "ShipperAddress")] [Description("发货人地址")] - public string ShipperAddress{ get; set; } - + public string ShipperAddress { get; set; } + /// /// 发货人国家 /// [SugarColumn(ColumnName = "ShipperCountry")] [Description("发货人国家")] - public string ShipperCountry{ get; set; } - + public string ShipperCountry { get; set; } + /// /// 发货人省份 /// [SugarColumn(ColumnName = "ShipperProvince")] [Description("发货人省份")] - public string ShipperProvince{ get; set; } - + public string ShipperProvince { get; set; } + /// /// 发货人城市 /// [SugarColumn(ColumnName = "ShipperCity")] [Description("发货人城市")] - public string ShipperCity{ get; set; } - + public string ShipperCity { get; set; } + /// /// 发货人区县 /// [SugarColumn(ColumnName = "ShipperCounty")] [Description("发货人区县")] - public string ShipperCounty{ get; set; } - + public string ShipperCounty { get; set; } + /// /// 发货人邮政编码 /// [SugarColumn(ColumnName = "ShipperPostCode")] [Description("发货人邮政编码")] - public string ShipperPostCode{ get; set; } - + public string ShipperPostCode { get; set; } + /// /// 发货人联系人名 /// [SugarColumn(ColumnName = "ShipperFirstName")] [Description("发货人联系人名")] - public string ShipperFirstName{ get; set; } - + public string ShipperFirstName { get; set; } + /// /// 发货人联系人姓 /// [SugarColumn(ColumnName = "ShipperLastName")] [Description("发货人联系人姓")] - public string ShipperLastName{ get; set; } - + public string ShipperLastName { get; set; } + + /// + /// 发货人电话国家代码 + /// + [SugarColumn(ColumnName = "ShipperPhoneCountryCode")] + [Description("发货人电话国家代码")] + public string ShipperPhoneCountryCode { get; set; } + /// /// 发货人电话区号 /// [SugarColumn(ColumnName = "ShipperPhoneCode")] [Description("发货人电话区号")] - public string ShipperPhoneCode{ get; set; } - + public string ShipperPhoneCode { get; set; } + /// /// 发货人电话 /// [SugarColumn(ColumnName = "ShipperPhone")] [Description("发货人电话")] - public string ShipperPhone{ get; set; } - + public string ShipperPhone { get; set; } + /// /// 发货人分机号 /// [SugarColumn(ColumnName = "ShipperPhoneExtension")] [Description("发货人分机号")] - public string ShipperPhoneExtension{ get; set; } - + public string ShipperPhoneExtension { get; set; } + /// /// 收货人名称 /// [SugarColumn(ColumnName = "ConsigneeName")] [Description("收货人名称")] - public string ConsigneeName{ get; set; } - + public string ConsigneeName { get; set; } + /// /// 收货人地址 /// [SugarColumn(ColumnName = "ConsigneeAddress")] [Description("收货人地址")] - public string ConsigneeAddress{ get; set; } - + public string ConsigneeAddress { get; set; } + /// /// 收货人国家 /// [SugarColumn(ColumnName = "ConsigneeCountry")] [Description("收货人国家")] - public string ConsigneeCountry{ get; set; } - + public string ConsigneeCountry { get; set; } + /// /// 收货人省份 /// [SugarColumn(ColumnName = "ConsigneeProvince")] [Description("收货人省份")] - public string ConsigneeProvince{ get; set; } - + public string ConsigneeProvince { get; set; } + /// /// 收货人城市 /// [SugarColumn(ColumnName = "ConsigneeCity")] [Description("收货人城市")] - public string ConsigneeCity{ get; set; } - + public string ConsigneeCity { get; set; } + /// /// 收货人区县 /// [SugarColumn(ColumnName = "ConsigneeCounty")] [Description("收货人区县")] - public string ConsigneeCounty{ get; set; } - + public string ConsigneeCounty { get; set; } + /// /// 收货人邮政编码 /// [SugarColumn(ColumnName = "ConsigneePostCode")] [Description("收货人邮政编码")] - public string ConsigneePostCode{ get; set; } - + public string ConsigneePostCode { get; set; } + /// /// 收货人联系人名 /// [SugarColumn(ColumnName = "ConsigneeFirstName")] [Description("收货人联系人名")] - public string ConsigneeFirstName{ get; set; } - + public string ConsigneeFirstName { get; set; } + /// /// 收货人联系人姓 /// [SugarColumn(ColumnName = "ConsigneeLastName")] [Description("收货人联系人姓")] - public string ConsigneeLastName{ get; set; } - + public string ConsigneeLastName { get; set; } + + /// + /// 收货人电话国家代码 + /// + [SugarColumn(ColumnName = "ConsigneePhoneCountryCode")] + [Description("收货人电话国家代码")] + public string ConsigneePhoneCountryCode { get; set; } + /// /// 收货人电话区号 /// [SugarColumn(ColumnName = "ConsigneePhoneCode")] [Description("收货人电话区号")] - public string ConsigneePhoneCode{ get; set; } - + public string ConsigneePhoneCode { get; set; } + /// /// 收货人电话 /// [SugarColumn(ColumnName = "ConsigneePhone")] [Description("收货人电话")] - public string ConsigneePhone{ get; set; } - + public string ConsigneePhone { get; set; } + /// /// 收货人分机号 /// [SugarColumn(ColumnName = "ConsigneePhoneExtension")] [Description("收货人分机号")] - public string ConsigneePhoneExtension{ get; set; } - + public string ConsigneePhoneExtension { get; set; } + /// /// 通知人名称 /// [SugarColumn(ColumnName = "NotifypartName")] [Description("通知人名称")] - public string NotifypartName{ get; set; } - + public string NotifypartName { get; set; } + /// /// 通知人地址 /// [SugarColumn(ColumnName = "NotifypartAddress")] [Description("通知人地址")] - public string NotifypartAddress{ get; set; } - + public string NotifypartAddress { get; set; } + /// /// 通知人国家 /// [SugarColumn(ColumnName = "NotifypartCountry")] [Description("通知人国家")] - public string NotifypartCountry{ get; set; } - + public string NotifypartCountry { get; set; } + /// /// 通知人省份 /// [SugarColumn(ColumnName = "NotifypartProvince")] [Description("通知人省份")] - public string NotifypartProvince{ get; set; } - + public string NotifypartProvince { get; set; } + /// /// 通知人城市 /// [SugarColumn(ColumnName = "NotifypartCity")] [Description("通知人城市")] - public string NotifypartCity{ get; set; } - + public string NotifypartCity { get; set; } + /// /// 通知人区县 /// [SugarColumn(ColumnName = "NotifypartCounty")] [Description("通知人区县")] - public string NotifypartCounty{ get; set; } - + public string NotifypartCounty { get; set; } + /// /// 通知人邮政编码 /// [SugarColumn(ColumnName = "NotifypartPostCode")] [Description("通知人邮政编码")] - public string NotifypartPostCode{ get; set; } - + public string NotifypartPostCode { get; set; } + /// /// 通知人联系人名 /// [SugarColumn(ColumnName = "NotifypartFirstName")] [Description("通知人联系人名")] - public string NotifypartFirstName{ get; set; } - + public string NotifypartFirstName { get; set; } + /// /// 通知人联系人姓 /// [SugarColumn(ColumnName = "NotifypartLastName")] [Description("通知人联系人姓")] - public string NotifypartLastName{ get; set; } - + public string NotifypartLastName { get; set; } + + /// + /// 通知人电话国家代码 + /// + [SugarColumn(ColumnName = "NotifypartPhoneCountryCode")] + [Description("通知人电话国家代码")] + public string NotifypartPhoneCountryCode { get; set; } + /// /// 通知人电话区号 /// [SugarColumn(ColumnName = "NotifypartPhoneCode")] [Description("通知人电话区号")] - public string NotifypartPhoneCode{ get; set; } - + public string NotifypartPhoneCode { get; set; } + /// /// 通知人电话 /// [SugarColumn(ColumnName = "NotifypartPhone")] [Description("通知人电话")] - public string NotifypartPhone{ get; set; } - + public string NotifypartPhone { get; set; } + /// /// 通知人分机号 /// [SugarColumn(ColumnName = "NotifypartPhoneExtension")] [Description("通知人分机号")] - public string NotifypartPhoneExtension{ get; set; } - + public string NotifypartPhoneExtension { get; set; } + /// /// 订舱公司名称 /// [SugarColumn(ColumnName = "BookingName")] [Description("订舱公司名称")] - public string BookingName{ get; set; } - + public string BookingName { get; set; } + /// /// 订舱公司地址 /// [SugarColumn(ColumnName = "BookingAddress")] [Description("订舱公司地址")] - public string BookingAddress{ get; set; } - + public string BookingAddress { get; set; } + /// /// 订舱公司国家 /// [SugarColumn(ColumnName = "BookingCountry")] [Description("订舱公司国家")] - public string BookingCountry{ get; set; } - + public string BookingCountry { get; set; } + /// /// 订舱公司省份 /// [SugarColumn(ColumnName = "BookingProvince")] [Description("订舱公司省份")] - public string BookingProvince{ get; set; } - + public string BookingProvince { get; set; } + /// /// 订舱公司城市 /// [SugarColumn(ColumnName = "BookingCity")] [Description("订舱公司城市")] - public string BookingCity{ get; set; } - + public string BookingCity { get; set; } + /// /// 订舱公司区县 /// [SugarColumn(ColumnName = "BookingCounty")] [Description("订舱公司区县")] - public string BookingCounty{ get; set; } - + public string BookingCounty { get; set; } + /// /// 订舱公司邮政编码 /// [SugarColumn(ColumnName = "BookingPostCode")] [Description("订舱公司邮政编码")] - public string BookingPostCode{ get; set; } - + public string BookingPostCode { get; set; } + /// /// 订舱公司联系人名 /// [SugarColumn(ColumnName = "BookingFirstName")] [Description("订舱公司联系人名")] - public string BookingFirstName{ get; set; } - + public string BookingFirstName { get; set; } + /// /// 订舱公司联系人姓 /// [SugarColumn(ColumnName = "BookingLastName")] [Description("订舱公司联系人姓")] - public string BookingLastName{ get; set; } - + public string BookingLastName { get; set; } + + /// + /// 订舱公司电话国家代码 + /// + [SugarColumn(ColumnName = "BookingPhoneCountryCode")] + [Description("订舱公司电话国家代码")] + public string BookingPhoneCountryCode { get; set; } + /// /// 订舱公司电话区号 /// [SugarColumn(ColumnName = "BookingPhoneCode")] [Description("订舱公司电话区号")] - public string BookingPhoneCode{ get; set; } - + public string BookingPhoneCode { get; set; } + /// /// 订舱公司电话 /// [SugarColumn(ColumnName = "BookingPhone")] [Description("订舱公司电话")] - public string BookingPhone{ get; set; } - + public string BookingPhone { get; set; } + /// /// 订舱公司分机号 /// [SugarColumn(ColumnName = "BookingPhoneExtension")] [Description("订舱公司分机号")] - public string BookingPhoneExtension{ get; set; } - + public string BookingPhoneExtension { get; set; } + /// /// 品名货描 /// diff --git a/Myshipping.Application/Service/BookingSoTemplate/Dto/BookingSoTemplateDto.cs b/Myshipping.Application/Service/BookingSoTemplate/Dto/BookingSoTemplateDto.cs index 3a0c8fa1..7395cfa5 100644 --- a/Myshipping.Application/Service/BookingSoTemplate/Dto/BookingSoTemplateDto.cs +++ b/Myshipping.Application/Service/BookingSoTemplate/Dto/BookingSoTemplateDto.cs @@ -117,6 +117,11 @@ namespace Myshipping.Application /// public string ShipperLastName { get; set; } + /// + /// 发货人电话国家代码 + /// + public string ShipperPhoneCountryCode { get; set; } + /// /// 发货人电话区号 /// @@ -177,6 +182,11 @@ namespace Myshipping.Application /// public string ConsigneeLastName { get; set; } + /// + /// 收货人电话国家代码 + /// + public string ConsigneePhoneCountryCode { get; set; } + /// /// 收货人电话区号 /// @@ -237,6 +247,11 @@ namespace Myshipping.Application /// public string NotifypartLastName { get; set; } + /// + /// 通知人电话国家代码 + /// + public string NotifypartPhoneCountryCode { get; set; } + /// /// 通知人电话区号 /// @@ -297,6 +312,11 @@ namespace Myshipping.Application /// public string BookingLastName { get; set; } + /// + /// 订舱公司电话国家代码 + /// + public string BookingPhoneCountryCode { get; set; } + /// /// 订舱公司电话区号 /// From dcb307705b92176083dc4786635b5cdb58f6c5c9 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Thu, 4 Apr 2024 08:38:48 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A9=AC=E5=A3=AB?= =?UTF-8?q?=E5=9F=BAAPI=E8=AE=A2=E8=88=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookingOrder/BookingMSKAPIService.cs | 2 + .../TaskManagePlat/TaskManageBCService.cs | 204 ++++++++++++++---- .../Entities/TaskBCEntity.cs | 37 ++++ ServiceProjectSyncWin/Program.cs | 11 +- 4 files changed, 213 insertions(+), 41 deletions(-) create mode 100644 ServiceProjectSyncWin/Entities/TaskBCEntity.cs diff --git a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs index b4b10f48..987e7efa 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingMSKAPIService.cs @@ -520,6 +520,8 @@ namespace Myshipping.Application.Service.BookingOrder result.succ = false; result.msg = $"MSK API订舱失败,{ex.Message}"; + + throw Oops.Bah($"MSK API订舱失败,{ex.Message}"); } return result; diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index 084178d5..7532d197 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -80,6 +80,7 @@ namespace Myshipping.Application private readonly IBookingValueAddedService _bookingValueAddedService; private readonly IDjyCustomerService _djyCustomerService; private readonly INamedServiceProvider _namedBookingMSKAPIServiceProvider; + private readonly IDjyTenantParamService _djyTenantParamService; private readonly INamedServiceProvider _namedBookingSlotServiceProvider; @@ -89,6 +90,17 @@ namespace Myshipping.Application const string CONST_BC_NOTICE_FILE_CODE = "bc_notice"; const string CONST_BC_NOTICE_FILE_NAME = "Booking Confirmation Notice"; + //租户BC默认转发KEY + const string CONST_BC_DEFAULT_PARAM = "BC_TASK_AUTO_TRANSMIT"; + //租户AMENDMENT默认转发KEY + const string CONST_AMENDMENT_DEFAULT_PARAM = "AMENDMENT_TASK_AUTO_TRANSMIT"; + //租户CANCELLATION默认转发KEY + const string CONST_CANCELLATION_DEFAULT_PARAM = "CANCELLATION_TASK_AUTO_TRANSMIT"; + //租户AMENDMENT默认钉钉消息KEY + const string CONST_AMENDMENT_DING_DEFAULT_PARAM = "AMENDMENT_TASK_DING_NOTICE"; + //租户CANCELLATION默认钉钉消息KEY + const string CONST_CANCELLATION_DING_DEFAULT_PARAM = "CANCELLATION_TASK_DING_NOTICE"; + public TaskManageBCService(SqlSugarRepository taskBCInfoRepository, SqlSugarRepository taskBaseRepository, SqlSugarRepository taskBCCTNInfoRepository, @@ -104,6 +116,7 @@ namespace Myshipping.Application IBookingSlotService bookingSlotService, ISysCacheService cache, IBookingValueAddedService bookingValueAddedService, INamedServiceProvider namedBookingSlotServiceProvider, INamedServiceProvider namedBookingMSKAPIServiceProvider, + IDjyTenantParamService djyTenantParamService, SqlSugarRepository bookingSlotBaseRepository, SqlSugarRepository bookingSlotBaseCtnRepository, SqlSugarRepository bookingSlotAllocationRepository, @@ -135,6 +148,7 @@ namespace Myshipping.Application _bookingSlotAllocationCtnRepository = bookingSlotAllocationCtnRepository; _namedBookingMSKAPIServiceProvider = namedBookingMSKAPIServiceProvider; _namedBookingSlotServiceProvider = namedBookingSlotServiceProvider; + _djyTenantParamService = djyTenantParamService; _logger = logger; } @@ -2308,66 +2322,161 @@ namespace Myshipping.Application TaskManageOrderResultDto result = new TaskManageOrderResultDto(); /* - 1、检索对应舱位,提取比对差异结果 - 2、检索舱位对应的订舱信息,如果有则生成用户通知邮件 - 3、推送钉钉消息@操作人 通知收到变更 + * Amendment + 1、需要先匹配舱位,如果没有舱位不能执行后续的步骤。 + 2、判断当前租户是否配置了自动转发客户邮件。 + 3、如果配置了自动转发,需要判断订舱是否已有,没有不能执行自动转发。 + 4、转发需要提取差异数据,如果没有差异数据也不能转发邮件。 + 5、默认通过钉钉通知操作收到了变更通知。 + * Cancellation + 1、需要先匹配舱位,如果没有舱位不能执行后续的步骤。 + 2、判断当前租户是否配置了自动转发客户邮件。 + 3、如果配置了自动转发,需要判断订舱是否已有,没有不能执行自动转发。 + 4、转发需要提取差异数据,如果没有差异数据也不能转发邮件。 */ try { + var baseTask = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId); + if (baseTask == null) + throw Oops.Oh($"主任务获取失败,不存在或已作废"); + var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == taskPKId); if (bcOrder == null) - throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息"); + throw Oops.Oh($"BC任务获取失败,不存在或已作废"); - - if(bcOrder.BOOKING_SLOT_ID.HasValue && bcOrder.BOOKING_SLOT_ID.Value > 0) + if (!bcOrder.BOOKING_SLOT_ID.HasValue || bcOrder.BOOKING_SLOT_ID.Value == 0) { - var slotInfo = await _bookingSlotBaseRepository.AsQueryable() - .FirstAsync(t => t.Id == bcOrder.BOOKING_SLOT_ID.Value); + var server = _namedBookingSlotServiceProvider.GetService(nameof(BookingSlotService)); + var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO).GetAwaiter().GetResult(); - if(slotInfo != null) + if (slotModel != null && slotModel.BookingSlotId > 0) { - //查询对应的订舱信息 - var slotAlloc = await _bookingSlotAllocationRepository.AsQueryable() - .FirstAsync(a => a.BOOKING_SLOT_ID == slotInfo.Id && a.IsDeleted == false); + if (slotModel.HasBookingOrder) + { + bcOrder.BOOKING_SLOT_ID = slotModel.BookingSlotId; + bcOrder.BOOKING_ORDER_ID = slotModel.BookingOrderList.FirstOrDefault(); + bcOrder.UpdatedTime = DateTime.Now; + bcOrder.UpdatedUserId = UserManager.UserId; + bcOrder.UpdatedUserName = UserManager.Name; - if (slotAlloc != null && slotAlloc.BOOKING_ID > 0) + await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new + { + it.BOOKING_SLOT_ID, + it.BOOKING_ORDER_ID, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); + } + else { - //查询订舱记录 - var bookingInfo = _bookingOrderRepository.AsQueryable() - .FirstAsync(a => a.Id == slotAlloc.BOOKING_ID && a.IsDeleted == false); + bcOrder.BOOKING_SLOT_ID = slotModel.BookingSlotId; + bcOrder.UpdatedTime = DateTime.Now; + bcOrder.UpdatedUserId = UserManager.UserId; + bcOrder.UpdatedUserName = UserManager.Name; - //如果订舱记录推送客户邮件 + await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new + { + it.BOOKING_SLOT_ID, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); + } + + if (baseTask != null) + { + if (baseTask.IS_PUBLIC == 1) + { + baseTask.IS_PUBLIC = 0; + baseTask.RealUserId = UserManager.UserId; + baseTask.RealUserName = UserManager.Name; + baseTask.UpdatedTime = DateTime.Now; + baseTask.UpdatedUserId = UserManager.UserId; + baseTask.UpdatedUserName = UserManager.Name; + + //更新任务台,将当前任务变更为个人任务 + await _taskBaseRepository.AsUpdateable(baseTask).UpdateColumns(it => new + { + it.IS_PUBLIC, + it.RealUserId, + it.RealUserName, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + + }).ExecuteCommandAsync(); + } } } + else + { + throw Oops.Oh($"无法获取舱位信息"); + } + } - /* - 推送钉钉消息给相关的操作OP - */ + DjyTenantParamValueOutput paramConfig = null; + DjyTenantParamValueOutput dingdingConfig = null; + + var paramList = _djyTenantParamService.GetParaCodeWithValue(new[] { CONST_AMENDMENT_DEFAULT_PARAM, + CONST_CANCELLATION_DEFAULT_PARAM, + CONST_AMENDMENT_DING_DEFAULT_PARAM, + CONST_CANCELLATION_DING_DEFAULT_PARAM }).GetAwaiter().GetResult(); - //如果有舱位只能推送钉钉消息 - //var bcCtnList = _taskBCCTNInfoRepository.AsQueryable().Where(a => a.P_ID == bcOrder.PK_ID).ToList(); + if (baseTask.TASK_TYPE == TaskBaseTypeEnum.BC_MODIFY.ToString()) + { + if (paramList != null && paramList.Count > 0) + { + paramConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_AMENDMENT_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase)); - //var fileList = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskPKId).ToList(); + dingdingConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_AMENDMENT_DING_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase)); + } + + } + else if (baseTask.TASK_TYPE == TaskBaseTypeEnum.CANCELLATION.ToString()) + { + if (paramList != null && paramList.Count > 0) + { + paramConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_CANCELLATION_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase)); - //推送舱位 - //var bookingSlotId = GenerateBookingSlot(bcOrder, bcCtnList, fileList,"update").GetAwaiter().GetResult(); + dingdingConfig = paramList.FirstOrDefault(a => a.ParaCode.Equals(CONST_CANCELLATION_DING_DEFAULT_PARAM, StringComparison.OrdinalIgnoreCase)); + } + } + + _logger.LogInformation($"taskPKId={taskPKId} 判断是否默认转发邮件 paramConfig={JSON.Serialize(paramConfig)}"); + + //如果值是ENABLE表示可以自动发送 + if (paramConfig != null && paramConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase)) + { + _logger.LogInformation($"taskPKId={taskPKId} 准备发送邮件"); + + var emailRlt = await SendEmail(taskPKId); + + _logger.LogInformation($"taskPKId={taskPKId} 发送邮件完成 结果={JSON.Serialize(emailRlt)}"); + + } + else + { + _logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件"); + } + + if (dingdingConfig != null && dingdingConfig.ParaValue.Equals("ENABLE", StringComparison.OrdinalIgnoreCase)) + { + _logger.LogInformation($"taskPKId={taskPKId} 准备发送钉钉消息"); + + var emailRlt = await SendEmail(taskPKId); - //检索是否有差异 - //var compareResult = _bookingSlotCompareRepository.AsQueryable().Filter(null, true) - // .Where(x => x.SLOT_ID == bookingSlotId && x.IsDeleted == false && x.TenantId == - // bcOrder.TenantId).OrderByDescending(a=>a.CreatedTime).First(); + _logger.LogInformation($"taskPKId={taskPKId} 发送钉钉消息完成 结果={JSON.Serialize(emailRlt)}"); - //if(compareResult != null && compareResult.COMPARE_DIFF_NUM > 0) - //{ - // //准备推送邮件 - // await GenerateSendEmail(bcOrder); - //} } else { - throw Oops.Oh($"未检索到对应的舱位信息"); + _logger.LogInformation($"taskPKId={taskPKId} 未配置自动发送邮件"); } + + result.succ = true; + result.msg = "执行成功"; } catch (Exception ex) { @@ -2614,6 +2723,7 @@ namespace Myshipping.Application } #endregion + #region 重新比对 /// /// 重新比对 /// @@ -2693,6 +2803,27 @@ namespace Myshipping.Application it.UpdatedUserName }).ExecuteCommandAsync(); } + + if (baseTask.IS_PUBLIC == 1) + { + baseTask.IS_PUBLIC = 0; + baseTask.RealUserId = UserManager.UserId; + baseTask.RealUserName = UserManager.Name; + baseTask.UpdatedTime = DateTime.Now; + baseTask.UpdatedUserId = UserManager.UserId; + baseTask.UpdatedUserName = UserManager.Name; + + //更新任务台,将当前任务变更为个人任务 + await _taskBaseRepository.AsUpdateable(baseTask).UpdateColumns(it => new { + it.IS_PUBLIC, + it.RealUserId, + it.RealUserName, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + + }).ExecuteCommandAsync(); + } } } @@ -2739,7 +2870,6 @@ namespace Myshipping.Application if (modifyBCReadInfo == null) throw Oops.Oh($"重新读取BC变更文件详情失败"); - TaskBCInfoReadDto BCReadInfo = await GetBCReaderInfo(bcFileFullPath, bcFileName, UserManager.TENANT_ID, taskPKId, App.Configuration["BCReadWebApiUrl"]); @@ -2785,6 +2915,7 @@ namespace Myshipping.Application _logger.LogInformation($"触发比对差异结束,reqBatchNo={reqBatchNo}"); } + #endregion #region 读BC详情详情 /// @@ -2926,7 +3057,6 @@ namespace Myshipping.Application } #endregion - } /// diff --git a/ServiceProjectSyncWin/Entities/TaskBCEntity.cs b/ServiceProjectSyncWin/Entities/TaskBCEntity.cs new file mode 100644 index 00000000..f5f9d635 --- /dev/null +++ b/ServiceProjectSyncWin/Entities/TaskBCEntity.cs @@ -0,0 +1,37 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceProjectSyncWin.Entities +{ + [Tenant("db_master")] + [SugarTable("task_bc_info")] + public class TaskBCEntity + { + /// + /// 主键 + /// + [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true)] + public string PK_ID { get; set; } + + + public string MBL_NO { get; set; } + + + public string BUSI_TYPE { get; set; } + + public Nullable SI_CUT_DATE { get; set; } + + public Nullable ETD { get; set; } + + public Nullable ETA { get; set; } + + public Nullable VGM_CUTOFF_TIME { get; set; } + + public string TASK_ID { get; set; } + } +} diff --git a/ServiceProjectSyncWin/Program.cs b/ServiceProjectSyncWin/Program.cs index 86f9fac0..058d3f80 100644 --- a/ServiceProjectSyncWin/Program.cs +++ b/ServiceProjectSyncWin/Program.cs @@ -8,6 +8,7 @@ using Furion.RemoteRequest.Extensions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using ServiceProjectSyncWin; +using ServiceProjectSyncWin.Entities; using SqlSugar; using System.Text; using System.Text.RegularExpressions; @@ -420,10 +421,12 @@ public class SyncHisRecord: ISyncHisRecord,ITransient public void SyncServiceProjectRecord4() { - string s = "\n预期运输计划\nFrom To Mode Vessel Voy No. ETD ETA\nTianjin PAC Intl Cntr PELABUHAN TANJUNG MVS MERETE MAERSK 351W 2023-12-25 2024-01-10\nTerminal PELEPAS TERMINAL\nPELABUHAN TANJUNG SYDNEY DPW TERMINAL MVS RIO MADEIRA 402S 2024-01-14 2024-01-27\nPELEPAS TERMINAL\n"; - - - string s1 = Regex.Match(s, "(?<=ETD\\sETA\\\\n)(\\w|\\s)+(?=\\\\n)").Value; + /* + 批量更新SI 截止时间 + 1、更新任务台 + 2、更新舱位的截止时间记录 + */ + //_db.Queryable().Max(a => a.ORG_STATUS_ID); }