杨前锦
2025-06-04 d44e3abf0d51cfea1ed7df510974d69458cf516d
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
 
using HH.WCS.Mobox3.FJJT.wms;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Web.Http;
using static HH.WCS.Mobox3.FJJT.api.ApiHelper;
using static HH.WCS.Mobox3.FJJT.api.ApiModel;
using static HH.WCS.Mobox3.FJJT.util.ExcetionHelper;
 
namespace HH.WCS.Mobox3.FJJT.api
{
    /// <summary>
    /// 第三方调用的接口
    /// </summary>
    /*[RoutePrefix("api")]*/
    public class WmsController : System.Web.Http.ApiController
    {
        /// <summary>
        /// 1.空工装出库
        /// 业务场景:
        /// 1.直连流程初始化,补充空工装
        /// 2.非直连流程,固定站台自动补充空工装
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
       /* [Route("emptyPalletOutStock")]*/
        public ResponseResult emptyPalletOutStock(OutStockModel model)
        {
            LogHelper.Info("emptyPalletOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult responseResult = new ResponseResult();
            try
            {
                responseResult = ApiHelper.emptyPalletOutStock(model);
            }
            catch (BusinessException be)
            {
                responseResult.code = 501;
                responseResult.msg = be.Message;
            }
            catch (Exception ex) 
            {
                responseResult.code = 500;
                responseResult.msg = $"WMS内部错误,请联系开发人员处理";
                WMSHelper.addAlarmRecord("系统错误", "高", $"WMS内部错误: 空工装出库错误,错误原因:{ex.Message}");
            }
            
            LogHelper.Info("emptyPalletOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS");
            return responseResult;
        }
 
       
        /// <summary>
        /// 2.设备信号反馈
        /// 业务场景:
        /// 1.下线请求,机台生产完成后,满料工装退出机台时,WCS下发下线请求满料入库
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        /*[Route("notifyDeviceSignal")]*/
        public ResponseResult notifyDeviceSignal(DeviceSignalFeedbackModel model) {
            LogHelper.Info("notifyDeviceSignal 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult responseResult = new ResponseResult();
            try
            {
                if (model.signalType == 1)  // 物料下线入库请求
                {
                    OffLineRequest request = new OffLineRequest() { loc = model.loc, cntrNo = model.cntrNo, jtNo = model.deviceNo };
                    responseResult = ApiHelper.offLineProcess(request);
                }
                else if (model.signalType == 3)  // 读码入库请求
                {
                    ReadCodeRequest request = new ReadCodeRequest() { loc = model.loc, cntrNo = model.cntrNo };
                    responseResult = ApiHelper.readCodeProcess(request);
                }
                else if (model.signalType == 5)  // 异常工装入库请求
                {
                    OffLineRequest request = new OffLineRequest() { loc = model.loc, cntrNo = model.cntrNo, jtNo = model.deviceNo };
                    responseResult = ApiHelper.offLineProcess(request);
                }
            }
            catch (BusinessException be)
            {
                responseResult.code = 501;
                responseResult.msg = be.Message;
            }
            catch (Exception ex)
            {
                responseResult.code = 500;
                responseResult.msg = $"WMS内部错误,请联系开发人员处理";
                WMSHelper.addAlarmRecord("系统错误", "高", $"WMS内部错误: 设备信号反馈错误,错误原因:{ex.Message}");
            }
            LogHelper.Info("notifyDeviceSignal 出参:" + JsonConvert.SerializeObject(responseResult), "WMS");
            return responseResult;
        }
 
        /// <summary>
        /// 3.任务状态反馈
        /// 业务场景:WCS在执行任务时,回报任务状态
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        /*[Route("notifyTaskStatus")]*/
        public ResponseResult notifyTaskStatus(TaskStatusFeedbackModel model) {
            LogHelper.Info("notifyTaskStatus 入参:" + JsonConvert.SerializeObject(model), "WMS");
            var result = ApiHelper.taskStatusFeedback(model);
            LogHelper.Info("notifyTaskStatus 出参:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        /// <summary>
        /// 3.申请终点
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
       /* [Route("applyDest")]*/
        public ResponseResult applyDest(ApplyDestinationModel model)
        {
            LogHelper.Info("applyDest 入参:" + JsonConvert.SerializeObject(model), "WMS");
            var result = ApiHelper.applyDest(model);
            LogHelper.Info("applyDest 出参:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        /// <summary>
        /// 4.获取托盘物料信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
       /* [Route("findTrayItemInfo")]*/
        public ResponseResult findTrayItemInfo(FindTrayItemInfoModel model)
        {
            LogHelper.Info("findTrayItemInfo 入参:" + JsonConvert.SerializeObject(model), "WMS");
            var result = ApiHelper.findTrayItemInfo(model);
            LogHelper.Info("findTrayItemInfo 出参:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        /// <summary>
        /// 5.设备报警上报
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
       /* [Route("notifyAlarm")]*/
        public ResponseResult notifyAlarm(DeviceAlertorFeedbackModel model)
        {
            LogHelper.Info("notifyAlarm 入参:" + JsonConvert.SerializeObject(model), "WMS");
            var result = ApiHelper.notifyAlarm(model);
            LogHelper.Info("notifyAlarm 出参:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        /// <summary>
        /// 5.解绑货位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
      /*  [Route("notifyAlarm")]*/
        public ResponseResult unBindingLoc(LocModel model)
        {
            LogHelper.Info("UnBindingLoc 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult result = new ResponseResult();
            LocationHelper.UnBindingLoc(model.locCode);
            LogHelper.Info("UnBindingLoc 出参:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        /// <summary>
        /// 6.绑定货位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        /*[Route("notifyAlarm")]*/
        public ResponseResult bindingLoc(LocCntrModel model)
        {
            LogHelper.Info("BindingLoc 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult result = new ResponseResult();
            LocationHelper.BindingLoc(model.locCode, new List<string>() { model.cntrCode });
            LogHelper.Info("BindingLoc 出参:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        /// <summary>
        /// 7.切换站台属性
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
       /* [Route("notifyAlarm")]*/
        public ResponseResult switchStationAttribute(SwitchStationAttributeModel model)
        {
            LogHelper.Info("switchStationAttribute 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult result = new ResponseResult();
            var bo = ApiHelper.switchStationAttribute(model);
            if (!bo) 
            {
                result.code = 201;
            }
            LogHelper.Info("switchStationAttribute 出参:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        /// <summary>
        /// 8.WCS反馈货位状态
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        /* [Route("notifyAlarm")]*/
        public ResponseResult locStateFeedBack(LocStateFeedBackModel model)
        {
            LogHelper.Info("locStateFeedBack 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult result = new ResponseResult();
            bool bo = ApiHelper.locStateFeedBack(model);
            if (!bo) 
            {
                result.code = 201;
            }
            LogHelper.Info("locStateFeedBack 出参:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        public class LocStateFeedBackModel 
        {
            public string reqId { get; set; }
            public string reqTime { get; set; }
            public string loc_code { get; set; } // 站台编码
            public string type { get; set; } // 请求类型 1 允许取货 2 允许放货
            public string req_no { get; set; } // 站台编码
        }
 
        public class SwitchStationAttributeModel
        {
            public string reqId { get; set; }
            public string reqTime { get; set; }
            public string locCode { get; set; } // 站台编码
            public string signalType { get; set; } // 1.agv上料模式 2.人工模式
        }
 
        public class LocCntrModel
        {
            public string locCode { get; set; }
            public string cntrCode { get; set; }
        }
 
        public class OutStockModel
        {
            public string endLocCode { get; set; }
            public string reqId { get; set; }
            public string reqTime { get; set; }
        }
    }
}