优化错误处理和地址获取逻辑
在 `RequestInbound.cs` 中,修改了对 `content.Message` 的检查逻辑,确保在特定错误信息情况下不执行不必要的操作,并添加了错误信息的日志记录以增强可读性和调试能力。
在 `Dt_TaskService.cs` 中,增加了对 `ToAddress` 变量的空值检查,确保在获取地址失败时能够及时反馈错误信息,增强了代码的健壮性。
| | |
| | | } |
| | | else |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, content.Message); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationManager.stationNGChildCode, childDeviceCode); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); |
| | | if (content.Message != "请求过于频繁,请稍后再试" || content.Message != "无法获取目标地址") |
| | | { |
| | | WriteInfo(conveyorLine.DeviceName, content.Message); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, stationManager.stationNGChildCode, childDeviceCode); |
| | | conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode); |
| | | ConsoleHelper.WriteErrorLine($"【{conveyorLine.DeviceName}】托盘号:【{command.ConveyorLineBarcode}】请求点位:【{childDeviceCode}】异常信息【{content.Message}】"); |
| | | } |
| | | ConsoleHelper.WriteErrorLine($"【{conveyorLine.DeviceName}】托盘号:【{command.ConveyorLineBarcode}】请求点位:【{childDeviceCode}】异常信息【{content.Message}】"); |
| | | } |
| | | } |
| | |
| | | ToAddress = await GetRoadWayAsync(process); |
| | | else |
| | | ToAddress = process[0]; |
| | | |
| | | if (string.IsNullOrEmpty(ToAddress)) |
| | | { |
| | | return content.Error("无法获取目标地址"); |
| | | } |
| | | // 创建新任务实例 |
| | | var task = new Dt_Task |
| | | { |