Blame view

src/main/java/com/huaheng/api/mes/controller/MesController.java 26.1 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
10
11
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;
import com.huaheng.pc.task.taskHeader.service.WorkTaskService;
import io.swagger.annotations.ApiOperation;
12
13
14
15
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
肖超群 authored
16
17

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

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

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

    /**
     * 生成空托盘入库任务
36
     * 料点呼叫移走空载具
肖超群 authored
37
38
     */
    @PostMapping("/receiptEmptyContainer")
39
40
    @ApiOperation("空托盘入库")
    @ApiLogger(apiName = "空托盘入库", from = "MES")
41
42
    public AjaxResult receiptEmptyContainer(@RequestBody MesEmptyContainer mesEmptyContainer) {
        String taskNo = mesEmptyContainer.getTaskNo();
43
        String fromPort = mesEmptyContainer.getFromPort();
44
45
46
        // 交换载具和盛具的值
        String containerCode = mesEmptyContainer.getVehicleCode();
        String vehicleCode = mesEmptyContainer.getContainerCode();
47
        if (StringUtils.isEmpty(containerCode)) {
48
            return AjaxResult.error("vehicleCode 为空");
49
50
51
52
        }
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
53
54
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
55
        }
56
        /*if (!isEmptyVehBack && StringUtils.isEmpty(vehicleCode)) {
57
            return AjaxResult.error("containerCode 为空");
58
        }*/
59
        // 因MES传的载具和盛具码是反的,此处交换载具与盛具的值 反着入参
60
        return handleMultiProcess(() -> workTaskService.createEmptyIn(
61
                taskNo, fromPort, containerCode, vehicleCode, null));
肖超群 authored
62
63
64
    }

    /**
65
     * MES下发空托盘出库
肖超群 authored
66
67
     */
    @PostMapping("/shipmentEmptyContainer")
68
69
    @ApiOperation("空托盘出库")
    @ApiLogger(apiName = "空托盘出库", from = "MES")
肖超群 authored
70
71
    public AjaxResult shipmentEmptyContainer(@RequestBody MesEmptyContainer mesEmptyContainer) {
        String taskNo = mesEmptyContainer.getTaskNo();
72
        String orderCode = mesEmptyContainer.getOrderCode();
肖超群 authored
73
        String toPort = mesEmptyContainer.getToPort();
74
        String vehicleTypeCode = mesEmptyContainer.getVehicleTypeCode();
75
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
76
77
            return AjaxResult.error("taskNo 为空");
        }
78
        if (StringUtils.isEmpty(toPort)) {
肖超群 authored
79
80
            return AjaxResult.error("toPort 为空");
        }
81
        if (StringUtils.isEmpty(vehicleTypeCode)) {
82
            return AjaxResult.error("containerTypeCode 为空");
肖超群 authored
83
        }
84
        return handleMultiProcess(() -> workTaskService.shipmentEmptyContainer(
85
                taskNo, orderCode, toPort, vehicleTypeCode));
肖超群 authored
86
87
88
    }

    /**
89
     * MES查询库存
肖超群 authored
90
91
     */
    @PostMapping("/searchInventory")
92
93
    @ApiOperation("查询库存")
    @ApiLogger(apiName = "查询库存", from = "MES")
94
    public AjaxResult searchInventory(@RequestBody MesSearch mesSearch) {
yuxiao authored
95
        String taskNo = mesSearch.getTaskNo();
96
        List<MaterialDataQuery> list = mesSearch.getMaterialDataList();
97
        if (StringUtils.isEmpty(taskNo)) {
98
            return AjaxResult.error("taskNo 为空");
yuxiao authored
99
        }
yuxiao authored
100
        if (StringUtils.isEmpty(list)) {
101
            return AjaxResult.error("materialDataList 为空");
肖超群 authored
102
        }
103
104
        try {
            return mesService.searchInventory(mesSearch);
105
        } catch (Exception e) {
106
            return AjaxResult.error(e.getMessage());
107
        }
108
    }
肖超群 authored
109
110
    /**
111
     * MES主工单下发
112
113
     */
    @PostMapping("/workOrder")
114
115
    @ApiOperation("主工单下发")
    @ApiLogger(apiName = "主工单下发", from = "MES")
116
    public AjaxResult workOrder(@RequestBody MesWorkOrder workOrder) {
117
        if (StringUtils.isEmpty(workOrder.getTaskNo())) {
118
119
            return AjaxResult.error("taskNo 为空");
        }
120
        if (StringUtils.isEmpty(workOrder.getOrderCode())) {
121
122
            return AjaxResult.error("orderCode 为空");
        }
123
124
125
126
127
128
        if (StringUtils.isEmpty(workOrder.getBatchNumber())) {
            return AjaxResult.error("batchNumber 为空");
        }
        if (StringUtils.isEmpty(workOrder.getOrderNumber())) {
            return AjaxResult.error("orderNumber 为空");
        }
129
        if (workOrder.getOrderStatus() == null) {
130
131
            return AjaxResult.error("orderStatus 为空");
        }
132
        if (StringUtils.isEmpty(workOrder.getMaterialDataList()) || workOrder.getMaterialDataList().isEmpty()) {
133
            return AjaxResult.error("materialDataList 为空");
134
        }
135
        return mesService.workOrder(workOrder);
肖超群 authored
136
137
    }
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    @PostMapping("/syncWorkOrder")
    @ApiOperation("工单状态同步")
    @ApiLogger(apiName = "主工单下发", from = "MES")
    public AjaxResult syncWorkOrder(@RequestBody MesWorkOrder workOrder) {
        if (StringUtils.isEmpty(workOrder.getTaskNo())) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(workOrder.getOrderCode())) {
            return AjaxResult.error("orderCode 为空");
        }
        if (workOrder.getOrderStatus() == null) {
            return AjaxResult.error("orderStatus 为空");
        }
        return mesService.syncWorkOrder(workOrder);
    }
肖超群 authored
154
    /**
155
     * MES工单入库单(弃用)
156
157
     * 已经取消该接口 9
     *
肖超群 authored
158
159
     * @return
     */
pengyongcheng authored
160
    /*@Deprecated
肖超群 authored
161
162
    @PostMapping("/receiptOrder")
    @ApiOperation("MES工单入库单")
163
    @ApiLogger(apiName = "MES工单入库单", from = "MES")
肖超群 authored
164
    public AjaxResult receiptOrder(@RequestBody MesOrder mesOrder) {
165
        String orderCode = mesOrder.getOrderCode();
肖超群 authored
166
        String taskNo = mesOrder.getTaskNo();
167
        List<MesOrderMaterial> list = mesOrder.getMaterialDataList();
168
        if (StringUtils.isEmpty(orderCode)) {
肖超群 authored
169
170
            return AjaxResult.error("orderCode 为空");
        }
171
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
172
173
            return AjaxResult.error("taskNo 为空");
        }
174
        if (StringUtils.isEmpty(mesOrder.getChidOrderCode())) {
175
176
            return AjaxResult.error("chidOrderCode 为空");
        }
177
        if (mesOrder.getOrderStatus() == null) {
178
179
            return AjaxResult.error("orderStatus 为空");
        }
180
        if (StringUtils.isEmpty(mesOrder.getReceiptReferCode())) {
181
182
            return AjaxResult.error("receiptReferCode 为空");
        }
183
        if (StringUtils.isEmpty(list) || list.isEmpty()) {
184
            return AjaxResult.error("materialDataList 为空");
肖超群 authored
185
        }
186
        return handleMultiProcess(() -> mesService.receiptOrder(mesOrder));
pengyongcheng authored
187
    }*/
肖超群 authored
188
189

    /**
pengyongcheng authored
190
     * 3 MES工单领料单出库单 (弃用)
191
     *
肖超群 authored
192
193
     * @return
     */
pengyongcheng authored
194
    /*@PostMapping("/shipmentOrder")
yuxiao authored
195
    @ApiOperation("MES工单领料单出库单")
周峰 authored
196
    @ApiLogger(apiName = "3 MES工单领料单出库单", from = "MES")
197
198
    public AjaxResult shipmentOrder(@RequestBody MesShipmentOrder mesOrder) {
        String orderCode = mesOrder.getOrderCode();
肖超群 authored
199
200
        String taskNo = mesOrder.getTaskNo();
        BigDecimal orderQty = mesOrder.getOrderQty();
201
        if (StringUtils.isEmpty(orderCode)) {
肖超群 authored
202
203
            return AjaxResult.error("orderCode 为空");
        }
204
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
205
206
            return AjaxResult.error("taskNo 为空");
        }
207
        if (StringUtils.isEmpty(mesOrder.getChidOrderCode())) {
周鸿 authored
208
            return AjaxResult.error("childOrderCode 为空");
209
210
211
212
        }
        if (StringUtils.isEmpty(mesOrder.getProductCode())) {
            return AjaxResult.error("productCode 为空");
        }
213
        if (orderQty == null) {
肖超群 authored
214
215
            return AjaxResult.error("orderQty 为空");
        }
周鸿 authored
216
        if (StringUtils.isEmpty(mesOrder.getMaterialDataList())) {
217
            return AjaxResult.error("materialDataList 为空");
218
        }
219
        return handleMultiProcess(() -> mesService.shipmentOrder(mesOrder));
pengyongcheng authored
220
    }*/
肖超群 authored
221
222

    /**
pengyongcheng authored
223
     * MES成品出库(弃用)
224
     *
肖超群 authored
225
226
     * @return
     */
pengyongcheng authored
227
    /*@PostMapping("/shipmentProduct")
肖超群 authored
228
    @ApiOperation("MES成品出库")
229
    @ApiLogger(apiName = "MES成品出库", from = "MES")
230
    public AjaxResult shipmentProduct(@RequestBody MesShipmentProduct mesShipmentProduct) {
肖超群 authored
231
        String containerCode = mesShipmentProduct.getContainerCode();
232
233
        String fromPort = mesShipmentProduct.getFromPort();
        String toPort = mesShipmentProduct.getToPort();
肖超群 authored
234
        String taskNo = mesShipmentProduct.getTaskNo();
235
236
        String vehicleCode = mesShipmentProduct.getVehicleCode();
        String orderCode = mesShipmentProduct.getOrderCode();
237
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
238
239
            return AjaxResult.error("containerCode 为空");
        }
240
241
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
肖超群 authored
242
        }
243
244
        if (StringUtils.isEmpty(toPort)) {
            return AjaxResult.error("toPort 为空");
肖超群 authored
245
        }
246
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
247
248
            return AjaxResult.error("taskNo 为空");
        }
249
250
251
252
253
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
254
        }
255
        return handleMultiProcess(() -> mesService.shipmentProduct(mesShipmentProduct));
pengyongcheng authored
256
    }*/
肖超群 authored
257
258

    /**
259
     * 工位之间载具流转
260
261
     */
    @PostMapping("/overStation")
262
263
    @ApiOperation("载具流转")
    @ApiLogger(apiName = "载具流转", from = "MES")
264
265
    public AjaxResult overStation(@RequestBody MesOverStationDto mesOverStationDto) {
        String containerCode = mesOverStationDto.getContainerCode();
266
267
        String fromPort = mesOverStationDto.getFromPort();
        String toPort = mesOverStationDto.getToPort();
268
269
270
271
272
        String taskNo = mesOverStationDto.getTaskNo();
        String vehicleCode = mesOverStationDto.getVehicleCode();
        if (StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("containerCode 为空");
        }
273
        if (StringUtils.isEmpty(fromPort)) {
274
            return AjaxResult.error("fromPort 为空");
275
        }
276
        if (StringUtils.isEmpty(toPort)) {
277
            return AjaxResult.error("toPort 为空");
278
279
280
281
282
283
284
        }
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
285
286
287
        // 交换载具盛具的值,MES给的与WMS的是反的
        mesOverStationDto.setContainerCode(vehicleCode);
        mesOverStationDto.setVehicleCode(containerCode);
288
289
290
291
        return handleMultiProcess(() -> mesService.createOverStation(mesOverStationDto));
    }

    /**
肖超群 authored
292
     * MES物料入库
293
     * 料点呼叫移走物料
肖超群 authored
294
295
     */
    @PostMapping("/receipt")
296
297
    @ApiOperation("物料入库")
    @ApiLogger(apiName = "物料入库", from = "MES")
肖超群 authored
298
299
    public AjaxResult receipt(@RequestBody MesReceipt mesReceipt) {
        String taskNo = mesReceipt.getTaskNo();
周峰 authored
300
301
        //设置入库单类型为半成品入库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_SEMI);
302
        String orderCode = mesReceipt.getOrderCode();
肖超群 authored
303
        String containerCode = mesReceipt.getContainerCode();
pengyongcheng authored
304
        String fromPort = mesReceipt.getFromPort();
305
        String vehicleCode = mesReceipt.getVehicleCode();
pengyongcheng authored
306
        List<ReceiptMaterialData> materialDataList = mesReceipt.getReceiptMaterialDataList();
肖超群 authored
307
308
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
309
310
            return AjaxResult.error("taskNo 为空");
        }
311
312
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
肖超群 authored
313
        }
314
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
315
316
            return AjaxResult.error("containerCode 为空");
        }
pengyongcheng authored
317
318
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
肖超群 authored
319
        }
320
321
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
肖超群 authored
322
        }
323
324
        if (StringUtils.isEmpty(materialDataList)) {
            return AjaxResult.error("materialDataList 为空");
325
        }
326
        HashMap<String, String> quTest = new HashMap<>();
pengyongcheng authored
327
        for (ReceiptMaterialData data : mesReceipt.getReceiptMaterialDataList()) {
328
329
330
            if (data.getLocationNoX() == null || data.getLocationNoY() == null) {
                return AjaxResult.error("物料信息坐标为空");
            }
331
            if (data.getLocationNoX() == -1 || data.getLocationNoY() == -1) {
332
                return AjaxResult.error("物料信息坐标错误");
333
334
335
336
337
338
339
340
            }
            String key = data.getLocationNoX() + "  " + data.getLocationNoY();
            if (quTest.get(key) == null) {
                quTest.put(key, key);
            } else {
                return AjaxResult.error("坐标重复: " + key);
            }
        }
341
342
343
        // 交换载具盛具的值,MES给的与WMS的是反的
        mesReceipt.setContainerCode(vehicleCode);
        mesReceipt.setVehicleCode(containerCode);
344
        return handleMultiProcess(() -> mesService.receipt(mesReceipt));
345
346
347
    }

    /**
348
     * 余料回库(弃用)
349
350
351
     *
     * @return
     */
352
    /*@PostMapping("/rawReceipt")
353
    @ApiOperation("余料回库")
354
    @ApiLogger(apiName = "余料回库", from = "MES")
355
    public AjaxResult rawReceipt(@RequestBody MesReceipt mesReceipt) {
356
357
358
        //mes调用接口时,代表入库单类型为余料退库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_BACK);
359
360
        String taskNo = mesReceipt.getTaskNo();
361
        String containerCode = mesReceipt.getContainerCode();
pengyongcheng authored
362
        String fromPort = mesReceipt.getFromPort();
363
        String vehicleCode = mesReceipt.getVehicleCode();
pengyongcheng authored
364
        List<ReceiptMaterialData> materialData = mesReceipt.getReceiptMaterialDataList();
365
        HashMap<String, String> quTest = new HashMap<>();
pengyongcheng authored
366
        for (ReceiptMaterialData data : mesReceipt.getReceiptMaterialDataList()) {
367
368
369
            Integer locationNoY = data.getLocationNoY();
            Integer locationNoX = data.getLocationNoX();
            if (locationNoX == null || locationNoY == null) {
370
371
                return AjaxResult.error("物料信息坐标为空");
            }
372
            if (locationNoX == -1 || locationNoY == -1) {
373
                return AjaxResult.error("物料信息坐标错误");
374
            }
375
            String key = locationNoX + "  " + locationNoY;
376
377
378
379
380
381
382
383
384
385
386
387
            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(containerCode)) {
            return AjaxResult.error("containerCode 为空");
        }
pengyongcheng authored
388
389
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
390
391
392
393
394
395
396
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(materialData)) {
            return AjaxResult.error("materialData 为空");
        }
397
398
399
400

        // 交换载具盛具的值,MES给的与WMS的是反的
        mesReceipt.setContainerCode(vehicleCode);
        mesReceipt.setVehicleCode(containerCode);
401
        return handleMultiProcess(() -> mesService.receipt(mesReceipt));
402
    }*/
403
404
405
406
407
408
409

    /**
     * 原材料入库
     *
     * @return
     */
    @PostMapping("/wmsReceipt")
410
411
    /*@ApiOperation("原材料入库")
    @ApiLogger(apiName = "原材料入库", from = "wms-pc")*/
412
    public AjaxResult wmsReceipt(@RequestBody MesReceipt mesReceipt) {
413
414
        //wms调用接口时,代表入库单类型为原材料入库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_RAW);
415
416
        String taskNo = mesReceipt.getTaskNo();
417
        String orderCode = mesReceipt.getOrderCode();
418
419
        String orderNumber = mesReceipt.getOrderNumber();
        String batchNumber = mesReceipt.getBatchNumber();
420
421
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
pengyongcheng authored
422
        List<ReceiptMaterialData> materialData = mesReceipt.getReceiptMaterialDataList();
423
        HashMap<String, String> quTest = new HashMap<>();
424
425
        // 通用盛具不做校验
        if (!QuantityConstant.VEHICLE_TYPE_COMMON.equals(vehicleTypeCode)) {
pengyongcheng authored
426
            for (ReceiptMaterialData data : mesReceipt.getReceiptMaterialDataList()) {
427
428
429
                if (data.getLocationNoX() == null || data.getLocationNoY() == null) {
                    return AjaxResult.error("物料信息坐标为空");
                }
430
                if (data.getLocationNoX() == -1 || data.getLocationNoY() == -1) {
431
                    return AjaxResult.error("物料信息坐标错误");
432
433
434
435
436
437
438
                }
                String key = data.getLocationNoX() + "  " + data.getLocationNoY();
                if (quTest.get(key) == null) {
                    quTest.put(key, key);
                } else {
                    return AjaxResult.error("坐标重复: " + key);
                }
439
440
            }
        }
441
442
443
444
445
446
447
448
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
肖超群 authored
449
        }
周鸿 authored
450
        if (StringUtils.isEmpty(materialData)) {
肖超群 authored
451
452
            return AjaxResult.error("materialData 为空");
        }
453
454
455
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
        }
456
457
458
459
460
461
        if (StringUtils.isEmpty(orderNumber)) {
            return AjaxResult.error("orderNumber 为空");
        }
        if (StringUtils.isEmpty(batchNumber)) {
            return AjaxResult.error("batchNumber 为空");
        }
462
        return handleMultiProcess(() -> mesService.wmsReceipt(mesReceipt));
肖超群 authored
463
    }
464
465
466

    /**
     * 物料出库
467
     * 料点呼叫送物料
468
     *
469
470
471
472
     * @return
     */
    @PostMapping("/shipment")
    @ApiOperation("物料出库")
473
    @ApiLogger(apiName = "物料出库", from = "MES")
474
475
476
477
478
479
480
481
482
483
    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.getToPort())) {
            return AjaxResult.error("toPort 为空");
        }
pengyongcheng authored
484
        /*if (mesShipment.getVehicleinsert() == null) {
485
            return AjaxResult.error("vehicleinsert 为空");
pengyongcheng authored
486
487
        }*/
        if (StringUtils.isEmpty(mesShipment.getShipmentMaterialDataList())) {
488
489
            return AjaxResult.error("materialData 为空");
        }
周峰 authored
490
491
492
493
        if (mesShipment.getSequenceCount() <= 0) {
            return AjaxResult.error("sequenceCount 为空");
        }
494
        if (StringUtils.isEmpty(mesShipment.getSequenceGroup())) {
周峰 authored
495
496
            return AjaxResult.error("sequenceGroup 为空");
        }
497
        return handleMultiProcess(() -> mesService.shipment(mesShipment));
498
    }
499
500

    /**
501
     * 入库回传
502
503
504
     */
    @PostMapping("/backReceipt")
    @ApiLogger(from = "WMS", to = "MES", apiName = "入库回传")
505
506
    public AjaxResult backReceipt(Integer id) {
        if (StringUtils.isNull(id)) {
507
508
509
510
511
512
            return AjaxResult.error("id不能为空");
        }
        return mesService.backReceipt(id);
    }

    /**
513
     * 出库回传
514
     */
515
    @PostMapping("/backShipment")
516
    @ApiLogger(from = "WMS", to = "MES", apiName = "出库回传")
517
518
    public AjaxResult backShipment(Integer id) {
        if (Objects.isNull(id)) {
519
520
521
522
523
524
            return AjaxResult.error("id不能为空");
        }
        return mesService.backShipment(id);
    }

    /**
525
     * 工位之间载具流转回传
526
     */
527
528
    @PostMapping("/backChangeStation")
    @ApiLogger(from = "WMS", to = "MES", apiName = "工位之间载具流转回传")
529
530
    public AjaxResult backEmpty(Integer id) {
        if (Objects.isNull(id)) {
531
            return AjaxResult.error("任务id不能为空");
532
        }
533
        return mesService.backChangeStation(id);
534
    }
535
536
537
538
539

    /**
     * MES质检查询
     */
    @PostMapping("/searchInventoryByQC")
540
541
    @ApiOperation("质检抽样查询")
    @ApiLogger(apiName = "质检抽样查询", from = "MES")
542
    public AjaxResult searchInventoryByQC(@RequestBody MesSearchRequestByQCDto mesSearchRequestByQCDto) {
543
544
545
        String taskNo = mesSearchRequestByQCDto.getTaskNo();
        String orderCode = mesSearchRequestByQCDto.getOrderCode();
        String materialCode = mesSearchRequestByQCDto.getMaterialCode();
546
        if (StringUtils.isEmpty(taskNo)) {
547
            return AjaxResult.error("taskNo 为空");
548
549
        }
        if (StringUtils.isEmpty(orderCode)) {
550
            return AjaxResult.error("orderCode 为空");
551
        }
552
        if (StringUtils.isEmpty(materialCode)) {
553
            return AjaxResult.error("materialCode 为空");
554
555
        }
        try {
556
            return mesService.searchInventoryByQC(mesSearchRequestByQCDto);
557
        } catch (Exception e) {
558
            return AjaxResult.error(e.getMessage());
559
560
        }
    }
561
562
563
564
565

    /**
     * MES质检抽样出库
     */
    @PostMapping("/shipmentByQC")
566
567
    @ApiOperation("质检抽样出库")
    @ApiLogger(apiName = "质检抽样出库", from = "MES")
568
    public AjaxResult shipmentByQC(@RequestBody MesShipmentByQCDto mesShipmentByQCDto) {
569
570
571
572
        String taskNo = mesShipmentByQCDto.getTaskNo();
        String orderCode = mesShipmentByQCDto.getOrderCode();
        List<String> locationCode = mesShipmentByQCDto.getLocationCodeList();
        String toPort = mesShipmentByQCDto.getToPort();
pengyongcheng authored
573
        Integer materialInspectStatus = mesShipmentByQCDto.getMaterialInspectStatus();
574
        if (StringUtils.isEmpty(taskNo)) {
575
            return AjaxResult.error("taskNo 为空");
576
577
        }
        if (StringUtils.isEmpty(locationCode)) {
578
            return AjaxResult.error("locationCode 为空");
579
580
        }
        if (StringUtils.isEmpty(orderCode)) {
581
            return AjaxResult.error("orderCode 为空");
582
583
        }
        if (StringUtils.isEmpty(toPort)) {
584
            return AjaxResult.error("toPort 为空");
585
        }
pengyongcheng authored
586
        if (StringUtils.isNull(materialInspectStatus)) {
587
            return AjaxResult.error("materialStatus 为空");
588
        }
589
590
591
        try {
            return mesService.shipmentByQC(mesShipmentByQCDto);
        } catch (Exception e) {
592
            return AjaxResult.error(e.getMessage());
593
594
        }
    }
595
596

    /**
597
     * MES质检抽样余料回库
598
599
     */
    @PostMapping("/receiptByQC")
600
601
    @ApiOperation("质检抽样余料回库")
    @ApiLogger(apiName = "质检抽样余料回库", from = "MES")
602
    public AjaxResult receiptByQC(@RequestBody MesReceiptByQCDto mesReceiptByQCDto) {
603
        String taskNo = mesReceiptByQCDto.getTaskNo();
604
        Integer materialInspectStatus = mesReceiptByQCDto.getMaterialInspectStatus();
605
606
607
608
609
610
        String fromPort = mesReceiptByQCDto.getFromPort();
        String orderCode = mesReceiptByQCDto.getOrderCode();
        String containerCode = mesReceiptByQCDto.getContainerCode();
        String vehicleCode = mesReceiptByQCDto.getVehicleCode();
        List<MaterialData> materialDataList = mesReceiptByQCDto.getMaterialDataList();
        if (StringUtils.isEmpty(taskNo)) {
611
            return AjaxResult.error("taskNo 为空");
612
        }
613
        if (StringUtils.isNull(materialInspectStatus)) {
614
            return AjaxResult.error("materialStatus 为空");
615
616
        }
        if (StringUtils.isEmpty(fromPort)) {
617
            return AjaxResult.error("fromPort 为空");
618
619
        }
        if (StringUtils.isEmpty(orderCode)) {
620
            return AjaxResult.error("orderCode 为空");
621
622
        }
        if (StringUtils.isEmpty(containerCode)) {
623
            return AjaxResult.error("containerCode 为空");
624
625
        }
        if (StringUtils.isEmpty(vehicleCode)) {
626
            return AjaxResult.error("vehicleCode 为空");
627
628
        }
        if (StringUtils.isEmpty(materialDataList)) {
629
            return AjaxResult.error("materialDataList 为空");
630
631
632
633
        }
        try {
            return mesService.receiptByQC(mesReceiptByQCDto);
        } catch (Exception e) {
634
            return AjaxResult.error(e.getMessage());
635
636
        }
    }
pengyongcheng authored
637
638

    /**
639
     * 挪料(弃用)
pengyongcheng authored
640
     */
641
    /*@PostMapping("/movingMaterial")
pengyongcheng authored
642
643
    @ApiOperation("MES挪料")
    @ApiLogger(apiName = "MES挪料", from = "MES")
644
    public AjaxResult movingMaterial(@RequestBody MesMovingMaterialDto mesMovingMaterialDto) {
pengyongcheng authored
645
        if (Objects.isNull(mesMovingMaterialDto)) {
646
            return AjaxResult.error("挪料对象 mesMovingMaterialDto 为空");
pengyongcheng authored
647
648
649
650
651
652
        }
        String sourceOrderCode = mesMovingMaterialDto.getSourceOrderCode();
        String targetOrderCode = mesMovingMaterialDto.getTargetOrderCode();
        String materialCode = mesMovingMaterialDto.getMaterialCode();
        BigDecimal qty = mesMovingMaterialDto.getQty();
        if (StringUtils.isEmpty(sourceOrderCode)) {
653
            return AjaxResult.error("sourceOrderCode 为空");
pengyongcheng authored
654
655
        }
        if (StringUtils.isNull(targetOrderCode)) {
656
            return AjaxResult.error("targetOrderCode 为空");
pengyongcheng authored
657
658
        }
        if (StringUtils.isEmpty(materialCode)) {
659
            return AjaxResult.error("materialCode 为空");
pengyongcheng authored
660
661
        }
        if (Objects.isNull(qty) || qty.compareTo(BigDecimal.ZERO) <= 0) {
662
            return AjaxResult.error("qty 为空或 qty小于等于0");
pengyongcheng authored
663
664
665
666
        }
        try {
            return mesService.movingMaterial(mesMovingMaterialDto);
        } catch (Exception e) {
667
            return AjaxResult.error(e.getMessage());
pengyongcheng authored
668
        }
669
    }*/
肖超群 authored
670
}