| | |
| | | using Mapster; |
| | | using Autofac.Core; |
| | | using Mapster; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System.Diagnostics.CodeAnalysis; |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (commonStackerCrane != null) |
| | | { |
| | |
| | | StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task); |
| | | if (stackerCraneTaskCommand != null) |
| | | { |
| | | var taskNum = commonStackerCrane.GetValue<StackerCraneDBName, int>(StackerCraneDBName.TaskNum); |
| | | //var taskBarCode = commonStackerCrane.GetValue<StackerCraneDBName, string>(StackerCraneDBName.Barcode); |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】堆垛机任务号:【{taskNum}】任务任务号:【{task.TaskNum}】", ConsoleColor.DarkBlue); |
| | | if (taskNum == 0) |
| | | bool IsInStock = commonStackerCrane.Communicator.Read<bool>("DB14.4.3"); |
| | | if (!IsInStock) |
| | | { |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务号为【{0}】,任务号不一致可以下发任务", ConsoleColor.DarkBlue); |
| | | |
| | | Thread.Sleep(1000); |
| | | bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); |
| | | if (sendFlag) |
| | | var taskNum = commonStackerCrane.GetValue<StackerCraneDBName, int>(StackerCraneDBName.TaskNum); |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】堆垛机任务号:【{taskNum}】任务任务号:【{task.TaskNum}】", ConsoleColor.DarkBlue); |
| | | if (taskNum == 0) |
| | | { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.AppendLine(); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】堆垛机状态:【{commonStackerCrane.StackerCraneStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】手自动状态:【{commonStackerCrane.StackerCraneAutoStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】作业状态:【{commonStackerCrane.StackerCraneWorkStatusDes}】,时间:【{DateTime.Now}】"); |
| | | builder.AppendLine($"【{commonStackerCrane.DeviceName}】下发任务成功,【{JsonConvert.SerializeObject(stackerCraneTaskCommand, Formatting.Indented)}】"); |
| | | builder.AppendLine($"时间:【{DateTime.Now}】"); |
| | | builder.AppendLine(); |
| | | ConsoleHelper.WriteColorLine(builder, ConsoleColor.Blue); |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | |
| | | |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | Thread.Sleep(1000); |
| | | bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand); |
| | | if (sendFlag) |
| | | { |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务号不为【{0}】,不可以下发任务", ConsoleColor.DarkBlue); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务号不为【{0}】,不可以下发任务", ConsoleColor.DarkBlue); |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】有货信息不为【{0}】,不可以下发任务", ConsoleColor.DarkBlue); |
| | | WriteInfo("堆垛机有货信号", $"【{commonStackerCrane.DeviceName}】有货信息不为【{IsInStock}】,不可以下发任务"); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5) |
| | | { |
| | | ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】堆垛机作业状态:【{(int)commonStackerCrane.StackerCraneWorkStatusValue}】时间【{DateTime.Now}】", ConsoleColor.Magenta); |
| | | |
| | | string str = $"【{commonStackerCrane.DeviceName}】任务完成,任务号:【{e.TaskNum}】时间【{DateTime.Now}】"; |
| | | WriteInfo(commonStackerCrane.DeviceName, str); |
| | | ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue); |
| | |
| | | |
| | | if (task == null) commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); |
| | | |
| | | if (commonStackerCrane.DeviceCode.Contains("CW") && task.TaskType==(int)TaskOutboundTypeEnum.InToOut) |
| | | if (commonStackerCrane.DeviceCode.Contains("CW") && task.TaskType == (int)TaskOutboundTypeEnum.InToOut) |
| | | { |
| | | var stationinfo = _stationManagerRepository.QueryFirst(x => (x.stationPLC == "1017"||x.stationPLC=="1024") && x.stationType == 10 && x.Roadway == commonStackerCrane.DeviceCode); |
| | | var stationinfo = _stationManagerRepository.QueryFirst(x => (x.stationPLC == "1017" || x.stationPLC == "1024") && x.stationType == 10 && x.Roadway == commonStackerCrane.DeviceCode); |
| | | |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC); |
| | | if (device != null) |
| | |
| | | { |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device; |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(4000), stationinfo.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode); |
| | | } |
| | | } |
| | | WriteInfo(commonStackerCrane.DeviceName, $"【手动出库记录】任务号【{e.TaskNum}】托盘号【{task.PalletCode}】"); |
| | | } |
| | | |
| | | if (task.TaskType == (int)TaskOutboundTypeEnum.OutNG) |
| | | { |
| | | Dt_StationManager stationinfo = null; |
| | | if (commonStackerCrane.DeviceCode.Contains("CW")) |
| | | stationinfo = _stationManagerRepository.QueryFirst(x => (x.stationPLC == "1017" || x.stationPLC == "1024") && x.stationType == 10 && x.Roadway == commonStackerCrane.DeviceCode); |
| | | else |
| | | stationinfo = _stationManagerRepository.QueryFirst(x => x.stationType == 1 && x.stationChildCode == task.TargetAddress); |
| | | |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC); |
| | | if (device != null) |
| | | { |
| | | if (device.DeviceCode == "1024" || device.DeviceCode == "1023") |
| | | { |
| | | CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device; |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(4000), stationinfo.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, stationinfo.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode); |
| | | } |
| | | else if (device.DeviceCode == "1015" || device.DeviceCode == "2025") |
| | | { |
| | | CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device; |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(1815), stationinfo.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, stationinfo.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode); |
| | | } |
| | | else |
| | | { |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device; |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, Convert.ToInt16(4000), stationinfo.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, stationinfo.stationChildCode); |
| | | Thread.Sleep(100); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTaskNum, 1000, stationinfo.stationChildCode); |
| | | } |
| | |
| | | } |
| | | |
| | | var content = _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); |
| | | _taskService.UpdateData(newTask); |
| | | } |
| | | |
| | | if ((task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && (task.TargetAddress == "002-021-001" || task.TargetAddress == "001-021-001"))|| task.TaskType == (int)TaskOutboundTypeEnum.OutFireAlarm) |
| | | { |
| | | var TASKHTY = task.Adapt<Dt_Task_Hty>(); |
| | | _taskRepository.DeleteData(task); |
| | | _htyRepository.AddData(TASKHTY); |
| | | } |
| | | |
| | | var isWorkType = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5); |
| | | |
| | | str = $"{commonStackerCrane.DeviceName}】WMS|WCS任务完成:【{content.Status}】,堆垛机完成信号写入:【{isWorkType}】,任务号:【{e.TaskNum}】时间【{DateTime.Now}】"; |
| | | WriteInfo(commonStackerCrane.DeviceName, str); |
| | | ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue); |
| | |
| | | /// <returns>如果未被占用,返回传入的任务信息,否则,返回null</returns> |
| | | private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task) |
| | | { |
| | | Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); |
| | | if (task.Roadway.Contains("GW") || task.Roadway.Contains("CW")) |
| | | if (task.TaskType == (int)TaskOutboundTypeEnum.OutNG) |
| | | { |
| | | if (router != null) |
| | | if (task.Roadway.Contains("CW")) |
| | | { |
| | | IDevice? device = null; |
| | | if (task.Roadway.Contains("CW")) |
| | | var stationinfo = _stationManagerRepository.QueryFirst(x => (x.stationPLC == "1017" || x.stationPLC == "1024") && x.stationType == 10 && x.Roadway == task.Roadway); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC); |
| | | if (device != null) |
| | | { |
| | | device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | if (device.DeviceCode == "1024" || device.DeviceCode == "1023") |
| | | { |
| | | if (device.DeviceCode == "1024" || device.DeviceCode == "1023") |
| | | CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device; |
| | | |
| | | if (conveyorLine.IsOccupied(task.TargetAddress))//出库站台未被占用 |
| | | { |
| | | CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device; |
| | | if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用 |
| | | return task; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device; |
| | | |
| | | if (conveyorLine.IsOccupied(task.TargetAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationType == 1 && x.stationChildCode == task.TargetAddress); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationinfo.stationPLC); |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device; |
| | | if (conveyorLine.IsOccupied(task.TargetAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); |
| | | if (task.Roadway.Contains("GW") || task.Roadway.Contains("CW")) |
| | | { |
| | | if (router != null) |
| | | { |
| | | IDevice? device = null; |
| | | if (task.Roadway.Contains("CW")) |
| | | { |
| | | device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | { |
| | | if (device.DeviceCode == "1024" || device.DeviceCode == "1023") |
| | | { |
| | | CommonConveyorLine_NewCW conveyorLine = (CommonConveyorLine_NewCW)device; |
| | | |
| | | if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device; |
| | | |
| | | if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | IDevice? device = null; |
| | | if (task.Roadway.Contains("GW")) |
| | | { |
| | | string targetDeviceCode = task.Roadway == "GWSC3" ? "2025" : "1015"; |
| | | device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == targetDeviceCode); |
| | | |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device; |
| | | if (conveyorLine.IsOccupied(task.TargetAddress))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device; |
| | | if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.TargetAddress}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | //_taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.TargetAddress}】信息,无法校验站台"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if ((task.NextAddress == ("002-021-001") || task.NextAddress == ("001-021-001")) && task.Roadway.Contains("JZ")) |
| | | { |
| | | return task; |
| | | } |
| | | else |
| | | { |
| | | //Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); |
| | | if (router != null) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | if (conveyorLine.IsOccupiedx(router.ChildPosi))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | IDevice? device = null; |
| | | if (task.Roadway.Contains("GW")) |
| | | { |
| | | string targetDeviceCode = task.Roadway == "GWSC3" ? "2025" : "1015"; |
| | | device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == targetDeviceCode); |
| | | |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device; |
| | | if (conveyorLine.IsOccupied(task.TargetAddress))//出库站台未被占用 |
| | | else |
| | | { |
| | | return task; |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{router.ChildPosiDeviceCode}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.TargetAddress}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法校验站台"); |
| | | } |
| | | } |
| | | //_taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.TargetAddress}】信息,无法校验站台"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if ((task.NextAddress == ("002-021-001") || task.NextAddress == ("001-021-001")) && task.Roadway.Contains("JZ")) |
| | | { |
| | | return task; |
| | | } |
| | | else |
| | | { |
| | | //Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); |
| | | if (router != null) |
| | | { |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); |
| | | if (device != null) |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | if (conveyorLine.IsOccupiedx(router.ChildPosi))//出库站台未被占用 |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{router.ChildPosiDeviceCode}】对应的通讯对象,无法判断出库站台是否被占用"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法校验站台"); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查找其他出库任务的辅助方法(排除指定任务ID的任务) |
| | | /// </summary> |
| | |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) |
| | | { |
| | | if (task.Roadway.Contains("GW")|| task.TaskType == (int)TaskOutboundTypeEnum.OutFireAlarm) |
| | | if (task.Roadway.Contains("GW")|| task.TaskType == (int)TaskOutboundTypeEnum.OutFireAlarm || task.TaskType == (int)TaskOutboundTypeEnum.OutNG) |
| | | { |
| | | string[] endCodes = task.NextAddress.Split("-"); |
| | | stackerCraneTaskCommand.EndRow = Convert.ToInt16(endCodes[0]); |