优化 WMS 接口请求和设备处理逻辑
在 `RequestInbound.cs` 中删除与 GW 相关的代码注释,添加 WMS 接口请求处理,更新 `RequestWmsTask` 方法以支持异步请求和结果处理。
在 `CommonConveyorLine_CWJob.cs` 中移除不必要的代码,简化设备处理逻辑,并增加调度执行时间记录,改进异常处理输出。
在 `CommonStackerCraneJob.cs` 中将设备类型转换从 `CommonConveyorLine_GW` 更新为 `CommonConveyorLine_CW`,确保任务处理的正确性。
已修改3个文件
51 ■■■■ 文件已修改
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs
@@ -169,22 +169,6 @@
                    break;
                case 1:
                    //if (stationManager.stationArea.Contains("GW"))
                    //{
                    //var taskGW = _taskRepository.QueryFirst(x => x.TargetAddress == childDeviceCode && (x.TaskState == (int)TaskOutStatusEnum.OutFinish || x.TaskState == (int)TaskOutStatusEnum.OutPending));
                    //if (taskGW != null)
                    //{
                    //    command.ConveyorLineBarcode = taskGW.PalletCode;
                    //}
                    //}
                    //如高温出库后任务标记NG异常则将任务更新为异常排出任务   --冠宇取消超时检测后  托盘超时不在出库至异常口
                    //Dt_Task NGtask = _taskRepository.QueryFirst(x => x.Remark == "NG" && x.Roadway == stationManager.Roadway && x.Roadway.Contains("GW"));
                    //if (NGtask != null)
                    //{
                    //    CreateAbNormalOutbound(conveyorLine, command, childDeviceCode, NGtask);
                    //    break;
                    //}
                    RequestWmsTask(conveyorLine, command, childDeviceCode, stationManager);
                    break;
            }
@@ -296,7 +280,9 @@
                throw new InvalidOperationException("WMS IP 未配置");
            }
            var wmsIpAddrss = wmsBase + requestTrayInTask;
            var result = HttpHelper.PostAsync(wmsIpAddrss, request.ToJsonString()).Result;
            if (result == null)
                return new WMSTaskDTO();
@@ -315,7 +301,9 @@
            try
            {
                if (command.ConveyorLineBarcode.IsNullOrEmpty()) return;
                var content = await _taskService.RequestWMSTask(command.ConveyorLineBarcode, childDeviceCode);
                if (content.Status)
                {
                    var task = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode);
@@ -332,7 +320,6 @@
                        }
                        ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
                        //conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode);
                        if (sendFlag)
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs
@@ -116,20 +116,11 @@
                    #endregion 站台方式
                    #region 路由方式
                    List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
                    //DateTime dateTime = DateTime.Now;
                    //Console.WriteLine($"循环开始时间{dateTime}");
                    foreach (string childDeviceCode in childDeviceCodes)
                    {
                        //Thread.Sleep(1000);
                        //if (childCodeList.Contains(childDeviceCode))
                        //{
                        //    Console.WriteLine($"当前{childDeviceCode}执行中,已跳过");
                        //    continue;
                        //}
                        //childCodeList.Add(childDeviceCode);
                        //Console.WriteLine(childDeviceCode);
                        ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
                        if (command == null) continue;
@@ -164,7 +155,6 @@
                            }
                        }
                        //childCodeList.Remove(childDeviceCode);
                        #region 调用事件总线通知前端
@@ -187,20 +177,16 @@
                        #endregion 调用事件总线通知前端
                    }
                    DateTime ENDdateTime = DateTime.Now;
                    //Console.WriteLine($"循环结束时间{ENDdateTime}");
                    #endregion 路由方式
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(nameof(CommonConveyorLine_CWJob) + ":" + DateTime.Now + ":" + ex.ToString());
                Console.Out.WriteLine(nameof(CommonConveyorLine_CWJob) + ":" + DateTime.Now + ":" + ex.ToString(),ex.StackTrace);
            }
            finally
            {
                //WriteDebug("CommonConveyorLineJob", "test");
                //Console.Out.WriteLine(DateTime.Now);
            }
            return Task.CompletedTask;
        }
@@ -556,12 +542,14 @@
                }
                var wmsIpAddress = wmsBase + requestTrayOutTask;
                //var device = _deviceInfoRepository.QueryData(x => x.DeviceStatus == "1" && x.DeviceRemark == platform.Id.ToString());
                //var deviceCode = device.Select(x => x.DeviceCode).ToList();
                List<string> strings = platform.Location.Split(',').ToList();
                WriteInfo("调度执行时间记录", "【调取WMS出库接口开始时间:】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                var result = await HttpHelper.PostAsync(wmsIpAddress, new { Position = childDeviceCode, Tag = (int)taskType, AreaCdoe = platform.Stacker, AreaCdoes = strings, platform.ProductionLine }.Serialize());
                //var result = await HttpHelper.PostAsync("http://localhost:5000/api/Task/RequestTrayOutTaskAsync", dynamic.ToJsonString());
                WriteInfo("调度执行时间记录", "【调取WMS出库接口结束时间:】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -319,7 +319,7 @@
                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode);
                        if (device != null)
                        {
                            CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
                            CommonConveyorLine_CW conveyorLine = (CommonConveyorLine_CW)device;
                            if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用
                            {
                                return task;