From adb4016b5eb5b119a899480c321be996d9bf10bd Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 08 四月 2026 00:55:22 +0800
Subject: [PATCH] feat(robot): 完善机械手任务处理逻辑与状态管理

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
index ea25892..c35e485 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/RobotJob.cs
@@ -1,7 +1,7 @@
 using Microsoft.Extensions.Logging;
 using Quartz;
-using System.Net;
 using WIDESEA_Core;
+using WIDESEAWCS_Common;
 using WIDESEAWCS_Core.Caches;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_Core.LogHelper;
@@ -29,15 +29,6 @@
     [DisallowConcurrentExecution]
     public class RobotJob : IJob
     {
-        /// <summary>
-        /// 浠诲姟鎬绘暟涓婇檺
-        /// </summary>
-        /// <remarks>
-        /// 褰撴満鍣ㄤ汉澶勭悊鐨勮揣鐗╂暟閲忚揪鍒版涓婇檺鏃讹紝涓嶅啀涓嬪彂鏂颁换鍔°��
-        /// 闃叉鏈哄櫒浜鸿繃搴﹀姵绱垨绯荤粺杩囪浇銆�
-        /// </remarks>
-        private const int MaxTaskTotalNum = 48;
-
         /// <summary>
         /// 娑堟伅浜嬩欢璁㈤槄鏍囧織
         /// </summary>
@@ -131,7 +122,7 @@
 
             // 鍒濆鍖栧懡浠ゅ鐞嗗櫒
             // 绠�鍗曞懡浠ゅ鐞嗗櫒锛氬鐞嗙姸鎬佹洿鏂扮瓑绠�鍗曞懡浠�
-            var simpleCommandHandler = new RobotSimpleCommandHandler(_taskProcessor);
+            var simpleCommandHandler = new RobotSimpleCommandHandler(_taskProcessor, socketGateway);
             // 鍓嶇紑鍛戒护澶勭悊鍣細澶勭悊 pickfinished銆乸utfinished 绛夊甫鍙傛暟鐨勫懡浠�
             var prefixCommandHandler = new RobotPrefixCommandHandler(robotTaskService, _taskProcessor, _stateManager, socketGateway);
 
@@ -214,8 +205,19 @@
                     return;
                 }
 
+                if (state.CurrentAction == "Picking" || state.CurrentAction == "Puting")
+                {
+                    return;
+                }
+
                 // 杞鑾峰彇璇ヨ澶囩殑寰呭鐞嗕换鍔�
                 var task = _taskProcessor.GetTask(robotCrane);
+
+                // 濡傛灉娌℃湁鑾峰彇鍒板緟澶勭悊浠诲姟锛屼笖RobotArmObject涓�1锛堟湁鐗╂枡锛夛紝鍒欒幏鍙栬璁惧鎵ц涓殑浠诲姟
+                if (task == null && state.RobotArmObject == 1)
+                {
+                    task = _taskProcessor.GetExecutingTask(robotCrane);
+                }
 
                 // 濡傛灉鏈夊緟澶勭悊浠诲姟
                 if (task != null)
@@ -229,12 +231,12 @@
                     }
 
                     // 妫�鏌ヤ换鍔℃�绘暟鏄惁鏈揪鍒颁笂闄�
-                    //if (latestState.RobotTaskTotalNum < MaxTaskTotalNum)
-                    //{
+                    if (latestState.RobotTaskTotalNum < RobotConst.MaxTaskTotalNum)
+                    {
                         // 璋冪敤宸ヤ綔娴佺紪鎺掑櫒鎵ц浠诲姟
                         // 缂栨帓鍣ㄤ細鏍规嵁褰撳墠鐘舵�佸喅瀹氫笅涓�姝ュ姩浣�
                         await _workflowOrchestrator.ExecuteAsync(latestState, task, ipAddress);
-                    //}
+                    }
                 }
             }
             catch (Exception ex)
@@ -246,4 +248,4 @@
             }
         }
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3