| | |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_DTO.Agv; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.APIEnum; |
| | |
| | | } |
| | | 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) |
| | | { |