From 1164314b1f0183dadf760171e5a494eda53a1c95 Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期四, 09 一月 2025 19:59:56 +0800 Subject: [PATCH] 更新多个文件,增强请求处理和日志记录 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerStationCrane.cs | 12 ++-- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs | 29 +++++++++ Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs | 12 ++++ .gitignore | 2 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 4 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs | 12 ++-- Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs | 2 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs | 8 ++ Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs | 2 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs | 2 Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/HttpHelper.cs | 36 +++++++++++ Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/AgingOutputDto.cs | 2 12 files changed, 103 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 8f6d1e2..1e65336 100644 --- a/.gitignore +++ b/.gitignore @@ -1650,3 +1650,5 @@ /Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/obj/Debug/net6.0/WIDESEA_StorageTaskServices.csproj.CopyComplete /Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/obj/Debug/net6.0/WIDESEA_StoragIntegrationServices.csproj.CopyComplete /Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/obj/Debug/net6.0/WIDESEA_WMSServer.csproj.CopyComplete +/Code Management/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/copilot-chat/bef6627e/sessions/22de66c6-d93f-400b-aaa1-cc12e218c2e7 +/Code Management/WCS/WIDESEAWCS_Server/.vs/WIDESEAWCS_Server/copilot-chat/bef6627e/sessions/36708593-3f69-4656-815a-651b3ad17c7d diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/HttpHelper.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/HttpHelper.cs index d6982b4..5c5bace 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/HttpHelper.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Core/Helper/HttpHelper.cs @@ -1,4 +1,6 @@ -锘縰sing System; +锘縰sing AngleSharp.Dom; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Net.Http.Headers; @@ -37,10 +39,42 @@ return null; } + + // 鐢ㄤ簬杩借釜姣忎釜璇锋眰鐨勮皟鐢ㄦ鏁板拰鏈�鍚庤姹傛椂闂淬�� + private static readonly Dictionary<string, (int Count, DateTime LastRequestTime)> requestTracker = new(); + public static async Task<string> PostAsync(string serviceAddress, string requestJson = null, string contentType = "application/json", Dictionary<string, string>? headers = null) { try { + // 灏� JSON 瀛楃涓茶浆鎹负瀛楀吀 + var parameters = JsonConvert.DeserializeObject<Dictionary<string, object>>(requestJson); + + // 鍒涘缓涓�涓柊鐨勫瓧鍏革紝鎺掗櫎 RequestTime 鍜� SessionId + var filteredParameters = parameters.Where(p => p.Key != "RequestTime" && p.Key != "SessionId").ToDictionary(p => p.Key, p => p.Value); + + string requestKey = $"{serviceAddress}:{JsonConvert.SerializeObject(filteredParameters)}"; + + // 妫�鏌ヨ姹傛鏁板拰鏃堕棿闄愬埗 + if (requestTracker.TryGetValue(requestKey, out var requestInfo)) + { + if (requestInfo.Count >= 5 && DateTime.Now < requestInfo.LastRequestTime.AddMinutes(10)) + { + // 濡傛灉璇锋眰娆℃暟瓒呰繃闄愬埗涓旀湭瓒呰繃10鍒嗛挓锛屾姏鍑哄紓甯� + throw new InvalidOperationException("璇锋眰娆℃暟宸茶揪鍒伴檺鍒讹紝璇风◢鍚庡啀璇曘��"); + } + } + + // 鏇存柊璇锋眰璺熻釜淇℃伅 + if (requestTracker.ContainsKey(requestKey)) + { + requestTracker[requestKey] = (requestInfo.Count + 1, DateTime.Now); + } + else + { + requestTracker[requestKey] = (1, DateTime.Now); + } + string result = string.Empty; using (HttpContent httpContent = new StringContent(requestJson)) { diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs index 022cb6b..1d1a3ce 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs @@ -396,22 +396,22 @@ switch (typeCode) { case TypeCode.Boolean: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToBoolean(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToBoolean(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.Byte: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToByte(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToByte(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.Int16: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToInt16(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToInt16(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.Int32: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToInt32(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToInt32(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.UInt16: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToUInt16(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToUInt16(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.UInt32: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToUInt32(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToUInt32(deviceProtocolDetail.ProtocalDetailValue)); break; default: break; diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerStationCrane.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerStationCrane.cs index 4ddff26..b481134 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerStationCrane.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerStationCrane.cs @@ -396,22 +396,22 @@ switch (typeCode) { case TypeCode.Boolean: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToBoolean(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToBoolean(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.Byte: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToByte(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToByte(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.Int16: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToInt16(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToInt16(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.Int32: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToInt32(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToInt32(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.UInt16: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToUInt16(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToUInt16(deviceProtocolDetail.ProtocalDetailValue)); break; case TypeCode.UInt32: - operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1000, 20 * 6000, Convert.ToUInt32(deviceProtocolDetail.ProtocalDetailValue)); + operateResult = Communicator.Wait(devicePro.DeviceProAddress, 1500, 20 * 6000, Convert.ToUInt32(deviceProtocolDetail.ProtocalDetailValue)); break; default: break; 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 64ffdc4..4f85150 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 @@ -198,7 +198,7 @@ var task = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode); //HandleTaskOut(conveyorLine, command, childDeviceCode, task); // && command.ConveyorLineBarcode != "NoRead" && !command.ConveyorLineBarcode.IsNotEmptyOrNull() - ConsoleHelper.WriteSuccessLine($"銆恵conveyorLine.DeviceName}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戣澶囩紪鐮侊細銆恵childDeviceCode}銆�"); + ConsoleHelper.WriteSuccessLine($"銆恵conveyorLine.DeviceName}銆戞墭鐩樺彿锛氥�恵command.ConveyorLineBarcode}銆戜换鍔″彿锛氥�恵command.ConveyorLineTaskNum}銆戣澶囩紪鐮侊細銆恵childDeviceCode}銆�"); if (task == null) { HandleNewTask(conveyorLine, command, childDeviceCode); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs index 3a0a4af..4058397 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Common/HttpClient/HttpsClient.cs @@ -42,9 +42,36 @@ } } + // 鐢ㄤ簬杩借釜姣忎釜璇锋眰鐨勮皟鐢ㄦ鏁板拰鏈�鍚庤姹傛椂闂淬�� + private static readonly Dictionary<string, (int Count, DateTime LastRequestTime)> requestTracker = new(); // 灏佽涓�涓敤HttpClient鍙戦�丳ost璇锋眰鐨勬柟娉曟湁鍙傛暟 public static async Task<string> PostAsync(string url, Dictionary<string, object> parameters) { + // 鍒涘缓涓�涓柊鐨勫瓧鍏革紝鎺掗櫎 RequestTime 鍜� SessionId + var filteredParameters = parameters.Where(p => p.Key != "RequestTime"&& p.Key != "SessionId").ToDictionary(p => p.Key, p => p.Value); + + string requestKey = $"{url}:{JsonConvert.SerializeObject(filteredParameters)}"; + // 妫�鏌ヨ姹傛鏁板拰鏃堕棿闄愬埗 + if (requestTracker.TryGetValue(requestKey, out var requestInfo)) + { + if (requestInfo.Count >= 5 && DateTime.Now < requestInfo.LastRequestTime.AddMinutes(10)) + { + // 濡傛灉璇锋眰娆℃暟瓒呰繃闄愬埗涓旀湭瓒呰繃10鍒嗛挓锛屾姏鍑哄紓甯� + throw new InvalidOperationException("璇锋眰娆℃暟宸茶揪鍒伴檺鍒讹紝璇风◢鍚庡啀璇曘��"); + } + } + + // 鏇存柊璇锋眰璺熻釜淇℃伅 + if (requestTracker.ContainsKey(requestKey)) + { + requestTracker[requestKey] = (requestInfo.Count + 1, DateTime.Now); + } + else + { + requestTracker[requestKey] = (1, DateTime.Now); + } + + // 璁板綍璇锋眰鍙傛暟 LogRequestParameters(parameters, url); @@ -78,7 +105,7 @@ } } - private static void LogRequestParameters(Dictionary<string, object> parameters,string url = "") + private static void LogRequestParameters(Dictionary<string, object> parameters, string url = "") { StringBuilder builder = new StringBuilder(); builder.Append(Environment.NewLine); diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/AgingOutputDto.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/AgingOutputDto.cs index d4aeabe..f1a31af 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/AgingOutputDto.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/AgingOutputDto.cs @@ -66,7 +66,7 @@ /// <summary> /// 涓嬮檺 /// </summary> - public string LowerLomit { get; set; } + public string LowerLimit { get; set; } /// <summary> /// 鐩爣鍊� diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs index b9cdd63..ded2b2d 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/ProcessApply/IProcessApplyService.cs @@ -19,4 +19,12 @@ /// <param name="areaID">鍖哄煙涓婚敭</param> /// <returns></returns> Task<WebResponseContent> StockInDataBackfillInterfaceAsync(string palletCode, int areaID); + + /// <summary> + /// 琛ュ綍鍑哄簱鏁版嵁 + /// </summary> + /// <param name="palletCode">鎵樼洏鍙�</param> + /// <param name="areaID">鍖哄煙涓婚敭</param> + /// <returns></returns> + Task<WebResponseContent> StockOutDataBackfillInterfaceAsync(string palletCode, int areaID); } \ No newline at end of file diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs index a06a7b0..1941906 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/ProcessApply/ProcessApplyService.cs @@ -129,7 +129,7 @@ ParameterDesc = parameterInfo.Description, ParameterResult = "OK", //isNG.ToString(), TargetValue = parameterInfo.TargetValue, - LowerLomit = parameterInfo.LowerSpecificationsLimit, + LowerLimit = parameterInfo.LowerSpecificationsLimit, UpperLimit = parameterInfo.UpperSpecificationsLimit, DefectCode = defectCode, UOMCode = parameterInfo.UOMCode, diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs index 32c25c8..8b05bd5 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Location/LocationInfoService.cs @@ -182,7 +182,7 @@ { string[] chineseNumbers = new string[] { "闆�", "涓�", "浜�", "涓�", "鍥�", "浜�", "鍏�", "涓�", "鍏�", "涔�" }; var locationList = new List<DtLocationInfo>(); - for (int line = 3; line <= x; line++) + for (int line = 7; line <= x; line++) { for (int column = 1; column <= y; column++) { diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs index 78d25a5..88aa8f9 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs @@ -258,7 +258,7 @@ ParameterDesc = parameterInfo.Description, ParameterResult = "OK", //isNG.ToString(), TargetValue = parameterInfo.TargetValue, - LowerLomit = parameterInfo.LowerSpecificationsLimit, + LowerLimit = parameterInfo.LowerSpecificationsLimit, UpperLimit = parameterInfo.UpperSpecificationsLimit, DefectCode = defectCode, UOMCode = parameterInfo.UOMCode, @@ -2417,7 +2417,7 @@ ParameterDesc = parameterInfo.Description, ParameterResult = "OK", TargetValue = parameterInfo.TargetValue, - LowerLomit = parameterInfo.LowerSpecificationsLimit, + LowerLimit = parameterInfo.LowerSpecificationsLimit, UpperLimit = parameterInfo.UpperSpecificationsLimit, DefectCode = defectCode, } diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs index 4f42cf1..38d627d 100644 --- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs +++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/ProcessApplyController.cs @@ -37,4 +37,16 @@ { return await _processApplyService.StockInDataBackfillInterfaceAsync(palletCode, areaID); } + + /// <summary> + /// 琛ュ綍鍑哄簱鏁版嵁 + /// </summary> + /// <param name="palletCode">鎵樼洏鍙�</param> + /// <param name="areaID">鍖哄煙涓婚敭</param> + /// <returns></returns> + [HttpPost("StockOutDataBack")] + public async Task<WebResponseContent> StockOutDataBackfillInterfaceAsync(string palletCode, int areaID) + { + return await _processApplyService.StockOutDataBackfillInterfaceAsync(palletCode, areaID); + } } \ No newline at end of file -- Gitblit v1.9.3