| | |
| | | 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; |
| | | task.Dispatchertime = DateTime.Now; |
| | | task.ExceptionMessage = ""; |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Executing); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(commonStackerCrane.DeviceName, ex.Message, ex); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(commonStackerCrane.DeviceName, ex.Message, ex); |
| | | } |
| | | } |
| | | |
| | | |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | |
| | | { |
| | | if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) |
| | | { |
| | | WriteInfo(commonStackerCrane.DeviceName, $"读åå°ä»»å¡å®æä¿¡å·,{e.TaskNum}"); |
| | | WriteDebug(commonStackerCrane.DeviceName, $"读åå°ä»»å¡å®æä¿¡å·,{e.TaskNum}"); |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum); |
| | | if (task != null) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | WriteInfo(commonStackerCrane.DeviceName, $"读åå°ä»»å¡å®æä¿¡å·,æªæ¾å°å¯¹åºçä»»å¡ä¿¡æ¯,{e.TaskNum}"); |
| | | WriteError(commonStackerCrane.DeviceName, $"读åå°ä»»å¡å®æä¿¡å·,æªæ¾å°å¯¹åºçä»»å¡ä¿¡æ¯,{e.TaskNum}"); |
| | | } |
| | | commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); |
| | | } |
| | |
| | | catch (Exception ex) |
| | | { |
| | | WriteError(commonStackerCrane?.DeviceCode ?? nameof(StackerCraneJob_YM), ex.Message, ex); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | 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); |
| | |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"å
¥åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | WriteInfo(task.DeviceCode, $"å
¥åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | WriteError(task.DeviceCode, $"å
¥åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | return null; |
| | | } |
| | | |
| | |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"å
¥åºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | WriteInfo(task.DeviceCode, $"å
¥åºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | WriteError(task.DeviceCode, $"å
¥åºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | return null; |
| | | } |
| | | } |
| | |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"åºåºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | WriteInfo(task.DeviceCode, $"åºåºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | WriteError(task.DeviceCode, $"åºåºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | return null; |
| | | } |
| | | |
| | |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"åºåºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | WriteInfo(task.DeviceCode, $"åºåºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | WriteError(task.DeviceCode, $"åºåºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | return null; |
| | | } |
| | | } |
| | |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"ç§»åºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | WriteInfo(task.DeviceCode, $"ç§»åºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | WriteError(task.DeviceCode, $"ç§»åºä»»å¡ç»ç¹é误ï¼ç»ç¹ï¼ã{task.NextAddress}ã"); |
| | | return null; |
| | | } |
| | | string[] sourceCodes = task.CurrentAddress.Split("-"); |
| | |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"ç§»åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | WriteInfo(task.DeviceCode, $"ç§»åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | WriteError(task.DeviceCode, $"ç§»åºä»»å¡èµ·ç¹é误ï¼èµ·ç¹ï¼ã{task.CurrentAddress}ã"); |
| | | return null; |
| | | } |
| | | } |