From 5336bfc54525253a30f1f8238806d3a67f388e14 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期五, 21 十一月 2025 15:12:03 +0800
Subject: [PATCH] 优化接口,增加字段等
---
项目代码/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs | 51 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 41 insertions(+), 10 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
index 5ffc5eb..df327ec 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -18,6 +18,7 @@
using Newtonsoft.Json;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
+using System.Net.Http.Headers;
using WIDESEA_DTO.Agv;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.APIEnum;
@@ -484,24 +485,54 @@
}
return content;
}
- public WebResponseContent MESAvgArriveNotice(RequestAGVArriveDTO requestAGVArriveDTO)
+ /// <summary>
+ /// 鍒ゆ柇鍏佽鏀捐揣
+ /// </summary>
+ /// <returns></returns>
+ public string MESAvgArriveNotice(RequestAGVArriveDTO requestAGVArriveDTO)
{
- WebResponseContent content = new WebResponseContent();
+ Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.MESAvgArriveNotice.ToString());
+
+ string response = Post(apiInfo.ApiAddress, JsonConvert.SerializeObject(requestAGVArriveDTO));
+
+ return response;
+ }
+ public static string Post(string serviceAddress, string requestJson = "", string contentType = "application/json", Dictionary<string, string>? headers = null)
+ {
+ string result = string.Empty;
+ DateTime beginDate = DateTime.Now;
try
{
- string address = AppSettings.Get("WMSApiAddress");
- if (string.IsNullOrEmpty(address))
+ using (HttpContent httpContent = new StringContent(requestJson))
{
- return WebResponseContent.Instance.Error($"鏈壘鍒癢MSApi鍦板潃");
+ httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+
+ using HttpClient httpClient = new HttpClient();
+ httpClient.Timeout = new TimeSpan(0, 0, 30);
+ string LoginToken = AppSettings.Get("MESLoginToken");
+ headers = new Dictionary<string, string>
+ {
+ //姝e紡
+ { "LoginToken", LoginToken }
+ };
+ if (headers != null)
+ {
+ foreach (var header in headers)
+ httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
+ }
+ HttpResponseMessage responseMessage = httpClient.PostAsync(serviceAddress, httpContent).Result;
+ result = responseMessage.Content.ReadAsStringAsync().Result;
}
- string responseStr = HttpHelper.Post($"{address}/api/Mes/MESAvgArriveNotice", requestAGVArriveDTO.Serialize());
- return content.OK(responseStr);
+ return result;
}
- catch (Exception ex)
+ catch (Exception e)
{
- content = WebResponseContent.Instance.Error(ex.Message);
+ throw new Exception(e.Message);
}
- return content;
+ finally
+ {
+ Logger.Add(serviceAddress, requestJson == null ? "" : requestJson, result, beginDate);
+ }
}
public WebResponseContent CPEmptyInbound(string palletCode,string SourceAddress)
{
--
Gitblit v1.9.3