| | |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core.Caches; |
| | |
| | | else |
| | | return; |
| | | } |
| | | |
| | | |
| | | _taskService.StackCraneTaskCompleted(e.TaskNum); |
| | | if (commonStackerCrane.DeviceCode.Contains("CH") && task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum); |
| | | Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); |
| | | } |
| | | if(task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TargetAddress == "1359-4") |
| | | if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TargetAddress == "002-021-001") |
| | | { |
| | | var TASKHTY = task.Adapt<Dt_Task_Hty>(); |
| | | _taskRepository.DeleteData(task); |
| | |
| | | private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane) |
| | | { |
| | | Dt_Task task; |
| | | var taskRun = _taskRepository.QueryFirst(x => x.Roadway == commonStackerCrane.DeviceCode && (x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting || x.TaskState == (int)TaskInStatusEnum.SC_InExecuting)); |
| | | if (taskRun != null) { return null; } |
| | | if (commonStackerCrane.LastTaskType == null) |
| | | { |
| | | task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode); |
| | | } |
| | | else |
| | | { |
| | | if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | var lastTaskTypeGroup = commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup(); |
| | | if (lastTaskTypeGroup == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); |
| | | if (task == null) |
| | |
| | | |
| | | if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | if (OutTaskStationIsOccupied(task) != null) |
| | | // 检查当前出库任务站台是否允许放货 |
| | | var occupiedStation = OutTaskStationIsOccupied(task); |
| | | if (occupiedStation == null) |
| | | { |
| | | // 如果当前出库任务站台不允许放货,排除当前任务,查找其他出库任务 |
| | | ConsoleHelper.WriteErrorLine($"任务号:【{task.TaskNum}】出库地址:【{task.NextAddress}】不允许放货"); |
| | | task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task.TaskId); |
| | | } |
| | | else |
| | | { |
| | | return task; |
| | | } |
| | | //else |
| | | //{ |
| | | // List<string> otherOutStaionCodes = _routerService.QueryNextRoutes(commonStackerCrane.DeviceCode, task.NextAddress).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; |
| | | // } |
| | | // } |
| | | // task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); |
| | | //} |
| | | } |
| | | else if (task == null) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查找其他出库任务的辅助方法(排除指定任务ID的任务) |
| | | /// </summary> |
| | | /// <param name="deviceCode">设备代码</param> |
| | | /// <param name="excludedTaskId">要排除的任务ID</param> |
| | | /// <returns></returns> |
| | | private Dt_Task? FindAnotherOutboundTask(string deviceCode, int excludedTaskId) |
| | | { |
| | | // 先获取所有符合条件(排除指定任务ID)的出库任务列表 |
| | | var allOutboundTasks = _taskService.QueryAllOutboundTasks(deviceCode); |
| | | var availableTasks = allOutboundTasks?.Where(t => excludedTaskId != t.TaskId && t.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup).ToList(); |
| | | |
| | | if (availableTasks == null || availableTasks.Count == 0) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | // 遍历可用任务列表,检查任务站台是否允许放货,找到第一个允许放货的任务就返回 |
| | | foreach (var candidateTask in availableTasks) |
| | | { |
| | | var occupiedStation = OutTaskStationIsOccupied(candidateTask); |
| | | if (occupiedStation != null) |
| | | { |
| | | return candidateTask; |
| | | } |
| | | ConsoleHelper.WriteErrorLine($"任务号:【{occupiedStation.TaskNum}】出库地址:【{occupiedStation.NextAddress}】不允许放货"); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 任务实体转换成命令Model |
| | | /// </summary> |