| | |
| | | using WIDESEAWCS_Core; |
| | | using SqlSugar.Extensions; |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | |
| | | private readonly ITaskExecuteDetailService _taskExecuteDetailService; |
| | | private readonly ITaskRepository _taskRepository; |
| | | private readonly IRouterService _routerService; |
| | | private readonly IRouterRepository _routerRepository; |
| | | private readonly IStationMangerRepository _stationMangerRepository; |
| | | |
| | | public StackerCraneJob_CP(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository) |
| | | public StackerCraneJob_CP(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IStationMangerRepository stationMangerRepository,IRouterRepository routerRepository) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | | _taskRepository = taskRepository; |
| | | _routerService = routerService; |
| | | _stationMangerRepository = stationMangerRepository; |
| | | _routerRepository = routerRepository; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | |
| | | { |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StackerCraneStationCode == task.NextAddress); |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StackerCraneStationCode == task.NextAddress && x.StackerCraneCode==deviceCode); |
| | | if (stationManger == null) |
| | | { |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"è¾é线åºåºç«ç¹æªé
ç½®,{task.NextAddress}"); |
| | | _taskService.UpdateTaskExceptionMessage(taskNum, $"è¾é线åºåºç«ç¹æªé
ç½®,{task.NextAddress}"); |
| | | return WebResponseContent.Instance.Error($"è¾é线åºåºç«ç¹æªé
ç½®,{task.NextAddress}"); |
| | | } |
| | | |
| | | Dt_Router router = _routerRepository.QueryFirst(x => x.InOutType == task.TaskType && x.StartPosi == stationManger.StationCode && x.ChildPosi == stationManger.StationDeviceCode); |
| | | if (router == null) |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(taskNum, $"æªæ¾å°è·¯ç±ä¿¡æ¯,{task.NextAddress}"); |
| | | WriteError(deviceCode, $"æªæ¾å°è·¯ç±ä¿¡æ¯,{task.NextAddress}"); |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è·¯ç±ä¿¡æ¯,{task.NextAddress}"); |
| | | } |
| | | int oldStatus = task.TaskState; |
| | | task.DeviceCode = stationManger.StationDeviceCode; |
| | | task.TaskState = TaskStatusEnum.Line_Execute.ObjToInt(); |
| | | task.CurrentAddress = stationManger.StationCode; |
| | | task.NextAddress = router.NextPosi; |
| | | task.TargetAddress = router.NextPosi; |
| | | _taskRepository.UpdateData(task); |
| | | //todo å åæºå®æå®æ |
| | | //_taskService.UpdateTask(task, TaskStatusEnum.Line_Execute, deviceCode: stationManger.StationDeviceCode, currentAddress: stationManger.StationCode, nextAddress: router.NextPosi, targetAddress: router.NextPosi); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"ç³»ç»èªå¨æµç¨,ä»»å¡ç¶æä»ã{oldStatus}ã转å°ã{task.TaskState}ã"); |
| | | //todo 宿 |
| | | WriteInfo(deviceCode, $"å åæºä»»å¡å®æ,ä»»å¡å·:{taskNum}"); |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup || task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) |
| | | { |
| | |
| | | |
| | | if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | if (OutTaskStationIsOccupied(task) != null || true) |
| | | if (OutTaskStationIsOccupied(task) == null) |
| | | { |
| | | return task; |
| | | } |
| | | else |
| | | { |
| | | List<string> otherOutStaionCodes = _routerService.QueryNextRoutes(commonStackerCrane.DeviceCode, task.NextAddress).Select(x => x.ChildPosi).ToList(); |
| | | bool flag = false; |
| | | List<string> otherOutStaionCodes = _routerService.QueryNextRoutes(commonStackerCrane.DeviceCode, task.NextAddress, task.TaskType).Select(x => x.ChildPosi).ToList(); |
| | | List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode, otherOutStaionCodes); |
| | | foreach (var item in tasks) |
| | | { |
| | | if (OutTaskStationIsOccupied(task) != null) |
| | | { |
| | | return task; |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); |
| | | if (!flag) |
| | | { |
| | | task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | /// <returns>妿æªè¢«å ç¨ï¼è¿åä¼ å
¥çä»»å¡ä¿¡æ¯ï¼å¦åï¼è¿ånull</returns> |
| | | private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task) |
| | | { |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.TargetAddress && x.StackerCraneCode == task.DeviceCode); |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.NextAddress && x.StackerCraneCode == task.DeviceCode); |
| | | if (stationManger != null) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); |