杨前锦
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
262
263
264
265
266
 
using HH.WCS.Mobox3.YNJT_PT.dispatch;
using HH.WCS.Mobox3.YNJT_PT.wms;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Web.Http;
using static HH.WCS.Mobox3.YNJT_PT.api.ApiHelper;
using static HH.WCS.Mobox3.YNJT_PT.api.ApiModel;
using static HH.WCS.Mobox3.YNJT_PT.util.ExcetionHelper;
 
namespace HH.WCS.Mobox3.YNJT_PT.api
{
    /// <summary>
    /// 第三方调用的接口
    /// </summary>
    [RoutePrefix("api")]
    public class WmsController : System.Web.Http.ApiController
    {
 
        /// <summary>
        /// 1.成型机下线记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseResult cxjOffLineRecord(OffLineModel model)
        {
            LogHelper.Info("【1.成型机下线记录】Request:" + JsonConvert.SerializeObject(model), "WMS");
            var result = ApiHelper.cxjOffLineRecord(model);
            LogHelper.Info("【1.成型机下线记录】response:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        /// <summary>
        /// 2.设备信号反馈
        /// 业务场景:WCS反馈成型机胚胎下线入库信号(注:必须两托一起上报,没有两托,则补充一个空托)
        /// 逻辑:
        /// 1.查询成型机下线记录表,判断RFID是否存在,状态是否OK,不存在或NG异常排出
        /// 2.查询物料条码信息表(green_tire_information),保存胚胎信息
        /// 3.开始计算终点,生成任务
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseResult notifyDeviceSignal(NotifyDeviceSignalModel model)
        {
            LogHelper.Info("【2.设备信号反馈】notifyDeviceSignal 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult responseResult = new ResponseResult();
            try
            {
                if (model.signalType == 1)
                {
                    responseResult = ApiHelper.offLineRequest(model);
                }
                else if(model.signalType == 3)
                {
                    responseResult = ApiHelper.readCodeRequest(model);
                }
            }
            catch (BusinessException be)
            {
                responseResult.code = 501;
                responseResult.msg = be.Message;
            }
            catch (Exception ex)
            {
                LogHelper.Info($"WMS内部错误,错误原因:{ex.Message}", "WMS");
                responseResult.code = 500;
                responseResult.msg = $"WMS内部错误,请联系开发人员处理";
            }
            LogHelper.Info("【2.设备信号反馈】notifyDeviceSignal 出参:" + JsonConvert.SerializeObject(responseResult), "WMS");
            return responseResult;
        }
 
        /// <summary>
        /// 3.硫化机呼叫胚胎出库
        /// 逻辑:
        /// 1.根据机台号查询【硫化机工单表】、【胚胎已完成的条码中间表】筛选当前班次的生产计划数量是否满足,当预计生产数量 = 实际数+在途数量 ,则停止叫料
        /// 2.查询机台号在【硫化机工单表】对应的物料编码,
        ///   开始计算(1.巷道不报警、2.物料状态OK、3.小于失效时间 大于等于生效时间 4.加急料先出、5.先入先出(生产时间))出库物料,生成任务
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseResult callItemOutStock(CallItemModel model ) 
        {
            LogHelper.Info("【3.硫化机呼叫胚胎出库】callItemOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult responseResult = new ResponseResult();
            responseResult = ApiHelper.callItemOutStock(model);
            LogHelper.Info("【3.硫化机呼叫胚胎出库】callItemOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS");
            return responseResult;
        }
 
        /// <summary>
        /// 4.空托回立库
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseResult emptyTrayInStock(EmptyTrayInStockModel model ) 
        {
            LogHelper.Info("【4.空托回立库】emptyTrayInStock 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult responseResult = new ResponseResult();
            responseResult = ApiHelper.emptyTrayInStock(model);
            LogHelper.Info("【4.空托回立库】emptyTrayInStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS");
            return responseResult;
        }
 
        /// <summary>
        /// 5.成型机呼叫空托
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseResult callEmptyTrayOutStock(CallEmptyTrayOutStockModel model)
        {
            LogHelper.Info("【5.成型机呼叫空托】callEmptyTrayOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult responseResult = new ResponseResult();
            responseResult = ApiHelper.callEmptyTrayOutStock(model);
            LogHelper.Info("【5.成型机呼叫空托】callEmptyTrayOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS");
            return responseResult;
        }
 
        /// <summary>
        /// 6.胎胚立库抽检出库、人工出库胎胚
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseResult embryoCheckOutStock(EmbryoCheckOutStockModel model)
        {
            LogHelper.Info("【6.胎胚立库抽检出库】embryoCheckOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult responseResult = new ResponseResult();
            responseResult = ApiHelper.embryoCheckOutStock(model);
            LogHelper.Info("【 6.胎胚立库抽检出库】embryoCheckOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS");
            return responseResult;
        }
 
        /// <summary>
        /// 7.异常回库流程
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseResult anomalyTrayInStock(AnomalyTrayInStockModel model) 
        {
            LogHelper.Info("【7.异常回库流程】embryoCheckOutStock 入参:" + JsonConvert.SerializeObject(model), "WMS");
            ResponseResult responseResult = new ResponseResult();
            responseResult = ApiHelper.anomalyTrayInStock(model);
            LogHelper.Info("【7.异常回库流程】embryoCheckOutStock 出参:" + JsonConvert.SerializeObject(responseResult), "WMS");
            return responseResult;
        }
 
        /// <summary>
        /// 8.WCS 任务状态反馈
        /// 业务场景:WCS在执行任务时,回报任务状态
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        /*[Route("notifyTaskStatus")]*/
        public ReturnResult notifyTaskStatus(TaskStatusFeedbackModel model)
        {
            LogHelper.Info("【8.WCS任务状态反馈】Request:" + JsonConvert.SerializeObject(model), "WMS");
            var result = ApiHelper.taskStatusFeedback(model);
            LogHelper.Info("【8.WCS任务状态反馈】response:" + JsonConvert.SerializeObject(result), "WMS");
            return result;
        }
 
        /// <summary>
        /// 任务状态反馈模型
        /// </summary>
        public class TaskStatusFeedbackModel
        {
            public string taskNo { get; set; } // 任务号
            public string subTaskNo { get; set; } // 子任务号
            public int status { get; set; } // 任务状态 1:开始/执行中;2:完成;3:准备取货;4:取货完成;5:准备卸货;6:卸货完成;7:异常取消;8:强制完成
            public string deviceNo { get; set; } // 设备号
            public string errCode { get; set; } // 异常代码  0.无异常 1.设备故障码、2.rfid校验失败、3.取货无货、4.放货有货
            public string loc { get; set; } // 当前货位
        }
 
        public class AnomalyTrayInStockModel 
        {
            public string reqId { get; set; }
            public string reqTime { get; set; }
            public string startLoc { get; set; }
            public string trayCode { get; set; } // 容器编码
        }
 
        public class EmbryoCheckOutStockModel 
        {
            public string reqId { get; set; }
            public string reqTime { get; set; }
            public string trayCode { get; set; } // 容器编码
        }
 
        public class CallEmptyTrayOutStockModel
        {
            public string reqId { get; set; }
            public string reqTime { get; set; }
            public string endLoc { get; set; } // 终点
        }
 
        public class EmptyTrayInStockModel 
        {
            public string reqId { get; set; }
            public string reqTime { get; set; }
            public string startLoc { get; set; } // 起点
            public string trayCode { get; set; } // 容器编码
        }
 
        public class CallItemModel 
        {
            public string reqId { get; set; }
            public string reqTime { get; set; }
            public string mcn { get; set; }
            public List<string> locCodes { get; set; }
        }
 
        public class NotifyDeviceSignalModel 
        {
            public string reqId { get; set; }
            public string reqTime { get; set; }
            public string loc { get; set; }
            public string taskNo { get; set; }
            public string cntrNo { get; set; }
            public int signalType { get; set; }
            public List<BarcodeModel> extData { get; set; }
            public string deviceNo { get; set; }
        }
 
        public class BarcodeModel 
        {
            public string rfid { get; set; }
            public string barcode { get; set; }
        }
 
        /*   /// <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;
           }*/
    }
}