|  |  | 
 |  |  |                                             //builder.AppendLine(); | 
 |  |  |                                             //ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); | 
 |  |  |                                             commonStackerCrane.LastTaskType = task.TaskType; | 
 |  |  |  | 
 |  |  |                                             _taskService.UpdateTaskStatusToNext(task.TaskNum); | 
 |  |  |  | 
 |  |  |                                         } | 
 |  |  |                                     } | 
 |  |  |                                     else | 
 |  |  | 
 |  |  |  | 
 |  |  |                     if (task == null) commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); | 
 |  |  |  | 
 |  |  |                     if (commonStackerCrane.DeviceCode.Contains("CW") && task.TaskType == (int)TaskOutboundTypeEnum.InToOut) | 
 |  |  |                     { | 
 |  |  |                         var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1006" && x.stationType == 10 && x.Roadway == commonStackerCrane.DeviceCode); | 
 |  |  |  | 
 |  |  |                         IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC); | 
 |  |  |                         if (device != null) | 
 |  |  |                         { | 
 |  |  |                             CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device; | 
 |  |  |                             conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(3292), stationinfo.stationChildCode); | 
 |  |  |                             Thread.Sleep(100); | 
 |  |  |                             conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode); | 
 |  |  |                         } | 
 |  |  |                         WriteInfo(commonStackerCrane.DeviceName, $"【手动出库记录】任务号【{e.TaskNum}】托盘号【{task.PalletCode}】"); | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                     if (commonStackerCrane.DeviceCode.Contains("GW") && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) | 
 |  |  |                     { | 
 |  |  |                         var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress); | 
 |  |  | 
 |  |  |                     { | 
 |  |  |                         task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum); | 
 |  |  |                         Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress); | 
 |  |  |                         _taskService.UpdateData(newTask); | 
 |  |  |                     } | 
 |  |  |                     if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && (task.TargetAddress == "002-071-001" || task.TargetAddress == "001-061-001")) | 
 |  |  |                     if ((task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && (task.TargetAddress == "002-071-001" || task.TargetAddress == "001-061-001"))||task.TaskType == (int)TaskOutboundTypeEnum.OutFireAlarm) | 
 |  |  |                     { | 
 |  |  |                         var TASKHTY = task.Adapt<Dt_Task_Hty>(); | 
 |  |  |                         _taskRepository.DeleteData(task); | 
 |  |  | 
 |  |  |         private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane) | 
 |  |  |         { | 
 |  |  |             Dt_Task task = null; | 
 |  |  |  | 
 |  |  |             task = _taskService.QueryOutFireAlarmTask(commonStackerCrane.DeviceCode); | 
 |  |  |             if (task != null) | 
 |  |  |             { | 
 |  |  |                 return task; | 
 |  |  |             } | 
 |  |  |             if (commonStackerCrane.LastTaskType == null) | 
 |  |  |             { | 
 |  |  |                 task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode); | 
 |  |  | 
 |  |  |  | 
 |  |  |             if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) | 
 |  |  |             { | 
 |  |  |                 #region 静置出库判断是否能执行任务 | 
 |  |  |                 if (task != null && task.Roadway.Contains("JZ") && task.TaskType==(int)TaskOutboundTypeEnum.Outbound) | 
 |  |  |                 { | 
 |  |  |                     // 查询是否存在静置入库任务 | 
 |  |  |                     var inJZTask = _taskRepository.QueryData(x => x.Roadway == task.Roadway && | 
 |  |  |                         (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || | 
 |  |  |                          x.TaskState == (int)TaskInStatusEnum.SC_InExecuting || | 
 |  |  |                          x.TaskState == (int)TaskInStatusEnum.Line_InFinish)); | 
 |  |  |  | 
 |  |  |                     ConsoleHelper.WriteErrorLine($"当前静置线体存在入库任务{inJZTask.Count()}条,{(inJZTask.Count() <= 0 ? "可出库" : "不可出库")}"); | 
 |  |  |                     WriteInfo(commonStackerCrane.DeviceName, $"当前静置线体存在入库任务{inJZTask.Count()}条,{(inJZTask.Count() <= 0 ? "可出库" : "不可出库")}"); | 
 |  |  |                     if (inJZTask.Any() || inJZTask.Count() > 0) | 
 |  |  |                     { | 
 |  |  |                         var x = inJZTask.Where(x => x.TaskState == (int)TaskInStatusEnum.Line_InFinish).FirstOrDefault(); | 
 |  |  |                         if (x != null) | 
 |  |  |                         { | 
 |  |  |                             return x; | 
 |  |  |                         } | 
 |  |  |                         else | 
 |  |  |                         { | 
 |  |  |                             return null; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 #endregion | 
 |  |  |  | 
 |  |  |                 // 检查当前出库任务站台是否允许放货 | 
 |  |  |                 var occupiedStation = OutTaskStationIsOccupied(task); | 
 |  |  |                 if (occupiedStation == null) | 
 |  |  | 
 |  |  |                     return task; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 #region 静置出库判断是否能执行任务 | 
 |  |  |  | 
 |  |  |                 if (!task.IsNullOrEmpty() && task.Roadway.Contains("JZ") && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) | 
 |  |  |                 { | 
 |  |  |                     // 查询是否存在静置入库任务 | 
 |  |  |                     var inJZTask = _taskRepository.QueryData(x => x.Roadway == task.Roadway && | 
 |  |  |                         (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || | 
 |  |  |                          x.TaskState == (int)TaskInStatusEnum.SC_InExecuting || | 
 |  |  |                          x.TaskState == (int)TaskInStatusEnum.Line_InFinish)); | 
 |  |  |  | 
 |  |  |                     ConsoleHelper.WriteErrorLine($"当前静置线体存在入库任务{inJZTask.Count()}条,{(inJZTask.Count() > 0 ? "可入库" : "不可入库")}"); | 
 |  |  |                     if (!inJZTask.IsNullOrEmpty()) | 
 |  |  |                         return null; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 #endregion 静置出库判断是否能执行任务 | 
 |  |  |                  | 
 |  |  |             } | 
 |  |  |             else if (task == null) | 
 |  |  |             { | 
 |  |  | 
 |  |  |             stackerCraneTaskCommand.WorkType = 1; | 
 |  |  |             stackerCraneTaskCommand.TrayType = 0; | 
 |  |  |             stackerCraneTaskCommand.StartCommand = 1; | 
 |  |  |             stackerCraneTaskCommand.FireCommand = Convert.ToInt16(task.TaskType == (int)TaskOutboundTypeEnum.OutFireAlarm ? 2 : 0); | 
 |  |  |  | 
 |  |  |             if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//判断是否是入库任务 | 
 |  |  |             { | 
 |  |  |                 var value = _sys_ConfigService.GetByConfigKey(CateGoryConst.CONFIG_SYS_InStation, SysConfigKeyConst.JZNGInBoundStation).ConfigValue; | 
 |  |  |                 var valueList = value.Split(',').ToList(); | 
 |  |  |                 if ((valueList.Contains(task.SourceAddress)) && (task.Roadway.Contains("CH") || task.Roadway.Contains("JZ"))) | 
 |  |  |                 if(task.TaskType == (int)TaskInboundTypeEnum.InNG) | 
 |  |  |                 { | 
 |  |  |                     string[] souredCodes = task.CurrentAddress.Split("-"); | 
 |  |  |                     if (souredCodes.Length == 3) | 
 |  |  |                     { | 
 |  |  |                         stackerCraneTaskCommand.StartRow = Convert.ToInt16(souredCodes[0]); | 
 |  |  |                         stackerCraneTaskCommand.StartColumn = Convert.ToInt16(souredCodes[1]); | 
 |  |  |                         stackerCraneTaskCommand.StartLayer = Convert.ToInt16(souredCodes[2]); | 
 |  |  |                     } | 
 |  |  |                     else | 
 |  |  |                     { | 
 |  |  |                         //数据配置错误 | 
 |  |  |                         _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"入库任务起点错误,起点:【{task.CurrentAddress}】"); | 
 |  |  |                         return null; | 
 |  |  |                     } | 
 |  |  |                     string[] targetCodes = task.NextAddress.Split("-"); | 
 |  |  |                     if (targetCodes.Length == 3) | 
 |  |  |                     { | 
 |  |  |                         stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2; | 
 |  |  |                         stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); | 
 |  |  |                         stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); | 
 |  |  |                     } | 
 |  |  |                     else | 
 |  |  |                     { | 
 |  |  |                         //数据配置错误 | 
 |  |  |                         _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"入库任务终点错误,起点:【{task.NextAddress}】"); | 
 |  |  |                         return null; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 else if ((valueList.Contains(task.SourceAddress)) && (task.Roadway.Contains("CH") || task.Roadway.Contains("JZ"))) | 
 |  |  |                 { | 
 |  |  |                     string[] souredCodes = task.CurrentAddress.Split("-"); | 
 |  |  |                     if (souredCodes.Length == 3) | 
 |  |  | 
 |  |  |             } | 
 |  |  |             else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) | 
 |  |  |             { | 
 |  |  |                 if (task.Roadway.Contains("GW")) | 
 |  |  |                 if (task.TaskType == (int)TaskOutboundTypeEnum.InToOut) | 
 |  |  |                 { | 
 |  |  |                     string[] endCodes = task.TargetAddress.Split("-"); | 
 |  |  |                     stackerCraneTaskCommand.EndRow = Convert.ToInt16(endCodes[0]); | 
 |  |  |                     stackerCraneTaskCommand.EndColumn = Convert.ToInt16(endCodes[1]); | 
 |  |  |                     stackerCraneTaskCommand.EndLayer = Convert.ToInt16(endCodes[2]); | 
 |  |  |                     string[] sourceCodes = task.SourceAddress.Split("-"); | 
 |  |  |                     stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2; | 
 |  |  |                     stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); | 
 |  |  |                     stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); | 
 |  |  |                 } | 
 |  |  |                 else if (task.Roadway.Contains("GW") || task.TaskType == (int)TaskOutboundTypeEnum.OutFireAlarm) | 
 |  |  |                 { | 
 |  |  |                     string[] endCodes = task.NextAddress.Split("-"); | 
 |  |  |                     stackerCraneTaskCommand.EndRow = Convert.ToInt16(endCodes[0]); | 
 |  |  | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     if ((task.TargetAddress == "002-071-001" || task.TargetAddress == "001-061-001") && (task.Roadway.Contains("JZ") || task.Roadway.Contains("CH"))) | 
 |  |  |                     if (((task.TargetAddress == "002-071-001" || task.TargetAddress == "001-061-001") && (task.Roadway.Contains("JZ") || task.Roadway.Contains("CH"))) || task.TaskType == (int)TaskOutboundTypeEnum.OutFireAlarm) | 
 |  |  |                     { | 
 |  |  |                         string[] endCodes = task.NextAddress.Split("-"); | 
 |  |  |                         stackerCraneTaskCommand.EndRow = Convert.ToInt16(endCodes[0]); |