wangxinhui
3 天以前 a0a0df2e824b6fe7e5a3c0afce78127fecf84fc9
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
102
103
104
105
106
107
108
109
110
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_Common.CommonEnum;
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;
        }
        // 创建一个使用小驼峰命名法的序列化设置
        JsonSerializerSettings settings = new JsonSerializerSettings
        {
            ContractResolver = new CamelCasePropertyNamesContractResolver()
        };
        /// <summary>
        /// 调用BST上报RFID接口
        /// </summary>
        public string BSTPurchaseUp(BSTPurchaseUpModel bSTPurchaseUpModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x=>x.ApiCode==APIEnum.BSTPurchaseUp.ToString());
            if (apiInfo.Enable == WhetherEnum.False.ObjToInt())
            {
                BSTResponse<object> bSTResponse = new BSTResponse<object>() { Code=200,Msg="接口禁用"};
                return bSTResponse.Serialize();
            }
            string request = JsonConvert.SerializeObject(bSTPurchaseUpModel, settings);
 
            string response = HttpHelper.Post(apiInfo.ApiAddress, request);
 
            return response;
        }
        /// <summary>
        /// 调用ERP原纸库存接口
        /// </summary>
        public string BSTStockAsync(string barCode)
        {
            
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.BSTStockAsync.ToString() && x.Enable == WhetherEnum.True.ObjToInt());
 
            string response = HttpHelper.Post(apiInfo.ApiAddress + "?barcode=" + barCode);
 
            return response;
        }
        /// <summary>
        /// ERP上传采购信息
        /// </summary>
        /// <returns></returns>
        public string ERPPurchaseUp(ERPPurchaseUpModel eRPPurchaseUpModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.ERPPurchaseUpModel.ToString() && x.Enable == WhetherEnum.True.ObjToInt());
 
            string response = HttpHelper.Post(apiInfo.ApiAddress, eRPPurchaseUpModel.Serialize().ToUpper());
 
            return response;
        }
        /// <summary>
        /// ERP成品销售出库上传信息
        /// </summary>
        /// <returns></returns>
        public string ERPProOutUp(ERPProOutUpModel eRPProOutUpModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.ERPProOutUp.ToString() && x.Enable == WhetherEnum.True.ObjToInt());
 
            string response = HttpHelper.Post(apiInfo.ApiAddress, eRPProOutUpModel.Serialize().ToUpper());
 
            return response;
        }
        /// <summary>
        /// ERP上传成品入库信息
        /// </summary>
        /// <returns></returns>
        public string ERPProInUp(ERPProInUpModel eRPProInUpModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.ERPProInUp.ToString() && x.Enable == WhetherEnum.True.ObjToInt());
 
            string response = HttpHelper.Post(apiInfo.ApiAddress, eRPProInUpModel.Serialize().ToUpper());
 
            return response;
        }
        /// <summary>
        /// ERP上传半成品入库信息
        /// </summary>
        /// <returns></returns>
        public string ERPSemiProInUp(ERPProInUpModel eRPProInUpModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.ERPSemiProInUp.ToString() && x.Enable == WhetherEnum.True.ObjToInt());
 
            string response = HttpHelper.Post(apiInfo.ApiAddress, eRPProInUpModel.Serialize().ToUpper());
 
            return response;
        }
    }
}