From bee9c13db16cb6fedb17f8cbf91a260b327e8d98 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 9 Jul 2024 08:55:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=B7=E9=A2=86?= =?UTF-8?q?=E6=88=AA=E5=8D=95=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/EDI/SeaLeadEdiHelper.cs | 9 +++++---- ServiceProjectSyncWin/Program.cs | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Myshipping.Application/EDI/SeaLeadEdiHelper.cs b/Myshipping.Application/EDI/SeaLeadEdiHelper.cs index 9b4fdece..6191a572 100644 --- a/Myshipping.Application/EDI/SeaLeadEdiHelper.cs +++ b/Myshipping.Application/EDI/SeaLeadEdiHelper.cs @@ -5,6 +5,7 @@ using NPOI.HPSF; using NPOI.HSSF.UserModel; using NPOI.OpenXmlFormats.Wordprocessing; using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; using StackExchange.Profiling.Internal; using System; using System.Collections.Generic; @@ -46,7 +47,7 @@ namespace Myshipping.Application.EDI.SeaLead //读取文件 var file = new FileStream(fileAbsPath, FileMode.Open); - var excelwork = new HSSFWorkbook(file); + var excelwork = new XSSFWorkbook(file); //截单主信息 var sheetBase = excelwork.GetSheetAt(0); @@ -55,7 +56,7 @@ namespace Myshipping.Application.EDI.SeaLead throw Oops.Bah("读取模板Sheet Header data失败"); - var lstLabelRow = sheetBase.GetRow(sheetBase.LastRowNum); + var lstLabelRow = sheetBase.GetRow(sheetBase.LastRowNum - 1); Dictionary baseColsDict = lstLabelRow.Cells.Select((p, idx) => { @@ -65,7 +66,7 @@ namespace Myshipping.Application.EDI.SeaLead return new { Name = "", Idx = idx }; }).Where(p => !string.IsNullOrWhiteSpace(p.Name)).ToDictionary(a => a.Idx, b => b.Name); - var newRow = sheetBase.CreateRow(sheetBase.LastRowNum + 1); + var newRow = sheetBase.CreateRow(sheetBase.LastRowNum); for (int i = 0; i < lstLabelRow.Cells.Count; i++) { @@ -281,7 +282,7 @@ namespace Myshipping.Application.EDI.SeaLead ctnStartNo++; } - var fileName = $"{model.BookingId}_SLS_{DateTime.Now.Ticks.ToString()}.xls";//名称 + var fileName = $"{model.BookingId}_SLS_{DateTime.Now.Ticks.ToString()}.xlsx";//名称 var excelFileName = Path.Combine(model.FilePath, fileName); diff --git a/ServiceProjectSyncWin/Program.cs b/ServiceProjectSyncWin/Program.cs index 971e1c9f..3cdb4e22 100644 --- a/ServiceProjectSyncWin/Program.cs +++ b/ServiceProjectSyncWin/Program.cs @@ -1284,7 +1284,7 @@ public class SyncHisRecord: ISyncHisRecord,ITransient html.LoadHtml(strBody); //获取第一个font节点的内容 - var baseNode = html.DocumentNode.SelectSingleNode("//font"); + var baseNode = html.DocumentNode.SelectSingleNode("//font[1]"); var s = baseNode.InnerText; @@ -1295,8 +1295,21 @@ public class SyncHisRecord: ISyncHisRecord,ITransient billNo = Regex.Match(s, "(?<=订舱号)[a-zA-Z0-9]+").Value; } + var baseNodes = baseNode.SelectNodes("./b"); + } + public class ForInformationShipmentNotice + { + /// + /// 提单号 + /// + public string BillNo { get; set; } + + /// + /// 通知内容 + /// + public string Notice { get; set; } } private List GetChildList(HtmlNode node) From 74a0d2b0ee9fdf36adda5def82f3bde2a9fcf092 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 9 Jul 2024 09:26:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=B7=E9=A2=86?= =?UTF-8?q?=E6=88=AA=E5=8D=95=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Myshipping.Application/EDI/SeaLeadEdiHelper.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Myshipping.Application/EDI/SeaLeadEdiHelper.cs b/Myshipping.Application/EDI/SeaLeadEdiHelper.cs index 6191a572..2792d241 100644 --- a/Myshipping.Application/EDI/SeaLeadEdiHelper.cs +++ b/Myshipping.Application/EDI/SeaLeadEdiHelper.cs @@ -194,7 +194,7 @@ namespace Myshipping.Application.EDI.SeaLead #region 箱信息填写 if (ctnColsDict[k].Equals("Item Number", StringComparison.OrdinalIgnoreCase)) { - GenerateCellInfo(model.ContaList[j].SNo.ToString(), k + 1, newCtnRow); + GenerateCellInfoWithInt(model.ContaList[j].SNo, k + 1, newCtnRow); } else if (ctnColsDict[k].Equals("Container Serial Number", StringComparison.OrdinalIgnoreCase)) { @@ -314,6 +314,11 @@ namespace Myshipping.Application.EDI.SeaLead } } + private static void GenerateCellInfoWithInt(int val, int cellIndex, IRow row) + { + row.CreateCell(cellIndex).SetCellValue(val); + } + #region 校验VOLTA请求参数s /// /// 校验VOLTA请求参数