wangxinhui
2025-10-26 733c975cd8647f6d006736f1863bad731e32e6fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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;
        }
    }
}