| | |
| | | Dt_Task? candidateTask; |
| | | var deviceCode = commonStackerCrane.DeviceCode; |
| | | |
| | | QuartzLogHelper.LogDebug(_logger, $"开始选择任务,设备: {deviceCode},上一任务类型: {commonStackerCrane.LastTaskType}",commonStackerCrane.DeviceName); |
| | | QuartzLogHelper.LogInfo(_logger, $"开始选择任务,设备: {deviceCode},上一任务类型: {commonStackerCrane.LastTaskType}", commonStackerCrane.DeviceName); |
| | | |
| | | // 根据上一任务类型决定查询策略 |
| | | if (commonStackerCrane.LastTaskType == null || commonStackerCrane.LastTaskType == TaskRelocationTypeEnum.Relocation.GetHashCode()) |
| | | { |
| | | // 没有上一任务类型,查询普通任务 |
| | | candidateTask = _taskService.QueryStackerCraneTask(deviceCode); |
| | | QuartzLogHelper.LogDebug(_logger, $"查询普通任务,设备: {deviceCode},结果: {candidateTask?.TaskNum}", commonStackerCrane.DeviceName); |
| | | QuartzLogHelper.LogInfo(_logger, $"查询普通任务,设备: {deviceCode},结果: {candidateTask?.TaskNum}", commonStackerCrane.DeviceName); |
| | | } |
| | | else if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | |
| | | candidateTask = _taskService.QueryStackerCraneInTask(deviceCode); |
| | | // 如果没有入库任务,再查一下出库任务 |
| | | candidateTask ??= _taskService.QueryStackerCraneOutTask(deviceCode); |
| | | QuartzLogHelper.LogDebug(_logger, $"出库后优先查入库,设备: {deviceCode},结果: {candidateTask?.TaskNum}", commonStackerCrane.DeviceName); |
| | | QuartzLogHelper.LogInfo(_logger, $"出库后优先查入库,设备: {deviceCode},结果: {candidateTask?.TaskNum}", commonStackerCrane.DeviceName); |
| | | } |
| | | else |
| | | { |
| | | // 上一任务是入库(非出库),优先查出库任务 |
| | | candidateTask = _taskService.QueryStackerCraneOutTask(deviceCode); |
| | | QuartzLogHelper.LogDebug(_logger, $"入库后优先查出库,设备: {deviceCode},结果: {candidateTask?.TaskNum}", commonStackerCrane.DeviceName); |
| | | |
| | | // 如果没有出库任务,再查一下入库任务 |
| | | candidateTask ??= _taskService.QueryStackerCraneInTask(deviceCode); |
| | | QuartzLogHelper.LogInfo(_logger, $"入库后优先查出库,设备: {deviceCode},结果: {candidateTask?.TaskNum}", commonStackerCrane.DeviceName); |
| | | } |
| | | |
| | | // 如果没有候选任务,返回 null |
| | | if (candidateTask == null) |
| | | { |
| | | QuartzLogHelper.LogDebug(_logger, $"没有候选任务,设备: {deviceCode}", commonStackerCrane.DeviceName); |
| | | QuartzLogHelper.LogInfo(_logger, $"没有候选任务,设备: {deviceCode}", commonStackerCrane.DeviceName); |
| | | return null; |
| | | } |
| | | |
| | | // 如果不是出库任务,直接返回 |
| | | if (candidateTask.TaskType.GetTaskTypeGroup() != TaskTypeGroup.OutbondGroup) |
| | | { |
| | | QuartzLogHelper.LogDebug(_logger, $"选中非出库任务,任务号: {candidateTask.TaskNum},任务类型: {candidateTask.TaskType}", commonStackerCrane.DeviceName); |
| | | QuartzLogHelper.LogInfo(_logger, $"选中非出库任务,任务号: {candidateTask.TaskNum},任务类型: {candidateTask.TaskType}", commonStackerCrane.DeviceName); |
| | | return candidateTask; |
| | | } |
| | | |
| | |
| | | Dt_Task? selectedTask = TrySelectOutboundTask(candidateTask); |
| | | if (selectedTask != null) |
| | | { |
| | | QuartzLogHelper.LogDebug(_logger, $"选中出库任务,任务号: {selectedTask.TaskNum}", commonStackerCrane.DeviceName); |
| | | QuartzLogHelper.LogInfo(_logger, $"选中出库任务,任务号: {selectedTask.TaskNum}", commonStackerCrane.DeviceName); |
| | | return selectedTask; |
| | | } |
| | | |
| | |
| | | selectedTask = TrySelectOutboundTask(sameStationTask); |
| | | if (selectedTask != null) |
| | | { |
| | | QuartzLogHelper.LogDebug(_logger, $"选中同站台备选出库任务,任务号: {selectedTask.TaskNum}", commonStackerCrane.DeviceName); |
| | | QuartzLogHelper.LogInfo(_logger, $"选中同站台备选出库任务,任务号: {selectedTask.TaskNum}", commonStackerCrane.DeviceName); |
| | | return selectedTask; |
| | | } |
| | | } |
| | |
| | | selectedTask = TrySelectOutboundTask(alternativeTask); |
| | | if (selectedTask != null) |
| | | { |
| | | QuartzLogHelper.LogDebug(_logger, $"选中备选出库任务,任务号: {selectedTask.TaskNum}", commonStackerCrane.DeviceName); |
| | | QuartzLogHelper.LogInfo(_logger, $"选中备选出库任务,任务号: {selectedTask.TaskNum}", commonStackerCrane.DeviceName); |
| | | return selectedTask; |
| | | } |
| | | } |
| | | |
| | | // 没有可用出库任务,尝试返回入库任务 |
| | | var inboundTask = _taskService.QueryStackerCraneInTask(deviceCode); |
| | | QuartzLogHelper.LogDebug(_logger, $"返回入库任务,任务号: {inboundTask?.TaskNum}", commonStackerCrane.DeviceName); |
| | | QuartzLogHelper.LogInfo(_logger, $"返回入库任务,任务号: {inboundTask?.TaskNum}", commonStackerCrane.DeviceName); |
| | | return inboundTask; |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | // 检查是否有正在执行的输送线任务去往同一 TargetAddress |
| | | if (_taskService.HasExecutingTaskToTarget(outboundTask.Roadway, outboundTask.TargetAddress)) |
| | | { |
| | | QuartzLogHelper.LogInfo(_logger, "TrySelectOutboundTask:TargetAddress: {TargetAddress} 已有正在执行的输送线任务,任务号: {TaskNum}", |
| | | $"TrySelectOutboundTask:TargetAddress: {outboundTask.TargetAddress} 已有正在执行的输送线任务", outboundTask.Roadway, outboundTask.TargetAddress, outboundTask.TaskNum); |
| | | return null; |
| | | } |
| | | |
| | | // 站台检查通过后,调用 WMS 判断是否需要移库 |
| | | var taskAfterTransferCheck = _transferCheck(outboundTask.TaskNum) ?? outboundTask; |
| | | var taskGroup = taskAfterTransferCheck.TaskType.GetTaskTypeGroup(); |