From 637d269fd640fbc43dbeab9c96663430db415525 Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期一, 15 十二月 2025 18:08:30 +0800
Subject: [PATCH] 1111

---
 StandardPda/MES.Service/Modes/MesPalletBindingLog.cs                  |   66 +++++++++++++
 StandardPda/MES.Service/service/Warehouse/MesPalletBinding1Manager.cs |  177 +++++++++++++++++++---------------
 2 files changed, 165 insertions(+), 78 deletions(-)

diff --git a/StandardPda/MES.Service/Modes/MesPalletBindingLog.cs b/StandardPda/MES.Service/Modes/MesPalletBindingLog.cs
new file mode 100644
index 0000000..0a58af6
--- /dev/null
+++ b/StandardPda/MES.Service/Modes/MesPalletBindingLog.cs
@@ -0,0 +1,66 @@
+using SqlSugar;
+
+namespace MES.Service.Modes;
+
+/// <summary>
+///     鏍堟澘缁戝畾璁板綍琛�
+/// </summary>
+[SugarTable("MES_PALLET_BINDING_LOG")]
+public class MesPalletBindingLog
+{
+    /// <summary>
+    ///     涓婚敭ID
+    /// </summary>
+    [SugarColumn(ColumnName = "ID",
+        OracleSequenceName = "MES_PALLET_BINDING_LOG_ID",
+        IsPrimaryKey = true)]
+    public decimal Id { get; set; }
+
+    /// <summary>
+    ///     鏍堟澘鐮�
+    /// </summary>
+    [SugarColumn(ColumnName = "STACKCODE")]
+    public string? StackCode { get; set; }
+
+    /// <summary>
+    ///     鐧诲綍鍙�
+    /// </summary>
+    [SugarColumn(ColumnName = "LOGIN_ID")]
+    public string? LoginId { get; set; }
+
+    /// <summary>
+    ///     SN鍙�
+    /// </summary>
+    [SugarColumn(ColumnName = "SN_NO")]
+    public string? SnNo { get; set; }
+
+    /// <summary>
+    ///     宸ュ崟鍗曞彿
+    /// </summary>
+    [SugarColumn(ColumnName = "TICKET_NO")]
+    public string? TicketNo { get; set; }
+
+    /// <summary>
+    ///     涓鐮�
+    /// </summary>
+    [SugarColumn(ColumnName = "MEDIUMBOXCODE")]
+    public string? MediumBoxCode { get; set; }
+
+    /// <summary>
+    ///     鍒涘缓鏃堕棿
+    /// </summary>
+    [SugarColumn(ColumnName = "CREATE_DATE")]
+    public DateTime? CreateDate { get; set; }
+
+    /// <summary>
+    ///     鍒涘缓浜�
+    /// </summary>
+    [SugarColumn(ColumnName = "CREATED_BY")]
+    public string? CreatedBy { get; set; }
+
+    /// <summary>
+    ///     鎿嶄綔绫诲瀷锛�0锛氱粦瀹氾紝1锛氳В缁戯級
+    /// </summary>
+    [SugarColumn(ColumnName = "OPERATION_TYPE")]
+    public string? OperationType { get; set; }
+}
diff --git a/StandardPda/MES.Service/service/Warehouse/MesPalletBinding1Manager.cs b/StandardPda/MES.Service/service/Warehouse/MesPalletBinding1Manager.cs
index 75ef3a3..219dc6b 100644
--- a/StandardPda/MES.Service/service/Warehouse/MesPalletBinding1Manager.cs
+++ b/StandardPda/MES.Service/service/Warehouse/MesPalletBinding1Manager.cs
@@ -49,99 +49,120 @@
     }
 
     /// <summary>
-        /// 灏嗘帴鍙h繑鍥炵殑鏁版嵁鎻掑叆鍒版暟鎹簱涓�
-        /// </summary>
-        /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
-        /// <returns>鎻掑叆璁板綍鏁�</returns>
-        public int InsertPalletBindingData(MesPalletBinding palletBinding)
+    /// 灏嗘帴鍙h繑鍥炵殑鏁版嵁鎻掑叆鍒版暟鎹簱涓�
+    /// </summary>
+    /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
+    /// <returns>鎻掑叆璁板綍鏁�</returns>
+    public int InsertPalletBindingData(MesPalletBinding palletBinding)
+    {
+        var response = GetTransferListByStackCodeAsync(palletBinding).Result;
+
+        if (response?.Data?.SnList == null ||
+            string.IsNullOrEmpty(response.Data.StackCode))
         {
-            var response = GetTransferListByStackCodeAsync(palletBinding).Result;
-
-            if (response?.Data?.SnList == null || string.IsNullOrEmpty(response.Data.StackCode))
-            {
-                return 0;
-            }
-
-            int insertedCount = 0;
-            
-            try
-            {
-                // 鍑嗗瑕佹彃鍏ョ殑鏁版嵁鍒楄〃
-                var bindingList = new List<MesPalletBinding1>();
-                
-                foreach (var snItem in response.Data.SnList)
-                {
-                    var binding = new MesPalletBinding1
-                    {
-                        Stackcode = response.Data.StackCode,
-                        SnNo = snItem.SnNo,
-                        TicketNo = snItem.TickeNo,
-                        Mediumboxcode = snItem.MediumBoxCode,
-                        CreateDate = DateTime.Now,
-                        IsInbound = 0 // 榛樿鏈叆搴�
-                    };
-                    
-                    bindingList.Add(binding);
-                }
-                
-                // 鎵归噺鎻掑叆鏁版嵁鍒版暟鎹簱
-                if (bindingList.Any())
-                {
-                    // 鎵归噺鎻掑叆鏂版暟鎹�
-                    var insertedIds = Db.Insertable(bindingList).PageSize(1)
-                        .IgnoreColumnsNull()
-                        .ExecuteCommand();
-                    insertedCount = insertedIds;
-                }
-            }
-            catch (Exception ex)
-            {
-                throw new Exception($"鎻掑叆鏍堟澘缁戝畾鏁版嵁澶辫触: {ex.Message}");
-            }
-            
-            return insertedCount;
+            return 0;
         }
 
-        /// <summary>
-        /// 妫�鏌ユ爤鏉跨爜鍦ㄦ暟鎹簱涓槸鍚﹀瓨鍦�
-        /// </summary>
-        /// <param name="stackCode">鏍堟澘鐮�</param>
-        /// <returns>瀛樺湪杩斿洖true锛屽惁鍒欒繑鍥瀎alse</returns>
-        public bool CheckStackCodeExists(string stackCode)
+        int insertedCount = 0;
+
+        try
         {
-            try
+            // 鍑嗗瑕佹彃鍏ョ殑鏁版嵁鍒楄〃
+            var bindingList = new List<MesPalletBinding1>();
+            var bindingLogList = new List<MesPalletBindingLog>();
+
+            foreach (var snItem in response.Data.SnList)
             {
-                if (string.IsNullOrEmpty(stackCode))
+                var binding = new MesPalletBinding1
                 {
-                    return false;
-                }
+                    Stackcode = response.Data.StackCode,
+                    SnNo = snItem.SnNo,
+                    TicketNo = snItem.TickeNo,
+                    Mediumboxcode = snItem.MediumBoxCode,
+                    CreateDate = DateTime.Now,
+                    IsInbound = 0 // 榛樿鏈叆搴�
+                };
 
-                // 鏌ヨMES_PALLET_BINDING琛ㄤ腑鏄惁瀛樺湪璇ユ爤鏉跨爜鐨勬暟鎹�
-                var exists = Db.Queryable<MesPalletBinding1>()
-                    .Any(x => x.Stackcode == stackCode);
+                bindingList.Add(binding);
 
-                return exists;
+                var bindingLog = new MesPalletBindingLog
+                {
+                    StackCode = response.Data.StackCode,
+                    SnNo = snItem.SnNo,
+                    TicketNo = snItem.TickeNo,
+                    MediumBoxCode = snItem.MediumBoxCode,
+                    CreateDate = DateTime.Now,
+                    OperationType = "0" // 榛樿鏈叆搴�
+                };
+
+                bindingLogList.Add(bindingLog);
             }
-            catch (Exception ex)
+
+            // 鎵归噺鎻掑叆鏁版嵁鍒版暟鎹簱
+            if (bindingList.Any())
             {
-                throw new Exception($"妫�鏌ユ爤鏉跨爜鏄惁瀛樺湪鏃跺嚭閿�: {ex.Message}");
+                // 鎵归噺鎻掑叆鏂版暟鎹�
+                var insertedIds = Db.Insertable(bindingList).PageSize(1)
+                    .IgnoreColumnsNull()
+                    .ExecuteCommand();
+
+                var insertedIds1 = Db.Insertable(bindingLogList).PageSize(1)
+                    .IgnoreColumnsNull()
+                    .ExecuteCommand();
+                insertedCount = insertedIds + insertedIds1;
             }
         }
-
-        /// <summary>
-        /// 灏嗘帴鍙h繑鍥炵殑鏁版嵁鎻掑叆鍒版暟鎹簱涓紙甯﹀瓨鍦ㄦ�ф鏌ワ級
-        /// </summary>
-        /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
-        /// <returns>鎿嶄綔缁撴灉</returns>
-        public async Task<int> InsertPalletBindingDataWithCheckAsync(MesPalletBinding palletBinding)
+        catch (Exception ex)
         {
-            // 鍏堟鏌ユ爤鏉跨爜鏄惁瀛樺湪
-            bool exists = CheckStackCodeExists(palletBinding.StackCode);
-            return exists ? 1 :
-                // 璋冪敤鍘熸潵鐨勬彃鍏ユ柟娉�
-                InsertPalletBindingData(palletBinding);
+            throw new Exception($"鎻掑叆鏍堟澘缁戝畾鏁版嵁澶辫触: {ex.Message}");
         }
 
+        return insertedCount;
+    }
+
+    /// <summary>
+    /// 妫�鏌ユ爤鏉跨爜鍦ㄦ暟鎹簱涓槸鍚﹀瓨鍦�
+    /// </summary>
+    /// <param name="stackCode">鏍堟澘鐮�</param>
+    /// <returns>瀛樺湪杩斿洖true锛屽惁鍒欒繑鍥瀎alse</returns>
+    public bool CheckStackCodeExists(string stackCode)
+    {
+        try
+        {
+            if (string.IsNullOrEmpty(stackCode))
+            {
+                return false;
+            }
+
+            // 鏌ヨMES_PALLET_BINDING琛ㄤ腑鏄惁瀛樺湪璇ユ爤鏉跨爜鐨勬暟鎹�
+            var exists = Db.Queryable<MesPalletBinding1>()
+                .Any(x => x.Stackcode == stackCode);
+
+            return exists;
+        }
+        catch (Exception ex)
+        {
+            throw new Exception($"妫�鏌ユ爤鏉跨爜鏄惁瀛樺湪鏃跺嚭閿�: {ex.Message}");
+        }
+    }
+
+    /// <summary>
+    /// 灏嗘帴鍙h繑鍥炵殑鏁版嵁鎻掑叆鍒版暟鎹簱涓紙甯﹀瓨鍦ㄦ�ф鏌ワ級
+    /// </summary>
+    /// <param name="palletBinding">鏍堟澘缁戝畾淇℃伅</param>
+    /// <returns>鎿嶄綔缁撴灉</returns>
+    public async Task<int> InsertPalletBindingDataWithCheckAsync(
+        MesPalletBinding palletBinding)
+    {
+        // 鍏堟鏌ユ爤鏉跨爜鏄惁瀛樺湪
+        bool exists = CheckStackCodeExists(palletBinding.StackCode);
+        return exists
+            ? 1
+            :
+            // 璋冪敤鍘熸潵鐨勬彃鍏ユ柟娉�
+            InsertPalletBindingData(palletBinding);
+    }
+
     /// <summary>
     /// 鏍规嵁鏍堟澘鐮佸垹闄ゆ棫鏁版嵁
     /// </summary>

--
Gitblit v1.9.3