liulijun
2025-11-24 9086b238cd9fbb9fbeae7cab11d59576cd9d2853
项目代码/WCS/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -18,7 +18,6 @@
using Newtonsoft.Json;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using WIDESEA_DTO.Agv;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.APIEnum;
@@ -524,24 +523,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鍦板潃");
                }
                string responseStr = HttpHelper.Post($"{address}/api/Mes/MESAvgArriveNotice", requestAGVArriveDTO.Serialize());
                return content.OK(responseStr);
            }
            catch (Exception ex)
                    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>
            {
                content = WebResponseContent.Instance.Error(ex.Message);
                        //姝e紡
                        { "LoginToken", LoginToken }
                    };
                    if (headers != null)
                    {
                        foreach (var header in headers)
                            httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
            }
            return content;
                    HttpResponseMessage responseMessage = httpClient.PostAsync(serviceAddress, httpContent).Result;
                    result = responseMessage.Content.ReadAsStringAsync().Result;
                }
                return result;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                Logger.Add(serviceAddress, requestJson == null ? "" : requestJson, result, beginDate);
            }
        }
        public WebResponseContent CPEmptyInbound(string palletCode,string SourceAddress)
        {