From a2f06e43a6f4ed3c613aefbb8bc0ccf3dd30ff8f Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期五, 26 十二月 2025 13:34:20 +0800
Subject: [PATCH] 1

---
 项目代码/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db     |    0 
 项目代码/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs                                  |   21 ++--
 项目代码/WCSServices/WIDESEAWCS_Server/Program.cs                                               |    2 
 项目代码/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db          |    0 
 项目代码/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db-shm      |    0 
 项目代码/WCSServices/WIDESEAWCS_Server/HostedService/WebSocketSetup.cs                          |   48 ++++++++++++
 项目代码/WCSServices/WIDESEAWCS_DTO/ConnectDTO.cs                                               |    6 -
 项目代码/WCSServices/WIDESEAWCS_Server/Controllers/PTLAPIController.cs                          |  155 +++++++++++++++++++-------------------
 项目代码/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db-wal |    0 
 项目代码/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db-wal      |    0 
 项目代码/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db-shm |    0 
 项目代码/WCSServices/WIDESEAWCS_Server/Controllers/RYB_PTL_API.dll                              |    0 
 12 files changed, 137 insertions(+), 95 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db"
new file mode 100644
index 0000000..1651c9d
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db-shm" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db-shm"
new file mode 100644
index 0000000..d84d5d8
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db-shm"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db-wal" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db-wal"
new file mode 100644
index 0000000..2633fdd
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/CodeChunks.db-wal"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db"
new file mode 100644
index 0000000..d0e0753
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db-shm" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db-shm"
new file mode 100644
index 0000000..9509fed
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db-shm"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db-wal" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db-wal"
new file mode 100644
index 0000000..62f6455
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/.vs/WIDESEAWCS_Server/CopilotIndices/18.0.934.24903/SemanticSymbols.db-wal"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_DTO/ConnectDTO.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_DTO/ConnectDTO.cs"
index 2fd434e..7e6b398 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_DTO/ConnectDTO.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_DTO/ConnectDTO.cs"
@@ -11,14 +11,10 @@
         /// <summary>
         /// 鎺у埗鍣↖P鍦板潃
         /// </summary>
-        public string sIp { get; set; }
+        public string sIp { get; set; } = "11.2.30.252";
         /// <summary>
         /// 绔彛鍙烽粯璁ゅ��6020
         /// </summary>
         public int iPort { get; set; } = 6020;
-        /// <summary>
-        /// 鍙�夌殑瓒呮椂鍙傛暟
-        /// </summary>
-        public int? iTimeOut { get; set; }
     }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/PTLAPIController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/PTLAPIController.cs"
index 29fa81e..bd9cf8e 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/PTLAPIController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/PTLAPIController.cs"
@@ -1,13 +1,11 @@
 锘縰sing Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using RYB_PTL_API;
-using System.Security.Policy;
+using System.Collections.Generic;
+using System.Linq;
 using WIDESEAWCS_DTO;
 using WIDESEAWCS_DTO.TaskInfo;
-using WIDESEAWCS_IBasicInfoRepository;
-using WIDESEAWCS_ITaskInfoRepository;
 using WIDESEAWCS_ITaskInfoService;
-using WIDESEAWCS_QuartzJob.Repository;
 
 namespace WIDESEAWCS_Server.Controllers
 {
@@ -16,70 +14,75 @@
     public class PTLAPIController : ControllerBase
     {
         private readonly ITaskService _taskService;
-        //private bool _eventSubscribed = false;
+        private bool _eventSubscribed = false;
 
         public PTLAPIController(ITaskService taskService)
         {
             _taskService = taskService;
-            //SubscribeEvent();
+            SubscribeEvent();
         }
 
         /// <summary>
         /// 璁㈤槄PTL浜嬩欢
         /// </summary>
-        //private void SubscribeEvent()
-        //{
-        //    if (!_eventSubscribed)
-        //    {
-        //        RYB_PTL.UserResultAvailable += RYB_PTL_UserResultAvailable;
-        //        _eventSubscribed = true;
-        //    }
-        //}
+        private void SubscribeEvent()
+        {
+            if (!_eventSubscribed)
+            {
+                RYB_PTL.UserResultAvailable += new RYB_PTL.UserResultAvailableEventHandler(RYB_PTL_UserResultAvailable);
+                _eventSubscribed = true;
+            }
+        }
+        
+        /// <summary>
+        /// 鍙栨秷璁㈤槄PTL浜嬩欢
+        /// </summary>
+        private void UnsubscribeEvent()
+        {
+            if (_eventSubscribed)
+            {
+                RYB_PTL.UserResultAvailable -= new RYB_PTL.UserResultAvailableEventHandler(RYB_PTL_UserResultAvailable);
+                _eventSubscribed = false;
+            }
+        }
+        /// <summary>
+        /// PTL鍥炶皟浜嬩欢澶勭悊锛堝彧澶勭悊鎵嬫媿浜嬩欢锛�
+        /// </summary>
+        private void RYB_PTL_UserResultAvailable(RYB_PTL.RtnValueStruct rs)
+        {
+            try
+            {
+                if (rs.KeyCode == null)
+                {
+                    return;
+                }
+                // 鏋勫缓鍥炶皟鏁版嵁
+                var pTLCallBackDTO = new PTLCallBackDTO
+                {
+                    sIp = rs.Ip,
+                    sTagID = rs.Tagid,
+                    sValue = rs.Number,
+                    sKeyCode = rs.KeyCode,
+                    sLocator = rs.Locator
+                };
 
-        ///// <summary>
-        ///// 鍙栨秷璁㈤槄PTL浜嬩欢
-        ///// </summary>
-        //private void UnsubscribeEvent()
-        //{
-        //    if (_eventSubscribed)
-        //    {
-        //        RYB_PTL.UserResultAvailable -= RYB_PTL_UserResultAvailable;
-        //        _eventSubscribed = false;
-        //    }
-        //}
+                // 鏍规嵁涓氬姟闇�瑕佹瀯寤轰换鍔′俊鎭�
+                var taskBackLight = new TaskBackLight()
+                {
+                    TagNo = "B1", 
+                    TagCode = pTLCallBackDTO.sLocator,
+                };
 
-        ///// <summary>
-        ///// PTL鍥炶皟浜嬩欢澶勭悊
-        ///// </summary>
-        //private void RYB_PTL_UserResultAvailable(RYB_PTL.RtnValueStruct rs)
-        //{
-        //    try
-        //    {
-        //        var content = new EPLightContent();
-        //        var pTLCallBackDTO = new PTLCallBackDTO
-        //        {
-        //            sIp = rs.Ip,
-        //            sTagID = rs.Tagid,
-        //            sValue = rs.Number,
-        //            sKeyCode = rs.KeyCode,
-        //            sLocator = rs.Locator
-        //        };
-
-        //        var taskBackLight = new TaskBackLight()
-        //        {
-        //            TagNo = "B1",
-        //            TagCode = pTLCallBackDTO.sLocator,
-        //        };
-        //        // 璋冪敤鏈嶅姟澶勭悊
-        //        _taskService.WMSLightBack(new List<TaskBackLight> { taskBackLight });
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        // 璁板綍鏃ュ織鎴栧鐞嗗紓甯�
-        //        Console.WriteLine($"澶勭悊PTL鍥炶皟鏃跺嚭閿�: {ex.Message}");
-        //    }
-        //}
-
+                // 璋冪敤鏈嶅姟澶勭悊鎵嬫媿浜嬩欢
+                _taskService.WMSLightBack(new List<TaskBackLight> { taskBackLight });
+                UnsubscribeEvent();
+            }
+            catch (Exception ex)
+            {
+                // 璁板綍鏃ュ織鎴栧鐞嗗紓甯�
+                Console.WriteLine($"澶勭悊PTL鎵嬫媿鍥炶皟鏃跺嚭閿�: {ex.Message}");
+            }
+        }
         /// <summary>
         /// 鎾澧欎笅鍙�(涓�鏈�)
         /// </summary>
@@ -95,8 +98,6 @@
                     request.iNum,
                     request.iMode,
                     request.iColorIndex);
-
-
             }
             catch (Exception ex)
             {
@@ -104,8 +105,6 @@
             }
             return content;
         }
-
-
         /// <summary>
         /// 鍥炶皟涓婁紶
         /// </summary>
@@ -134,6 +133,7 @@
             }
             return content;
         }
+
         /// <summary>
         /// 鎾澧欏垵濮嬪寲(涓�鏈�)
         /// </summary>
@@ -144,16 +144,11 @@
             EPLightContent content = new EPLightContent();
             try
             {
-                bool isConnected;
+                //RYB_PTL.UserResultAvailable += new RYB_PTL.UserResultAvailableEventHandler(RYB_PTL_UserResultAvailable);
+                
 
-                if (request.iTimeOut.HasValue)
-                {
-                    isConnected = RYB_PTL.RYB_PTL_Connect(request.sIp, request.iPort, request.iTimeOut.Value);
-                }
-                else
-                {
-                    isConnected = RYB_PTL.RYB_PTL_Connect(request.sIp, request.iPort);
-                }
+                bool isCfg = RYB_PTL.RYB_PTL_InitialConfiguration(new string[,] { { "11.2.30.252", "0001-0016" },{ "11.2.30.252", "1-16" } });
+                bool isConnected = RYB_PTL.RYB_PTL_Connect(request.sIp, request.iPort);
             }
             catch (Exception ex)
             {
@@ -161,6 +156,7 @@
             }
             return content;
         }
+
         /// <summary>
         /// 鎾澧欑粨鏉熶綔涓�(涓�鏈�)
         /// </summary>
@@ -179,13 +175,14 @@
             }
             return content;
         }
-        ///// <summary>
-        ///// 璧勬簮閲婃斁
-        ///// </summary>
-        //public void Dispose()
-        //{
-        //    UnsubscribeEvent();
-        //}
-    }
 
-}
+        /// <summary>
+        /// 璧勬簮閲婃斁锛堟爣璁颁负涓嶆毚闇茬粰Swagger锛�
+        /// </summary>
+        [ApiExplorerSettings(IgnoreApi = true)]
+        public void Dispose()
+        {
+            UnsubscribeEvent();
+        }
+    }
+}
\ No newline at end of file
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/RYB_PTL_API.dll" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/RYB_PTL_API.dll"
new file mode 100644
index 0000000..dd30c2c
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/RYB_PTL_API.dll"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/HostedService/WebSocketSetup.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/HostedService/WebSocketSetup.cs"
index 383a146..978fed6 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/HostedService/WebSocketSetup.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/HostedService/WebSocketSetup.cs"
@@ -1,5 +1,8 @@
 锘縰sing HslCommunication.WebSocket;
+using RYB_PTL_API;
 using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO;
+using WIDESEAWCS_DTO.TaskInfo;
 
 namespace WIDESEAWCS_Server.HostedService
 {
@@ -26,5 +29,50 @@
                 });
             }
         }
+        /// <summary>
+        ///// 璁㈤槄PTL浜嬩欢
+        ///// </summary>
+        //public static void SubscribeEvent(this IServiceCollection services)
+        //{
+        //    if (!_eventSubscribed)
+        //    {
+        //        RYB_PTL.UserResultAvailable += new RYB_PTL.UserResultAvailableEventHandler(RYB_PTL_UserResultAvailable);
+        //        _eventSubscribed = true;
+        //    }
+        //}
+        ///// <summary>
+        ///// PTL鍥炶皟浜嬩欢澶勭悊锛堝彧澶勭悊鎵嬫媿浜嬩欢锛�
+        ///// </summary>
+        //public static void RYB_PTL_UserResultAvailable(RYB_PTL.RtnValueStruct rs)
+        //{
+        //    try
+        //    {
+        //        if (rs.KeyCode == null)
+        //        {
+        //            return;
+        //        }
+        //        // 鏋勫缓鍥炶皟鏁版嵁
+        //        var pTLCallBackDTO = new PTLCallBackDTO
+        //        {
+        //            sIp = rs.Ip,
+        //            sTagID = rs.Tagid,
+        //            sValue = rs.Number,
+        //            sKeyCode = rs.KeyCode,
+        //            sLocator = rs.Locator
+        //        };
+
+        //        // 鏍规嵁涓氬姟闇�瑕佹瀯寤轰换鍔′俊鎭�
+        //        var taskBackLight = new TaskBackLight()
+        //        {
+        //            TagNo = "B1",
+        //            TagCode = pTLCallBackDTO.sLocator,
+        //        };
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        // 璁板綍鏃ュ織鎴栧鐞嗗紓甯�
+        //        Console.WriteLine($"澶勭悊PTL鎵嬫媿鍥炶皟鏃跺嚭閿�: {ex.Message}");
+        //    }
+        //}
     }
 }
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Program.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Program.cs"
index 19e3f9d..446e0fc 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Program.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Program.cs"
@@ -54,6 +54,8 @@
 
 builder.Services.AddWebSocketSetup();
 
+//builder.Services.SubscribeEvent(); // 播种墙订阅
+
 builder.Services.AddAutoMapperSetup();
 
 builder.Services.AddCorsSetup();
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
index f270d4a..8789af7 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -334,13 +334,13 @@
                         {
                             operationResult = RYB_PTL.RYB_PTL_CloseDigit5(url, lightSendDTO.LOCATION);
                             // TODO: 鍏抽棴鐏厜鍥炶皟澶勭悊
-                            List<EPLightBackDTO> lightBackDTOs = new List<EPLightBackDTO>();
-                            List<TaskBackLight> taskBackLights = lightBackDTOs.Select(x => new TaskBackLight()
-                            {
-                                TagNo = "B1",
-                                TagCode = x.LOCATION,
-                            }).ToList();
-                            content = WMSLightBack(taskBackLights);
+                            //List<EPLightBackDTO> lightBackDTOs = new List<EPLightBackDTO>();
+                            //List<TaskBackLight> taskBackLights = lightSendDTOs.Select(x => new TaskBackLight()
+                            //{
+                            //    TagNo = "B1",
+                            //    TagCode = x.LOCATION,
+                            //}).ToList();
+                            //content = WMSLightBack(taskBackLights);
                         }
                         // 澶勭悊鏄剧ず鐏厜璇锋眰
                         else
@@ -361,7 +361,6 @@
                                 lightType,
                                 lightColor);
                         }
-
                         if (!operationResult)
                         {
                             allSuccess = false;
@@ -407,9 +406,9 @@
                             QUANTITY=taskSendLight.TagQunity,
                             LIGHTCOLOR=taskSendLight.Color switch
                             {
-                                "Blue" => "1",
+                                "Blue" => "4",
                                 "Green" => "2",
-                                "Red" => "4",
+                                "Red" => "1",
                                 _ => throw new Exception($"鏈壘鍒伴鑹插畾涔�")
                             },
                             ORDERTYPE="1",
@@ -849,7 +848,7 @@
                     return content.Error($"鏈壘鍒版挱绉嶅涓嬪彂鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
                 }
                 string request = JsonConvert.SerializeObject(lightSendDTOs, settings).ToUpper();
-                //璋冪敤鎺ュ彛
+                // 璋冪敤鎺ュ彛
                 string response = HttpHelper.Post(url, request);
                 EPLightContent lightContent = JsonConvert.DeserializeObject<EPLightContent>(response) ?? throw new Exception($"鏈帴鏀跺埌鎾澧欎笅鍙戜笂鎶ヨ繑鍥炲��");
                 if (lightContent.Result != "0") throw new Exception($"鎾澧欎笅鍙戦敊璇�,淇℃伅:{lightContent.Msg}");

--
Gitblit v1.9.3