Tjiny
2025-05-20 74938606dd1dd8d7d77f053492b987f96a867338
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using HH.WCS.Mobox3.Template.Entity.Dto;
using HH.WCS.Mobox3.Template.Util.Helper;
using Newtonsoft.Json;
 
namespace HH.WCS.Mobox3.Template.Controller.Service
{
    /// <summary>
    /// 第三方实现类
    /// </summary>
    public static class ThirdPartyService
    {
        /// <summary>
        /// Http帮助类
        /// </summary>
        private static readonly HttpHelper apiHelper = new HttpHelper();
        
        /// <summary>
        /// WMS任务创建
        /// </summary>
        /// <param name="baseUrl"></param>
        /// <param name="url"></param>
        /// <param name="model"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static bool CallWMSOperationCreate<T>(string baseUrl, string url, T model)
        {
            var request = JsonConvert.SerializeObject(model);
 
            var response = apiHelper.Post(baseUrl + url, request);
            
            if (!string.IsNullOrEmpty(response))
            {
                var dataResult = JsonConvert.DeserializeObject<ResultDto<object>>(response);
            
                if (dataResult.code == 0) 
                {
                    LogHelper.Info($"WMS任务创建:CallWMSOperationCreate接口调用成功,入参为{request},返回值为{response}","AMS和WCS接口交互");
                    return true;
                }
            }
            else 
            {
                LogHelper.Info($"WMS任务创建:CallWMSOperationCreate接口调用失败,入参为{request},返回值为{response}","AMS和WCS接口交互");
            }
            
            return false;
        } 
        
        /// <summary>
        /// 四向车任务创建
        /// </summary>
        /// <param name="baseUrl"></param>
        /// <param name="url"></param>
        /// <param name="model"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static bool CallCarOperationCreate<T>(string baseUrl, string url, T model)
        {
            var request = JsonConvert.SerializeObject(model);
 
            var response = apiHelper.Post(baseUrl + url, request);
            
            if (!string.IsNullOrEmpty(response))
            {
                var dataResult = JsonConvert.DeserializeObject<ResultDto<string>>(response);
            
                if (dataResult.code == 0) 
                {
                    LogHelper.Info($"四向车任务创建:CallCarOperationCreate接口调用成功,入参为{request},返回值为{response}","四向车和WCS接口交互");
                    return true;
                }
            }
            else 
            {
                LogHelper.Info($"四向车任务创建:CallCarOperationCreate接口调用失败,入参为{request},返回值为{response}","四向车和WCS接口交互");
            }
            
            return false;
        }
        
        /// <summary>
        /// 四向车任务取消/强制完成
        /// </summary>
        /// <param name="baseUrl"></param>
        /// <param name="url"></param>
        /// <param name="model"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static ResultDto<string> CallCarOperationCommon<T>(string baseUrl, string url, T model)
        {
            var result = new ResultDto<string>();
            result.code = -1;
            
            var request = JsonConvert.SerializeObject(model);
 
            var response = apiHelper.Post(baseUrl + url, request);
            
            if (!string.IsNullOrEmpty(response))
            {
                result = JsonConvert.DeserializeObject<ResultDto<string>>(response);
            
                if (result.code == 0) 
                {
                    LogHelper.Info($"四向车任务取消/强制完成:CallCarOperationCommon接口调用成功,入参为{request},返回值为{response}","四向车和WCS接口交互");
                }
            }
            else 
            {
                LogHelper.Info($"四向车任务取消/强制完成:CallCarOperationCommon接口调用失败,入参为{request},返回值为{response}","四向车和WCS接口交互");
            }
            
            return result;
        }
        
        /// <summary>
        /// 提升机任务
        /// </summary>
        /// <param name="baseUrl"></param>
        /// <param name="url"></param>
        /// <param name="model"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static ResultDto<string> CreateHoister<T>(string baseUrl, string url, T model)
        {
            var result = new ResultDto<string>();
            result.code = -1;
            
            var request = JsonConvert.SerializeObject(model);
 
            var response = apiHelper.Post(baseUrl + url, request);
            
            if (!string.IsNullOrEmpty(response))
            {
                result = JsonConvert.DeserializeObject<ResultDto<string>>(response);
            
                if (result.code == 0) 
                {
                    LogHelper.Info($"提升机任务:CreateHoister接口调用成功,入参为{request},返回值为{response}","四向车和WCS接口交互");
                }
            }
            else 
            {
                LogHelper.Info($"提升机任务:CreateHoister接口调用失败,入参为{request},返回值为{response}","四向车和WCS接口交互");
            }
            
            return result;
        }
    }
}