称重优化日志

This commit is contained in:
2024-06-21 10:00:24 +08:00
parent f40e3c8b61
commit 05d38cbb2e
2 changed files with 11 additions and 4 deletions

View File

@@ -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}");
}
}

View File

@@ -99,9 +99,12 @@ namespace Tnb.Common.Utils
return respJson;
}
public static async Task<string> GetRequestAsync(string url, Dictionary<string, string> pars = null)
public static async Task<string> GetRequestAsync(string url, Dictionary<string, string> pars = null,bool isLog = true)
{
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();
if (isLog)
{
Log.Information($"请求 {url} 结果: {result}");
}
return result;
}