From 48f00ebb059660cc11c12c74b1bd59490bc040b9 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Mon, 8 Apr 2024 22:41:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9EINTTRA?= =?UTF-8?q?=E8=AE=A2=E8=88=B1=EF=BC=88MSK=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/EDI/InttraEdiHelper.cs | 147 ++- .../Entities/TaskBCEntity.cs | 37 + .../Entities/TaskFileEntities.cs | 47 + ServiceProjectSyncWin/Program.cs | 901 +++++++++++++++++- ServiceProjectSyncWin/appsettings.json | 2 +- 5 files changed, 1089 insertions(+), 45 deletions(-) create mode 100644 ServiceProjectSyncWin/Entities/TaskFileEntities.cs diff --git a/Myshipping.Application/EDI/InttraEdiHelper.cs b/Myshipping.Application/EDI/InttraEdiHelper.cs index de24c7ab..18f0e6dc 100644 --- a/Myshipping.Application/EDI/InttraEdiHelper.cs +++ b/Myshipping.Application/EDI/InttraEdiHelper.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace Myshipping.Application.EDI @@ -31,6 +32,7 @@ namespace Myshipping.Application.EDI if (str == "DAAE") return "DELMAS"; if (str == "UASC") return "UASC"; if (str == "COSU") return "COSCO"; + if (str == "OOLU") return "OOCL"; else return ""; } public static string GetBillNum(string str) @@ -186,6 +188,9 @@ namespace Myshipping.Application.EDI /// public static string formatEdiStr(string fileType, string str) { + if (str == null) + str = string.Empty; + if (fileType == "txt") { return str.Replace("?", "??").Replace(":", "?:").Replace("+", "?+").Replace("'", "?'"); @@ -340,7 +345,7 @@ namespace Myshipping.Application.EDI if (headData.CARGOID == "D" || headData.SERVICE == "DOOR-DOOR" || headData.SERVICE == "DOOR-CY" || headData.SERVICE == "CY-DOOR") { - if (headData.CARRIER != "YML") + if (headData.CARRIERID != "YML") { if (string.IsNullOrEmpty(headData.EDIATTN)) { error = error + "
EDI信息联系人不能为空"; } @@ -771,7 +776,7 @@ namespace Myshipping.Application.EDI r.WriteLine("UNH+" + bill.ORDERNO + "+IFTMBF:D:99B:UN'"); icount = icount + 2; - if (bill.CARRIEREDICODE == "HLCU") + if (bill.CARRIERID == "HLCU") { if (InttrEdi.filerole == "9") r.WriteLine("BGM+335+" + bill.ORDERNO + "SO+9'"); @@ -795,15 +800,15 @@ namespace Myshipping.Application.EDI r.WriteLine("DTM+137:" + DateTime.Now.ToString("yyyyMMddHHmm") + ":203'"); icount = icount + 2; - if (bill.SERVICE.ToUpper() == "DOOR-DOOR") + if (bill.SERVICEEDICODE.ToUpper() == "DOOR-DOOR") { r.WriteLine("TSR+27+2'"); } - else if (bill.SERVICE.ToUpper() == "DOOR-CY") + else if (bill.SERVICEEDICODE.ToUpper() == "DOOR-CY") { r.WriteLine("TSR+28+2'"); } - else if (bill.SERVICE.ToUpper() == "CY-DOOR") + else if (bill.SERVICEEDICODE.ToUpper() == "CY-DOOR") { r.WriteLine("TSR+29+2'"); } @@ -818,7 +823,7 @@ namespace Myshipping.Application.EDI if (bill.BLFRT.IndexOf("COLLECT") >= 0) str_pay = bill.PAYABLEAT; - + /* 2024-04-08 JHQ 参考东胜去掉了 if (bill.CARRIEREDICODE == "HLCU") { r.WriteLine("FTX+AAI+++" + bill.BLFRT + " Payable at " + str_pay + " " + bill.SERVICE + " " + bill.CONTRACTNO + " " @@ -834,17 +839,34 @@ namespace Myshipping.Application.EDI 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; + */ + + icount = icount + 1; + + var Shipping = ""; + Shipping = formatEdiStr("txt", bill.EDIREMARK); + 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; + } + } + /*件重尺*/ - r.WriteLine("CNT+7:" + Math.Round(Convert.ToDecimal(bill.KGS), 3) + ":KGM'");//按照四舍五入的国际标准 + r.WriteLine("CNT+7:" + bill.KGS.ToString("0.###") + ":KGM'");//按照四舍五入的国际标准 r.WriteLine("CNT+11:" + bill.PKGS.ToString() + "'"); - r.WriteLine("CNT+15:" + Math.Round(Convert.ToDecimal(bill.CBM), 3) + ":MTQ'"); + r.WriteLine("CNT+15:" + bill.CBM.ToString("0.###") + ":MTQ'"); icount = icount + 3; - - if (bill.CARRIEREDICODE == "UASC") + //2024-04-08 这里看2.0文档显示不使用 CNT + if (bill.CARRIERID == "UASC") { if (bill.CTNLIST.Count > 0) { @@ -861,7 +883,7 @@ namespace Myshipping.Application.EDI if (bill.BLFRT == "FREIGHT COLLECT") { - if (bill.PAYABLEAT != "") + if (!string.IsNullOrWhiteSpace(bill.PAYABLEAT)) { r.WriteLine("LOC+57+" + bill.PREPARDATID + "::6:" + bill.PAYABLEAT + "'"); icount = icount + 1; @@ -924,17 +946,25 @@ namespace Myshipping.Application.EDI 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 + "'"); + + if (!string.IsNullOrEmpty(bill.PLACERECEIPTID)) + r.WriteLine("LOC+88+" + bill.PLACERECEIPTID + ":139:6:" + bill.PLACERECEIPT + "'"); + else + 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 != "") + if (!string.IsNullOrWhiteSpace(bill.DESTINATIONID)) { r.WriteLine("LOC+7+" + bill.DESTINATIONID + ":139:6:" + bill.DESTINATION + "'"); icount = icount + 1; } - var Shipping = ""; - var DescriptionShipper = ""; + + //处理发货人 + Shipping = string.Empty; + var DescriptionShipper = string.Empty; + Shipping = formatEdiStr("txt", bill.SHIPPER); List ShippingList = formatlengthStr(Shipping, 35); @@ -957,6 +987,7 @@ namespace Myshipping.Application.EDI } else Shipping = Shipping + ":" + ShippingList[i]; + if (bill.CARRIEREDICODE == "HLCU") { Shipping = Shipping + "-"; @@ -1008,6 +1039,7 @@ namespace Myshipping.Application.EDI } else Shipping = Shipping + ":" + ShippingList[i]; + if (bill.CARRIEREDICODE == "HLCU") { Shipping = Shipping + "--"; @@ -1061,7 +1093,6 @@ namespace Myshipping.Application.EDI if (ShippingList.Count != 0 && Shipping.Length > 0) { - for (var i = 0; i < ShippingList.Count; i++) { if (i == 0) Shipping = "NAD+NI+++" + ShippingList[0] + "+"; @@ -1109,10 +1140,10 @@ namespace Myshipping.Application.EDI } else if (bill.BYCOUNTRY == "BRAZIL") { - if (bill.NOTIFYPARTYCOUNTRY != "") + if (!string.IsNullOrWhiteSpace(bill.NOTIFYPARTYCOUNTRY)) Shipping = Shipping + "++++" + bill.NOTIFYPARTYCOUNTRY; r.WriteLine(Shipping + "'"); - if (bill.NOTIFYPARTYTAXNO != "") + if (!string.IsNullOrWhiteSpace(bill.NOTIFYPARTYTAXNO)) { r.WriteLine("RFF+GN:" + bill.NOTIFYPARTYTAXNO + "'"); icount = icount + 1; @@ -1125,7 +1156,7 @@ namespace Myshipping.Application.EDI r.WriteLine("NAD+CA+" + bill.CARRIEREDICODE + ":160:86++" + GetCarrierName(bill.CARRIEREDICODE) + "'"); icount = icount + 1; - if (bill.SERVICE == "DOOR-DOOR") + if (bill.SERVICEEDICODE == "DOOR-DOOR") { Shipping = formatEdiStr("txt", bill.SHIPPER); ShippingList = formatlengthStr(Shipping, 35); @@ -1208,7 +1239,7 @@ namespace Myshipping.Application.EDI } - if (bill.WEITUO != "") + if (!string.IsNullOrWhiteSpace(bill.WEITUO)) { if (bill.WEITUO.Length > 35) r.WriteLine("NAD+FW+++" + formatEdiStr("txt", bill.WEITUO.Substring(0, 35)) + "+" + formatEdiStr("txt", bill.WEITUO.Substring(35)) + "'"); @@ -1258,7 +1289,7 @@ namespace Myshipping.Application.EDI icount = icount + 8; - if (bill.HSCODE != "") + if (!string.IsNullOrWhiteSpace(bill.HSCODE)) { r.WriteLine("PIA+5+" + bill.HSCODE + ":HS'"); icount = icount + 1; @@ -1278,27 +1309,27 @@ namespace Myshipping.Application.EDI } } - if (DescriptionShipper != "") + if (!string.IsNullOrWhiteSpace(DescriptionShipper)) { r.WriteLine("FTX+AAA+++" + DescriptionShipper + "'"); icount = icount + 1; } - if (DescriptionConsignee != "") + if (!string.IsNullOrWhiteSpace(DescriptionConsignee)) { r.WriteLine("FTX+AAA+++" + DescriptionConsignee + "'"); icount = icount + 1; } - if (DescriptionNotifyparty != "") + if (!string.IsNullOrWhiteSpace(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) + "'"); + r.WriteLine("MEA+AAE+WT+KGM:" + bill.KGS.ToString("0.###") + "'"); + r.WriteLine("MEA+AAE+AAW+MTQ:" + bill.CBM.ToString("0.###") + "'"); icount = icount + 2; Shipping = formatEdiStr("txt", bill.MARKS); @@ -1316,6 +1347,7 @@ namespace Myshipping.Application.EDI } } + //危险品 if (bill.CARGOID == "D") { r.WriteLine("DGS+IMD+" + bill.DCLASS + "+" + bill.DUNNO + "'"); @@ -1336,6 +1368,7 @@ namespace Myshipping.Application.EDI isfind = true; } }); + if (!isfind) { var ctnnum = new MsOpSeaeCtnEDIBaseModel(); @@ -1350,16 +1383,41 @@ namespace Myshipping.Application.EDI 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 != "") + if (!string.IsNullOrWhiteSpace(bill.REEFERF)) r.WriteLine("MEA+AAE+AAS+CBM:" + bill.REEFERF + "'"); - if (bill.HUMIDITY != "") + if (!string.IsNullOrWhiteSpace(bill.HUMIDITY)) r.WriteLine("MEA+AAE+AAO+HMD:" + bill.HUMIDITY + "'"); - r.WriteLine("TMP+2+" + bill.TEMPSET + ":CEL'"); + + //温度这里如果是带小数点的值,会导致错误,这里需要慎重 + var tempset = bill.TEMPSET; + if (!string.IsNullOrWhiteSpace(tempset)) + { + var fuhao = ""; + if (tempset.IndexOf("-") == 0) + { + fuhao = "-"; + tempset = tempset.Replace("-", ""); + } + if (tempset.Length < 3) + { + for (int i = 0; i < 3 - tempset.Length + 1; i++) + { + tempset = "0" + tempset; + } + } + tempset = fuhao + tempset; + } + else + { + tempset = "000"; + } + r.WriteLine("TMP+2+" + tempset + ":CEL'"); icount = icount + 2; @@ -1405,15 +1463,15 @@ namespace Myshipping.Application.EDI - if (bill.SERVICE.ToUpper() == "DOOR-DOOR") + if (bill.SERVICEEDICODE.ToUpper() == "DOOR-DOOR") { r.WriteLine("TSR+27+2'"); } - else if (bill.SERVICE.ToUpper() == "DOOR-CY") + else if (bill.SERVICEEDICODE.ToUpper() == "DOOR-CY") { r.WriteLine("TSR+28+2'"); } - else if (bill.SERVICE.ToUpper() == "CY-DOOR") + else if (bill.SERVICEEDICODE.ToUpper() == "CY-DOOR") { r.WriteLine("TSR+29+2'"); } @@ -1423,11 +1481,11 @@ namespace Myshipping.Application.EDI } var str_pay = ""; - if (bill.BLFRT.IndexOf("PREPAID") >= 0) + if (bill.BLFRTEDICODE.IndexOf("PREPAID") >= 0) str_pay = bill.PREPARDAT; - if (bill.BLFRT.IndexOf("COLLECT") >= 0) + if (bill.BLFRTEDICODE.IndexOf("COLLECT") >= 0) str_pay = bill.PAYABLEAT; - r.WriteLine("FTX+AAI+++" + bill.BLFRT + " Payable at " + str_pay + " " + bill.SERVICE + " " + r.WriteLine("FTX+AAI+++" + bill.BLFRTEDICODE + " Payable at " + str_pay + " " + bill.SERVICEEDICODE + " " + bill.PKGS.ToString() + bill.KINDPKGS + "'"); icount = icount + 5; @@ -1593,8 +1651,6 @@ namespace Myshipping.Application.EDI } - - var DescriptionShipper = ""; Shipping = formatEdiStr("txt", bill.SHIPPER); @@ -1715,6 +1771,7 @@ namespace Myshipping.Application.EDI else r.WriteLine(Shipping + "'"); icount = icount + 1; + /*2024-04-08 JHQ 看文档2.0应该没有这段代码了 if (!string.IsNullOrEmpty(bill.WEITUO)) { if (bill.WEITUO.Length > 35) @@ -1739,10 +1796,11 @@ namespace Myshipping.Application.EDI r.WriteLine("NAD+FW+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME + "'"); } } + icount++; + */ - icount++; Shipping = formatEdiStr("txt", bill.NOTIFYPARTY); @@ -1813,6 +1871,7 @@ namespace Myshipping.Application.EDI else r.WriteLine(Shipping + "'"); icount = icount + 1; + /* 2024-04-08 JHQ 参考文档2.0去掉了 Shipping = formatEdiStr("txt", bill.NOTIFYPARTY2); ShippingList = formatlengthStr(Shipping, 35); if (ShippingList.Count != 0 && Shipping.Length > 0) @@ -1826,10 +1885,11 @@ namespace Myshipping.Application.EDI } r.WriteLine(Shipping + "'"); } - + */ r.WriteLine("NAD+CA+" + bill.CARRIEREDICODE + ":160:86++" + GetCarrierName(bill.CARRIEREDICODE) + "'"); + icount = icount + 1; if (InttrEdi.SENDNAME.Length > 35) r.WriteLine("NAD+HI+" + InttrEdi.SENDCODE + ":160:86++" + InttrEdi.SENDNAME.Substring(0, 35) + "+" + InttrEdi.SENDNAME.Substring(35) + "'"); @@ -1853,7 +1913,8 @@ namespace Myshipping.Application.EDI } } - 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无正本") + 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; @@ -2016,9 +2077,9 @@ namespace Myshipping.Application.EDI } //MEA+AAE+WT+KGM:3000' //MEA+AAE+AAW+MTQ:110.11' - r.WriteLine("MEA+AAE+WT+KGM:" + Math.Round(Convert.ToDecimal(ctngood.KGS), 3) + "'"); + r.WriteLine("MEA+AAE+WT+KGM:" + ctngood.KGS.ToString("0.###") + "'"); icount++; - r.WriteLine("MEA+AAE+AAW+MTQ:" + Math.Round(Convert.ToDecimal(ctngood.CBM), 3) + "'"); + r.WriteLine("MEA+AAE+AAW+MTQ:" + ctngood.CBM.ToString("0.###") + "'"); icount++; //PCI++MARKS AND NUMBERS:FOR MATERIAL 1: OUR PONUMBER: PO_123456' //if (isbill != 1) diff --git a/ServiceProjectSyncWin/Entities/TaskBCEntity.cs b/ServiceProjectSyncWin/Entities/TaskBCEntity.cs index f5f9d635..24473c07 100644 --- a/ServiceProjectSyncWin/Entities/TaskBCEntity.cs +++ b/ServiceProjectSyncWin/Entities/TaskBCEntity.cs @@ -26,12 +26,49 @@ namespace ServiceProjectSyncWin.Entities public Nullable SI_CUT_DATE { get; set; } + /// + /// 截关时间 + /// + public Nullable CLOSING_DATE { get; set; } + public Nullable ETD { get; set; } public Nullable ETA { get; set; } public Nullable VGM_CUTOFF_TIME { get; set; } + /// + /// 截单时间 + /// + public Nullable CUT_SINGLE_TIME { get; set; } + + /// + /// 舱单截止时间 + /// + public Nullable MANIFEST_CUT_DATE { get; set; } + + /// + /// MDGF提交截止时间 + /// + public Nullable MDGF_CUT_DATE { get; set; } + + /// + /// 截港时间 + /// + public Nullable CY_CUTOFF_TIME { get; set; } + public string TASK_ID { get; set; } + + public bool IsDeleted { get; set; } + + /// + /// 租户id + /// + public long? TenantId { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreatedTime { get; set; } } } diff --git a/ServiceProjectSyncWin/Entities/TaskFileEntities.cs b/ServiceProjectSyncWin/Entities/TaskFileEntities.cs new file mode 100644 index 00000000..5d28ef66 --- /dev/null +++ b/ServiceProjectSyncWin/Entities/TaskFileEntities.cs @@ -0,0 +1,47 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceProjectSyncWin.Entities +{ + [Tenant("db_master")] + [SugarTable("task_file")] + public class TaskFileEntities + { + /// + /// 主键 + /// + [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true)] + public string PK_ID { get; set; } + + /// + /// 任务主键(父主键) + /// + public string TASK_PKID { get; set; } + /// + /// 文件路径 + /// + public string FILE_PATH { get; set; } + /// + /// 文件类型 + /// + public string FILE_TYPE { get; set; } + /// + /// 文件名 + /// + public string FILE_NAME { get; set; } + + /// + /// 附件类型代码 BC-Booking Confirmation + /// + public string FILE_CATEGORY { get; set; } + + /// + /// 附件类型名称 BC-Booking Confirmation + /// + public string FILE_CATEGORY_NAME { get; set; } + } +} diff --git a/ServiceProjectSyncWin/Program.cs b/ServiceProjectSyncWin/Program.cs index 058d3f80..95ef2ff2 100644 --- a/ServiceProjectSyncWin/Program.cs +++ b/ServiceProjectSyncWin/Program.cs @@ -5,13 +5,18 @@ using Furion.DistributedIDGenerator; using Furion.FriendlyException; using Furion.JsonSerialization; using Furion.RemoteRequest.Extensions; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using ServiceProjectSyncWin; using ServiceProjectSyncWin.Entities; using SqlSugar; +using System.Collections.Specialized; +using System.ComponentModel.DataAnnotations; +using System.Net.Http.Headers; using System.Text; using System.Text.RegularExpressions; +using System.Web; using static System.Net.Mime.MediaTypeNames; Serve.RunGeneric(additional: services => @@ -426,9 +431,903 @@ public class SyncHisRecord: ISyncHisRecord,ITransient 1、更新任务台 2、更新舱位的截止时间记录 */ - //_db.Queryable().Max(a => a.ORG_STATUS_ID); + var taskList = _db.Queryable().Where(a => (a.BUSI_TYPE == "BookingConfirmation" || a.BUSI_TYPE == "BookingAmendment") && a.TASK_ID == "08dc56ae-e1bd-4650-818e-85447143df67") + .OrderBy(t=>t.CreatedTime) + .ToList(); + + string batchNo = Guid.NewGuid().ToString(); + + _logger.LogInformation($"批次={batchNo} 提取待处理任务 num={taskList.Count}"); + + string bcReadUrl = "http://localhost:5110/api/TaskBCParser/ExcuteBCFileRead"; + string amendReadUrl = "http://localhost:5110/api/TaskBookingAmendmentParser/ExcuteBookingAmendmentRead"; + + //foreach (var task in taskList) + for(int i=0;i().Where(a => a.TASK_PKID == task.TASK_ID && a.FILE_CATEGORY == "BC").First(); + + if (fileInfo != null) + { + _logger.LogInformation($"批次={batchNo} 提取待处理任务 MBLNO={task.MBL_NO} 取到文件"); + + string bcFileFullPath = $"D:\\djy\\backend\\wwwroot\\{fileInfo.FILE_PATH}"; + + var bcFileName = Path.GetFileName(bcFileFullPath); + + TaskBCInfoReadDto BCReadInfo = GetBCReaderInfo(bcFileFullPath, bcFileName, task.TenantId.Value, task.TASK_ID, bcReadUrl).GetAwaiter().GetResult(); + + _logger.LogInformation($"批次={batchNo} 提取待处理任务 MBLNO={task.MBL_NO} 识别完文件 BCReadInfo={JSON.Serialize(BCReadInfo)}"); + + if (BCReadInfo != null) + { + //SI_CUT_DATE + if (BCReadInfo.SICutDate.HasValue) + { + if (task.SI_CUT_DATE.HasValue && task.SI_CUT_DATE.Value == BCReadInfo.SICutDate.Value) + { + + } + task.SI_CUT_DATE = BCReadInfo.SICutDate.Value; + } + else + { + task.SI_CUT_DATE = null; + } + //VGM_CUTOFF_TIME + if (BCReadInfo.VGMCutoffTime.HasValue) + { + task.VGM_CUTOFF_TIME = BCReadInfo.VGMCutoffTime.Value; + } + else + { + task.VGM_CUTOFF_TIME = null; + } + //MANIFEST_CUT_DATE + if (BCReadInfo.ManifestCutDate.HasValue) + { + task.MANIFEST_CUT_DATE = BCReadInfo.ManifestCutDate.Value; + } + else + { + task.MANIFEST_CUT_DATE = null; + } + //CY_CUTOFF_TIME + if (BCReadInfo.CYCutoffTime.HasValue) + { + task.CY_CUTOFF_TIME = BCReadInfo.CYCutoffTime.Value; + } + else + { + task.CY_CUTOFF_TIME = null; + } + //MDGF_CUT_DATE + if (BCReadInfo.MDGFCutDate.HasValue) + { + task.MDGF_CUT_DATE = BCReadInfo.MDGFCutDate.Value; + } + else + { + task.MDGF_CUT_DATE = null; + } + //CLOSING_DATE + if (BCReadInfo.ClosingDate.HasValue) + { + task.CLOSING_DATE = BCReadInfo.ClosingDate.Value; + } + else + { + task.CLOSING_DATE = null; + } + + _db.Updateable(task).UpdateColumns(it => new + { + it.SI_CUT_DATE, + it.VGM_CUTOFF_TIME, + it.MANIFEST_CUT_DATE, + it.CY_CUTOFF_TIME, + it.MDGF_CUT_DATE, + it.CLOSING_DATE + }).ExecuteCommand(); + } + + } + } + else if (task.BUSI_TYPE == "BookingAmendment") + { + var fileInfo = _db.Queryable().Where(a => a.TASK_PKID == task.TASK_ID && a.FILE_CATEGORY == "BC_MODIFY").First(); + + if (fileInfo != null) + { + string bcFileFullPath = $"D:\\djy\\backend\\wwwroot\\{fileInfo.FILE_PATH}"; + + var bcFileName = Path.GetFileName(bcFileFullPath); + + TaskBCInfoReadDto BCReadInfo = GetBCReaderInfo(bcFileFullPath, bcFileName, task.TenantId.Value, task.TASK_ID, amendReadUrl).GetAwaiter().GetResult(); + + if (BCReadInfo != null) + { + //SI_CUT_DATE + if (BCReadInfo.SICutDate.HasValue) + { + task.SI_CUT_DATE = BCReadInfo.SICutDate.Value; + } + else + { + task.SI_CUT_DATE = null; + } + //VGM_CUTOFF_TIME + if (BCReadInfo.VGMCutoffTime.HasValue) + { + task.VGM_CUTOFF_TIME = BCReadInfo.VGMCutoffTime.Value; + } + else + { + task.VGM_CUTOFF_TIME = null; + } + //MANIFEST_CUT_DATE + if (BCReadInfo.ManifestCutDate.HasValue) + { + task.MANIFEST_CUT_DATE = BCReadInfo.ManifestCutDate.Value; + } + else + { + task.MANIFEST_CUT_DATE = null; + } + //CY_CUTOFF_TIME + if (BCReadInfo.CYCutoffTime.HasValue) + { + task.CY_CUTOFF_TIME = BCReadInfo.CYCutoffTime.Value; + } + else + { + task.CY_CUTOFF_TIME = null; + } + //MDGF_CUT_DATE + if (BCReadInfo.MDGFCutDate.HasValue) + { + task.MDGF_CUT_DATE = BCReadInfo.MDGFCutDate.Value; + } + else + { + task.MDGF_CUT_DATE = null; + } + //CLOSING_DATE + if (BCReadInfo.ClosingDate.HasValue) + { + task.CLOSING_DATE = BCReadInfo.ClosingDate.Value; + } + else + { + task.CLOSING_DATE = null; + } + + _db.Updateable(task).UpdateColumns(it => new + { + it.SI_CUT_DATE, + it.VGM_CUTOFF_TIME, + it.MANIFEST_CUT_DATE, + it.CY_CUTOFF_TIME, + it.MDGF_CUT_DATE, + it.CLOSING_DATE + }).ExecuteCommand(); + } + } + } + + + Thread.Sleep(500); + } + + } + + #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 + + public class EmailBCReadMessageInfo + { + /// + /// 表头 + /// + public TaskMessageHead Head { get; set; } + + /// + /// 表体 + /// + public EmailBCReadMessageMainInfo Main { get; set; } + } + + public class EmailBCReadMessageMainInfo + { + /// + /// 所属租户ID + /// + public string TenantId { get; set; } + } + + public class TaskMessageHead : WebAPIHeadBase + { } + public class WebAPIHeadBase + { + /// + /// 报文惟一主键 + /// + /// 08dab66c-96a1-4f90-8606-2626e06202ad + [Required(ErrorMessage = "必填")] + public string GID { get; set; } + + /// + /// 报文类型 BUSI_RULE-业务规则校验 + /// + /// BUSI_RULE + [Required(ErrorMessage = "必填")] + public string MessageType { get; set; } + + /// + /// 发送方代码 + /// + /// CUSTOMER1 + [Required(ErrorMessage = "必填")] + public string SenderId { get; set; } + + /// + /// 发送方名称 + /// + /// 企业A + [Required(ErrorMessage = "必填")] + public string SenderName { get; set; } + + /// + /// 接收方代码 + /// + /// RulesEngine + [Required(ErrorMessage = "必填")] + public string ReceiverId { get; set; } + + /// + /// 接收方名称 + /// + /// 大简云规则引擎 + [Required(ErrorMessage = "必填")] + public string ReceiverName { get; set; } + + /// + /// 请求方登录TOKEN(可以是真实的登录人TOKEN或者是服务模拟登录人TOKEN) + /// + /// eyJhbGciOiJSUzI1NiIsImtpZCI6IkQ1RTkxMDI5OUU0RURFNUZEM0EwNTJBMEFDRDUzMUQzIiwidHlwIjoiYXQrand0In0 + public string Token { get; set; } + + /// + /// 版本号 默认1.0 + /// + /// 1.0 + [Required(ErrorMessage = "必填")] + public string Version { get; set; } = "1.0"; + + /// + /// 请求时间 + /// + /// 2022-10-10 10:00:00 + public string RequestDate { get; set; } + + /// + /// 请求操作类型 + /// + /// Add + [Required(ErrorMessage = "必填")] + public string RequestAction { get; set; } = "Add"; + } +} + +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; } +} +/// +/// +/// +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; } } \ No newline at end of file diff --git a/ServiceProjectSyncWin/appsettings.json b/ServiceProjectSyncWin/appsettings.json index c3787421..a663635f 100644 --- a/ServiceProjectSyncWin/appsettings.json +++ b/ServiceProjectSyncWin/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "db_master": "Data Source=rm-m5e0s0o35bo87087b3o.mysql.rds.aliyuncs.com;Database=booking_hechuan;User ID=hechuan;Password=HcDjy@123;pooling=true;port=3306;sslmode=none;CharSet=utf8mb4;Convert Zero Datetime=True;Allow Zero Datetime=True;" + "db_master": "Data Source=rm-m5e06xxqpa68a68ry5o.mysql.rds.aliyuncs.com;Database=booking_data;User ID=rulesengine_admin;Password=Rule1qaz2wsx!QAZ;pooling=true;port=3306;sslmode=none;CharSet=utf8;" }, "ServiceStatusPushUrl": "http://47.104.85.216:12345/api/ServiceWorkFlowManage/PushStatus" } \ No newline at end of file From 63c94c7fa272225b76e3f5543664a419ba27303f Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 9 Apr 2024 11:47:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9BC=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=82=AE=E4=BB=B6=E8=87=AA=E5=8A=A8=E8=BD=AC?= =?UTF-8?q?=E5=8F=91=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/EDI/InttraEdiHelper.cs | 14 ++-- .../BookingOrder/BookingOrderService.cs | 4 +- .../Service/BookingSlot/BookingSlotService.cs | 13 ++-- .../BookingSlot/IBookingSlotService.cs | 3 +- .../Interface/ITaskManageBCService.cs | 3 +- .../TaskManagePlat/TaskManageBCService.cs | 64 +++++++++++++------ .../TaskManagePlat/TaskManageService.cs | 4 +- .../Service/DjyCustomer/DjyCustomerService.cs | 6 +- 8 files changed, 70 insertions(+), 41 deletions(-) diff --git a/Myshipping.Application/EDI/InttraEdiHelper.cs b/Myshipping.Application/EDI/InttraEdiHelper.cs index 18f0e6dc..26c1b4c6 100644 --- a/Myshipping.Application/EDI/InttraEdiHelper.cs +++ b/Myshipping.Application/EDI/InttraEdiHelper.cs @@ -293,14 +293,14 @@ namespace Myshipping.Application.EDI if (InttrEdi.filetype == "B") { - if (InttrEdi.UseForWarderCode) - { - if (string.IsNullOrEmpty(InttrEdi.ForWarderCode)) - { error = error + "
货代代码不能为空"; } + //if (InttrEdi.UseForWarderCode) + //{ + // if (string.IsNullOrEmpty(InttrEdi.ForWarderCode)) + // { error = error + "
货代代码不能为空"; } - if (string.IsNullOrEmpty(InttrEdi.ForWarderName)) - { error = error + "
货代称呼不能为空"; } - } + // if (string.IsNullOrEmpty(InttrEdi.ForWarderName)) + // { error = error + "
货代称呼不能为空"; } + //} } diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index efe1ae31..c982ae52 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -7216,7 +7216,7 @@ namespace Myshipping.Application //ESL、PIL、WY、YML、YT 需要付费方式映射EDI代码 if (ediRouteEnum == EDIRouteEnum.ESL || ediRouteEnum == EDIRouteEnum.PIL || ediRouteEnum == EDIRouteEnum.WY - || ediRouteEnum == EDIRouteEnum.YML || ediRouteEnum == EDIRouteEnum.YT) + || ediRouteEnum == EDIRouteEnum.YML || ediRouteEnum == EDIRouteEnum.YT || ediRouteEnum == EDIRouteEnum.INTTRA) { //付费方式基础数据 var baseFrtList = _cache.GetAllCodeFrt().GetAwaiter().GetResult(); @@ -8783,7 +8783,7 @@ namespace Myshipping.Application strCheck = Regex.Replace(strCheck, "\\", "\n"); } - throw Oops.Bah($"发送{EDIRouteEnum.ESL.ToString()}校验失败,{strCheck}"); + throw Oops.Bah($"发送{EDIRouteEnum.INTTRA.ToString()}校验失败,{strCheck}"); } CommonWebApiResult currRlt = new CommonWebApiResult(); diff --git a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs index dce4d948..304b6e7d 100644 --- a/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/BookingSlotService.cs @@ -1062,7 +1062,7 @@ namespace Myshipping.Application DateTime nowDate = DateTime.Now; - var hisInfo = _bookingSlotCompareRepository.AsQueryable().First(a => a.COMPARE_BATCHNO == reqBatchNo); + var hisInfo = _bookingSlotCompareRepository.AsQueryable().Filter(null, true).First(a => a.COMPARE_BATCHNO == reqBatchNo); if (hisInfo == null) { @@ -1180,7 +1180,7 @@ namespace Myshipping.Application [HttpGet("/BookingSlot/GetSlotCompareResult")] public async Task> GetSlotCompareResult([FromQuery] long id, [FromQuery] string batchNo) { - var compareInfo = await _bookingSlotCompareRepository.AsQueryable() + var compareInfo = await _bookingSlotCompareRepository.AsQueryable().Filter(null, true) .FirstAsync(t => t.SLOT_ID == id && t.COMPARE_BATCHNO == batchNo); if (compareInfo == null) @@ -1543,13 +1543,14 @@ namespace Myshipping.Application /// 检索舱位对应的订舱订单(BY 订舱编号) /// /// 订舱编号 + /// 租户ID /// 返回回执 [HttpGet("/BookingSlot/SearchBookingSlotWithOrderByNo")] - public async Task SearchBookingSlotWithOrderByNo(string slotBookingNo) + public async Task SearchBookingSlotWithOrderByNo(string slotBookingNo, long tenantId) { BookingSlotWithOrderDto dto = null; - var slotInfo = await _repBase.AsQueryable().FirstAsync(a => a.SLOT_BOOKING_NO == slotBookingNo); + var slotInfo = await _repBase.AsQueryable().Filter(null,true).FirstAsync(a => a.SLOT_BOOKING_NO == slotBookingNo && a.TenantId == tenantId); if (slotInfo == null) { @@ -1558,7 +1559,7 @@ namespace Myshipping.Application return dto; } - var list = _repAllocation.AsQueryable().Where(a => a.BOOKING_SLOT_ID == slotInfo.Id).ToList(); + var list = _repAllocation.AsQueryable().Filter(null, true).Where(a => a.BOOKING_SLOT_ID == slotInfo.Id && a.TenantId == tenantId).ToList(); dto = new BookingSlotWithOrderDto { @@ -1568,7 +1569,7 @@ namespace Myshipping.Application if (list.Count > 0) { dto.HasBookingOrder = true; - dto.BookingOrderList = list.Select(x => x.Id).ToList(); + dto.BookingOrderList = list.Select(x => x.BOOKING_ID).ToList(); } return dto; diff --git a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs index 414a555f..6495174c 100644 --- a/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs +++ b/Myshipping.Application/Service/BookingSlot/IBookingSlotService.cs @@ -110,9 +110,10 @@ namespace Myshipping.Application /// 检索舱位对应的订舱订单(BY 订舱编号) /// /// 订舱编号 + /// 租户ID /// 返回回执 - Task SearchBookingSlotWithOrderByNo(string slotBookingNo); + Task SearchBookingSlotWithOrderByNo(string slotBookingNo,long tenantId); /// /// 校验是否可以生成订舱订单 diff --git a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs index 1ca0d748..a3c07788 100644 --- a/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/Interface/ITaskManageBCService.cs @@ -95,8 +95,9 @@ namespace Myshipping.Application /// 同步舱位变更 /// /// BC任务主键 + /// 租户ID /// 返回回执 - Task SyncBookingSlotChange(string taskPKId); + Task SyncBookingSlotChange(string taskPKId,long tenantId); /// /// 重新处理BC任务 diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs index 7532d197..b76351f0 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageBCService.cs @@ -1558,7 +1558,7 @@ namespace Myshipping.Application */ //读取订舱数据 - var bookingOrderEntity = _bookingOrderRepository.AsQueryable() + var bookingOrderEntity = _bookingOrderRepository.AsQueryable().Filter(null, true) .First(a => a.Id == taskBCInfo.BOOKING_ORDER_ID); @@ -1574,6 +1574,7 @@ namespace Myshipping.Application throw Oops.Oh($"订舱的委托客户不能为空"); } + var djyCustomerInfo = _djyCustomerService.Detail(new GetDjyCustomerInput { Id = bookingOrderEntity.CUSTOMERID.Value }) .GetAwaiter().GetResult(); @@ -1591,7 +1592,7 @@ namespace Myshipping.Application //订舱OP的邮箱 string opEmail = string.Empty; - var bookingContactList = _bookingOrderContactRepository.AsQueryable() + var bookingContactList = _bookingOrderContactRepository.AsQueryable().Filter(null, true) .Where(a => a.BookingId == taskBCInfo.BOOKING_ORDER_ID).ToList(); if (bookingContactList == null || bookingContactList.Count == 0) @@ -1605,7 +1606,7 @@ namespace Myshipping.Application if (!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID)) { var opId = long.Parse(bookingOrderEntity.OPID); - var opUser = _sysUserRepository.AsQueryable().First(a => a.Id == opId); + var opUser = _sysUserRepository.AsQueryable().Filter(null, true).First(a => a.Id == opId); if (opUser != null && !string.IsNullOrWhiteSpace(opUser.Email)) { @@ -1620,13 +1621,13 @@ namespace Myshipping.Application if(usePersonalEmailSend) { - publicMailAccount = _djyUserMailAccount.FirstOrDefault(x => x.CreatedUserId == UserManager.UserId + publicMailAccount = _djyUserMailAccount.AsQueryable().Filter(null, true).First(x => x.CreatedUserId == UserManager.UserId && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != ""); } else { //这个是公共邮箱配置 - publicMailAccount = _djyUserMailAccount.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID && x.ShowName == "PublicSend" + publicMailAccount = _djyUserMailAccount.AsQueryable().Filter(null, true).First(x => x.TenantId == UserManager.TENANT_ID && x.ShowName == "PublicSend" && x.SmtpPort > 0 && x.SmtpServer != null && x.SmtpServer != ""); } @@ -1644,7 +1645,7 @@ namespace Myshipping.Application SysUser opUserInfo = null; if (!string.IsNullOrWhiteSpace(bookingOrderEntity.OPID) && Regex.IsMatch(bookingOrderEntity.OPID, "[0-9]+")) - opUserInfo = _sysUserRepository.AsQueryable().First(u => u.Id == long.Parse(bookingOrderEntity.OPID)); + opUserInfo = _sysUserRepository.AsQueryable().Filter(null, true).First(u => u.Id == long.Parse(bookingOrderEntity.OPID)); if (taskBCInfo.BUSI_TYPE == "BookingAmendment") { @@ -1669,12 +1670,12 @@ namespace Myshipping.Application if (bcTaskInfo.TASK_BASE_TYPE == TaskBaseTypeEnum.BC.ToString()) { - fileInfo = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_NOTICE")) + fileInfo = _taskFileRepository.AsQueryable().Filter(null, true).Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_NOTICE")) .OrderByDescending(a => a.CreatedTime).First(); } else if (bcTaskInfo.TASK_BASE_TYPE == TaskBaseTypeEnum.BC_MODIFY.ToString()) { - fileInfo = _taskFileRepository.AsQueryable().Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY_NOTICE")) + fileInfo = _taskFileRepository.AsQueryable().Filter(null, true).Where(a => a.TASK_PKID == taskBCInfo.TASK_ID && a.FILE_CATEGORY.Contains("BC_MODIFY_NOTICE")) .OrderByDescending(a => a.CreatedTime).First(); } @@ -2268,13 +2269,13 @@ namespace Myshipping.Application if (string.IsNullOrWhiteSpace(taskPKId)) throw Oops.Oh($"BC任务主键不能为空"); - var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId); + var bcTaskInfo = await _taskBaseRepository.AsQueryable().Filter(null,true).FirstAsync(u => u.PK_ID == taskPKId); if (bcTaskInfo == null) { throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); } - var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == bcTaskInfo.PK_ID); + var bcOrder = _taskBCInfoRepository.AsQueryable().Filter(null, true).First(a => a.TASK_ID == bcTaskInfo.PK_ID); if (bcOrder == null) throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息"); @@ -2295,13 +2296,13 @@ namespace Myshipping.Application if (string.IsNullOrWhiteSpace(taskPKId)) throw Oops.Oh($"BC任务主键不能为空"); - var bcTaskInfo = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId); + var bcTaskInfo = await _taskBaseRepository.AsQueryable().Filter(null,true).FirstAsync(u => u.PK_ID == taskPKId); if (bcTaskInfo == null) { throw Oops.Oh($"任务主键{taskPKId}无法获取业务信息"); } - var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == bcTaskInfo.PK_ID); + var bcOrder = _taskBCInfoRepository.AsQueryable().Filter(null, true).First(a => a.TASK_ID == bcTaskInfo.PK_ID); if (bcOrder == null) throw Oops.Oh($"任务主键{taskPKId}无法获取BC业务信息"); @@ -2315,9 +2316,10 @@ namespace Myshipping.Application /// 同步舱位变更 /// /// BC任务主键 + /// 租户ID /// 返回回执 [HttpGet("/TaskManageBC/SyncBookingSlotChange")] - public async Task SyncBookingSlotChange(string taskPKId) + public async Task SyncBookingSlotChange(string taskPKId, long tenantId) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); @@ -2336,11 +2338,11 @@ namespace Myshipping.Application */ try { - var baseTask = await _taskBaseRepository.AsQueryable().FirstAsync(u => u.PK_ID == taskPKId); + var baseTask = _taskBaseRepository.AsQueryable().Filter(null, true).First(u => u.PK_ID == taskPKId && u.TenantId == tenantId); if (baseTask == null) throw Oops.Oh($"主任务获取失败,不存在或已作废"); - var bcOrder = _taskBCInfoRepository.AsQueryable().First(a => a.TASK_ID == taskPKId); + var bcOrder = _taskBCInfoRepository.AsQueryable().Filter(null, true).First(a => a.TASK_ID == taskPKId && a.TenantId == tenantId); if (bcOrder == null) throw Oops.Oh($"BC任务获取失败,不存在或已作废"); @@ -2348,7 +2350,7 @@ namespace Myshipping.Application if (!bcOrder.BOOKING_SLOT_ID.HasValue || bcOrder.BOOKING_SLOT_ID.Value == 0) { var server = _namedBookingSlotServiceProvider.GetService(nameof(BookingSlotService)); - var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO).GetAwaiter().GetResult(); + var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO, bcOrder.TenantId.Value).GetAwaiter().GetResult(); if (slotModel != null && slotModel.BookingSlotId > 0) { @@ -2416,6 +2418,30 @@ namespace Myshipping.Application } } + //去关联的订舱ID + if(bcOrder.BOOKING_ORDER_ID == null || bcOrder.BOOKING_ORDER_ID.Value == 0) + { + var server = _namedBookingSlotServiceProvider.GetService(nameof(BookingSlotService)); + var slotModel = server.SearchBookingSlotWithOrderByNo(bcOrder.MBL_NO, bcOrder.TenantId.Value).GetAwaiter().GetResult(); + + if (slotModel.HasBookingOrder) + { + bcOrder.BOOKING_ORDER_ID = slotModel.BookingOrderList.FirstOrDefault(); + bcOrder.UpdatedTime = DateTime.Now; + bcOrder.UpdatedUserId = UserManager.UserId; + bcOrder.UpdatedUserName = UserManager.Name; + + await _taskBCInfoRepository.AsUpdateable(bcOrder).UpdateColumns(it => new + { + it.BOOKING_ORDER_ID, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); + } + } + + DjyTenantParamValueOutput paramConfig = null; DjyTenantParamValueOutput dingdingConfig = null; @@ -2523,7 +2549,7 @@ namespace Myshipping.Application if (!taskBCInfo.BOOKING_SLOT_ID.HasValue) { //var server = _namedBookingSlotServiceProvider.GetService(nameof(BookingSlotService)); - var slotInfo = await server.SearchBookingSlotWithOrderByNo(mblNo); + var slotInfo = await server.SearchBookingSlotWithOrderByNo(mblNo, taskBCInfo.TenantId.Value); if (slotInfo == null) throw Oops.Oh($"提单号{mblNo}未提取有效的舱位信息"); @@ -2566,7 +2592,7 @@ namespace Myshipping.Application //对应订舱订单 if (!taskBCInfo.BOOKING_ORDER_ID.HasValue) { - var slotInfo = await server.SearchBookingSlotWithOrderByNo(mblNo); + var slotInfo = await server.SearchBookingSlotWithOrderByNo(mblNo, taskBCInfo.TenantId.Value); if (slotInfo == null) throw Oops.Oh($"提单号{mblNo}未提取有效的舱位信息"); @@ -2767,7 +2793,7 @@ namespace Myshipping.Application //没有舱位先要匹配舱位,才能比对 if (!bcTaskInfo.BOOKING_SLOT_ID.HasValue) { - var searchInfo = await server.SearchBookingSlotWithOrderByNo(bcTaskInfo.MBL_NO); + var searchInfo = await server.SearchBookingSlotWithOrderByNo(bcTaskInfo.MBL_NO, bcTaskInfo.TenantId.Value); if (searchInfo != null) { diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs index f1d0c698..ba64b170 100644 --- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs +++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs @@ -815,7 +815,7 @@ namespace Myshipping.Application var name = _namedTaskManageBCServiceProvider .GetService(nameof(TaskManageBCService)); - await name.SyncBookingSlotChange(bcInfo.TASK_ID); + await name.SyncBookingSlotChange(bcInfo.TASK_ID, bcInfo.TenantId.Value); } } #endregion @@ -5688,7 +5688,7 @@ namespace Myshipping.Application /// BC变更内容后文件 /// BC任务详情JSON /// 返回回执 - [AllowAnonymous, HttpPost("/TaskManage/CreateBCTaskJob"), ApiUser(ApiCode = "BCTaskManage")] + [HttpPost("/TaskManage/CreateBCTaskJob"), AllowAnonymous, ApiUser(ApiCode = "BCTaskManage")] public async Task CreateBCTaskJob(IFormFile file, IFormFile modifyFile, [FromForm] string jsonData) { TaskManageOrderResultDto result = new TaskManageOrderResultDto(); diff --git a/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs b/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs index c790a1e9..c0e6a3be 100644 --- a/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs +++ b/Myshipping.Core/Service/DjyCustomer/DjyCustomerService.cs @@ -196,14 +196,14 @@ namespace Myshipping.Core.Service { Log.Information($"查询客户详情:{input.Id}"); _logger.LogInformation($"查询客户详情:{input.Id}"); - var cust = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); + var cust = await _rep.AsQueryable().Filter(null,true).FirstAsync(u => u.Id == input.Id); if (cust == null) { throw Oops.Oh(ErrorCode.D1002); } var custOut = cust.Adapt(); - custOut.Contacts = _repContact.Where(x => x.CustomerId == input.Id).OrderBy(x => x.Sort).ToList().Adapt>(); - custOut.Addrs = _repAddr.Where(x => x.CustomerId == input.Id).ToList().Adapt>(); + custOut.Contacts = _repContact.AsQueryable().Filter(null, true).Where(x => x.CustomerId == input.Id).OrderBy(x => x.Sort).ToList().Adapt>(); + custOut.Addrs = _repAddr.AsQueryable().Filter(null, true).Where(x => x.CustomerId == input.Id).ToList().Adapt>(); return custOut; }