wangxinhui
2024-12-23 942e47f8987bd8c266e58863bed3895d9cb4ded0
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
98
99
100
101
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.ERPService
{
    /// <summary>
    /// 调用ERP接口
    /// </summary>
    public class InvokeERPService : IInvokeERPService
    {
        private readonly IApiInfoRepository _apiInfoRepository;
        public InvokeERPService(IApiInfoRepository apiInfoRepository)
        {
            _apiInfoRepository= apiInfoRepository;
        }
        /// <summary>
        /// ERP收货单接口调用
        /// </summary>
        /// <param name="receiveModel"></param>
        /// <returns></returns>
        public string InvokeMatReceiveApi(ERPReceiveModel receiveModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x=>x.ApiCode==APIEnum.InvokeMatReceiveApi.ToString());
            ERPBaseModel<ERPReceiveModel> model = new ERPBaseModel<ERPReceiveModel>()
            {
                Data = receiveModel,
                Desc = "收货单",
                Type = "toTCWMSReceive",
                SecurityCode = ""
            };
            string response = HttpHelper.Post(apiInfo.ApiAddress, model.Serialize());
            return response;
        }
 
        /// <summary>
        /// ERP物料IQC检验单接口调用
        /// </summary>
        /// <param name="checkModel"></param>
        /// <returns></returns>
        public string InvokeCheckOrderApi(ERPCheckModel checkModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.InvokeCheckOrderApi.ToString());
            ERPBaseModel<ERPCheckModel> model = new ERPBaseModel<ERPCheckModel>()
            {
                Data = checkModel,
                Desc = "收货单",
                Type = "toTCWMSIQCTest",
                SecurityCode = ""
            };
 
            string response = HttpHelper.Post(apiInfo.ApiAddress, model.Serialize());
            return response;
        }
 
        /// <summary>
        /// ERP物料入库单接口调用
        /// </summary>
        /// <param name="inboundModel"></param>
        /// <returns></returns>
        public string InvokeInboundOrderApi(ERPInboundModel inboundModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.InvokeInboundOrderApi.ToString());
            ERPBaseModel<ERPInboundModel> model = new ERPBaseModel<ERPInboundModel>()
            {
                Data = inboundModel,
                Desc = "收货单",
                Type = "toTCWMSMaterialWarehousing",
                SecurityCode = ""
            };
 
            string response = HttpHelper.Post(apiInfo.ApiAddress, model.Serialize());
            return response;
        }
        /// <summary>
        /// ERP物料出库接口调用
        /// </summary>
        /// <param name="outboundModel"></param>
        /// <returns></returns>
        public string InvokeOutboundOrderApi(ERPOutboundModel outboundModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.InvokeOutboundOrderApi.ToString());
            ERPBaseModel<ERPOutboundModel> model = new ERPBaseModel<ERPOutboundModel>()
            {
                Data = outboundModel,
                Desc = "材料出库",
                Type = "toBomMaterialOutTC",
                SecurityCode = "LxkgPgN3$U"
            };
            string response = HttpHelper.Post(apiInfo.ApiAddress, model.Serialize());
            return response;
        }
    }
}