1
z8018
2025-06-10 e46aa927d231af83724683c7286d9db503e24cf7
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GantryPositionJob.cs
@@ -10,11 +10,18 @@
namespace WIDESEAWCS_Tasks
{
    /// <summary>
    /// é¾™é—¨ä½ç½®ä½œä¸šä»»åŠ¡ï¼Œç”¨äºŽè¯»å–å¹¶æ›´æ–°H和Z轴设备的位置信息
    /// </summary>
    /// <remarks>
    /// 1. ä»ŽJobParams中获取设备参数 <br/>
    /// 2. è¯»å–H轴设备位置并更新到OPositions.HPositions字典 <br/>
    /// 3. è¯»å–Z轴设备位置并更新到OPositions.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;
        }
    }
}