From a95c4e748b01da8bea6ba0f8e6af9c281bc582d7 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com> Date: 星期二, 29 七月 2025 09:22:13 +0800 Subject: [PATCH] 优化日志格式并增强库存查询逻辑在 CommonConveyorLineJob.cs和CommonConveyorLine_GWJob.cs文件中,修改了日志输出格式,添加了时间戳以提高可读性和可追溯性。部分代码中的ToJsonString()方法被替换为 Serialize()方法,以统一序列化方式。与此同时,在 Dt_TaskService.cs文件中增加了库存信息查询逻辑,以确保出库时能够正确处理库存条件,增强系统的健壮性。 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs index b710291..cc448ff 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs @@ -21,6 +21,7 @@ using AutoMapper; using HslCommunication; +using Masuit.Tools; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Quartz; @@ -150,7 +151,6 @@ } } } - #region 璋冪敤浜嬩欢鎬荤嚎閫氱煡鍓嶇 var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken"); @@ -170,6 +170,8 @@ _noticeService.LineData(userIds?.FirstOrDefault(), userTokenIds, new { conveyorLine.DeviceName, data = obj }); #endregion 璋冪敤浜嬩欢鎬荤嚎閫氱煡鍓嶇 + + } #endregion 璺敱鏂瑰紡 @@ -199,7 +201,7 @@ try { var task = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode); - var log = $"銆恵conveyorLine.DeviceName}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戜换鍔″彿锛氥�恵command.ConveyorLineTaskNum}銆戣澶囩紪鐮侊細銆恵childDeviceCode}銆�"; + var log = $"鏃堕棿锛氥�恵DateTime.Now}銆戙�恵conveyorLine.DeviceName}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戜换鍔″彿锛氥�恵command.ConveyorLineTaskNum}銆戣澶囩紪鐮侊細銆恵childDeviceCode}銆�"; ConsoleHelper.WriteSuccessLine(log); _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); @@ -214,11 +216,10 @@ var GWTask = _taskRepository.QueryData(x => x.Roadway.Contains("GWSC2") && x.SourceAddress == "1039" && (x.TaskState == (int)TaskInStatusEnum.Line_InExecuting || x.TaskState == (int)TaskInStatusEnum.Line_InFinish)).ToList(); if (GWTask.Count >= 2 && childDeviceCode == "1039" && task.Roadway.Contains("GWSC2")) { - ConsoleHelper.WriteErrorLine($"鎵樼洏鍙凤細銆恵command.ConveyorLineBarcode}銆戦珮娓╀簩宸插瓨鍦ㄣ�恵GWTask.Count}銆戜釜浠诲姟澶т簬2涓换鍔′笉鍙笅鍙�"); + ConsoleHelper.WriteErrorLine($"鏃堕棿锛氥�恵DateTime.Now}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戦珮娓╀簩宸插瓨鍦ㄣ�恵GWTask.Count}銆戜釜浠诲姟澶т簬2涓换鍔′笉鍙笅鍙�"); return; } ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task); - //conveyorLine.SendCommand(taskCommand, childDeviceCode); bool sendFlag = SendCommand(taskCommand, conveyorLine, childDeviceCode); if (sendFlag) @@ -360,8 +361,8 @@ var MOMIpAddress = wmsBase + ipAddress; - var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.ToJsonString()).Result; - WriteInfo("鍏ョ珯鏍¢獙", $"銆恵childDeviceCode}銆戝叆绔欐牎楠岃姹傚弬鏁般�恵trayCells.ToJsonString()}銆�"); + var result = HttpHelper.PostAsync(MOMIpAddress, trayCells.Serialize()).Result; + WriteInfo("鍏ョ珯鏍¢獙", $"銆恵childDeviceCode}銆戝叆绔欐牎楠岃姹傚弬鏁般�恵trayCells.Serialize()}銆�"); WriteInfo("鍏ョ珯鏍¢獙", ""); WriteInfo("鍏ョ珯鏍¢獙", $"銆恵childDeviceCode}銆戝叆绔欐牎楠岃繑鍥炲弬鏁般�恵result}銆�"); ResultTrayCellsStatus result1 = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(result); @@ -405,7 +406,7 @@ /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param> public void ConveyorLineOutFinish(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode) { - var log = $"銆恵conveyorLine.DeviceName}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戜换鍔″彿锛氥�恵command.ConveyorLineTaskNum}銆戣澶囩紪鐮侊細銆恵childDeviceCode}銆�"; + var log = $"鏃堕棿锛氥�恵DateTime.Now}銆戙�恵conveyorLine.DeviceName}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戜换鍔″彿锛氥�恵command.ConveyorLineTaskNum}銆戣澶囩紪鐮侊細銆恵childDeviceCode}銆�"; ConsoleHelper.WriteSuccessLine(log); _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" }); @@ -539,7 +540,7 @@ //var deviceCode = device.Select(x => x.DeviceCode).ToList(); List<string> strings = platform.Location.Split(',').ToList(); - var result = await HttpHelper.PostAsync(wmsIpAddress, new { Position = childDeviceCode, Tag = (int)taskType, AreaCdoe = platform.Stacker, AreaCdoes = strings, platform.ProductionLine }.ToJsonString()); + 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()); WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); @@ -583,7 +584,7 @@ { if (command.ConveyorLineBarcode == taskCommand.ConveyorLineBarcode && command.ConveyorLineTaskNum == taskCommand.ConveyorLineTaskNum && command.ConveyorLineTargetAddress == taskCommand.ConveyorLineTargetAddress) { - WriteInfo(conveyorLine.DeviceName, $"鍐欏叆浠诲姟鎴愬姛鍐欏叆娆℃暟{i}鍐欏叆浠诲姟銆恵JsonConvert.SerializeObject(taskCommand)}銆�"); + WriteInfo(conveyorLine.DeviceName, $"鏃堕棿锛氥�恵DateTime.Now}銆戝啓鍏ヤ换鍔℃垚鍔熷啓鍏ユ鏁皗i}鍐欏叆浠诲姟銆恵JsonConvert.SerializeObject(taskCommand)}銆�"); return true; } if (command.ConveyorLineTargetAddress != taskCommand.ConveyorLineTargetAddress) @@ -603,7 +604,7 @@ } } - WriteInfo(conveyorLine.DeviceName, $"鍐欏叆浠诲姟澶辫触浠诲姟鍙枫�恵taskCommand.ConveyorLineTaskNum}銆戞墭鐩樺彿銆恵taskCommand.ConveyorLineBarcode}銆戠洰鏍囧湴鍧�銆恵taskCommand.ConveyorLineTargetAddress}銆戝綋鍓嶈妭鐐广�恵childDeviceCode}銆�"); + WriteInfo(conveyorLine.DeviceName, $"鏃堕棿锛氥�恵DateTime.Now}銆戝啓鍏ヤ换鍔″け璐ヤ换鍔″彿銆恵taskCommand.ConveyorLineTaskNum}銆戞墭鐩樺彿銆恵taskCommand.ConveyorLineBarcode}銆戠洰鏍囧湴鍧�銆恵taskCommand.ConveyorLineTargetAddress}銆戝綋鍓嶈妭鐐广�恵childDeviceCode}銆�"); return false; } } -- Gitblit v1.9.3