From cb689799ee3c847eca78052473312aea3be37518 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期二, 20 五月 2025 08:46:30 +0800
Subject: [PATCH] 1.获取携客云条码

---
 entity/TblBarcodeInformation.cs    |  308 ++++++++++++++++++++------------------
 Dto/Xky/XkyBarcodeDataDto.cs       |  103 ++++++++++++
 service/Warehouse/MesXkyService.cs |   60 +++++-
 3 files changed, 312 insertions(+), 159 deletions(-)

diff --git a/Dto/Xky/XkyBarcodeDataDto.cs b/Dto/Xky/XkyBarcodeDataDto.cs
new file mode 100644
index 0000000..3759eb8
--- /dev/null
+++ b/Dto/Xky/XkyBarcodeDataDto.cs
@@ -0,0 +1,103 @@
+using Newtonsoft.Json;
+
+namespace NewPdaSqlServer.Dto.Xky
+{
+    public class XkyBarcodeDataDto
+    {
+        [JsonProperty("poErpNo")]
+        public string PoErpNo { get; set; }
+
+        [JsonProperty("poLineNo")]
+        public string PoLineNo { get; set; }
+
+        [JsonProperty("productCode")]
+        public string ProductCode { get; set; }
+
+        [JsonProperty("productName")]
+        public string ProductName { get; set; }
+
+        [JsonProperty("productScale")]
+        public string ProductScale { get; set; }
+
+        [JsonProperty("smallBarcode")]
+        public string SmallBarcode { get; set; }
+
+        [JsonProperty("bigBarcode")]
+        public string BigBarcode { get; set; }
+
+        [JsonProperty("outerBarcode")]
+        public string OuterBarcode { get; set; }
+
+        [JsonProperty("includeQty")]
+        public int IncludeQty { get; set; }
+
+        [JsonProperty("smallPackageLength")]
+        public int? SmallPackageLength { get; set; }
+
+        [JsonProperty("smallPackageWidth")]
+        public int? SmallPackageWidth { get; set; }
+
+        [JsonProperty("smallPackageHeight")]
+        public int? SmallPackageHeight { get; set; }
+
+        [JsonProperty("bigPackageLength")]
+        public int? BigPackageLength { get; set; }
+
+        [JsonProperty("bigPackageWidth")]
+        public int? BigPackageWidth { get; set; }
+
+        [JsonProperty("bigPackageHeight")]
+        public int? BigPackageHeight { get; set; }
+
+        [JsonProperty("outerPackageLength")]
+        public int? OuterPackageLength { get; set; }
+
+        [JsonProperty("outerPackageWidth")]
+        public int? OuterPackageWidth { get; set; }
+
+        [JsonProperty("outerPackageHeight")]
+        public int? OuterPackageHeight { get; set; }
+
+        [JsonProperty("smallPackageSn")]
+        public string SmallPackageSn { get; set; }
+
+        [JsonProperty("bigPackageSn")]
+        public string BigPackageSn { get; set; }
+
+        [JsonProperty("outerPackageSn")]
+        public string OuterPackageSn { get; set; }
+
+        [JsonProperty("dnLines")]
+        public string DnLines { get; set; }
+
+        [JsonProperty("dynamicData")]
+        public XkyDynamicDataDto DynamicData { get; set; }
+
+        [JsonProperty("createType")]
+        public int CreateType { get; set; }
+
+        [JsonProperty("packLevel")]
+        public int PackLevel { get; set; }
+    }
+
+    public class XkyDynamicDataDto
+    {
+        [JsonProperty("poErpNo")]
+        public string PoErpNo { get; set; }
+
+        [JsonProperty("poLineNo")]
+        public string PoLineNo { get; set; }
+
+        [JsonProperty("innerVendorCode")]
+        public string InnerVendorCode { get; set; }
+
+        [JsonProperty("customize1")]
+        public string Customize1 { get; set; }
+
+        [JsonProperty("customize2")]
+        public string Customize2 { get; set; } // 注意:JSON中这里是数字1747584000000
+
+        [JsonProperty("customize3")]
+        public string Customize3 { get; set; }
+    }
+}
\ No newline at end of file
diff --git a/entity/TblBarcodeInformation.cs b/entity/TblBarcodeInformation.cs
index a84b347..17c57af 100644
--- a/entity/TblBarcodeInformation.cs
+++ b/entity/TblBarcodeInformation.cs
@@ -1,180 +1,198 @@
 锘縰sing SqlSugar;
 using System;
 
-namespace MES.Service.Models;
-
-/// <summary>
-/// 鎼哄浜戞潯鐮佷俊鎭〃
-/// </summary>
-[SugarTable("TBL_BARCODE_INFORMATION")]
-public class TblBarcodeInformation
+namespace MES.Service.Models
 {
     /// <summary>
-    /// 涓婚敭Guid锛圫EQ_XKY锛�
+    /// 鎼哄浜戞潯鐮佷俊鎭〃
     /// </summary>
-    [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
-    public Guid Id { get; set; }
+    [SugarTable("TBL_BARCODE_INFORMATION")]
+    public class TblBarcodeInformation
+    {
+        /// <summary>
+        /// 涓婚敭Guid锛圫EQ_XKY锛�
+        /// </summary>
+        [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
+        public Guid Id { get; set; }
 
-    /// <summary>
-    /// 浜у搧缂栫爜
-    /// </summary>
-    [SugarColumn(ColumnName = "product_code")]
-    public string ProductCode { get; set; }
+        /// <summary>
+        /// 浜у搧缂栫爜
+        /// </summary>
+        [SugarColumn(ColumnName = "product_code")]
+        public string ProductCode { get; set; }
 
-    /// <summary>
-    /// 灏忓寘鏉$爜
-    /// </summary>
-    [SugarColumn(ColumnName = "small_barcode")]
-    public string SmallBarcode { get; set; }
+        /// <summary>
+        /// 灏忓寘鏉$爜
+        /// </summary>
+        [SugarColumn(ColumnName = "small_barcode")]
+        public string SmallBarcode { get; set; }
 
-    /// <summary>
-    /// 澶у寘鏉$爜
-    /// </summary>
-    [SugarColumn(ColumnName = "big_barcode")]
-    public string BigBarcode { get; set; }
+        /// <summary>
+        /// 澶у寘鏉$爜
+        /// </summary>
+        [SugarColumn(ColumnName = "big_barcode")]
+        public string BigBarcode { get; set; }
 
-    /// <summary>
-    /// 澶栫鏉$爜
-    /// </summary>
-    [SugarColumn(ColumnName = "outer_barcode")]
-    public string OuterBarcode { get; set; }
+        /// <summary>
+        /// 澶栫鏉$爜
+        /// </summary>
+        [SugarColumn(ColumnName = "outer_barcode")]
+        public string OuterBarcode { get; set; }
 
-    /// <summary>
-    /// 褰撳墠灏忓寘鏉$爜鍖呭惈鐨勬暟閲�
-    /// </summary>
-    [SugarColumn(ColumnName = "include_qty")]
-    public string IncludeQty { get; set; }
+        /// <summary>
+        /// 褰撳墠灏忓寘鏉$爜鍖呭惈鐨勬暟閲�
+        /// </summary>
+        [SugarColumn(ColumnName = "include_qty")]
+        public string IncludeQty { get; set; }
 
-    /// <summary>
-    /// 灏忓寘鏉$爜-闀�
-    /// </summary>
-    [SugarColumn(ColumnName = "small_package_length")]
-    public string SmallPackageLength { get; set; }
+        /// <summary>
+        /// 灏忓寘鏉$爜-闀�
+        /// </summary>
+        [SugarColumn(ColumnName = "small_package_length")]
+        public string SmallPackageLength { get; set; }
 
-    /// <summary>
-    /// 灏忓寘鏉$爜-瀹�
-    /// </summary>
-    [SugarColumn(ColumnName = "small_package_width")]
-    public string SmallPackageWidth { get; set; }
+        /// <summary>
+        /// 灏忓寘鏉$爜-瀹�
+        /// </summary>
+        [SugarColumn(ColumnName = "small_package_width")]
+        public string SmallPackageWidth { get; set; }
 
-    /// <summary>
-    /// 灏忓寘鏉$爜-楂�
-    /// </summary>
-    [SugarColumn(ColumnName = "small_package_height")]
-    public string SmallPackageHeight { get; set; }
+        /// <summary>
+        /// 灏忓寘鏉$爜-楂�
+        /// </summary>
+        [SugarColumn(ColumnName = "small_package_height")]
+        public string SmallPackageHeight { get; set; }
 
-    /// <summary>
-    /// 澶у寘鏉$爜-闀�
-    /// </summary>
-    [SugarColumn(ColumnName = "big_package_length")]
-    public string BigPackageLength { get; set; }
+        /// <summary>
+        /// 澶у寘鏉$爜-闀�
+        /// </summary>
+        [SugarColumn(ColumnName = "big_package_length")]
+        public string BigPackageLength { get; set; }
 
-    /// <summary>
-    /// 澶у寘鏉$爜-瀹�
-    /// </summary>
-    [SugarColumn(ColumnName = "big_package_width")]
-    public string BigPackageWidth { get; set; }
+        /// <summary>
+        /// 澶у寘鏉$爜-瀹�
+        /// </summary>
+        [SugarColumn(ColumnName = "big_package_width")]
+        public string BigPackageWidth { get; set; }
 
-    /// <summary>
-    /// 澶у寘鏉$爜-楂�
-    /// </summary>
-    [SugarColumn(ColumnName = "big_package_height")]
-    public string BigPackageHeight { get; set; }
+        /// <summary>
+        /// 澶у寘鏉$爜-楂�
+        /// </summary>
+        [SugarColumn(ColumnName = "big_package_height")]
+        public string BigPackageHeight { get; set; }
 
-    /// <summary>
-    /// 澶栫鏉$爜-闀�
-    /// </summary>
-    [SugarColumn(ColumnName = "outer_package_length")]
-    public string OuterPackageLength { get; set; }
+        /// <summary>
+        /// 澶栫鏉$爜-闀�
+        /// </summary>
+        [SugarColumn(ColumnName = "outer_package_length")]
+        public string OuterPackageLength { get; set; }
 
-    /// <summary>
-    /// 澶栫鏉$爜-瀹�
-    /// </summary>
-    [SugarColumn(ColumnName = "outer_package_width")]
-    public string OuterPackageWidth { get; set; }
+        /// <summary>
+        /// 澶栫鏉$爜-瀹�
+        /// </summary>
+        [SugarColumn(ColumnName = "outer_package_width")]
+        public string OuterPackageWidth { get; set; }
 
-    /// <summary>
-    /// 澶栫鏉$爜-楂�
-    /// </summary>
-    [SugarColumn(ColumnName = "outer_package_height")]
-    public string OuterPackageHeight { get; set; }
+        /// <summary>
+        /// 澶栫鏉$爜-楂�
+        /// </summary>
+        [SugarColumn(ColumnName = "outer_package_height")]
+        public string OuterPackageHeight { get; set; }
 
-    /// <summary>
-    /// 褰撳墠灏忓寘鏉$爜鐨勬祦姘寸爜
-    /// </summary>
-    [SugarColumn(ColumnName = "small_package_sn")]
-    public string SmallPackageSn { get; set; }
+        /// <summary>
+        /// 褰撳墠灏忓寘鏉$爜鐨勬祦姘寸爜
+        /// </summary>
+        [SugarColumn(ColumnName = "small_package_sn")]
+        public string SmallPackageSn { get; set; }
 
-    /// <summary>
-    /// 褰撳墠澶у寘鏉$爜鐨勬祦姘寸爜
-    /// </summary>
-    [SugarColumn(ColumnName = "big_package_sn")]
-    public string BigPackageSn { get; set; }
+        /// <summary>
+        /// 褰撳墠澶у寘鏉$爜鐨勬祦姘寸爜
+        /// </summary>
+        [SugarColumn(ColumnName = "big_package_sn")]
+        public string BigPackageSn { get; set; }
 
-    /// <summary>
-    /// 褰撳墠澶栫鏉$爜鐨勬祦姘寸爜
-    /// </summary>
-    [SugarColumn(ColumnName = "out_package_sn")]
-    public string OutPackageSn { get; set; }
+        /// <summary>
+        /// 褰撳墠澶栫鏉$爜鐨勬祦姘寸爜
+        /// </summary>
+        [SugarColumn(ColumnName = "out_package_sn")]
+        public string OutPackageSn { get; set; }
 
-    /// <summary>
-    /// 鍖呰灞傜骇
-    /// </summary>
-    [SugarColumn(ColumnName = "pack_level")]
-    public string PackLevel { get; set; }
+        ///// <summary>
+        ///// 鏉$爜瑙勫垯涓搴旂殑鍔ㄦ�佸瓧娈电殑鍊�
+        ///// </summary>
+        //[SugarColumn(ColumnName = "dynamic_data")]
+        //public string DynamicData { get; set; }
 
-    /// <summary>
-    /// 鍒涘缓鏃堕棿
-    /// </summary>
-    [SugarColumn(ColumnName = "create_time")]
-    public DateTime CreateTime { get; set; } = DateTime.Now;
+        /// <summary>
+        /// 鍖呰灞傜骇
+        /// </summary>
+        [SugarColumn(ColumnName = "pack_level")]
+        public string PackLevel { get; set; }
 
-    /// <summary>
-    /// 鏇存柊鏃堕棿
-    /// </summary>
-    [SugarColumn(ColumnName = "update_time")]
-    public DateTime UpdateTime { get; set; } = DateTime.Now;
+        /// <summary>
+        /// 鍒涘缓鏃堕棿
+        /// </summary>
+        [SugarColumn(ColumnName = "create_time")]
+        public DateTime CreateTime { get; set; } = DateTime.Now;
 
-    /// <summary>
-    /// 閫佽揣鍗曞彿
-    /// </summary>
-    [SugarColumn(ColumnName = "delivery_no")]
-    public string DeliveryNo { get; set; }
+        /// <summary>
+        /// 鏇存柊鏃堕棿
+        /// </summary>
+        [SugarColumn(ColumnName = "update_time")]
+        public DateTime UpdateTime { get; set; } = DateTime.Now;
 
-    /// <summary>
-    /// 閲囪喘鍗曞彿
-    /// </summary>
-    [SugarColumn(ColumnName = "po_erp_no")]
-    public string PoErpNo { get; set; }
+        /// <summary>
+        /// 閫佽揣鍗曞彿
+        /// </summary>
+        [SugarColumn(ColumnName = "delivery_no")]
+        public string DeliveryNo { get; set; }
 
-    /// <summary>
-    /// 椤圭洰(鍗曡韩extendN01)
-    /// </summary>
-    [SugarColumn(ColumnName = "extend_n01")]
-    public string ExtendN01 { get; set; }
+        /// <summary>
+        /// 閲囪喘鍗曞彿
+        /// </summary>
+        [SugarColumn(ColumnName = "po_erp_no")]
+        public string PoErpNo { get; set; }
 
-    /// <summary>
-    /// 璁㈠崟椤规(ERP)
-    /// </summary>
-    [SugarColumn(ColumnName = "po_line_no")]
-    public string PoLineNo { get; set; }
+        /// <summary>
+        /// 閫佽揣鍗曢」娆�
+        /// </summary>
+        [SugarColumn(ColumnName = "dnLines")]
+        public string DnLines { get; set; }
 
-    /// <summary>
-    /// 渚涘簲鍟嗙紪鐮�
-    /// </summary>
-    [SugarColumn(ColumnName = "inner_vendor_code")]
-    public string InnerVendorCode { get; set; }
+        /// <summary>
+        /// 璁㈠崟椤规(ERP)
+        /// </summary>
+        [SugarColumn(ColumnName = "po_line_no")]
+        public string PoLineNo { get; set; }
 
-    /// <summary>
-    /// 鐢熶骇鏃ユ湡锛堣嚜瀹氫箟瀛楁customize1锛�
-    /// </summary>
-    [SugarColumn(ColumnName = "customize1")]
-    public string Customize1 { get; set; }
+        /// <summary>
+        /// 渚涘簲鍟嗙紪鐮�
+        /// </summary>
+        [SugarColumn(ColumnName = "inner_vendor_code")]
+        public string InnerVendorCode { get; set; }
 
+        /// <summary>
+        /// 鑷畾涔夊瓧娈�1锛圶锛�
+        /// </summary>
+        [SugarColumn(ColumnName = "customize1")]
+        public string Customize1 { get; set; }
 
-    /// <summary>
-    /// 鍚屾鏃堕棿
-    /// </summary>
-    [SugarColumn(ColumnName = "SYNCHRONOUS_DATE")]
-    public DateTime? SynchronousDate { get; set; }
+        /// <summary>
+        /// 鍚屾鏃堕棿
+        /// </summary>
+        [SugarColumn(ColumnName = "SYNCHRONOUS_DATE")]
+        public DateTime? SynchronousDate { get; set; }
+
+        /// <summary>
+        /// 鐢熶骇鏃ユ湡
+        /// </summary>
+        [SugarColumn(ColumnName = "customize2")]
+        public string Customize2 { get; set; }
+
+        /// <summary>
+        /// 鏈夋晥鏈�
+        /// </summary>
+        [SugarColumn(ColumnName = "customize3")]
+        public string Customize3 { get; set; }
+    }
 }
\ No newline at end of file
diff --git a/service/Warehouse/MesXkyService.cs b/service/Warehouse/MesXkyService.cs
index 7e8b66c..cbb4aca 100644
--- a/service/Warehouse/MesXkyService.cs
+++ b/service/Warehouse/MesXkyService.cs
@@ -8,8 +8,7 @@
 using System.Net;
 using System.Net.Http.Headers;
 using System.Text;
-using System.Data.SqlClient;
-using System.Data;
+using NewPdaSqlServer.Dto.Xky;
 using static NewPdaSqlServer.Controllers.Warehouse.MesXkyController;
 
 namespace NewPdaSqlServer.service.QC;
@@ -470,30 +469,63 @@
     private int SaveDeliveryNoticeBar(dynamic responseJson,string deliveryNo)
     {
         var result = 1;
-        List<TblBarcodeInformation> noticeList = JsonConvert.DeserializeObject<List<TblBarcodeInformation>>(responseJson.dataList.ToString());
-        
-        // 鏂板鍒楄〃绌哄�兼鏌�
-        if (noticeList == null || !noticeList.Any() || noticeList.Count < 1)
+        List<XkyBarcodeDataDto> noticeList = JsonConvert.DeserializeObject<List<XkyBarcodeDataDto>>(responseJson.dataList.ToString());
+
+        if (noticeList == null || !noticeList.Any())
         {
             _logMessageDhdBar += $"鏉$爜鏁版嵁涓虹┖锛岄�佽揣鍗曞彿锛歿deliveryNo}";
             return result;
         }
 
-        // 璧嬪�糶uid鍜屽埌璐у崟鍙�
-        noticeList.ForEach(n => n.Id = Guid.NewGuid());
-        noticeList.ForEach(n => n.DeliveryNo = deliveryNo);
-        noticeList.ForEach(n => n.SynchronousDate = DateTime.Now);
+        var barcodeList = noticeList.Select(n => new TblBarcodeInformation
+        {
+            Id = Guid.NewGuid(),
+            DeliveryNo = deliveryNo,
+            SynchronousDate = DateTime.Now,
 
+            // 鐩存帴鏄犲皠瀛楁
+            ProductCode = n.ProductCode,
+            SmallBarcode = n.SmallBarcode,
+            BigBarcode = n.BigBarcode,
+            OuterBarcode = n.OuterBarcode,
+            IncludeQty = n.IncludeQty.ToString(),
+            SmallPackageSn = n.SmallPackageSn,
+            BigPackageSn = n.BigPackageSn,
+            OutPackageSn = n.OuterPackageSn,
+            PackLevel = n.PackLevel.ToString(),
 
-        Db.Ado.UseTran(() =>
+            // 灏哄瀛楁鏄犲皠
+            SmallPackageLength = n.SmallPackageLength?.ToString(),
+            SmallPackageWidth = n.SmallPackageWidth?.ToString(),
+            SmallPackageHeight = n.SmallPackageHeight?.ToString(),
+            BigPackageLength = n.BigPackageLength?.ToString(),
+            BigPackageWidth = n.BigPackageWidth?.ToString(),
+            BigPackageHeight = n.BigPackageHeight?.ToString(),
+            OuterPackageLength = n.OuterPackageLength?.ToString(),
+            OuterPackageWidth = n.OuterPackageWidth?.ToString(),
+            OuterPackageHeight = n.OuterPackageHeight?.ToString(),
+
+            // 鍔ㄦ�佸瓧娈垫槧灏�
+            PoErpNo = n.DynamicData?.PoErpNo ?? n.PoErpNo,
+            PoLineNo = n.DynamicData?.PoLineNo ?? n.PoLineNo,
+            InnerVendorCode = n.DynamicData?.InnerVendorCode,
+            Customize1 = n.DynamicData?.Customize1,
+            Customize2 = n.DynamicData?.Customize2,
+            Customize3 = n.DynamicData?.Customize3,
+
+            // 鍏朵粬瀛楁
+            DnLines = n.DnLines // 鏍规嵁鏁版嵁搴撴敞閲婏紝ExtendN01瀵瑰簲椤圭洰(鍗曡韩extendN01)锛岃繖閲屾槧灏刣nLines
+        }).ToList();
+
+        Db.Ado.UseTran(() => 
         {
             // 鍒犻櫎鍏宠仈閫佽揣鏄庣粏鏁版嵁
             Db.Deleteable<TblBarcodeInformation>()
             .Where(d => d.DeliveryNo == deliveryNo)
-              .ExecuteCommand();
+            .ExecuteCommand();
 
-            // 鎵归噺鎻掑叆浼樺寲
-            result = Db.Fastest<TblBarcodeInformation>().BulkCopy(noticeList);
+            // 鎵归噺鎻掑叆浼樺寲锛堜娇鐢ㄦ纭殑barcodeList锛�
+            result = Db.Fastest<TblBarcodeInformation>().BulkCopy(barcodeList);
         },
         ex => {
             // 澧炲己寮傚父淇℃伅

--
Gitblit v1.9.3