From e46aa927d231af83724683c7286d9db503e24cf7 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期二, 10 六月 2025 11:46:20 +0800
Subject: [PATCH] 1

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GantryPositionJob.cs |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GantryPositionJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GantryPositionJob.cs"
index 9ddaaa4..5f61979 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GantryPositionJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GantryPositionJob.cs"
@@ -10,11 +10,18 @@
 
 namespace WIDESEAWCS_Tasks
 {
+    /// <summary>
+    /// 榫欓棬浣嶇疆浣滀笟浠诲姟锛岀敤浜庤鍙栧苟鏇存柊H鍜孼杞磋澶囩殑浣嶇疆淇℃伅
+    /// </summary>
+    /// <remarks>
+    /// 1. 浠嶫obParams涓幏鍙栬澶囧弬鏁� <br/>
+    /// 2. 璇诲彇H杞磋澶囦綅缃苟鏇存柊鍒癘Positions.HPositions瀛楀吀 <br/>
+    /// 3. 璇诲彇Z杞磋澶囦綅缃苟鏇存柊鍒癘Positions.ZPositions瀛楀吀 <br/>
+    /// 4. 澶勭悊杩囩▼涓崟鑾峰苟璁板綍寮傚父
+    /// </remarks>
     [DisallowConcurrentExecution]
     public class GantryPositionJob : JobBase, IJob
     {
-        
-
         public GantryPositionJob()
         {
 
@@ -22,12 +29,11 @@
 
         public Task Execute(IJobExecutionContext context)
         {
-            try
+            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
+            if (flag && value != null && value is OtherDevice otherDevice)
             {
-                bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
-                if (flag && value != null && value is OtherDevice)
+                try
                 {
-                    OtherDevice otherDevice = (OtherDevice)value;
                     {
                         List<string> hDeviceChildCodes = otherDevice.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(OPositions.HPositions)).GroupBy(x => x.DeviceChildCode).Select(x => x.Key).ToList();
                         DeviceProDTO deviceProDTOH = otherDevice.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(OPositions.HPositions)).OrderBy(x => x.DeviceProOffset).First();
@@ -45,7 +51,10 @@
                                     PositionR = hPositions[i * 4 + 3]
                                 };
 
-                                OPositions.HPositions.TryAdd(hDeviceChildCodes[i], position);
+                                if(!OPositions.HPositions.TryAdd(hDeviceChildCodes[i], position))
+                                {
+                                    OPositions.HPositions[hDeviceChildCodes[i]] = position;
+                                }
                             }
                         }
                     }
@@ -67,20 +76,26 @@
                                     PositionR = zPositions[i * 4 + 3]
                                 };
 
-                                OPositions.ZPositions.TryAdd(zDeviceChildCodes[i], position);
+                               if(! OPositions.ZPositions.TryAdd(zDeviceChildCodes[i], position))
+                                {
+                                    OPositions.ZPositions[zDeviceChildCodes[i]] = position;
+                                }
                             }
                         }
                     }
-                    
+                }
+                catch (Exception ex)
+                {
+                    WriteError($"{otherDevice.DeviceCode}-{otherDevice.DeviceName}", ex.Message, ex);
                 }
             }
-            catch (Exception ex)
+            else
             {
-                WriteError(nameof(GantryPositionJob), "閿欒", ex);
+                WriteError(nameof(CommonConveyorLightJob), "鍙傛暟閿欒,鏈紶閫掕澶囧弬鏁版垨璁惧绫诲瀷閿欒");
             }
             return Task.CompletedTask;
         }
     }
 
-    
+
 }

--
Gitblit v1.9.3