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
|
{
|
/// <summary>
|
/// 调用MES接口
|
/// </summary>
|
public class InvokeMESService : IInvokeMESService
|
{
|
private readonly IApiInfoRepository _apiInfoRepository;
|
public InvokeMESService(IApiInfoRepository apiInfoRepository)
|
{
|
_apiInfoRepository = apiInfoRepository;
|
}
|
// 创建一个使用小驼峰命名法的序列化设置
|
JsonSerializerSettings settings = new JsonSerializerSettings
|
{
|
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
};
|
/// <summary>
|
/// MES配送出发通知
|
/// </summary>
|
/// <param name="mESDispatchModel"></param>
|
/// <returns></returns>
|
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;
|
}
|
/// <summary>
|
/// MES配送到达通知
|
/// </summary>
|
/// <param name="mESDeliveryModel"></param>
|
/// <returns></returns>
|
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;
|
}
|
/// <summary>
|
/// MES退料空托接收通知
|
/// </summary>
|
/// <param name="mESRecepNoticeModel"></param>
|
/// <returns></returns>
|
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;
|
}
|
/// <summary>
|
/// MES小车到达通知
|
/// </summary>
|
/// <param name="mESAvgArriveNoticeModel"></param>
|
/// <returns></returns>
|
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;
|
}
|
/// <summary>
|
/// MES产量回传
|
/// </summary>
|
/// <param name="boxCode">成品箱码</param>
|
/// <returns></returns>
|
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;
|
}
|
}
|
}
|