|  |  | 
 |  |  |         private readonly ITaskRepository _taskRepository; | 
 |  |  |         private readonly IRouterService _routerService; | 
 |  |  |         private readonly IStationMangerRepository _stationMangerRepository; | 
 |  |  |         private List<Dt_ApiInfo> apiInfos; | 
 |  |  |  | 
 |  |  |         public StackerCraneJob_YM(ITaskService taskService, ICacheService cacheService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository) | 
 |  |  |         { | 
 |  |  | 
 |  |  |             _taskRepository = taskRepository; | 
 |  |  |             _routerService = routerService; | 
 |  |  |             _stationMangerRepository = stationMangerRepository; | 
 |  |  |  | 
 |  |  |             string? apiInfoStr = _cacheService.Get("apiInfos"); | 
 |  |  |             if (!string.IsNullOrEmpty(apiInfoStr)) | 
 |  |  |             { | 
 |  |  |                 apiInfos = JsonConvert.DeserializeObject<List<Dt_ApiInfo>>(apiInfoStr); | 
 |  |  |                 if (apiInfos == null || apiInfos.Count == 0) | 
 |  |  |                 { | 
 |  |  |                     apiInfos = new List<Dt_ApiInfo>(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public Task Execute(IJobExecutionContext context) | 
 |  |  |         { | 
 |  |  |             CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); | 
 |  |  |             try | 
 |  |  |             bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object value); | 
 |  |  |             if (flag && value != null) | 
 |  |  |             { | 
 |  |  |                 if (commonStackerCrane != null) | 
 |  |  |                 CommonStackerCrane commonStackerCrane = (CommonStackerCrane)value; | 
 |  |  |                 try | 
 |  |  |                 { | 
 |  |  |                     if (!commonStackerCrane.IsEventSubscribed) | 
 |  |  |                     if (commonStackerCrane != null) | 
 |  |  |                     { | 
 |  |  |                         commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//订é
ä»»å¡å®æäºä»¶ | 
 |  |  |                     } | 
 |  |  |                     commonStackerCrane.CheckStackerCraneTaskCompleted();//鲿¢ä»»å¡å®æäºä»¶çæµè¶
æ¶ï¼åæå¨è§¦å䏿¬¡ | 
 |  |  |                     if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) | 
 |  |  |                     { | 
 |  |  |                         Dt_Task? task = GetTask(commonStackerCrane); | 
 |  |  |                         if (task != null) | 
 |  |  |                         if (!commonStackerCrane.IsEventSubscribed) | 
 |  |  |                         { | 
 |  |  |                             StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); | 
 |  |  |                             if (stackerCraneTaskCommand != null) | 
 |  |  |                             commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//订é
ä»»å¡å®æäºä»¶ | 
 |  |  |                         } | 
 |  |  |                         commonStackerCrane.CheckStackerCraneTaskCompleted();//鲿¢ä»»å¡å®æäºä»¶çæµè¶
æ¶ï¼åæå¨è§¦å䏿¬¡ | 
 |  |  |                         if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal && commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) | 
 |  |  |                         { | 
 |  |  |                             Dt_Task? task = GetTask(commonStackerCrane); | 
 |  |  |                             if (task != null) | 
 |  |  |                             { | 
 |  |  |                                 bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); | 
 |  |  |                                 if (sendFlag) | 
 |  |  |                                 StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); | 
 |  |  |                                 if (stackerCraneTaskCommand != null) | 
 |  |  |                                 { | 
 |  |  |                                     commonStackerCrane.LastTaskType = task.TaskType; | 
 |  |  |                                     int oldState = task.TaskState; | 
 |  |  |                                     task.TaskState = TaskStatusEnum.SC_Executing.ObjToInt(); | 
 |  |  |                                     task.ExceptionMessage = ""; | 
 |  |  |                                     task.Dispatchertime = DateTime.Now; | 
 |  |  |                                     _taskRepository.UpdateData(task); | 
 |  |  |                                     _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"ç³»ç»èªå¨æµç¨ï¼ä»»å¡ç¶æä»ã{oldState}ã转å°ã{task.TaskState}ã"); | 
 |  |  |                                     bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); | 
 |  |  |                                     if (sendFlag) | 
 |  |  |                                     { | 
 |  |  |                                         commonStackerCrane.LastTaskType = task.TaskType; | 
 |  |  |                                         int oldState = task.TaskState; | 
 |  |  |                                         task.TaskState = TaskStatusEnum.SC_Executing.ObjToInt(); | 
 |  |  |                                         task.ExceptionMessage = ""; | 
 |  |  |                                         task.Dispatchertime = DateTime.Now; | 
 |  |  |                                         _taskRepository.UpdateData(task); | 
 |  |  |                                         _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"ç³»ç»èªå¨æµç¨ï¼ä»»å¡ç¶æä»ã{oldState}ã转å°ã{task.TaskState}ã"); | 
 |  |  |                                     } | 
 |  |  |                                 } | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             catch (Exception ex) | 
 |  |  |             { | 
 |  |  |                 WriteError(commonStackerCrane.DeviceName, ex.Message, ex); | 
 |  |  |             } | 
 |  |  |                 catch (Exception ex) | 
 |  |  |                 { | 
 |  |  |                     WriteError(commonStackerCrane.DeviceName, ex.Message, ex); | 
 |  |  |                 } | 
 |  |  |             }  | 
 |  |  |  | 
 |  |  |              | 
 |  |  |             return Task.CompletedTask; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  | 
 |  |  |                 if (device != null) | 
 |  |  |                 { | 
 |  |  |                     OtherDevice client = (OtherDevice)device; | 
 |  |  |                     if (client.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode))//åºåºç«å°æªè¢«å ç¨ | 
 |  |  |                     if (client.GetValue<HoisterDBName, bool>(HoisterDBName.Tray, stationManger.StationCode))//åºåºç«å°æªè¢«å ç¨ | 
 |  |  |                     { | 
 |  |  |                         task.NextAddress = stationManger.StackerCraneStationCode; | 
 |  |  |                         _taskRepository.UpdateData(task); |