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