From 05999b9c77f009ac9a7e98366bc3d23fbb8e83e7 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 26 四月 2026 17:46:10 +0800
Subject: [PATCH] feat: 更新数据库连接配置和机器人任务处理逻辑

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs |   42 ++++++++++++++++++++++++++----------------
 1 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs
index c78fc4f..3d5241e 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RobotJob/Workflow/RobotWorkflowOrchestrator.cs
@@ -118,7 +118,7 @@
                 // - 鎵嬭噦涓婃湁鐗╂枡锛圧obotArmObject == 1锛�
                 // - 浠诲姟鐘舵�佷负 RobotPickFinish锛堝凡璁板綍鍙栬揣瀹屾垚锛�
                 if ((latestState.CurrentAction == "PickFinished" || latestState.CurrentAction == "AllPickFinished")
-                    && (latestState.RobotArmObject.IsNullOrEmpty() || latestState.RobotArmObject == 1)
+                    //&& (latestState.RobotArmObject.IsNullOrEmpty() || latestState.RobotArmObject == 1)
                     && task.RobotTaskState == TaskRobotStatusEnum.RobotPickFinish.GetHashCode())
                 {
                     QuartzLogHelper.LogInfo(_logger, $"ExecuteAsync锛氭弧瓒虫斁璐ф潯浠讹紝寮�濮嬩笅鍙戞斁璐т换鍔�,浠诲姟鍙�: {task.RobotTaskNum}", latestState.RobotCrane?.DeviceName ?? ipAddress);
@@ -133,7 +133,7 @@
                 // - 鎵嬭噦涓婃棤鐗╂枡锛圧obotArmObject == 0锛�
                 // - 浠诲姟鐘舵�佷负 RobotPutFinish 鎴栦笉鏄� RobotExecuting
                 else if ((latestState.CurrentAction == "PutFinished" || latestState.CurrentAction == "AllPutFinished" || latestState.CurrentAction.IsNullOrEmpty())
-                    && (latestState.RobotArmObject.IsNullOrEmpty() || latestState.RobotArmObject == 0)
+                    //&& (latestState.RobotArmObject.IsNullOrEmpty() || latestState.RobotArmObject == 0)
                     && (task.RobotTaskState == TaskRobotStatusEnum.RobotPutFinish.GetHashCode() || task.RobotTaskState != TaskRobotStatusEnum.RobotExecuting.GetHashCode()))
                 {
                     QuartzLogHelper.LogInfo(_logger, $"ExecuteAsync锛氭弧瓒冲彇璐ф潯浠讹紝寮�濮嬩笅鍙戝彇璐т换鍔★紝浠诲姟鍙�: {task.RobotTaskNum}", latestState.RobotCrane?.DeviceName ?? ipAddress);
@@ -168,6 +168,9 @@
                 int currentCompletedCount = state?.RobotTaskTotalNum ?? 0;
 
                 bool isFlowA = task.RobotSourceAddressLineCode is "11001" or "11010";
+
+                await _taskProcessor.SendSocketRobotNumAsync(task, state, false);
+                Thread.Sleep(500);
 
                 // ==================== Phase 2: 鏀炬甯哥數鑺埌鐩爣鎵樼洏锛堜袱娴佸悜鐩稿悓锛�====================
                 // PickFinished 鍒拌揪锛歅hase 1 鐨� Pick 鍛戒护瀹屾垚锛岀幇鍦ㄤ笅鍙� Put 鍛戒护鏀炬甯哥數鑺�
@@ -239,8 +242,6 @@
                     return;
                 }
 
-                // 闈炴壒娆℃ā寮忔垨鍏朵粬闃舵涓嶄笅鍙戞寚浠�
-                return;
             }
 
             // 闈炴崲鐩樹换鍔★細浣跨敤鍘熸湁鏍煎紡
@@ -273,7 +274,7 @@
 
                     if (_stateManager.TryUpdateStateSafely(ipAddress, stateToUpdate))
                     {
-                        await _robotTaskService.UpdateRobotTaskAsync(task);
+                        //await _robotTaskService.UpdateRobotTaskAsync(task);
                     }
                 }
             }
@@ -337,17 +338,23 @@
                 // 濡傛灉鏉$爜鐢熸垚鎴愬姛
                 if (!string.IsNullOrEmpty(trayBarcode1) && !string.IsNullOrEmpty(trayBarcode2))
                 {
-                    if (stateForUpdate.CellBarcode.Contains(trayBarcode1) || stateForUpdate.CellBarcode.Contains(trayBarcode2))
-                    {
-                        QuartzLogHelper.LogInfo(_logger, $"HandlePutFinishedStateAsync锛氳鍙栫殑鎵樼洏鏉$爜宸插瓨鍦紝鍙兘瀛樺湪閲嶅锛屼换鍔″彿: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
+                    //if (stateForUpdate.CellBarcode.Contains(trayBarcode1) || stateForUpdate.CellBarcode.Contains(trayBarcode2))
+                    //{
+                    //    QuartzLogHelper.LogInfo(_logger, $"HandlePutFinishedStateAsync锛氳鍙栫殑鐢佃姱鏉$爜宸插瓨鍦紝鍙兘瀛樺湪閲嶅锛屼换鍔″彿: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
 
-                        // 鍙戦�佸彇璐ф寚浠� 鏍囪鎵爜NG锛屾斁璐ф椂涓嶄娇鐢ㄨ繖浜涙潯鐮侊紝骞舵斁鍏G鍙�
-                        //await _taskProcessor.SendSocketRobotPickAsync(task, stateForUpdate, true);
-                        return;
-                    }
-                    else
+                    //    // 鍙戦�佸彇璐ф寚浠� 鏍囪鎵爜NG锛屾斁璐ф椂涓嶄娇鐢ㄨ繖浜涙潯鐮侊紝骞舵斁鍏G鍙�
+                    //    //await _taskProcessor.SendSocketRobotPickAsync(task, stateForUpdate, true);
+                    //    return;
+                    //}
+                    //else
                     {
-                        QuartzLogHelper.LogInfo(_logger, $"HandlePutFinishedStateAsync锛氳鍙栫殑鎵樼洏鏉$爜鍞竴锛岀户缁墽琛岋紝浠诲姟鍙�: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
+                        if (trayBarcode1.Length < 13 || trayBarcode2.Length < 13)
+                        {
+                            QuartzLogHelper.LogError(_logger, $"HandlePutFinishedStateAsync锛氱數鑺潯鐮侀暱搴︿笉杈炬爣锛屼换鍔″彿: {task.RobotTaskNum}锛岃鍙栫數鑺潯鐮佹垚鍔�: 銆恵trayBarcode1}銆�-----銆恵trayBarcode2}銆�", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
+                            return;
+                        }
+
+                        QuartzLogHelper.LogInfo(_logger, $"HandlePutFinishedStateAsync锛氳鍙栫殑鐢佃姱鏉$爜鍞竴锛岀户缁墽琛岋紝浠诲姟鍙�: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
 
                         // 灏嗘潯鐮佹坊鍔犲埌鐘舵�佷腑锛屼緵鍚庣画鏀捐揣鏃朵娇鐢�
                         stateForUpdate.CellBarcode = new List<string>()
@@ -357,7 +364,7 @@
                     }
 
                     // 璁板綍鏃ュ織锛氳鍙栨墭鐩樻潯鐮佹垚鍔�
-                    QuartzLogHelper.LogInfo(_logger, $"HandlePutFinishedStateAsync锛氳鍙栨墭鐩樻潯鐮佹垚鍔�: 銆恵trayBarcode1}銆�-----銆恵trayBarcode2}銆戯紝浠诲姟鍙�: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
+                    QuartzLogHelper.LogInfo(_logger, $"HandlePutFinishedStateAsync锛氳鍙栫數鑺潯鐮佹垚鍔�: 銆恵trayBarcode1}銆�-----銆恵trayBarcode2}銆戯紝浠诲姟鍙�: {task.RobotTaskNum}", stateForUpdate?.RobotCrane?.DeviceName ?? ipAddress);
 
                     // 鍙戦�佸彇璐ф寚浠�
                     await _taskProcessor.SendSocketRobotPickAsync(task, stateForUpdate);
@@ -383,8 +390,11 @@
                 // 鍒ゆ柇娴佸悜锛坣ull-safe锛�
                 bool isFlowA = task.RobotSourceAddressLineCode is "11001" or "11010";
 
+                await _taskProcessor.SendSocketRobotNumAsync(task, stateForUpdate);
+                Thread.Sleep(500);
+
                 // 鐩爣鏁伴噺涓�48锛氱洿鎺ヨ蛋鍘熸湁閫昏緫锛屼笉杩涘叆鎵规妯″紡
-                if (targetNormalCount == targetTotal)
+                if (targetNormalCount + currentCompletedCount == targetTotal)
                 {
                     await _taskProcessor.SendSocketRobotPickAsync(task, stateForUpdate);
                     return;

--
Gitblit v1.9.3