| | |
| | | using WIDESEAWCS_Tasks.ConveyorLineJob; |
| | | using HslCommunication; |
| | | using OfficeOpenXml.ConditionalFormatting; |
| | | using WIDESEAWCS_DTO.WMS; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | partial class CommonConveyorLineJob |
| | | public partial class CommonConveyorLineJob |
| | | { |
| | | /// <summary> |
| | | /// 处理出库任务 |
| | |
| | | // 更新任务状态 |
| | | _taskService.UpdateTaskStatusToNext(taskOut); |
| | | } |
| | | else if (taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting) |
| | | else if (taskOut.TaskType == (int)TaskOutboundTypeEnum.OutTray && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting) |
| | | { |
| | | // 完成WMS任务 |
| | | CompleteWmsTask(taskOut, command, conveyorLine, childDeviceCode, ProtocalDetailValue); |
| | |
| | | private void HandleNewTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue) |
| | | { |
| | | // 特定条件下创建并发送空托盘入库任务 |
| | | if (conveyorLine.DeviceCode == "1003" && childDeviceCode == "1016") |
| | | if ((conveyorLine.DeviceCode == "1003" && childDeviceCode == "1016") || (conveyorLine.DeviceCode == "1005" && childDeviceCode == "1048")) |
| | | { |
| | | // 请求WMS空托盘任务 |
| | | CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue); |
| | | } |
| | | else if (conveyorLine.DeviceCode == "1001" && childDeviceCode == "1088") |
| | | else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1088") || (conveyorLine.DeviceCode == "1004" && childDeviceCode == "1339")) |
| | | { |
| | | // 请求WMS任务 |
| | | // 请求WMS入库任务 |
| | | RequestWmsTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue); |
| | | } |
| | | else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1073") || (conveyorLine.DeviceCode == "1003" && childDeviceCode == "1002")) |
| | |
| | | } |
| | | |
| | | // TODO调用WMS任务完成接口 |
| | | var result = HttpHelper.GetAsync("http://127.0.0.1:8098/api/Task/CompleteTaskAsync", new { taskNum = taskOut.TaskNum }.ToJsonString()).Result; |
| | | var keys = new Dictionary<string, object>() |
| | | { |
| | | {"taskNum", taskOut.TaskNum} |
| | | }; |
| | | var result = HttpHelper.GetAsync($"http://127.0.0.1:5000/api/Task/CompleteTaskAsync", keys).Result; |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | if (content.Status) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 创建并发送空托盘任务 |
| | | /// </summary> |
| | | private void CreateAndSendEmptyTrayTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue) |
| | | public void CreateAndSendEmptyTrayTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue) |
| | | { |
| | | if (command.Barcode != "NoRead") |
| | | { |
| | |
| | | /// </summary> |
| | | private WMSTaskDTO CreateEmptyTrayTaskDto(string barcode, string childDeviceCode) |
| | | { |
| | | // 创建并返回空托盘任务DTO |
| | | return new WMSTaskDTO |
| | | #region 向WMS请求空托盘任务 |
| | | WMSTaskDTO wMSTaskDTO = new WMSTaskDTO(); |
| | | RequestTaskDto request = new RequestTaskDto() |
| | | { |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | Grade = 1, |
| | | Position = childDeviceCode, |
| | | PalletCode = barcode, |
| | | RoadWay = "CHSC01", |
| | | SourceAddress = childDeviceCode, |
| | | TargetAddress = "CHSC01", |
| | | TaskState = (int)TaskInStatusEnum.InNew, |
| | | Id = 0, |
| | | TaskType = (int)TaskInboundTypeEnum.InTray, |
| | | }; |
| | | var result = HttpHelper.PostAsync("http://127.0.0.1:5000/api/Task/RequestTrayInTaskAsync", request.ToJsonString()).Result; |
| | | if (result == null) |
| | | return wMSTaskDTO; |
| | | |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | // 检查状态并返回 |
| | | if (!content.Status) |
| | | return wMSTaskDTO; |
| | | |
| | | return JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString()); |
| | | |
| | | #endregion 向WMS请求空托盘任务 |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status) |
| | | { |
| | | // 查询任务 |
| | | Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode); |
| | | Dt_Task task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | // 映射任务命令 |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |