From 04b4e2ca4bbbc147036a0bf15ce0b8b1c45cc74b Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期六, 11 十月 2025 16:26:22 +0800
Subject: [PATCH] 新增设备状态上传与包装站台换型功能在CommonConveyorLine_BZJob.cs和CommonConveyorLine_GWJob.cs中新增对信号状态判断逻辑。 在 ConfigConst.cs`中新增常量 EqptRun,用于设备状态上传。新增 EqptRunDTO类,支持设备运行状态的数据传输。在 IAgingInOrOutInputService.cs中定义 Change方法接口,并在AgingInOrOutInputService.cs中实现设备型号修改逻辑。优化 Dt_TaskService.cs中的异常电芯处理、组盘信息获取、库存查询逻辑,并新增包装站台换型功能。 - 增强日志记录,便于问题排查。

---
 CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs                        |   33 ++++++
 CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db-shm                                    |    0 
 CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/ResponeAgingInputDto.cs                                                                    |   25 +++++
 CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs                                                         |   63 +++++++++---
 CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_StoragIntegrationRepository.AssemblyInfo.cs   |    2 
 CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_IStoragIntegrationRepository.AssemblyInfo.cs |    2 
 CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/AgingInOrOutInput/IAgingInOrOutInputService.cs                      |    7 +
 CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db                                   |    0 
 CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs                                            |    7 +
 CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db-shm                               |    0 
 CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db                                        |    0 
 CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db-wal                                    |    0 
 CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db-wal                               |    0 
 CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs                                                                          |    5 +
 CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs                                            |   31 ++++++
 CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs                                                 |   84 +++++++++++++---
 16 files changed, 220 insertions(+), 39 deletions(-)

diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db
new file mode 100644
index 0000000..7e169b6
--- /dev/null
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db
Binary files differ
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db-shm b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db-shm
new file mode 100644
index 0000000..9f961df
--- /dev/null
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db-shm
Binary files differ
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db-wal b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db-wal
new file mode 100644
index 0000000..c18a298
--- /dev/null
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/CodeChunks.db-wal
Binary files differ
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db
new file mode 100644
index 0000000..86614c0
--- /dev/null
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db
Binary files differ
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db-shm b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db-shm
new file mode 100644
index 0000000..d86fb2e
--- /dev/null
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db-shm
Binary files differ
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db-wal b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db-wal
new file mode 100644
index 0000000..a913f2f
--- /dev/null
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/CopilotIndices/17.14.1231.31060/SemanticSymbols.db-wal
Binary files differ
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs
index 2c38342..e56d245 100644
--- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_BZ/CommonConveyorLine_BZJob.cs
@@ -186,6 +186,13 @@
         public void RequestOutbound(CommonConveyorLine_BZ conveyorLine, ConveyorLineTaskCommand_After command, Dt_StationManager station)
         {
             //鏌ヨ瀵瑰簲浜х嚎鐨勫湪閫旀暟鎹�
+
+            ConveyorLineTaskCommand_After readSignal = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationLocation);
+            if (readSignal.Reserved5 == 1)
+            {
+                ConsoleHelper.WriteErrorLine($"鍖呰{station.productLine}寮�濮嬫竻鏂�");
+                return;
+            }
             dt_needBarcode needBarcode = _needBarcodeRepository.QueryFirst(x => x.productLine == station.productLine && x.toArea == station.stationChildCode);
 
             needBarcode.inLineNum = _taskRepository.QueryData(x => x.TargetAddress == station.stationChildCode).Count();
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
index c0608b7..7275c18 100644
--- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
@@ -426,6 +426,22 @@
                     conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, taskCommand.ConveyorLineTargetAddress, childDeviceCode);
                     conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, taskCommand.ConveyorLineBarcode, childDeviceCode);
                     conveyorLine.Communicator.Write(address, 1);
+
+
+                    var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationArea == "Call" && x.stationType == 12);
+                    CommonConveyorLine_BZ? commonConveyorBZ = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC) as CommonConveyorLine_BZ;
+                    if (commonConveyorBZ != null)
+                    {
+                        ConveyorLineTaskCommand_After readSignal = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationLocation);
+                        if (readSignal.Reserved5 == 1)
+                        {
+                            var tasks = _taskRepository.QueryData(x => x.TargetAddress == childDeviceCode);
+                            if (tasks.Count == 0)
+                            {
+                                commonConveyorBZ.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), station.stationLocation);
+                            }
+                        }
+                    }
                     WriteInfo($"{conveyorLine.DeviceName}杈撻�佺嚎鍑哄簱瀹屾垚", $"瀛愯妭鐐广�恵childDeviceCode}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆�");
                 }
                 else
@@ -473,6 +489,21 @@
                         conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, taskCommand.ConveyorLineTargetAddress, childDeviceCode);
                         conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, taskCommand.ConveyorLineBarcode, childDeviceCode);
                         conveyorLine.Communicator.Write(address, 1);
+
+                        var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationArea == "Call" && x.stationType == 12);
+                        CommonConveyorLine_BZ? commonConveyorBZ = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC) as CommonConveyorLine_BZ;
+                        if (commonConveyorBZ != null)
+                        {
+                            ConveyorLineTaskCommand_After readSignal = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationLocation);
+                            if (readSignal.Reserved5 == 1)
+                            {
+                                var tasks = _taskRepository.QueryData(x => x.TargetAddress == childDeviceCode);
+                                if (tasks.Count == 0)
+                                {
+                                    commonConveyorBZ.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), station.stationLocation);
+                                }
+                            }
+                        }
                         WriteInfo($"{conveyorLine.DeviceName}杈撻�佺嚎鍑哄簱瀹屾垚", $"瀛愯妭鐐广�恵childDeviceCode}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆�");
                     }
                 }
diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs
index e8aa75d..b860023 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_Core/Const/ConfigConst.cs
@@ -113,6 +113,11 @@
         public const string AgingOutput = "AgingOutput";
 
         /// <summary>
+        /// 璁惧鐘舵�佷笂浼�
+        /// </summary>
+        public const string EqptRun = "EqptRun";
+
+        /// <summary>
         /// 宸ヨ壓璺嚎鐢宠
         /// </summary>
         public const string ProcessApply = "ProcessApply";
diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/ResponeAgingInputDto.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/ResponeAgingInputDto.cs
index f2f7358..3a44099 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/ResponeAgingInputDto.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/ResponeAgingInputDto.cs
@@ -91,4 +91,29 @@
         /// </summary>
         public string ParameterCode { get; set; }
     }
+
+    public class EqptRunDTO : BasicResult
+    {
+        public string WipOrderNo { get; set; }
+
+        public string ProductDesc { get; set; }
+
+        public string FirstArticleNum { get; set; }
+
+        public string DebugNum { get; set; }
+
+        public string ParamVersion { get; set; }
+
+        public string ParamRefreshFlag { get; set; }
+
+        public string ProductType { get; set; }
+
+        public bool ProductModel { get; set; }
+
+        public string ParameterInfo { get; set; }
+
+        public string IsProcessed { get; set; }
+
+        public string PreProductNo { get; set; }
+    }
 }
\ No newline at end of file
diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_IStoragIntegrationRepository.AssemblyInfo.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_IStoragIntegrationRepository.AssemblyInfo.cs
index 58175dc..6e4c26a 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_IStoragIntegrationRepository.AssemblyInfo.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_IStoragIntegrationRepository.AssemblyInfo.cs
@@ -14,7 +14,7 @@
 [assembly: System.Reflection.AssemblyCompanyAttribute("WIDESEA_IStoragIntegrationRepository")]
 [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
 [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b2feeabc23454a2c9e161aa3b26d0edf938e55bd")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1c637ea862816ae6fa53945fa0327b95c79aa18b")]
 [assembly: System.Reflection.AssemblyProductAttribute("WIDESEA_IStoragIntegrationRepository")]
 [assembly: System.Reflection.AssemblyTitleAttribute("WIDESEA_IStoragIntegrationRepository")]
 [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/AgingInOrOutInput/IAgingInOrOutInputService.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/AgingInOrOutInput/IAgingInOrOutInputService.cs
index 1e87d41..339f2fd 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/AgingInOrOutInput/IAgingInOrOutInputService.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/AgingInOrOutInput/IAgingInOrOutInputService.cs
@@ -18,4 +18,11 @@
     /// <param name="input">鍑哄簱鏁版嵁</param>
     /// <returns></returns>
     Task<WebResponseContent> GetOCVOutputAsync(AgingOutputDto input);
+
+    /// <summary>
+    /// 淇敼璁惧鍨嬪彿
+    /// </summary>
+    /// <param name="input"></param>
+    /// <returns></returns>
+    Task<WebResponseContent> Change(EqptRunDto input);
 }
\ No newline at end of file
diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_StoragIntegrationRepository.AssemblyInfo.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_StoragIntegrationRepository.AssemblyInfo.cs
index f6dc098..44e91f4 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_StoragIntegrationRepository.AssemblyInfo.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationRepository/obj/Debug/net6.0/WIDESEA_StoragIntegrationRepository.AssemblyInfo.cs
@@ -14,7 +14,7 @@
 [assembly: System.Reflection.AssemblyCompanyAttribute("WIDESEA_StoragIntegrationRepository")]
 [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
 [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b2feeabc23454a2c9e161aa3b26d0edf938e55bd")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1c637ea862816ae6fa53945fa0327b95c79aa18b")]
 [assembly: System.Reflection.AssemblyProductAttribute("WIDESEA_StoragIntegrationRepository")]
 [assembly: System.Reflection.AssemblyTitleAttribute("WIDESEA_StoragIntegrationRepository")]
 [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs
index 4280874..4b7265f 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs
@@ -123,4 +123,37 @@
         }
         return content;
     }
+    public async Task<WebResponseContent> Change(EqptRunDto input)
+    {
+        WebResponseContent content = new WebResponseContent();
+        try
+        {
+            input.SessionId = Guid.NewGuid().ToString();
+            input.EmployeeNo = "MITest";
+            input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
+            var inputJson = Masuit.Tools.ObjectExtensions.ToDictionary(input); // Specify the namespace explicitly
+            var configs = _configService.GetConfigsByCategory(CateGoryConst.SYS_MOMIPAddress);
+            var MOMBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.MOMBaseIP)?.ConfigValue;
+            var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.EqptRun)?.ConfigValue;
+            if (MOMBase == null || ipAddress == null)
+            {
+                throw new InvalidOperationException("WMS IP 鏈厤缃�");
+            }
+            var MOMIpAddress = MOMBase + ipAddress;
+
+            var result = HttpsClient.PostAsync(MOMIpAddress, inputJson).Result;
+
+            content.OK(data: result);
+            LogFactory.GetLog("鎹㈠瀷").Info(true, $"\r\r--------------------------------------");
+            LogFactory.GetLog("鎹㈠瀷").Info(true, input.EquipmentCode);
+            LogFactory.GetLog("鎹㈠瀷").Info(true, result);
+        }
+        catch (Exception err)
+        {
+            LogFactory.GetLog("鎹㈠瀷").Error(true, $"\r\r--------------------------------------");
+            LogFactory.GetLog("鎹㈠瀷").Error(true, err.StackTrace);
+            content.Error(err.Message);
+        }
+        return content;
+    }
 }
\ No newline at end of file
diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
index c346b05..41f4e30 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -758,11 +758,13 @@
             else
             {
                 // 澶勭悊寮傚父鐢佃姱鎯呭喌
-                var serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList();
-                if (serialNosError.Count > 0)
-                {
-                    return await HandleErrorCells(input, area, serialNosError);
-                }
+                #region 鐢佃姱鍒嗙粨鏋滃紓甯镐笉闇�瑕佹垜浠鐞�
+                //var serialNosError = result.SerialNos.Where(x => x.SerialNoStatus != 1 && x.SerialNoStatus != 4).ToList();
+                //if (serialNosError.Count > 0)
+                //{
+                //    return await HandleErrorCells(input, area, serialNosError);
+                //}
+                #endregion
 
                 var boxing = CreateBoxingInfo(result, input.PalletCode);
                 if (boxing == null) return content.Error("缁勭洏澶辫触");
@@ -873,21 +875,46 @@
     // 鑾峰彇缁勭洏淇℃伅
     private DtBoxingInfo CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode)
     {
-        return new DtBoxingInfo
+        var boxing = _boxingInfoRepository.QueryFirst(x => x.PalletCode == palletCode);
+        if (boxing == null)
         {
-            PalletCode = palletCode,
-            IsFull = true,
-            ProcessCode = result.ProcessCode,
-            ProductionLine = result.ProductionLine,
-            BoxingInfoDetails = result.SerialNos.Select(serialNoObj => new DtBoxingInfoDetail
+            return new DtBoxingInfo
             {
-                SerialNumber = serialNoObj.SerialNo,
-                OrderNo = serialNoObj.PositionNo.ToString(),
-                Status = serialNoObj.SerialNoStatus,
-                MaterielCode = result.BindCode,
-                Remark = result.TrayBarcodePropertys.ToJsonString(),
-            }).ToList()
-        };
+                PalletCode = palletCode,
+                IsFull = true,
+                ProcessCode = result.ProcessCode,
+                ProductionLine = result.ProductionLine,
+                BoxingInfoDetails = result.SerialNos.Select(serialNoObj => new DtBoxingInfoDetail
+                {
+                    SerialNumber = serialNoObj.SerialNo,
+                    OrderNo = serialNoObj.PositionNo.ToString(),
+                    Status = serialNoObj.SerialNoStatus,
+                    MaterielCode = result.BindCode,
+                    Remark = result.TrayBarcodePropertys.ToJsonString(),
+                }).ToList()
+            };
+        }
+        else
+        {
+            _boxingInfoRepository.Db.DeleteNav<DtBoxingInfo>(x => x.Id == boxing.Id)
+                                            .Include(x => x.BoxingInfoDetails)
+                                            .ExecuteCommandAsync();
+            return new DtBoxingInfo
+            {
+                PalletCode = palletCode,
+                IsFull = true,
+                ProcessCode = result.ProcessCode,
+                ProductionLine = result.ProductionLine,
+                BoxingInfoDetails = result.SerialNos.Select(seriaINoObj => new DtBoxingInfoDetail
+                {
+                    SerialNumber = seriaINoObj.SerialNo,
+                    OrderNo = seriaINoObj.PositionNo.ToString(),
+                    Status = seriaINoObj.SerialNoStatus,
+                    MaterielCode = result.BindCode,
+                    Remark = result.TrayBarcodePropertys.ToJsonString(),
+                }).ToList()
+            };
+        }
     }
 
     // 鑾峰彇宸ヨ壓鐢宠
diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
index 01591d9..8157244 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -1046,33 +1046,76 @@
             Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position && x.stationType == 12 && x.stationArea == "Call");
             if (station == null) { throw new Exception($"鏈壘鍒板寘瑁呯珯鍙颁俊鎭紝璇锋鏌ヤ紶鍏ュ弬鏁皗json.Position}"); }
 
+            EqptRunDto basic = new EqptRunDto()
+            {
+                EquipmentModel = "0",
+                Password = "",
+                EmployeeNo = "82412152",
+                SessionId = Guid.NewGuid().ToString(),
+                RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ"),
+                Software = "鍖呰涓婃枡",
+                EquipmentCode = station.stationEquipMOM,
+            };
+            var result = _agingInOrOutInputService.Change(basic).Result;
+            var respone = JsonConvert.DeserializeObject<EqptRunDTO>(result.Data.ToString());
+            if (!result.Status || !respone.Success)
+            {
+                throw new Exception($"{station.productLine}鑾峰彇MOM鎹㈠瀷鏁版嵁寮傚父,寮傚父淇℃伅{respone.MOMMessage}");
+            }
+
             var deviceCode = SqlSugarHelper.DbWCS.Queryable<Dt_DeviceInfo>()
                 .Where(x => x.DeviceStatus == "1")
                 .Where(x => x.DeviceCode.Contains("CWSC")) // 杩囨护鏉′欢
                 .ToList().Select(x => x.DeviceCode).ToList();
 
-            var outBoundMateriel = _dt_ChangeoversRepository.QueryData(x => x.Status == "1").ToList();
-            List<string>? materielCodes = outBoundMateriel.Count != 0
-                ? outBoundMateriel.Where(x => x.ProductionLine == station.productLine && x.ProcessCode == "CWSC3")
-                                  .Select(x => x.MaterielCode)
-                                  .ToList()
-                : null;
+            #region 鏃х殑鏌ヨ浠g爜
+            //var outBoundMateriel = _dt_ChangeoversRepository.QueryData(x => x.Status == "1").ToList();
+            //List<string>? materielCodes = outBoundMateriel.Count != 0
+            //    ? outBoundMateriel.Where(x => x.ProductionLine == station.productLine && x.ProcessCode == "CWSC3")
+            //                      .Select(x => x.MaterielCode)
+            //                      .ToList()
+            //    : null;
 
             // 淇敼鍚庣殑鏌ヨ浠g爜
-            var stockInfo = await _stockInfoRepository.Db.Queryable<DtStockInfo>()
-                                .Includes(x => x.LocationInfo)
-                                .Includes(x => x.StockInfoDetails)
-                                .Where(x => x.ProductionLine == station.productLine)
-                                .Where(x => x.AreaCode == "CWSC3" && x.IsFull == true)
-                                // 澧炲姞瀵� LocationInfo 鐨勭┖鍊兼鏌�
-                                .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock)
-                                // 澧炲姞瀵� LocationInfo 鐨勭┖鍊兼鏌�
-                                .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo))
-                                .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode)))
-                                .OrderBy(x => x.OutboundTime)
-                                .FirstAsync();
+            //var stockInfo = await _stockInfoRepository.Db.Queryable<DtStockInfo>()
+            //                    .Includes(x => x.LocationInfo)
+            //                    .Includes(x => x.StockInfoDetails)
+            //                    .Where(x => x.ProductionLine == station.productLine)
+            //                    .Where(x => x.AreaCode == "CWSC3" && x.IsFull == true)
+            //                    // 澧炲姞瀵� LocationInfo 鐨勭┖鍊兼鏌�
+            //                    .Where(x => x.LocationInfo.LocationStatus == (int)LocationEnum.InStock)
+            //                    // 澧炲姞瀵� LocationInfo 鐨勭┖鍊兼鏌�
+            //                    .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo))
+            //                    .WhereIF(!materielCodes.IsNullOrEmpty(), x => x.StockInfoDetails.Any(y => materielCodes.Contains(y.MaterielCode)))
+            //                    .OrderBy(x => x.OutboundTime)
+            //                    .FirstAsync();
+            #endregion
 
-            if (stockInfo.IsNullOrEmpty()) throw new Exception($"CWSC3搴撳唴{station.productLine}鏃犳弧瓒虫潯浠剁殑搴撳瓨鍙嚭搴�");
+            DtStockInfo stockInfo = null;
+            var stockInfoList = await _stockInfoRepository.Db.Queryable<DtStockInfo>()
+                .Includes(x => x.LocationInfo)
+                .Where(x => x.ProductionLine == station.productLine
+                        && x.AreaCode == "CWSC3"
+                        && x.IsFull == true
+                        && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock)
+                .WhereIF(!deviceCode.IsNullOrEmpty(), x => deviceCode.Contains(x.LocationInfo.RoadwayNo))
+                .OrderBy(x => x.OutboundTime)
+                .ToListAsync();
+
+            foreach (var stock in stockInfoList)
+            {
+                var hasMatchingDetail = await _stockInfoRepository.Db.Queryable<DtStockInfoDetail>()
+                    .Where(d => d.StockId == stock.Id && respone.PreProductNo.Contains(d.MaterielCode))
+                    .AnyAsync();
+
+                if (hasMatchingDetail)
+                {
+                    stockInfo = stock;
+                    break;
+                }
+            }
+
+            if (stockInfo.IsNullOrEmpty()) throw new Exception($"CWSC3搴撳唴銆恵station.productLine}銆�,銆愮墿鏂欑紪鐮亄respone.PreProductNo}銆戞棤婊¤冻鏉′欢鐨勫簱瀛樺彲鍑哄簱");
 
             DtLocationInfo locationInfo = _locationRepository.QueryFirst(x => x.AreaId == 5 && x.LocationCode == stockInfo.LocationCode);
 
@@ -1114,6 +1157,9 @@
         catch (Exception ex)
         {
             Console.WriteLine($"CW3鑷冲寘瑁呭嚭搴撳紓甯�:{ex.ToString()}");
+
+            LogFactory.GetLog($"鍖呰璇锋眰鍑哄簱浠诲姟").Info(true, $"銆愬紓甯搞�戯細銆恵ex.Message}銆憑Environment.NewLine}銆恵ex.StackTrace}銆憑Environment.NewLine}{Environment.NewLine}");
+
             return content.Error($"澶辫触锛歿ex.Message}");
         }
     }

--
Gitblit v1.9.3