| | |
| | | using WIDESEAWCS_Common.StackerCraneEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Caches; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_IShuttleCar; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | |
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using WIDESEAWCS_Tasks.ShuttleCarJob; |
| | | using WIDESEAWCS_Tasks.StackerCraneJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IShuttleCarService _shuttleCarService; |
| | | private readonly ICacheService _cacheService; |
| | | |
| | | public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IShuttleCarService shuttleCarService) |
| | | public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IShuttleCarService shuttleCarService, ICacheService cacheService) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _taskRepository = taskRepository; |
| | | _routerService = routerService; |
| | | _shuttleCarService = shuttleCarService; |
| | | _cacheService = cacheService; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | |
| | | if (commonStackerCrane != null) |
| | | { |
| | | commonStackerCrane.Communicator.IsReadAfterWrite = false; |
| | | #region è·åå åæºä¿¡æ¯ |
| | | StackerCraneTaskCommandR common = ReadCustomer<StackerCraneTaskCommandR>(commonStackerCrane, commonStackerCrane.DeviceCode); |
| | | _cacheService.AddOrUpdate(commonStackerCrane.DeviceCode, common); |
| | | #endregion |
| | | #region ä¿¡å·äº¤äºå¤ç |
| | | //Heartbeat(commonStackerCrane); |
| | | ShuttleCarSignal(commonStackerCrane); |
| | | #endregion |
| | | |
| | | #region ä»»å¡å®æ |
| | | DeviceProtocolDetailDTO? deviceProtocolDetail = commonStackerCrane.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.ProtocalDetailValue == commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.CompleteStatus).ToString() && x.DeviceProParamName == nameof(StackerCraneTaskCommandR.CompleteStatus)); |
| | | if (deviceProtocolDetail != null) |
| | | if (common.CompleteStatus == 2 || common.CompleteStatus == 3) |
| | | { |
| | | MethodInfo? method = GetType().GetMethod(deviceProtocolDetail.ProtocolDetailType); |
| | | if (method != null) method.Invoke(this, new object[] { commonStackerCrane }); |
| | | NormalCompleted(commonStackerCrane); |
| | | } |
| | | //DeviceProtocolDetailDTO? deviceProtocolDetail = commonStackerCrane.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.ProtocalDetailValue == commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.CompleteStatus).ToString() && x.DeviceProParamName == nameof(StackerCraneTaskCommandR.CompleteStatus)); |
| | | //if (deviceProtocolDetail != null) |
| | | //{ |
| | | // MethodInfo? method = GetType().GetMethod(deviceProtocolDetail.ProtocolDetailType); |
| | | // if (method != null) method.Invoke(this, new object[] { commonStackerCrane }); |
| | | //} |
| | | #endregion |
| | | #region ä»»å¡é»è¾å¤ç |
| | | var onlinestate = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.Onlinestate); |
| | | var writeStatus = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WriteStatus); |
| | | if (onlinestate == (short)Onlinestate.online && writeStatus == (short)WriteStatus.Permit) |
| | | if (common.Onlinestate == (short)Onlinestate.online) |
| | | { |
| | | #region æ¥è¯¢ä»»å¡,é»è¾å¤ç |
| | | if (Enum.Parse<RunStatus>(commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.RunStatus).ToString()) == RunStatus.Standby) |
| | | if (common.RunStatus == (short)RunStatus.Standby) |
| | | { |
| | | var Task = _taskService.GetTaskState(TaskType: (int)TaskOtherTypeEnum.RelocationCar);//è·åç§»è½¦ä»»å¡ |
| | | var Task = _taskService.GetTaskState((int)TaskCarStatusEnum.ShuttleCar_Finish, (int)TaskOtherTypeEnum.RelocationCar);//è·åç§»è½¦ä»»å¡ |
| | | var Task1 = _taskService.GetTaskState((int)CarChargingTaskEnum.ShuttleCar_Finish, (int)TaskOtherTypeEnum.RelocationCarCharging);//è·å移车å
çµä»»å¡ |
| | | if (Task != null) |
| | | { |
| | | if (Task.TaskState == (int)TaskCarStatusEnum.ShuttleCar_Finish) SendTask(commonStackerCrane, Task); |
| | | SendTask(commonStackerCrane, Task); |
| | | } |
| | | else if (Task1 != null) |
| | | { |
| | |
| | | SendTask(commonStackerCrane, task);//ä¸åå åæºä»»å¡ |
| | | } |
| | | } |
| | | #region MyRegion |
| | | //var ShuttleCar = GetShuttleCarInfo(task.TargetAddress);//ç§»åºä»»å¡å¤æç»ç¹æ¯å¦æç©¿æ¢è½¦ |
| | | //if (task.TargetIsPickPlace && ShuttleCar != null)//移走 |
| | | //{ |
| | | // _taskService.AddRelocationCarTask(task.TargetAddress, "", ShuttleCar.ShuttleCarCode); |
| | | //} |
| | | //else if (!task.TargetIsPickPlace && ShuttleCar == null) |
| | | //{ |
| | | // _taskService.AddRelocationCarTask("", task.TargetAddress); |
| | | //} |
| | | //else |
| | | //{ |
| | | // task.ShuttleCarCode = ShuttleCar?.ShuttleCarCode; |
| | | // _taskService.UpdateData(task); |
| | | // SendTask(commonStackerCrane, task);//ä¸åå åæºä»»å¡ |
| | | //} |
| | | #endregion |
| | | } |
| | | else if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) |
| | | else if (_taskService.TaskInboundTypes.Contains(task.TaskType)) |
| | | { |
| | | var ShuttleCar = GetShuttleCarInfo(task.TargetAddress);//å
¥åºä»»å¡å¤æç»ç¹æ¯å¦æç©¿æ¢è½¦ |
| | | if (task.TargetIsPickPlace && ShuttleCar != null)//移走 |