From 05d38cbb2e5b7a349b36f588fd18a1395c31719f Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 21 Jun 2024 10:00:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=B0=E9=87=8D=E4=BC=98=E5=8C=96=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs | 3 ++- common/Tnb.Common/Utils/HttpClientHelper.cs | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs b/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs index bf2133fa..26dff5dc 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs @@ -120,7 +120,8 @@ namespace Tnb.ProductionMgr Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand2)}"); for (int i = 0; i < 1; i++) { - await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2); + string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2,false); + Log.Information($"称重完成返回结果:{responseresult}"); } } diff --git a/common/Tnb.Common/Utils/HttpClientHelper.cs b/common/Tnb.Common/Utils/HttpClientHelper.cs index de1425df..a6a7753a 100644 --- a/common/Tnb.Common/Utils/HttpClientHelper.cs +++ b/common/Tnb.Common/Utils/HttpClientHelper.cs @@ -99,9 +99,12 @@ namespace Tnb.Common.Utils return respJson; } - public static async Task GetRequestAsync(string url, Dictionary pars = null) + public static async Task GetRequestAsync(string url, Dictionary pars = null,bool isLog = true) { - Log.Information($"开始请求 {url} 请求参数: {JsonConvert.SerializeObject(pars)}"); + if (isLog) + { + Log.Information($"开始请求 {url} 请求参数: {JsonConvert.SerializeObject(pars)}"); + } HttpClient Client = new HttpClient(); var reqUri = url; if (pars?.Count > 0) @@ -112,7 +115,10 @@ namespace Tnb.Common.Utils Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var respBody = await Client.GetAsync(reqUri); var result = await respBody.Content.ReadAsStringAsync(); - Log.Information($"请求 {url} 结果: {result}"); + if (isLog) + { + Log.Information($"请求 {url} 结果: {result}"); + } return result; }