From 3406bbd34469982efeefe164c207dcb5c4a0dac2 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 30 四月 2026 22:03:54 +0800
Subject: [PATCH] fix: 修复多个功能模块中的问题和优化逻辑

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs
index 38a97f2..13c1b80 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RobotTaskService.cs
@@ -20,10 +20,12 @@
 using MapsterMapper;
 using Microsoft.Extensions.Configuration;
 using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Serilog;
 using SqlSugar;
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
+using System.Text;
 using WIDESEA_Core;
 using WIDESEAWCS_Common;
 using WIDESEAWCS_Common.HttpEnum;
@@ -73,6 +75,7 @@
             _taskExecuteDetailService = taskExecuteDetailService;
             _logger = logger;
         }
+
         public override WebResponseContent DeleteData(object[] keys)
         {
             List<int> taskKeys = new List<int>();
@@ -83,8 +86,8 @@
             List<Dt_RobotTask> tasks = BaseDal.QueryData(x => taskKeys.Contains(x.RobotTaskId));
             BaseDal.DeleteAndMoveIntoHty(tasks, OperateTypeEnum.浜哄伐鍒犻櫎);
             return WebResponseContent.Instance.OK($"鎴愬姛鍒犻櫎{tasks.Count}鏉℃暟鎹�");
-
         }
+
         public bool DeleteRobotTask(int id)
         {
             Dt_RobotTask task = BaseDal.QueryFirst(x => x.RobotTaskId == id);
@@ -133,7 +136,7 @@
 
         public Dt_RobotTask? QueryRobotCraneTask(string deviceCode)
         {
-            return BaseDal.QueryFirst(x => x.RobotRoadway == deviceCode && x.RobotTaskState != (int)TaskRobotStatusEnum.RobotExecuting, TaskOrderBy);
+            return BaseDal.QueryFirst(x => x.RobotRoadway == deviceCode, TaskOrderBy);
         }
 
         public Dt_RobotTask? QueryRobotCraneExecutingTask(string deviceCode)
@@ -341,7 +344,7 @@
         /// 鑾峰彇鏈烘鎵嬩换鍔℃�绘暟閲忋��
         /// 缁勭洏浠诲姟鍥哄畾48锛屾崲鐩樺拰鎷嗙洏浠诲姟閫氳繃鎵樼洏鍙锋煡璇MS搴撳瓨鏄庣粏鏁伴噺銆�
         /// </summary>
-        private int GetRobotTaskTotalNum(int taskType, string? palletCode)
+        public int GetRobotTaskTotalNum(int taskType, string? palletCode)
         {
             if (taskType == (int)RobotTaskTypeEnum.GroupPallet)
                 return 48;
@@ -351,8 +354,10 @@
 
             try
             {
+                QuartzLogHelper.LogInfo(_logger, $"寮�濮嬭皟鐢╓MS鎺ュ彛鑾峰彇搴撳瓨鏄庣粏鏁伴噺,鎵樼洏鍙�:銆恵palletCode}銆�", "RobotTaskService");
                 string url = $"{BaseAPI.WMSBaseUrl}Stock/GetStockDetailCount?palletCode={Uri.EscapeDataString(palletCode)}";
                 var result = _httpClientHelper.Get(url);
+                QuartzLogHelper.LogInfo(_logger, $"璋冪敤WMS鑾峰彇搴撳瓨鏄庣粏鏁伴噺鎺ュ彛,璇锋眰URL:銆恵url}銆�,鍝嶅簲鏁版嵁:銆恵result.Content}銆�,鑰楁椂:{result.Duration}ms", "RobotTaskService");
                 if (!result.IsSuccess || string.IsNullOrEmpty(result.Content))
                     return 1;
 
@@ -360,8 +365,8 @@
                 if (response == null || !response.Status)
                     return 1;
 
-                var detailCount = response.Data?.GetType().GetProperty("DetailCount")?.GetValue(response.Data);
-                return detailCount is int count and > 0 ? count : 1;
+                var detailCount = (response.Data as JObject)?["detailCount"]?.Value<int>();
+                return detailCount.HasValue && detailCount.Value > 0 ? detailCount.Value : 1;
             }
             catch
             {
@@ -466,8 +471,10 @@
                     CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
 
                     DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineDBNameNew.Barcode) && x.DeviceChildCode == sourceLineNo);
+                    //conveyorLine.Communicator.Read(devicePro.DeviceProAddress, 20);
                     //ConveyorLineTaskCommandNew command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandNew>(sourceLineNo);  // 娴嬭瘯鐢�
-                    var barcode = conveyorLine.GetValue<ConveyorLineDBNameNew, string>(ConveyorLineDBNameNew.Barcode, sourceLineNo);
+                    var bytes = conveyorLine.Communicator.Read(devicePro.DeviceProAddress, 20);
+                    var barcode = Encoding.Default.GetString(bytes).Trim();
                     stock.SourcePalletNo = string.IsNullOrEmpty(barcode) ? string.Empty : barcode;
                 }
             }

--
Gitblit v1.9.3