From b6c983ac19c0c80744795e122575f4b9ac145414 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 19 四月 2026 18:53:40 +0800
Subject: [PATCH] feat: 更新机器人任务处理逻辑和接口配置

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs
index 8783ebf..f8155cc 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotMessageHandler.cs
@@ -1,5 +1,4 @@
 using Microsoft.Extensions.Logging;
-using System.Net;
 using System.Net.Sockets;
 using WIDESEAWCS_Common;
 using WIDESEAWCS_Core.Caches;
@@ -119,12 +118,24 @@
             _logger.LogInformation($"鎺ユ敹鍒板鎴风銆恵state.RobotCrane.DeviceName}銆戝彂閫佹秷鎭�恵message}銆�");
             QuartzLogger.Info($"鎺ユ敹鍒板鎴风娑堟伅銆恵message}銆�", state.RobotCrane.DeviceName);
 
+            // 妫�鏌ヤ换鍔℃�绘暟鏄惁鏈揪鍒颁笂闄�
+            if (state.RobotTaskTotalNum > RobotConst.MaxTaskTotalNum)
+            {
+                // 璁板綍鎺ユ敹鍒扮殑娑堟伅鏃ュ織
+                _logger.LogInformation($"鎺ユ敹鍒板鎴风銆恵state.RobotCrane.DeviceName}銆戝彂閫佹秷鎭�恵message}銆�");
+                QuartzLogger.Info($"鎺ユ敹鍒板鎴风娑堟伅銆恵message}銆�", state.RobotCrane.DeviceName);
+                // 澶勭悊鎴愬姛鍚庯紝灏嗗師娑堟伅鍥炲啓鍒板鎴风锛堜繚鎸佸師鏈夎涓猴級
+                await _socketClientGateway.SendMessageAsync(client, message);
+                return null;
+            }
+
             // 鏋勫缓缂撳瓨閿紝妫�鏌� Redis 涓槸鍚﹀瓨鍦ㄨ璁惧鐨勭姸鎬�
             var cacheKey = $"{RedisPrefix.Code}:{RedisName.SocketDevices}:{client.Client.RemoteEndPoint}";
 
             // 濡傛灉缂撳瓨涓笉瀛樺湪鎴栫姸鎬佷负 null锛屽拷鐣ユ娑堟伅
             if (!_cache.TryGetValue(cacheKey, out RobotSocketState? cachedState) || cachedState == null)
             {
+                _logger.LogInformation($"缂撳瓨涓笉瀛樺湪鎴栫姸鎬佷负 null锛屽拷鐣ユ娑堟伅");
                 return null;
             }
 
@@ -140,7 +151,6 @@
             {
                 // 澶勭悊鎴愬姛鍚庯紝灏嗗師娑堟伅鍥炲啓鍒板鎴风锛堜繚鎸佸師鏈夎涓猴級
                 await _socketClientGateway.SendMessageAsync(client, message);
-                _logger.LogInformation($"鍙戦�佹秷鎭�恵message}銆�");
                 QuartzLogger.Info($"鍙戦�佹秷鎭細銆恵message}銆�", state.RobotCrane.DeviceName);
 
                 // 瀹夊叏鏇存柊鐘舵�佸埌 Redis
@@ -161,4 +171,4 @@
             return null;
         }
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3