Blame view

src/main/java/com/huaheng/api/mes/controller/MesController.java 19.2 KB
肖超群 authored
1
2
3
4
package com.huaheng.api.mes.controller;

import com.huaheng.api.mes.domain.*;
import com.huaheng.api.mes.service.MesService;
5
import com.huaheng.common.constant.QuantityConstant;
肖超群 authored
6
7
8
9
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
10
import com.huaheng.framework.web.domain.AjaxResultMES;
肖超群 authored
11
12
13
14
15
16
import com.huaheng.pc.task.taskHeader.service.WorkTaskService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
17
import java.util.HashMap;
肖超群 authored
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.List;

/**
 * @author 游杰
 */
@RestController
@RequestMapping("/API/WMS/v2")
public class MesController extends BaseController {

    @Resource
    private WorkTaskService workTaskService;
    @Resource
    private MesService mesService;

    /**
     * 生成空托盘入库任务
周峰 authored
34
     * 7 料点呼叫移走空容器
肖超群 authored
35
36
37
38
     * @return
     */
    @PostMapping("/receiptEmptyContainer")
    @ApiOperation("生成空托盘入库任务")
周峰 authored
39
    @ApiLogger(apiName = "7 生成空托盘入库任务", from = "MES")
肖超群 authored
40
    @ResponseBody
41
    public AjaxResult receiptEmptyContainer(@RequestBody MesEmptyContainer mesEmptyContainer) {
42
        String containerTypeCode = mesEmptyContainer.getContainerTypeCode();
43
        String taskNo = mesEmptyContainer.getTaskNo();
44
        String orderCode = mesEmptyContainer.getOrderCode();
45
46
        String toPort = mesEmptyContainer.getToPort();
        String containerCode = mesEmptyContainer.getContainerCode();
47
48
        String vehicleTypeCode = mesEmptyContainer.getVehicleTypeCode();
        String vehicleCode = mesEmptyContainer.getVehicleCode();
49
50
51
        if (StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("containerCode 为空");
        }
52
53
54
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
        }
55
56
        if (StringUtils.isEmpty(containerTypeCode)) {
            return AjaxResult.error("containerTypeCode 为空");
57
58
59
60
61
62
63
        }
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(toPort)) {
            return AjaxResult.error("toPort 为空");
        }
64
65
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
66
        }
67
68
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
69
        }
pengyongcheng authored
70
71
        return handleMultiProcess(() -> workTaskService.createEmptyIn(
                taskNo, toPort, orderCode, containerCode, vehicleTypeCode, vehicleCode, null));
肖超群 authored
72
73
74
    }

    /**
周峰 authored
75
     * 5 MES下发空托盘出库
76
     *
肖超群 authored
77
78
79
80
     * @return
     */
    @PostMapping("/shipmentEmptyContainer")
    @ApiOperation("MES下发空托盘出库")
周峰 authored
81
    @ApiLogger(apiName = "5 MES下发空托盘出库", from = "MES")
肖超群 authored
82
83
    public AjaxResult shipmentEmptyContainer(@RequestBody MesEmptyContainer mesEmptyContainer) {
        String taskNo = mesEmptyContainer.getTaskNo();
84
        String orderCode = mesEmptyContainer.getOrderCode();
肖超群 authored
85
        String toPort = mesEmptyContainer.getToPort();
86
        String containerTypeCode = mesEmptyContainer.getContainerTypeCode();
87
88
        String vehicleTypeCode = mesEmptyContainer.getVehicleTypeCode();
        if (StringUtils.isEmpty(containerTypeCode)) {
89
            return AjaxResult.error("containerTypeCode 为空");
肖超群 authored
90
        }
91
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
92
93
            return AjaxResult.error("taskNo 为空");
        }
94
        if (StringUtils.isEmpty(toPort)) {
肖超群 authored
95
96
            return AjaxResult.error("toPort 为空");
        }
97
98
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
肖超群 authored
99
        }
100
101
102
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
        }
pengyongcheng authored
103
104
        return handleMultiProcess(() -> workTaskService.shipmentEmptyContainer(
                taskNo, orderCode, toPort, containerTypeCode, vehicleTypeCode));
肖超群 authored
105
106
107
    }

    /**
周峰 authored
108
     * 1 MES查询库存
109
     *
肖超群 authored
110
111
112
113
     * @return
     */
    @PostMapping("/searchInventory")
    @ApiOperation("MES查询库存")
周峰 authored
114
    @ApiLogger(apiName = "1 MES查询库存", from = "MES")
115
    public AjaxResultMES searchInventory(@RequestBody MesSearch mesSearch) {
yuxiao authored
116
        String taskNo = mesSearch.getTaskNo();
117
        List<MaterialDataQuery> list = mesSearch.getMaterialDataList();
118
        if (StringUtils.isEmpty(taskNo)) {
119
            return AjaxResultMES.error("taskNo 为空");
yuxiao authored
120
        }
yuxiao authored
121
        if (StringUtils.isEmpty(list)) {
122
            return AjaxResultMES.error("materialDataList 为空");
肖超群 authored
123
        }
124
125
        try {
            return mesService.searchInventory(mesSearch);
126
        } catch (Exception e) {
127
128
            return AjaxResultMES.error(e.getMessage());
        }
129
    }
肖超群 authored
130
131
    /**
周峰 authored
132
     * 2 MES主工单下发
133
     *
134
135
136
137
     * @return
     */
    @PostMapping("/workOrder")
    @ApiOperation("MES主工单下发")
周峰 authored
138
    @ApiLogger(apiName = "2 MES主工单下发", from = "MES")
周峰 authored
139
    public synchronized AjaxResult workOrder(@RequestBody MesWorkOrder workOrder) {
140
        if (StringUtils.isEmpty(workOrder.getTaskNo())) {
141
142
            return AjaxResult.error("taskNo 为空");
        }
143
        if (StringUtils.isEmpty(workOrder.getOrderCode())) {
144
145
            return AjaxResult.error("orderCode 为空");
        }
146
        if (workOrder.getOrderStatus() == null) {
147
148
            return AjaxResult.error("orderStatus 为空");
        }
149
        if (StringUtils.isEmpty(workOrder.getProductCode())) {
150
151
            return AjaxResult.error("productCode 为空");
        }
152
        if (workOrder.getProductQty() == null) {
153
154
            return AjaxResult.error("productQty 为空");
        }
155
        if (StringUtils.isEmpty(workOrder.getPlanStartTime())) {
156
157
            return AjaxResult.error("planStartTime 为空");
        }
158
        if (StringUtils.isEmpty(workOrder.getPlanEndTime())) {
159
160
            return AjaxResult.error("planEndTime 为空");
        }
161
        if (StringUtils.isEmpty(workOrder.getMaterialDataList()) || workOrder.getMaterialDataList().isEmpty()) {
162
            return AjaxResult.error("materialDataList 为空");
163
        }
164
        return mesService.workOrder(workOrder);
肖超群 authored
165
166
167
    }

    /**
168
     * MES工单入库单(弃用)
169
     *  已经取消该接口 9
肖超群 authored
170
171
     * @return
     */
172
173

    @Deprecated
肖超群 authored
174
175
    @PostMapping("/receiptOrder")
    @ApiOperation("MES工单入库单")
176
    @ApiLogger(apiName = "MES工单入库单", from = "MES")
肖超群 authored
177
    public AjaxResult receiptOrder(@RequestBody MesOrder mesOrder) {
178
        String orderCode = mesOrder.getOrderCode();
肖超群 authored
179
        String taskNo = mesOrder.getTaskNo();
180
        List<MesOrderMaterial> list = mesOrder.getMaterialDataList();
181
        if (StringUtils.isEmpty(orderCode)) {
肖超群 authored
182
183
            return AjaxResult.error("orderCode 为空");
        }
184
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
185
186
            return AjaxResult.error("taskNo 为空");
        }
187
        if (StringUtils.isEmpty(mesOrder.getChidOrderCode())) {
188
189
            return AjaxResult.error("chidOrderCode 为空");
        }
190
        if (mesOrder.getOrderStatus() == null) {
191
192
            return AjaxResult.error("orderStatus 为空");
        }
193
        if (StringUtils.isEmpty(mesOrder.getReceiptReferCode())) {
194
195
            return AjaxResult.error("receiptReferCode 为空");
        }
pengyongcheng authored
196
        if (StringUtils.isEmpty(list) || list.isEmpty()) {
197
            return AjaxResult.error("materialDataList 为空");
肖超群 authored
198
        }
pengyongcheng authored
199
        return handleMultiProcess(() -> mesService.receiptOrder(mesOrder));
肖超群 authored
200
201
202
    }

    /**
周峰 authored
203
     * 3 MES工单领料单出库单
204
     *
肖超群 authored
205
206
207
     * @return
     */
    @PostMapping("/shipmentOrder")
yuxiao authored
208
    @ApiOperation("MES工单领料单出库单")
周峰 authored
209
    @ApiLogger(apiName = "3 MES工单领料单出库单", from = "MES")
210
211
    public AjaxResult shipmentOrder(@RequestBody MesShipmentOrder mesOrder) {
        String orderCode = mesOrder.getOrderCode();
肖超群 authored
212
213
        String taskNo = mesOrder.getTaskNo();
        BigDecimal orderQty = mesOrder.getOrderQty();
214
        if (StringUtils.isEmpty(orderCode)) {
肖超群 authored
215
216
            return AjaxResult.error("orderCode 为空");
        }
217
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
218
219
            return AjaxResult.error("taskNo 为空");
        }
220
        if (StringUtils.isEmpty(mesOrder.getChidOrderCode())) {
周鸿 authored
221
            return AjaxResult.error("childOrderCode 为空");
222
223
224
225
        }
        if (StringUtils.isEmpty(mesOrder.getProductCode())) {
            return AjaxResult.error("productCode 为空");
        }
226
        if (StringUtils.isNull(mesOrder.getShipmentReferStatus())) {
227
228
            return AjaxResult.error("shipmentReferStatus 为空");
        }
229
230
231
        if (StringUtils.isEmpty(mesOrder.getShipmentReferCode())) {
            return AjaxResult.error("shipmentReferCode 为空");
        }
232
        if (orderQty == null) {
肖超群 authored
233
234
            return AjaxResult.error("orderQty 为空");
        }
周鸿 authored
235
        if (StringUtils.isEmpty(mesOrder.getMaterialDataList())) {
236
            return AjaxResult.error("materialDataList 为空");
237
        }
pengyongcheng authored
238
        return handleMultiProcess(() -> mesService.shipmentOrder(mesOrder));
肖超群 authored
239
240
241
242
    }

    /**
     * MES成品出库
243
     *
肖超群 authored
244
245
246
247
     * @return
     */
    @PostMapping("/shipmentProduct")
    @ApiOperation("MES成品出库")
248
    @ApiLogger(apiName = "MES成品出库", from = "MES")
249
    public AjaxResult shipmentProduct(@RequestBody MesShipmentProduct mesShipmentProduct) {
肖超群 authored
250
        String containerCode = mesShipmentProduct.getContainerCode();
251
        String starPort = mesShipmentProduct.getStartPort();
252
        String endPort = mesShipmentProduct.getEndPort();
肖超群 authored
253
        String taskNo = mesShipmentProduct.getTaskNo();
254
255
        String vehicleCode = mesShipmentProduct.getVehicleCode();
        String orderCode = mesShipmentProduct.getOrderCode();
256
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
257
258
            return AjaxResult.error("containerCode 为空");
        }
259
        if (StringUtils.isEmpty(starPort)) {
260
            return AjaxResult.error("startPort 为空");
肖超群 authored
261
        }
262
263
        if (StringUtils.isEmpty(endPort)) {
            return AjaxResult.error("endPort 为空");
肖超群 authored
264
        }
265
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
266
267
            return AjaxResult.error("taskNo 为空");
        }
268
269
270
271
272
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
273
        }
pengyongcheng authored
274
        return handleMultiProcess(() -> mesService.shipmentProduct(mesShipmentProduct));
肖超群 authored
275
276
277
278
    }

    /**
     * MES物料入库
279
     *  6 料点呼叫移走物料
肖超群 authored
280
281
282
283
     * @return
     */
    @PostMapping("/receipt")
    @ApiOperation("MES物料入库")
周峰 authored
284
    @ApiLogger(apiName = "6 MES物料入库", from = "MES")
肖超群 authored
285
286
    public AjaxResult receipt(@RequestBody MesReceipt mesReceipt) {
        String taskNo = mesReceipt.getTaskNo();
周峰 authored
287
288
        //设置入库单类型为半成品入库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_SEMI);
289
        String orderCode = mesReceipt.getOrderCode();
290
        String containerType = mesReceipt.getContainerTypeCode();
肖超群 authored
291
292
        String containerCode = mesReceipt.getContainerCode();
        String toPort = mesReceipt.getToPort();
293
294
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
295
        List<MaterialData> materialDataList = mesReceipt.getMaterialDataList();
肖超群 authored
296
297
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
298
299
            return AjaxResult.error("taskNo 为空");
        }
300
301
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
肖超群 authored
302
        }
303
304
        if (StringUtils.isEmpty(containerType)) {
            return AjaxResult.error("containerType 为空");
肖超群 authored
305
        }
306
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
307
308
            return AjaxResult.error("containerCode 为空");
        }
309
        if (StringUtils.isEmpty(toPort)) {
肖超群 authored
310
311
            return AjaxResult.error("toPort 为空");
        }
312
313
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
肖超群 authored
314
        }
315
316
317
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
        }
318
319
        if (StringUtils.isEmpty(materialDataList)) {
            return AjaxResult.error("materialDataList 为空");
320
        }
pengyongcheng authored
321
        return handleMultiProcess(() -> mesService.receipt(mesReceipt));
322
323
324
    }

    /**
周峰 authored
325
     * 10余料回库
326
327
328
329
     *
     * @return
     */
    @PostMapping("/rawReceipt")
330
    @ApiOperation("余料回库")
周峰 authored
331
    @ApiLogger(apiName = "10 余料回库", from = "MES")
332
333
    public AjaxResult rawReceipt(@RequestBody MesReceipt mesReceipt) {
        String taskNo = mesReceipt.getTaskNo();
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398

        if(StringUtils.isEmpty(mesReceipt.getReceiptType())){
            //mes调用接口时,代表入库单类型为余料退库
            mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_BACK);
        }

        String containerType = mesReceipt.getContainerTypeCode();
        String containerCode = mesReceipt.getContainerCode();
        String toPort = mesReceipt.getToPort();
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
        List<MaterialData> materialData = mesReceipt.getMaterialDataList();
        HashMap<String, String> quTest = new HashMap<>();
        for (MaterialData data : mesReceipt.getMaterialDataList()) {
            if (data.getLocationNoX() == -1 || data.getLocationNoY() == -1) {
                return AjaxResult.error("请填写xy信息");
            }
            String key = data.getLocationNoX() + "  " + data.getLocationNoY();
            if (quTest.get(key) == null) {
                quTest.put(key, key);
            } else {
                return AjaxResult.error("坐标重复: " + key);
            }
        }

        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(containerType)) {
            return AjaxResult.error("containerType 为空");
        }
        if (StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("containerCode 为空");
        }
        if (StringUtils.isEmpty(toPort)) {
            return AjaxResult.error("toPort 为空");
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
        }
        if (StringUtils.isEmpty(materialData)) {
            return AjaxResult.error("materialData 为空");
        }
        return handleMultiProcess(() -> mesService.receipt(mesReceipt));
    }

    /**
     * 原材料入库
     *
     * @return
     */
    @PostMapping("/wmsReceipt")
    @ApiOperation("原材料入库")
    @ApiLogger(apiName = "原材料入库", from = "wms-pc")
    public AjaxResult wmsReceipt(@RequestBody MesReceipt mesReceipt) {
        String taskNo = mesReceipt.getTaskNo();

        if(StringUtils.isEmpty(mesReceipt.getReceiptType())){
            //wms调用接口时,代表入库单类型为原材料入库
            mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_RAW);
        }
399
        String containerType = mesReceipt.getContainerTypeCode();
400
401
402
403
        String containerCode = mesReceipt.getContainerCode();
        String toPort = mesReceipt.getToPort();
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
404
        List<MaterialData> materialData = mesReceipt.getMaterialDataList();
405
        HashMap<String, String> quTest = new HashMap<>();
406
407
        for (MaterialData data : mesReceipt.getMaterialDataList()) {
            if (data.getLocationNoX() == -1 || data.getLocationNoY() == -1) {
408
409
                return AjaxResult.error("请填写xy信息");
            }
pengyongcheng authored
410
            String key = data.getLocationNoX() + "  " + data.getLocationNoY();
411
            if (quTest.get(key) == null) {
412
                quTest.put(key, key);
413
            } else {
414
415
416
417
                return AjaxResult.error("坐标重复: " + key);
            }
        }
418
419
420
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
421
422
        if (StringUtils.isEmpty(containerType)) {
            return AjaxResult.error("containerType 为空");
423
424
425
426
427
428
429
430
431
432
433
434
        }
        if (StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("containerCode 为空");
        }
        if (StringUtils.isEmpty(toPort)) {
            return AjaxResult.error("toPort 为空");
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
肖超群 authored
435
        }
周鸿 authored
436
        if (StringUtils.isEmpty(materialData)) {
肖超群 authored
437
438
            return AjaxResult.error("materialData 为空");
        }
439
440
441
        if (StringUtils.isEmpty(materialData)) {
            return AjaxResult.error("materialData 为空");
        }
pengyongcheng authored
442
        return handleMultiProcess(() -> mesService.receipt(mesReceipt));
肖超群 authored
443
    }
444
445
446

    /**
     * 物料出库
周峰 authored
447
     * 4 料点呼叫送物料
448
449
450
451
     * @return
     */
    @PostMapping("/shipment")
    @ApiOperation("物料出库")
周峰 authored
452
    @ApiLogger(apiName = "4 物料出库", from = "MES")
453
454
455
456
457
458
459
460
461
462
463
464
465
    public AjaxResult shipment(@RequestBody MesShipment mesShipment) {
        if (StringUtils.isEmpty(mesShipment.getTaskNo())) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(mesShipment.getOrderCode())) {
            return AjaxResult.error("orderCode 为空");
        }
        if (StringUtils.isEmpty(mesShipment.getShipmentReferCode())) {
            return AjaxResult.error("shipmentReferCode 为空");
        }
        if (StringUtils.isEmpty(mesShipment.getToPort())) {
            return AjaxResult.error("toPort 为空");
        }
466
        if (mesShipment.getVehicleinsert() == null) {
467
            return AjaxResult.error("vehicleinsert 为空");
468
        }
周鸿 authored
469
        if (StringUtils.isEmpty(mesShipment.getMaterialDataList())) {
470
471
            return AjaxResult.error("materialData 为空");
        }
pengyongcheng authored
472
        return handleMultiProcess(() -> mesService.shipment(mesShipment));
473
    }
474
475

    /**
476
     * 入库回传
477
478
479
480
481
     */
    @PostMapping("/backReceipt")
    @ResponseBody
    @ApiLogger(from = "WMS", to = "MES", apiName = "入库回传")
    public AjaxResult backReceipt(String id) {
482
        if (StringUtils.isEmpty(id)) {
483
484
485
486
487
488
            return AjaxResult.error("id不能为空");
        }
        return mesService.backReceipt(id);
    }

    /**
489
     * 出库回传
490
     */
491
    @PostMapping("/backShipment")
492
493
    @ResponseBody
    @ApiLogger(from = "WMS", to = "MES", apiName = "出库回传")
494
    public AjaxResult backShipment(String id) {
495
496
497
498
499
500
501
502
503
        if (StringUtils.isEmpty(id)) {
            return AjaxResult.error("id不能为空");
        }
        return mesService.backShipment(id);
    }

    /**
     * 空容器入库出库回传
     */
504
    @PostMapping("/backEmpty")
505
    @ResponseBody
506
    @ApiLogger(from = "WMS", to = "MES", apiName = "空容器任务回传")
507
    public AjaxResult backEmpty(String id) {
508
509
510
511
512
        if (StringUtils.isEmpty(id)) {
            return AjaxResult.error("id不能为空");
        }
        return mesService.backEmpty(id);
    }
肖超群 authored
513
}