From 4b43452bbdcae2dadc4543d0a4c836c2b89440fd Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期日, 20 七月 2025 22:33:58 +0800
Subject: [PATCH] 增强日志记录和简化代码实现
---
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs | 29 +++++++++++------------------
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs | 2 +-
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs | 17 +++++++++++------
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs | 9 +++++++--
4 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
index 15cf98b..33c3745 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
@@ -399,23 +399,28 @@
var wmsIpAddrss = wmsBase + requestTask;
var result = await HttpHelper.PostAsync(wmsIpAddrss, new { Position = stationManager.stationChildCode }.ToJsonString());
+
+ QuartzLogger.WriteLogToFile($"鍖呰鍑哄簱", $"杩斿洖鍙傛暟銆恵JsonConvert.SerializeObject(result)}銆憑Environment.NewLine}{Environment.NewLine}");
+
+
content = JsonConvert.DeserializeObject<WebResponseContent>(result);
if (!content.Status)
{
//鏃犳弧瓒虫潯浠跺彲鍑哄簱鑷冲寘瑁呯殑搴撳瓨
+ ConsoleHelper.WriteErrorLine(JsonConvert.SerializeObject(content));
+ QuartzLogger.WriteLogToFile($"鍖呰鍑哄簱", $"杩斿洖鍙傛暟銆恵JsonConvert.SerializeObject(content)}銆憑Environment.NewLine}{Environment.NewLine}");
return content;
}
var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
ConsoleHelper.WriteSuccessLine(content.Data.ToString());
+
+ QuartzLogger.WriteLogToFile($"鍖呰鍑哄簱", $"杩斿洖鍙傛暟銆恵JsonConvert.SerializeObject(task)}銆憑Environment.NewLine}{Environment.NewLine}");
//_taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO })鈥�
content = ReceiveWMSTask(new List<WMSTaskDTO> { task });
- //content = ReceiveByBZOtuTask(task);
- //if (content.Status)
- //{
- // //鐩稿簲鐨勫湪閫旀暟鎹�+1
- // // _taskNeedBarcodeRepository.UpdateData();
- //}
+
+ QuartzLogger.WriteLogToFile($"鍖呰鍑哄簱", $"杩斿洖鍙傛暟銆恵JsonConvert.SerializeObject(content)}銆憑Environment.NewLine}{Environment.NewLine}");
+ ConsoleHelper.WriteErrorLine(JsonConvert.SerializeObject(content));
return content;
}
catch (Exception ex)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs
index f91b37d..c6e503c 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicRepository/Location/LocationStatusChangeRecordRepository.cs
@@ -39,26 +39,19 @@
/// <exception cref="Exception"></exception>
public void AddLocationStatusChangeRecord(DtLocationInfo locationInfo, int lastStatus, int changeType, int? taskNum)
{
- try
+ DtLocationStatusChangeRecord locationStatusChangeRecord = new DtLocationStatusChangeRecord()
{
- DtLocationStatusChangeRecord locationStatusChangeRecord = new DtLocationStatusChangeRecord()
- {
- AfterStatus = locationInfo.LocationStatus,
- BeforeStatus = lastStatus,
- ChangeType = changeType,
- LocationCode = locationInfo.LocationCode,
- LocationId = locationInfo.Id,
- TaskNum = taskNum,
- Creater = "System",
- CreateDate = DateTime.Now,
- };
+ AfterStatus = locationInfo.LocationStatus,
+ BeforeStatus = lastStatus,
+ ChangeType = changeType,
+ LocationCode = locationInfo.LocationCode,
+ LocationId = locationInfo.Id,
+ TaskNum = taskNum,
+ Creater = "System",
+ CreateDate = DateTime.Now,
+ };
+ base.AddData(locationStatusChangeRecord);
- base.AddData(locationStatusChangeRecord);
- }
- catch (Exception ex)
- {
- throw new Exception($"{ex.Message}");
- }
}
public void AddLocationStatusChangeRecord(List<DtLocationInfo> locationInfos, int newStatus, int changeType, List<int>? taskNums)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
index 22294eb..cc0a1e0 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -1,5 +1,6 @@
锘縰sing Mapster;
using Masuit.Tools;
+using SixLabors.Fonts.Tables.AdvancedTypographic;
using SqlSugar;
using WIDESEA_Common.CustomModels;
using WIDESEA_Core.Const;
@@ -1076,6 +1077,7 @@
WebResponseContent content = new WebResponseContent();
try
{
+ LogFactory.GetLog($"鍖呰璇锋眰鍑哄簱浠诲姟").Info(true, $"銆愯姹傚弬鏁般�戯細銆恵JsonConvert.SerializeObject(json)}銆憑Environment.NewLine}{Environment.NewLine}");
Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position && x.stationType == 12 && x.stationArea == "Call");
if (station == null) { throw new Exception($"鏈壘鍒板寘瑁呯珯鍙颁俊鎭紝璇锋鏌ヤ紶鍏ュ弬鏁皗json.Position}"); }
@@ -1148,12 +1150,11 @@
SourceAddress = stockInfo.LocationCode,
TaskState = (int)TaskOutStatusEnum.OutNew,
TaskType = (int)TaskOutboundTypeEnum.Outbound,
- TaskNum = await BaseDal.GetTaskNo(),
+ TaskNum = BaseDal.GetTaskNo().Result,
Creater = "System",
ProductionLine = stockInfo.ProductionLine,
ProcessCode = stockInfo.ProcessCode,
};
-
WMSTaskDTO taskDTO = CreateTaskDTO(task);
int lastStatus = locationInfo.LocationStatus;
@@ -1166,11 +1167,15 @@
_locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(stockInfo.LocationInfo, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);
+ LogFactory.GetLog($"鍖呰璇锋眰鍑哄簱浠诲姟").Info(true, $"銆愯繑鍥炲弬鏁般�戯細銆恵JsonConvert.SerializeObject(taskDTO)}銆憑Environment.NewLine}{Environment.NewLine}");
return content.OK(data: taskDTO);
}
catch (Exception ex)
{
Console.WriteLine($"CW3鑷冲寘瑁呭嚭搴撳紓甯�:{ex.ToString()}");
+
+ LogFactory.GetLog($"鍖呰璇锋眰鍑哄簱浠诲姟").Info(true, $"銆愬紓甯搞�戯細銆恵ex.Message}銆憑Environment.NewLine}銆恵ex.StackTrace}銆憑Environment.NewLine}{Environment.NewLine}");
+
return content.Error($"澶辫触锛歿ex.Message}");
}
}
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
index a510ec9..0b914fb 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/TaskController.cs
@@ -185,7 +185,7 @@
/// <param name="input">璇锋眰鏁版嵁</param>
/// <returns></returns>
[HttpPost, AllowAnonymous, Route("RequestOutTaskToBZAsync")]
- [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 5 })] // 5绉掕妭娴�
+ [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 11 })] // 5绉掕妭娴�
public async Task<WebResponseContent> RequestOutTaskToBZAsync([FromBody] RequestTaskDto input)
{
return await Service.RequestOutTaskToBZAsync(input);
--
Gitblit v1.9.3