From 5efc3d1d1042ac74e7319fb04e490dd7295b9e22 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期四, 07 八月 2025 16:20:35 +0800 Subject: [PATCH] 优化 WMS 接口请求和设备处理逻辑 在 `RequestInbound.cs` 中删除与 GW 相关的代码注释,添加 WMS 接口请求处理,更新 `RequestWmsTask` 方法以支持异步请求和结果处理。 在 `CommonConveyorLine_CWJob.cs` 中移除不必要的代码,简化设备处理逻辑,并增加调度执行时间记录,改进异常处理输出。 在 `CommonStackerCraneJob.cs` 中将设备类型转换从 `CommonConveyorLine_GW` 更新为 `CommonConveyorLine_CW`,确保任务处理的正确性。 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 2 +- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs | 28 ++++++++-------------------- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs | 21 ++++----------------- 3 files changed, 13 insertions(+), 38 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs index b15cf35..987db4f 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CWTask/RequestInbound.cs +++ b/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) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs index bdeadd9..6ee670c 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_CW/CommonConveyorLine_CWJob.cs +++ b/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("璋冨害鎵ц鏃堕棿璁板綍", "銆愯皟鍙朩MS鍑哄簱鎺ュ彛寮�濮嬫椂闂达細銆�" + 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("璋冨害鎵ц鏃堕棿璁板綍", "銆愯皟鍙朩MS鍑哄簱鎺ュ彛缁撴潫鏃堕棿锛氥��" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs index 5ea680d..5f99e14 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs +++ b/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; -- Gitblit v1.9.3