From 2640679b2823cd68d74e255442cce1634aac773c Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 10 十二月 2025 12:40:03 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/HuaYiZhongHeng/BaiBuLiKu

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs                |   73 ++++++++++++++++++
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json                                    |    4 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob_NewCW/CommonStackerCrane_NewCWJob.cs |    4 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs                     |    2 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs                                          |    2 
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs             |   25 +----
 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs       |   76 ++++++++++++++++--
 7 files changed, 150 insertions(+), 36 deletions(-)

diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
index 043d29a..b1dba4c 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
@@ -146,4 +146,4 @@
 app.MapHubs();
 app.MapControllers();
 
-app.Run();
\ No newline at end of file
+app.Run();                                          
\ No newline at end of file
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
index ab8ccef..62c0338 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/appsettings.json
@@ -1,5 +1,5 @@
 {
-    "urls": "http://*:9291", //web鏈嶅姟绔彛锛屽鏋滅敤IIS閮ㄧ讲锛屾妸杩欎釜鍘绘帀
+    "urls": "http://*:9290", //web鏈嶅姟绔彛锛屽鏋滅敤IIS閮ㄧ讲锛屾妸杩欎釜鍘绘帀
     "Logging": {
         "LogLevel": {
             "Default": "Information",
@@ -12,7 +12,7 @@
     "MainDB": "DB_WIDESEA", //褰撳墠椤圭洰鐨勪富搴擄紝鎵�瀵瑰簲鐨勮繛鎺ュ瓧绗︿覆鐨凟nabled蹇呴』涓簍rue
     //杩炴帴瀛楃涓�
     //"ConnectionString": "Data Source=.\\LIULEI;Initial Catalog=WIDESEA_WCSDBB2F;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
-    "ConnectionString": "Data Source=.;Initial Catalog=WIDESEA_WCSDB;User ID=sa;Password=P@ssw0rd;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
+    "ConnectionString": "Data Source=.;Initial Catalog=WIDESEA_WCSDB;User ID=sa;Password=123456;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
     //璺ㄥ煙
     "Cors": {
         "PolicyName": "CorsIpAccess", //绛栫暐鍚嶇О
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
index 9736d13..e403edf 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
@@ -448,7 +448,7 @@
                 {
                     if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut && taskDTO.RoadWay.Contains("CW"))
                     {
-                        var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1017" && x.stationType == 10 && x.Roadway == taskDTO.RoadWay);
+                        var stationinfo = _stationManagerRepository.QueryFirst(x => (x.stationPLC == "1017" ||x.stationPLC=="1024")&& x.stationType == 10 && x.Roadway == taskDTO.RoadWay);
                         task.TaskState = (int)TaskOutStatusEnum.OutNew;
                         task.CurrentAddress = taskDTO.SourceAddress;
                         task.NextAddress = stationinfo.stationChildCode;
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs
index 854c468..d5cc717 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs
@@ -320,20 +320,36 @@
         /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
         /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
         /// <param name="ProtocalDetailValue">绾夸綋褰撳墠bool璇诲彇鍋忕Щ鍦板潃</param>
+        /// <summary>
+        /// 瑙﹀彂杈撻�佺嚎鍑哄簱璇锋眰澶勭悊
+        /// </summary>
+        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥锛圕ommonConveyorLine_CW绫诲瀷锛夛紝鍖呭惈杈撻�佺嚎璁惧鍩虹淇℃伅鍜屾搷浣滄柟娉�</param>
+        /// <param name="command">杈撻�佺嚎浠诲姟鎸囦护瀵硅薄锛堝悗缁増鏈級锛屾殏鏈洿鎺ヤ娇鐢紝棰勭暀鎸囦护涓婁笅鏂�</param>
+        /// <param name="childDeviceCode">瀛愯澶囩紪鐮侊紝鐢ㄤ簬瀹氫綅杈撻�佺嚎鐨勫叿浣撳瓙璁惧</param>
         public void RequestOutbound(CommonConveyorLine_CW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
         {
+            // 鏍规嵁涓昏緭閫佺嚎璁惧缂栫爜鍜屽瓙璁惧缂栫爜锛屾煡璇㈠搴旂殑杈撻�佺嚎浠诲姟
             var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+
+            // 鑻ユ煡璇㈠埌鏈夋晥浠诲姟锛屽垯鎵ц鍚庣画鎸囦护鍙戦�佸拰鐘舵�佹洿鏂伴�昏緫
             if (task != null)
             {
+                // 灏嗘暟鎹簱鏌ヨ鍒扮殑浠诲姟瀵硅薄鏄犲皠涓烘寚浠ゅ璞★紙閫傞厤鎸囦护鍙戦�佺殑鏁版嵁缁撴瀯锛�
                 ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
-                //conveyorLine.SendCommand(taskCommand, childDeviceCode);
 
+                // 鍙戦�佷换鍔℃寚浠ゅ埌鎸囧畾杈撻�佺嚎瀛愯澶囷紝骞惰幏鍙栧彂閫佺粨鏋滐紙鍘熸敞閲婃帀鐨刢onveyorLine.SendCommand宸叉浛鎹负灏佽鍚庣殑鏂规硶锛�
                 bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode);
+
+                // 鑻ユ寚浠ゅ彂閫佹垚鍔燂紝鎵ц鐘舵�佹洿鏂版搷浣�
                 if (sendFlag)
                 {
+                    // 鏇存柊杈撻�佺嚎瀛愯澶囩殑鍝嶅簲鐘舵�佷负1锛�1浠h〃鎸囦护宸插搷搴�/澶勭悊鎴愬姛锛屽搴旀暟鎹簱瀛楁ConveyorLineDBName_After.ResponState锛�
                     conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode);
 
+                    // 灏嗕换鍔$姸鎬佹洿鏂板埌涓嬩竴涓樁娈碉紙閫氱敤浠诲姟鐘舵�佹祦杞級
                     _taskService.UpdateTaskStatusToNext(task);
+
+                    // 鐗规畩澶勭悊锛氳嫢浠诲姟绫诲瀷涓哄嚭鎵樼洏锛圤utTray锛夛紝棰濆鍐嶆墽琛屼竴娆′换鍔$姸鎬佹洿鏂帮紙閫傞厤鍑烘墭鐩樹换鍔$殑鐗规畩鐘舵�佹祦杞�昏緫锛�
                     if (task.TaskType == (int)TaskOutboundTypeEnum.OutTray)
                     {
                         _taskService.UpdateTaskStatusToNext(task);
@@ -348,63 +364,103 @@
         /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
         /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
         /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
+        /// <summary>
+        /// 澶勭悊杈撻�佺嚎涓嬩竴鍦板潃璇锋眰锛堟牳蹇冮�昏緫锛氭煡璇㈡墽琛屼腑浠诲姟鈫掕幏鍙朚OM閰嶇疆鈫掕皟鐢∕OM鎺ュ彛鏍¢獙鈫掓牴鎹牎楠岀粨鏋�/浠诲姟鐘舵�佸彂閫佹寚浠ゅ苟鏇存柊浠诲姟锛�
+        /// </summary>
+        /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥锛圕ommonConveyorLine_CW绫诲瀷锛夛紝鍖呭惈杈撻�佺嚎璁惧鍩虹淇℃伅鍜屾搷浣滄柟娉�</param>
+        /// <param name="command">杈撻�佺嚎浠诲姟鎸囦护瀵硅薄锛堝悗缁増鏈級锛屾惡甯︿换鍔$紪鍙枫�佹潯鐮併�佸瓙璁惧缂栫爜绛夊叧閿寚浠ゅ弬鏁�</param>
+        /// <param name="childDeviceCode">瀛愯澶囩紪鐮侊紝鐢ㄤ簬瀹氫綅杈撻�佺嚎鐨勫叿浣撳瓙璁惧</param>
         public void RequestOutNextAddress(CommonConveyorLine_CW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
         {
+            // 1. 鏌ヨ鎸囧畾鏉′欢涓嬫鍦ㄦ墽琛岀殑杈撻�佺嚎浠诲姟锛堜换鍔$紪鍙�+瀛愯澶囩紪鐮�+杈撻�佺嚎鏉$爜锛�
             Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode, command.ConveyorLineBarcode);
+
+            // 浠呭綋鏌ヨ鍒版湁鏁堟墽琛屼腑浠诲姟鏃讹紝鎵ц鍚庣画閫昏緫
             if (task != null)
             {
+                // 2. 鑾峰彇绯荤粺閰嶇疆涓�孖P鍦板潃銆嶅垎绫讳笅鐨勯厤缃」锛堢敤浜庢嫾鎺OM鎺ュ彛鍦板潃锛�
                 var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+                // 鎻愬彇MOM鍩虹IP閰嶇疆鍊�
                 var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.MOMIP_BASE)?.ConfigValue;
+                // 鎻愬彇鎵樼洏鏍煎彛鐘舵�佹帴鍙g殑IP璺緞閰嶇疆鍊�
                 var ipAddress = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.TrayCellsStatus)?.ConfigValue;
+
+                // 鏍¢獙MOM IP閰嶇疆瀹屾暣鎬э紝缂哄け鍒欐姏鍑哄紓甯哥粓姝㈡祦绋�
                 if (wmsBase == null || ipAddress == null)
                 {
                     throw new InvalidOperationException("MOM IP 鏈厤缃�");
                 }
+
+                // 3. 鏌ヨ褰撳墠杈撻�佺嚎璁惧+瀛愯澶囧搴旂殑宸ヤ綅閰嶇疆淇℃伅锛堝叧鑱擯LC缂栫爜銆佸瓙缂栫爜涓嶮OM璁惧缂栫爜锛�
                 Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
+
+                // 4. 鏋勫缓鎵樼洏鏍煎彛鐘舵�佹牎楠岀殑璇锋眰DTO锛堥�傞厤MOM鎺ュ彛鍏ュ弬鏍煎紡锛�
                 TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
                 {
-                    Software = "WMS",
-                    TrayBarcode = command.ConveyorLineBarcode,
-                    EquipmentCode = stationManager.stationEquipMOM,
-                    SessionId = Guid.NewGuid().ToString(),
-                    EmployeeNo = "MITest",
-                    SceneType = "1",
-                    RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ")
+                    Software = "WMS",                // 璋冪敤鏂圭郴缁熸爣璇嗭紙鍥哄畾涓篧MS锛�
+                    TrayBarcode = command.ConveyorLineBarcode, // 杈撻�佺嚎鏉$爜锛堟墭鐩樻潯鐮侊級
+                    EquipmentCode = stationManager.stationEquipMOM, // MOM绯荤粺瀵瑰簲鐨勮澶囩紪鐮�
+                    SessionId = Guid.NewGuid().ToString(), // 鍞竴浼氳瘽ID锛堥槻姝㈤噸澶嶈姹傦級
+                    EmployeeNo = "MITest",           // 鎿嶄綔鍛樺伐缂栧彿锛堟祴璇曞浐瀹氬�硷級
+                    SceneType = "1",                 // 鍦烘櫙绫诲瀷锛�1浠h〃鍏ョ珯鏍¢獙鍦烘櫙锛�
+                    RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ") // UTC鏍煎紡璇锋眰鏃堕棿
                 };
 
+                // 鎷兼帴瀹屾暣鐨凪OM鎺ュ彛鍦板潃锛堝熀纭�IP + 鎺ュ彛璺緞锛�
                 var MOMIpAddress = wmsBase + ipAddress;
 
+                // 5. 璋冪敤MOM鎺ュ彛锛圥OST寮傛璇锋眰锛屽悓姝ョ瓑寰呯粨鏋滐級
                 var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.Serialize()).Result;
+
+                // 璁板綍鎺ュ彛璋冪敤鏃ュ織锛堣姹傚弬鏁般�佽繑鍥炲弬鏁帮級锛屼究浜庨棶棰樻帓鏌�
                 WriteInfo("鍏ョ珯鏍¢獙", $"銆恵childDeviceCode}銆戝叆绔欐牎楠岃姹傚弬鏁般�恵trayCells.Serialize()}銆�");
                 WriteInfo("鍏ョ珯鏍¢獙", "");
                 WriteInfo("鍏ョ珯鏍¢獙", $"銆恵childDeviceCode}銆戝叆绔欐牎楠岃繑鍥炲弬鏁般�恵result}銆�");
+
+                // 6. 瑙f瀽MOM鎺ュ彛杩斿洖缁撴灉涓哄疄浣撳璞�
                 ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result);
+
+                // 7. 鍒嗘敮1锛氭帴鍙f牎楠屾垚鍔� 鎴� 浠诲姟澶囨敞闈濶G锛堟甯告祦绋嬶級
                 if (result1.Success || task.Remark != "NG")
                 {
+                    // 鏇存柊浠诲姟鐨勪綅缃俊鎭紙浠诲姟缂栧彿+褰撳墠鍦板潃锛夛紝杩斿洖鏇存柊鍚庣殑浠诲姟瀵硅薄
                     Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
+
                     if (newTask != null)
                     {
+                        // 灏嗘洿鏂板悗鐨勪换鍔″璞℃槧灏勪负杈撻�佺嚎鎸囦护瀵硅薄锛堥�傞厤鎸囦护鍙戦�佺粨鏋勶級
                         ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(newTask);
-                        //conveyorLine.SendCommand(taskCommand, childDeviceCode);
 
+                        // 鍙戦�佹寚浠ゅ埌杈撻�佺嚎瀛愯澶囷紝鑾峰彇鍙戦�佺粨鏋滐紙灏佽鍚庣殑SendCommand鏂规硶锛�
                         bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode);
+
+                        // 鎸囦护鍙戦�佹垚鍔熷垯鏇存柊璁惧鍝嶅簲鐘舵�佸拰浠诲姟鏁版嵁
                         if (sendFlag)
                         {
+                            // 鏇存柊杈撻�佺嚎瀛愯澶囧搷搴旂姸鎬佷负1锛堜唬琛ㄦ寚浠ゅ鐞嗘垚鍔燂級
                             conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode);
+                            // 鎸佷箙鍖栨洿鏂板悗鐨勪换鍔℃暟鎹埌鏁版嵁搴�
                             _taskService.UpdateData(newTask);
                         }
                     }
                 }
+                // 8. 鍒嗘敮2锛氭帴鍙f牎楠屽け璐� 涓� 浠诲姟澶囨敞涓篘G锛堝紓甯告祦绋嬶紝鍙戦�丯G鍦板潃鎸囦护锛�
                 else
                 {
+                    // 灏嗗師浠诲姟瀵硅薄鏄犲皠涓鸿緭閫佺嚎鎸囦护瀵硅薄
                     ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
+                    // 璁剧疆鎸囦护鐨勭洰鏍囧湴鍧�涓哄伐浣嶉厤缃腑鐨凬G瀛愮紪鐮侊紙瀵煎悜寮傚父澶勭悊宸ヤ綅锛�
                     taskCommand.ConveyorLineTargetAddress = Convert.ToInt16(stationManager.stationNGChildCode);
-                    //conveyorLine.SendCommand(taskCommand, childDeviceCode);
 
+                    // 鍙戦�丯G鍦板潃鎸囦护鍒拌緭閫佺嚎瀛愯澶囷紝鑾峰彇鍙戦�佺粨鏋�
                     bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode);
+
+                    // 鎸囦护鍙戦�佹垚鍔熷垯鏇存柊璁惧鍝嶅簲鐘舵�佸拰浠诲姟鐘舵��
                     if (sendFlag)
                     {
+                        // 鏇存柊杈撻�佺嚎瀛愯澶囧搷搴旂姸鎬佷负1
                         conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, Convert.ToInt16(1), childDeviceCode);
+                        // 灏嗕换鍔$姸鎬佹祦杞埌涓嬩竴涓樁娈碉紙閫傞厤NG浠诲姟鐨勭姸鎬侀�昏緫锛�
                         _taskService.UpdateTaskStatusToNext(task);
                     }
                 }
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
index 28591d2..5b511f2 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -173,13 +173,13 @@
 
                     if (commonStackerCrane.DeviceCode.Contains("CW") && task.TaskType==(int)TaskOutboundTypeEnum.InToOut)
                     {
-                        var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1017" && x.stationType == 10 && x.Roadway == commonStackerCrane.DeviceCode);
+                        var stationinfo = _stationManagerRepository.QueryFirst(x => (x.stationPLC == "1017"||x.stationPLC=="1024") && x.stationType == 10 && x.Roadway == commonStackerCrane.DeviceCode);
 
                         IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC);
                         if (device != null)
                         {
                             CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device;
-                            conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(1815), stationinfo.stationChildCode);
+                            conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(4000), stationinfo.stationChildCode);
                             Thread.Sleep(100);
                             conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode);
                         }
@@ -334,24 +334,11 @@
                 else
                 {
                     IDevice? device = null;
-                    if (task.Roadway.Contains("GWSC3"))
+                    if (task.Roadway.Contains("GW"))
                     {
-                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "2025");
-                        if (device != null)
-                        {
-                            CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
-                            if (conveyorLine.IsOccupied(task.TargetAddress))//鍑哄簱绔欏彴鏈鍗犵敤
-                            {
-                                return task;
-                            }
-                        }
-                        else
-                        {
-                            _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.TargetAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤");
-                        }
-                    } else if (task.Roadway.Contains("GW"))
-                    {
-                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1015");
+                        string targetDeviceCode = task.Roadway == "GWSC3" ? "2025" : "1015";
+                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == targetDeviceCode);
+
                         if (device != null)
                         {
                             CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob_NewCW/CommonStackerCrane_NewCWJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob_NewCW/CommonStackerCrane_NewCWJob.cs
index 03cb8b8..018a456 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob_NewCW/CommonStackerCrane_NewCWJob.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob_NewCW/CommonStackerCrane_NewCWJob.cs
@@ -173,13 +173,13 @@
 
                     if (commonStackerCrane.DeviceCode.Contains("CW") && task.TaskType==(int)TaskOutboundTypeEnum.InToOut)
                     {
-                        var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1017" && x.stationType == 10 && x.Roadway == commonStackerCrane.DeviceCode);
+                        var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1024" && x.stationType == 10 && x.Roadway == commonStackerCrane.DeviceCode);
 
                         IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC);
                         if (device != null)
                         {
                             CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device;
-                            conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(1815), stationinfo.stationChildCode);
+                            conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(4000), stationinfo.stationChildCode);
                             Thread.Sleep(100);
                             conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode);
                         }
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs
index dd6432e..5757f64 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs
@@ -1,4 +1,6 @@
 锘縰sing AngleSharp.Dom;
+using Magicodes.ExporterAndImporter.Core;
+using Magicodes.ExporterAndImporter.Excel;
 using Mapster;
 using Masuit.Tools;
 using SqlSugar;
@@ -10,6 +12,8 @@
 using WIDESEA_Cache;
 using WIDESEA_Common;
 using WIDESEA_Core;
+using WIDESEA_IStorageBasicService;
+using WIDESEA_Model.Models.BasicModel;
 
 namespace WIDESEA_StorageBasicService;
 
@@ -18,10 +22,12 @@
 
     private readonly ISimpleCacheService _simpleCacheService;
     private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository;
-    public StockInfoService(IStockInfoRepository BaseDal, ISimpleCacheService simpleCacheService, ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal)
+    private readonly IStockInfoDetailRepository _IStockInfoDetailRepository;
+    public StockInfoService(IStockInfoRepository BaseDal, ISimpleCacheService simpleCacheService, ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository, IStockInfoDetailRepository stockInfoDetailService) : base(BaseDal)
     {
         _simpleCacheService = simpleCacheService;
         _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository;
+        _IStockInfoDetailRepository = stockInfoDetailService;
     }
 
     /// <summary>
@@ -151,6 +157,71 @@
             .ToDictionary(x => x.Key, x => x.Count());
         return result;
     }
+    public override WebResponseContent Export(PageDataOptions options)
+    {
+        WebResponseContent content = new WebResponseContent();
+        try
+        {
+            // 1. 鏋勫缓涓昏〃鏌ヨ鏉′欢鍜屾帓搴�
+            string wheres = ValidatePageOptions(options);
+            Dictionary<string, OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
+
+            // 2. 鏌ヨ涓昏〃鏁版嵁
+            List<DtStockInfo> mainList = BaseDal.QueryData(wheres, orderbyDic);
+            if (!mainList.Any())
+            {
+                return WebResponseContent.Instance.OK("鏃犳暟鎹彲瀵煎嚭");
+            }
+
+            // 3. 鎵归噺鏌ヨ瀛愯〃鏁版嵁锛堥�氳繃涓昏〃Id鍏宠仈锛�
+            var mainIds = mainList.Select(m => m.Id).Distinct().ToList();
+            List<DtStockInfoDetail> detailList = _IStockInfoDetailRepository.Db
+                .Queryable<DtStockInfoDetail>()
+                .Where(d => mainIds.Contains(d.StockId))
+                .ToList();
+
+            // 4. 鍏宠仈涓昏〃鍜屽瓙琛ㄦ暟鎹紙鍙彇瀛愯〃绗竴鏉★級
+            var exportData = new List<PalletWithDetailExportModel>();
+            foreach (var main in mainList)
+            {
+                // 鍙彇褰撳墠涓昏〃鏁版嵁鍏宠仈鐨勫瓙琛ㄧ涓�鏉★紙鍙�氳繃OrderBy鎸囧畾鎺掑簭锛岀‘淇濆彇鍒版兂瑕佺殑绗竴鏉★級
+                var firstDetail = detailList
+                    .Where(d => d.StockId == main.Id)
+                    .OrderBy(d => d.Id) // 鍙�夛細鎸夊瓙琛↖d鎺掑簭锛岀‘淇濈粨鏋滅ǔ瀹氾紙鍙浛鎹负鍏朵粬瀛楁锛�
+                    .FirstOrDefault();
+
+                var exportModel = new PalletWithDetailExportModel
+                {
+                    Id = main.Id,
+                    PalletCode = main.PalletCode,
+                    LocationCode = main.LocationCode,
+                    IsFull = main.IsFull,
+                    Remark = main.Remark,
+                    Creater = main.Creater,
+                    CreateDate = main.CreateDate,
+                    OutboundTime = (DateTime)main.OutboundTime,
+                    // 鏈夊瓙琛ㄦ暟鎹垯鍙栫涓�鏉$殑鐗╂枡缂栫爜锛屾棤鍒欎负绌�
+                    MaterielCode = firstDetail?.MaterielCode ?? ""
+                };
+                exportData.Add(exportModel);
+            }
+
+            // 5. 瀵煎嚭鏁版嵁锛堥�昏緫涓嶅彉锛�
+            string savePath = AppDomain.CurrentDomain.BaseDirectory + "ExcelExport";
+            IExporter exporter = new ExcelExporter();
+            byte[] data = exporter.ExportAsByteArray(exportData).Result;
+
+            string fileName = "鎵樼洏鍙婄墿鏂欑紪鐮佹暟鎹�.xlsx";
+            FileHelper.WriteFile(savePath, fileName, data);
+
+            content = WebResponseContent.Instance.OK(data: Path.Combine(savePath, fileName));
+        }
+        catch (Exception ex)
+        {
+            content = WebResponseContent.Instance.Error(ex.Message);
+        }
+        return content;
+    }
 
     //public override WebResponseContent UpdateData(DtStockInfo entity)
     //{

--
Gitblit v1.9.3