using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WIDESEA_Common.APIEnum; using WIDESEA_Core.Helper; using WIDESEA_External.Model; using WIDESEA_IBasicRepository; using WIDESEA_Model.Models; namespace WIDESEA_External.MESService { /// /// 调用MES接口 /// public class InvokeMESService : IInvokeMESService { private readonly IApiInfoRepository _apiInfoRepository; public InvokeMESService(IApiInfoRepository apiInfoRepository) { _apiInfoRepository = apiInfoRepository; } // 创建一个使用小驼峰命名法的序列化设置 JsonSerializerSettings settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; /// /// MES配送出发通知 /// /// /// public string MESDispatchUp(MESDispatchModel mESDispatchModel) { Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.MESDispatchUp.ToString()); string response = HttpMesHelper.Post(apiInfo.ApiAddress, JsonConvert.SerializeObject(mESDispatchModel)); return response; } /// /// MES配送到达通知 /// /// /// public string MESDelivery(MESDeliveryModel mESDeliveryModel) { Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.MESDelivery.ToString()); string response = HttpMesHelper.Post(apiInfo.ApiAddress, JsonConvert.SerializeObject(mESDeliveryModel)); return response; } /// /// MES退料空托接收通知 /// /// /// public string MESRecepNotice(MESRecepNoticeModel mESRecepNoticeModel) { Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.MESRecepNotice.ToString()); string response = HttpMesHelper.Post(apiInfo.ApiAddress, JsonConvert.SerializeObject(mESRecepNoticeModel)); return response; } /// /// MES小车到达通知 /// /// /// public string MESAvgArriveNotice(MESAvgArriveNoticeModel mESAvgArriveNoticeModel) { Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.MESAvgArriveNotice.ToString()); string response = HttpMesHelper.Post(apiInfo.ApiAddress, JsonConvert.SerializeObject(mESAvgArriveNoticeModel)); return response; } /// /// MES产量回传 /// /// 成品箱码 /// public string MESBoxCodeNotice(string boxCode) { Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.MESBoxCodeNotice.ToString()); string response = HttpMesHelper.Post(apiInfo.ApiAddress+ "?boxCode="+boxCode); return response; } } }