Admin
5 小时以前 1cd9280bbecf557f8978ad3839f14827ff9f4d34
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using System;
using System.Collections.Generic;
using System.Text;
using WIDESEA_Common;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
 
namespace WIDESEA_Services
{
    public class WMSApi
    {
 
        /// <summary>
        /// 发送入库请求至WMS,请求下发入库任务
        /// </summary>
        /// <param name="barcode">托盘号</param>
        /// <returns></returns>
        public static WebResponseContent PostInboundRequstToWMS(string barcode)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                SaveModel saveModel = new SaveModel();
                saveModel.MainData = new Dictionary<string, object>();
                saveModel.MainData.Add("barcode", barcode);
                content = HttpHelper<SaveModel>.GetHttpRequestData(
                    saveModel, APIAddress.WmsIPAddress + APIAddress.PostInboundRequstToWMS);
                if (!content.Status)
                    throw new Exception($"入库申请调用失败:" + content.Message);
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
 
 
        /// <summary>
        /// 向WMS上报任务状态
        /// </summary>
        /// <param name="barcode">托盘号</param>
        /// <returns></returns>
        public static WebResponseContent PostTaskStateToWMS(string barcode,string taskState, string rgvId = null)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                SaveModel saveModel = new SaveModel();
                saveModel.MainData = new Dictionary<string, object>();
                saveModel.MainData.Add("barcode", barcode);
                saveModel.MainData.Add("taskState", taskState);
                if(rgvId != null)
                    saveModel.MainData.Add("rgvId", rgvId);
                else
                    saveModel.MainData.Add("rgvId", 0);
 
                content = HttpHelper<SaveModel>.GetHttpRequestData(
                    saveModel, APIAddress.WmsIPAddress + APIAddress.PostTaskStateToWMS);
                if (!content.Status)
                {
                    throw new Exception($"向WMS上报任务状态调用失败:" + content.Message);
                }
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
 
 
 
        /// <summary>
        /// 向WMS上报任务完成
        /// </summary>
        /// <param name="barcode">托盘号</param>
        /// <returns></returns>
        public static WebResponseContent TellWmsTaskFinished(string barcode,string rgvId = null)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                SaveModel saveModel = new SaveModel();
                saveModel.MainData = new Dictionary<string, object>();
                saveModel.MainData.Add("barcode", barcode);
                if(rgvId != null)
                    saveModel.MainData.Add("rgvId", rgvId);
                else
                    saveModel.MainData.Add("rgvId", "");
                content = HttpHelper<SaveModel>.GetHttpRequestData(
                    saveModel, APIAddress.WmsIPAddress + APIAddress.TellWmsTaskFinished);
                if (!content.Status)
                {
                    throw new Exception($"向WMS上报任务状态调用失败:" + content.Message);
                }
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
 
 
 
        /// <summary>
        /// 向WMS上报称重得到的结果以及对应的托盘号RFID
        /// </summary>
        /// <param name="barcode">托盘号</param>
        /// <param name="weight">重量</param>
        /// <returns></returns>
        public static WebResponseContent TellWmsWeightResult(string barcode,string weight)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                SaveModel saveModel = new SaveModel();
                saveModel.MainData = new Dictionary<string, object>();
                saveModel.MainData.Add("barcode", barcode);
                saveModel.MainData.Add("weight", weight);
                content = HttpHelper<SaveModel>.GetHttpRequestData(
                    saveModel, APIAddress.WmsIPAddress + APIAddress.TellWmsWeightResult);
                if (!content.Status)
                {
                    throw new Exception($"向WMS上报称重结果异常:" + content.Message);
                }
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
 
 
 
        /// <summary>
        /// 当托盘码校验不一致时,上报WMS,由WMS处理
        /// </summary>
        /// <param name="systemRFID">系统记录到的托盘码</param>
        /// <param name="lineRFID">线体站台读取到的托盘码</param>
        /// <param name="taskNumber">任务号</param>
        /// <param name="station">发生站台</param>
        /// <returns></returns>
        public static WebResponseContent PostRFIDNoMatch(string systemRFID,string lineRFID,string taskNumber,string station)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                SaveModel saveModel = new SaveModel();
                saveModel.MainData = new Dictionary<string, object>();
                saveModel.MainData.Add("systemRFID", systemRFID);
                saveModel.MainData.Add("lineRFID", lineRFID);
                saveModel.MainData.Add("taskNumber", taskNumber);
                saveModel.MainData.Add("station", station);
                content = HttpHelper<SaveModel>.GetHttpRequestData(
                    saveModel, APIAddress.WmsIPAddress + APIAddress.TellWmsRFIDNoMatch);
                if (!content.Status)
                {
                    throw new Exception($"当托盘码校验不一致时调用失败:" + content.Message);
                }
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
 
 
        /// <summary>
        /// 向WMS申请新的货位,当入库任务和测量出库任务冲突时
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static WebResponseContent RequstNewLocationIdWhenConflict(string barcode)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                SaveModel saveModel = new SaveModel();
                saveModel.MainData = new Dictionary<string, object>();
                saveModel.MainData.Add("barcode", barcode);
                content = HttpHelper<SaveModel>.GetHttpRequestData(
                    saveModel, APIAddress.WmsIPAddress + APIAddress.RequstNewLocationIdWhenConflict);
                if (!content.Status)
                {
                    throw new Exception($"当托盘码校验不一致时调用失败:" + content.Message);
                }
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
    }
}