Blame view

src/main/java/com/huaheng/api/mes/controller/MesController.java 29.8 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
import com.huaheng.pc.task.taskHeader.service.WorkTaskService;
import io.swagger.annotations.ApiOperation;
13
14
15
16
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
17
18
19

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

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

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

    /**
     * 生成空托盘入库任务
38
     * 7 料点呼叫移走空载具
39
     *
肖超群 authored
40
41
42
43
     * @return
     */
    @PostMapping("/receiptEmptyContainer")
    @ApiOperation("生成空托盘入库任务")
周峰 authored
44
    @ApiLogger(apiName = "7 生成空托盘入库任务", from = "MES")
45
46
    public AjaxResult receiptEmptyContainer(@RequestBody MesEmptyContainer mesEmptyContainer) {
        String taskNo = mesEmptyContainer.getTaskNo();
47
        String orderCode = mesEmptyContainer.getOrderCode();
48
        String fromPort = mesEmptyContainer.getFromPort();
49
50
51
52
53
        // 交换载具和盛具的值
        String containerTypeCode = mesEmptyContainer.getVehicleTypeCode();
        String containerCode = mesEmptyContainer.getVehicleCode();
        String vehicleTypeCode = mesEmptyContainer.getContainerTypeCode();
        String vehicleCode = mesEmptyContainer.getContainerCode();
54
        boolean isEmptyVehBack = mesEmptyContainer.getIsEmptyVehBack() == 1;
55
        if (StringUtils.isEmpty(containerCode)) {
56
            return AjaxResult.error("vehicleCode 为空");
57
        }
58
59
60
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
        }
61
62
        if (StringUtils.isEmpty(containerTypeCode)) {
            return AjaxResult.error("containerTypeCode 为空");
63
64
65
66
        }
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
67
68
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
69
        }
70
        if (!isEmptyVehBack && StringUtils.isEmpty(vehicleTypeCode)) {
71
            return AjaxResult.error("containerTypeCode 为空");
72
        }
73
        if (!isEmptyVehBack && StringUtils.isEmpty(vehicleCode)) {
74
            return AjaxResult.error("containerCode 为空");
75
        }
76
        // 因MES传的载具和盛具码是反的,此处交换载具与盛具的值 反着入参
77
        return handleMultiProcess(() -> workTaskService.createEmptyIn(
78
                taskNo, fromPort, orderCode, containerCode, vehicleCode, null));
肖超群 authored
79
80
81
    }

    /**
周峰 authored
82
     * 5 MES下发空托盘出库
83
     *
肖超群 authored
84
85
86
87
     * @return
     */
    @PostMapping("/shipmentEmptyContainer")
    @ApiOperation("MES下发空托盘出库")
周峰 authored
88
    @ApiLogger(apiName = "5 MES下发空托盘出库", from = "MES")
肖超群 authored
89
90
    public AjaxResult shipmentEmptyContainer(@RequestBody MesEmptyContainer mesEmptyContainer) {
        String taskNo = mesEmptyContainer.getTaskNo();
91
        String orderCode = mesEmptyContainer.getOrderCode();
肖超群 authored
92
        String toPort = mesEmptyContainer.getToPort();
93
        String containerTypeCode = mesEmptyContainer.getContainerTypeCode();
94
95
        String vehicleTypeCode = mesEmptyContainer.getVehicleTypeCode();
        if (StringUtils.isEmpty(containerTypeCode)) {
96
            return AjaxResult.error("containerTypeCode 为空");
肖超群 authored
97
        }
98
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
99
100
            return AjaxResult.error("taskNo 为空");
        }
101
        if (StringUtils.isEmpty(toPort)) {
肖超群 authored
102
103
            return AjaxResult.error("toPort 为空");
        }
104
105
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
肖超群 authored
106
        }
107
108
109
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
        }
110
111
112
113
114
115
        // 载具与盛具和MES那边定义是反的,故WMS交换值
        String temp = containerTypeCode;
        containerTypeCode = vehicleTypeCode;
        vehicleTypeCode = temp;
        String finalContainerTypeCode = containerTypeCode;
        String finalVehicleTypeCode = vehicleTypeCode;
116
        return handleMultiProcess(() -> workTaskService.shipmentEmptyContainer(
117
                taskNo, orderCode, toPort, finalContainerTypeCode, finalVehicleTypeCode));
肖超群 authored
118
119
120
    }

    /**
周峰 authored
121
     * 1 MES查询库存
122
     *
肖超群 authored
123
124
125
126
     * @return
     */
    @PostMapping("/searchInventory")
    @ApiOperation("MES查询库存")
周峰 authored
127
    @ApiLogger(apiName = "1 MES查询库存", from = "MES")
128
    public AjaxResultMES searchInventory(@RequestBody MesSearch mesSearch) {
yuxiao authored
129
        String taskNo = mesSearch.getTaskNo();
130
        List<MaterialDataQuery> list = mesSearch.getMaterialDataList();
131
        if (StringUtils.isEmpty(taskNo)) {
132
            return AjaxResultMES.error("taskNo 为空");
yuxiao authored
133
        }
yuxiao authored
134
        if (StringUtils.isEmpty(list)) {
135
            return AjaxResultMES.error("materialDataList 为空");
肖超群 authored
136
        }
137
138
        try {
            return mesService.searchInventory(mesSearch);
139
        } catch (Exception e) {
140
141
            return AjaxResultMES.error(e.getMessage());
        }
142
    }
肖超群 authored
143
144
    /**
周峰 authored
145
     * 2 MES主工单下发
146
     *
147
148
149
150
     * @return
     */
    @PostMapping("/workOrder")
    @ApiOperation("MES主工单下发")
周峰 authored
151
    @ApiLogger(apiName = "2 MES主工单下发", from = "MES")
周峰 authored
152
    public synchronized AjaxResult workOrder(@RequestBody MesWorkOrder workOrder) {
153
        if (StringUtils.isEmpty(workOrder.getTaskNo())) {
154
155
            return AjaxResult.error("taskNo 为空");
        }
156
        if (StringUtils.isEmpty(workOrder.getOrderCode())) {
157
158
            return AjaxResult.error("orderCode 为空");
        }
159
160
161
162
163
164
        if (StringUtils.isEmpty(workOrder.getBatchNumber())) {
            return AjaxResult.error("batchNumber 为空");
        }
        if (StringUtils.isEmpty(workOrder.getOrderNumber())) {
            return AjaxResult.error("orderNumber 为空");
        }
165
        if (workOrder.getOrderStatus() == null) {
166
167
            return AjaxResult.error("orderStatus 为空");
        }
168
        /*if (StringUtils.isEmpty(workOrder.getProductCode())) {
169
170
            return AjaxResult.error("productCode 为空");
        }
171
        if (workOrder.getProductQty() == null) {
172
173
            return AjaxResult.error("productQty 为空");
        }
174
        if (StringUtils.isEmpty(workOrder.getPlanStartTime())) {
175
176
            return AjaxResult.error("planStartTime 为空");
        }
177
        if (StringUtils.isEmpty(workOrder.getPlanEndTime())) {
178
            return AjaxResult.error("planEndTime 为空");
179
        }*/
180
        if (StringUtils.isEmpty(workOrder.getMaterialDataList()) || workOrder.getMaterialDataList().isEmpty()) {
181
            return AjaxResult.error("materialDataList 为空");
182
        }
183
        return mesService.workOrder(workOrder);
肖超群 authored
184
185
186
    }

    /**
187
     * MES工单入库单(弃用)
188
189
     * 已经取消该接口 9
     *
肖超群 authored
190
191
     * @return
     */
pengyongcheng authored
192
    /*@Deprecated
肖超群 authored
193
194
    @PostMapping("/receiptOrder")
    @ApiOperation("MES工单入库单")
195
    @ApiLogger(apiName = "MES工单入库单", from = "MES")
肖超群 authored
196
    public AjaxResult receiptOrder(@RequestBody MesOrder mesOrder) {
197
        String orderCode = mesOrder.getOrderCode();
肖超群 authored
198
        String taskNo = mesOrder.getTaskNo();
199
        List<MesOrderMaterial> list = mesOrder.getMaterialDataList();
200
        if (StringUtils.isEmpty(orderCode)) {
肖超群 authored
201
202
            return AjaxResult.error("orderCode 为空");
        }
203
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
204
205
            return AjaxResult.error("taskNo 为空");
        }
206
        if (StringUtils.isEmpty(mesOrder.getChidOrderCode())) {
207
208
            return AjaxResult.error("chidOrderCode 为空");
        }
209
        if (mesOrder.getOrderStatus() == null) {
210
211
            return AjaxResult.error("orderStatus 为空");
        }
212
        if (StringUtils.isEmpty(mesOrder.getReceiptReferCode())) {
213
214
            return AjaxResult.error("receiptReferCode 为空");
        }
215
        if (StringUtils.isEmpty(list) || list.isEmpty()) {
216
            return AjaxResult.error("materialDataList 为空");
肖超群 authored
217
        }
218
        return handleMultiProcess(() -> mesService.receiptOrder(mesOrder));
pengyongcheng authored
219
    }*/
肖超群 authored
220
221

    /**
pengyongcheng authored
222
     * 3 MES工单领料单出库单 (弃用)
223
     *
肖超群 authored
224
225
     * @return
     */
pengyongcheng authored
226
    /*@PostMapping("/shipmentOrder")
yuxiao authored
227
    @ApiOperation("MES工单领料单出库单")
周峰 authored
228
    @ApiLogger(apiName = "3 MES工单领料单出库单", from = "MES")
229
230
    public AjaxResult shipmentOrder(@RequestBody MesShipmentOrder mesOrder) {
        String orderCode = mesOrder.getOrderCode();
肖超群 authored
231
232
        String taskNo = mesOrder.getTaskNo();
        BigDecimal orderQty = mesOrder.getOrderQty();
233
        if (StringUtils.isEmpty(orderCode)) {
肖超群 authored
234
235
            return AjaxResult.error("orderCode 为空");
        }
236
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
237
238
            return AjaxResult.error("taskNo 为空");
        }
239
        if (StringUtils.isEmpty(mesOrder.getChidOrderCode())) {
周鸿 authored
240
            return AjaxResult.error("childOrderCode 为空");
241
242
243
244
        }
        if (StringUtils.isEmpty(mesOrder.getProductCode())) {
            return AjaxResult.error("productCode 为空");
        }
245
        if (StringUtils.isNull(mesOrder.getShipmentReferStatus())) {
246
247
            return AjaxResult.error("shipmentReferStatus 为空");
        }
248
249
250
        if (StringUtils.isEmpty(mesOrder.getShipmentReferCode())) {
            return AjaxResult.error("shipmentReferCode 为空");
        }
251
        if (orderQty == null) {
肖超群 authored
252
253
            return AjaxResult.error("orderQty 为空");
        }
周鸿 authored
254
        if (StringUtils.isEmpty(mesOrder.getMaterialDataList())) {
255
            return AjaxResult.error("materialDataList 为空");
256
        }
257
        return handleMultiProcess(() -> mesService.shipmentOrder(mesOrder));
pengyongcheng authored
258
    }*/
肖超群 authored
259
260

    /**
pengyongcheng authored
261
     * MES成品出库(弃用)
262
     *
肖超群 authored
263
264
     * @return
     */
pengyongcheng authored
265
    /*@PostMapping("/shipmentProduct")
肖超群 authored
266
    @ApiOperation("MES成品出库")
267
    @ApiLogger(apiName = "MES成品出库", from = "MES")
268
    public AjaxResult shipmentProduct(@RequestBody MesShipmentProduct mesShipmentProduct) {
肖超群 authored
269
        String containerCode = mesShipmentProduct.getContainerCode();
270
271
        String fromPort = mesShipmentProduct.getFromPort();
        String toPort = mesShipmentProduct.getToPort();
肖超群 authored
272
        String taskNo = mesShipmentProduct.getTaskNo();
273
274
        String vehicleCode = mesShipmentProduct.getVehicleCode();
        String orderCode = mesShipmentProduct.getOrderCode();
275
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
276
277
            return AjaxResult.error("containerCode 为空");
        }
278
279
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
肖超群 authored
280
        }
281
282
        if (StringUtils.isEmpty(toPort)) {
            return AjaxResult.error("toPort 为空");
肖超群 authored
283
        }
284
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
285
286
            return AjaxResult.error("taskNo 为空");
        }
287
288
289
290
291
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
292
        }
293
        return handleMultiProcess(() -> mesService.shipmentProduct(mesShipmentProduct));
pengyongcheng authored
294
    }*/
肖超群 authored
295
296

    /**
297
298
299
300
301
302
303
304
305
     * 工位之间载具流转 11
     *
     * @return
     */
    @PostMapping("/overStation")
    @ApiOperation("MES载具流转")
    @ApiLogger(apiName = "MES载具流转", from = "MES")
    public AjaxResult overStation(@RequestBody MesOverStationDto mesOverStationDto) {
        String containerCode = mesOverStationDto.getContainerCode();
306
307
        String fromPort = mesOverStationDto.getFromPort();
        String toPort = mesOverStationDto.getToPort();
308
309
310
311
312
313
        String taskNo = mesOverStationDto.getTaskNo();
        String vehicleCode = mesOverStationDto.getVehicleCode();
        String orderCode = mesOverStationDto.getOrderCode();
        if (StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("containerCode 为空");
        }
314
        if (StringUtils.isEmpty(fromPort)) {
315
            return AjaxResult.error("fromPort 为空");
316
        }
317
        if (StringUtils.isEmpty(toPort)) {
318
            return AjaxResult.error("toPort 为空");
319
320
321
322
323
324
325
326
327
328
        }
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
        }
329
330
331
        // 交换载具盛具的值,MES给的与WMS的是反的
        mesOverStationDto.setContainerCode(vehicleCode);
        mesOverStationDto.setVehicleCode(containerCode);
332
333
334
335
        return handleMultiProcess(() -> mesService.createOverStation(mesOverStationDto));
    }

    /**
肖超群 authored
336
     * MES物料入库
337
338
     * 6 料点呼叫移走物料
     *
肖超群 authored
339
340
341
342
     * @return
     */
    @PostMapping("/receipt")
    @ApiOperation("MES物料入库")
周峰 authored
343
    @ApiLogger(apiName = "6 MES物料入库", from = "MES")
肖超群 authored
344
345
    public AjaxResult receipt(@RequestBody MesReceipt mesReceipt) {
        String taskNo = mesReceipt.getTaskNo();
周峰 authored
346
347
        //设置入库单类型为半成品入库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_SEMI);
348
        String orderCode = mesReceipt.getOrderCode();
349
        String containerType = mesReceipt.getContainerTypeCode();
肖超群 authored
350
        String containerCode = mesReceipt.getContainerCode();
pengyongcheng authored
351
        String fromPort = mesReceipt.getFromPort();
352
353
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
pengyongcheng authored
354
        List<ReceiptMaterialData> materialDataList = mesReceipt.getReceiptMaterialDataList();
肖超群 authored
355
356
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
357
358
            return AjaxResult.error("taskNo 为空");
        }
359
360
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
肖超群 authored
361
        }
362
363
        if (StringUtils.isEmpty(containerType)) {
            return AjaxResult.error("containerType 为空");
肖超群 authored
364
        }
365
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
366
367
            return AjaxResult.error("containerCode 为空");
        }
pengyongcheng authored
368
369
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
肖超群 authored
370
        }
371
372
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
肖超群 authored
373
        }
374
375
376
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
        }
377
378
        if (StringUtils.isEmpty(materialDataList)) {
            return AjaxResult.error("materialDataList 为空");
379
        }
380
        HashMap<String, String> quTest = new HashMap<>();
pengyongcheng authored
381
        for (ReceiptMaterialData data : mesReceipt.getReceiptMaterialDataList()) {
382
383
384
            if (data.getLocationNoX() == null || data.getLocationNoY() == null) {
                return AjaxResult.error("物料信息坐标为空");
            }
385
            if (data.getLocationNoX() == -1 || data.getLocationNoY() == -1) {
386
                return AjaxResult.error("物料信息坐标错误");
387
388
389
390
391
392
393
394
            }
            String key = data.getLocationNoX() + "  " + data.getLocationNoY();
            if (quTest.get(key) == null) {
                quTest.put(key, key);
            } else {
                return AjaxResult.error("坐标重复: " + key);
            }
        }
395
396
397
398
399
        // 交换载具盛具的值,MES给的与WMS的是反的
        mesReceipt.setContainerCode(vehicleCode);
        mesReceipt.setContainerTypeCode(vehicleTypeCode);
        mesReceipt.setVehicleCode(containerCode);
        mesReceipt.setVehicleTypeCode(containerType);
400
        return handleMultiProcess(() -> mesService.receipt(mesReceipt));
401
402
403
    }

    /**
周峰 authored
404
     * 10余料回库
405
406
407
408
     *
     * @return
     */
    @PostMapping("/rawReceipt")
409
    @ApiOperation("余料回库")
周峰 authored
410
    @ApiLogger(apiName = "10 余料回库", from = "MES")
411
    public AjaxResult rawReceipt(@RequestBody MesReceipt mesReceipt) {
412
413
414
        //mes调用接口时,代表入库单类型为余料退库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_BACK);
415
416
        String taskNo = mesReceipt.getTaskNo();
417
418
        String containerType = mesReceipt.getContainerTypeCode();
        String containerCode = mesReceipt.getContainerCode();
pengyongcheng authored
419
        String fromPort = mesReceipt.getFromPort();
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<>();
pengyongcheng authored
424
        for (ReceiptMaterialData data : mesReceipt.getReceiptMaterialDataList()) {
425
426
427
            Integer locationNoY = data.getLocationNoY();
            Integer locationNoX = data.getLocationNoX();
            if (locationNoX == null || locationNoY == null) {
428
429
                return AjaxResult.error("物料信息坐标为空");
            }
430
            if (locationNoX == -1 || locationNoY == -1) {
431
                return AjaxResult.error("物料信息坐标错误");
432
            }
433
            String key = locationNoX + "  " + locationNoY;
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
            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 为空");
        }
pengyongcheng authored
449
450
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
451
452
453
454
455
456
457
458
459
460
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
        }
        if (StringUtils.isEmpty(materialData)) {
            return AjaxResult.error("materialData 为空");
        }
461
462
463
464
465
466

        // 交换载具盛具的值,MES给的与WMS的是反的
        mesReceipt.setContainerCode(vehicleCode);
        mesReceipt.setContainerTypeCode(vehicleTypeCode);
        mesReceipt.setVehicleCode(containerCode);
        mesReceipt.setVehicleTypeCode(containerType);
467
468
469
470
471
472
473
474
475
476
477
478
        return handleMultiProcess(() -> mesService.receipt(mesReceipt));
    }

    /**
     * 原材料入库
     *
     * @return
     */
    @PostMapping("/wmsReceipt")
    @ApiOperation("原材料入库")
    @ApiLogger(apiName = "原材料入库", from = "wms-pc")
    public AjaxResult wmsReceipt(@RequestBody MesReceipt mesReceipt) {
479
480
        //wms调用接口时,代表入库单类型为原材料入库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_RAW);
481
482
        String taskNo = mesReceipt.getTaskNo();
483
        String orderCode = mesReceipt.getOrderCode();
484
485
        String orderNumber = mesReceipt.getOrderNumber();
        String batchNumber = mesReceipt.getBatchNumber();
486
487
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
pengyongcheng authored
488
        List<ReceiptMaterialData> materialData = mesReceipt.getReceiptMaterialDataList();
489
        HashMap<String, String> quTest = new HashMap<>();
490
491
        // 通用盛具不做校验
        if (!QuantityConstant.VEHICLE_TYPE_COMMON.equals(vehicleTypeCode)) {
pengyongcheng authored
492
            for (ReceiptMaterialData data : mesReceipt.getReceiptMaterialDataList()) {
493
494
495
                if (data.getLocationNoX() == null || data.getLocationNoY() == null) {
                    return AjaxResult.error("物料信息坐标为空");
                }
496
                if (data.getLocationNoX() == -1 || data.getLocationNoY() == -1) {
497
                    return AjaxResult.error("物料信息坐标错误");
498
499
500
501
502
503
504
                }
                String key = data.getLocationNoX() + "  " + data.getLocationNoY();
                if (quTest.get(key) == null) {
                    quTest.put(key, key);
                } else {
                    return AjaxResult.error("坐标重复: " + key);
                }
505
506
            }
        }
507
508
509
510
511
512
513
514
        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
515
        }
周鸿 authored
516
        if (StringUtils.isEmpty(materialData)) {
肖超群 authored
517
518
            return AjaxResult.error("materialData 为空");
        }
519
520
521
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
        }
522
523
524
525
526
527
        if (StringUtils.isEmpty(orderNumber)) {
            return AjaxResult.error("orderNumber 为空");
        }
        if (StringUtils.isEmpty(batchNumber)) {
            return AjaxResult.error("batchNumber 为空");
        }
528
        return handleMultiProcess(() -> mesService.wmsReceipt(mesReceipt));
肖超群 authored
529
    }
530
531
532

    /**
     * 物料出库
周峰 authored
533
     * 4 料点呼叫送物料
534
     *
535
536
537
538
     * @return
     */
    @PostMapping("/shipment")
    @ApiOperation("物料出库")
周峰 authored
539
    @ApiLogger(apiName = "4 物料出库", from = "MES")
540
541
542
543
544
545
546
    public AjaxResult shipment(@RequestBody MesShipment mesShipment) {
        if (StringUtils.isEmpty(mesShipment.getTaskNo())) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(mesShipment.getOrderCode())) {
            return AjaxResult.error("orderCode 为空");
        }
pengyongcheng authored
547
        /*if (StringUtils.isEmpty(mesShipment.getShipmentReferCode())) {
548
            return AjaxResult.error("shipmentReferCode 为空");
pengyongcheng authored
549
        }*/
550
551
552
        if (StringUtils.isEmpty(mesShipment.getToPort())) {
            return AjaxResult.error("toPort 为空");
        }
pengyongcheng authored
553
        /*if (mesShipment.getVehicleinsert() == null) {
554
            return AjaxResult.error("vehicleinsert 为空");
pengyongcheng authored
555
556
        }*/
        if (StringUtils.isEmpty(mesShipment.getShipmentMaterialDataList())) {
557
558
            return AjaxResult.error("materialData 为空");
        }
周峰 authored
559
560
561
562
        if (mesShipment.getSequenceCount() <= 0) {
            return AjaxResult.error("sequenceCount 为空");
        }
563
        if (StringUtils.isEmpty(mesShipment.getSequenceGroup())) {
周峰 authored
564
565
            return AjaxResult.error("sequenceGroup 为空");
        }
566
        return handleMultiProcess(() -> mesService.shipment(mesShipment));
567
    }
568
569

    /**
570
     * 入库回传
571
572
573
     */
    @PostMapping("/backReceipt")
    @ApiLogger(from = "WMS", to = "MES", apiName = "入库回传")
574
575
    public AjaxResult backReceipt(Integer id) {
        if (StringUtils.isNull(id)) {
576
577
578
579
580
581
            return AjaxResult.error("id不能为空");
        }
        return mesService.backReceipt(id);
    }

    /**
582
     * 出库回传
583
     */
584
    @PostMapping("/backShipment")
585
    @ApiLogger(from = "WMS", to = "MES", apiName = "出库回传")
586
    public AjaxResult backShipment(String id) {
587
588
589
590
591
592
593
        if (StringUtils.isEmpty(id)) {
            return AjaxResult.error("id不能为空");
        }
        return mesService.backShipment(id);
    }

    /**
594
     * 工位之间载具流转回传
595
     */
596
597
    @PostMapping("/backChangeStation")
    @ApiLogger(from = "WMS", to = "MES", apiName = "工位之间载具流转回传")
598
    public AjaxResult backEmpty(String id) {
599
        if (StringUtils.isEmpty(id)) {
600
            return AjaxResult.error("任务id不能为空");
601
        }
602
        return mesService.backChangeStation(id);
603
    }
604
605
606
607
608

    /**
     * MES质检查询
     */
    @PostMapping("/searchInventoryByQC")
609
610
    @ApiOperation("MES质检抽样查询")
    @ApiLogger(apiName = "MES质检抽样查询", from = "MES")
611
612
613
614
    public AjaxResultMES searchInventoryByQC(@RequestBody MesSearchRequestByQCDto mesSearchRequestByQCDto) {
        String taskNo = mesSearchRequestByQCDto.getTaskNo();
        String orderCode = mesSearchRequestByQCDto.getOrderCode();
        String materialCode = mesSearchRequestByQCDto.getMaterialCode();
615
616
617
618
619
620
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResultMES.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResultMES.error("orderCode 为空");
        }
621
622
        if (StringUtils.isEmpty(materialCode)) {
            return AjaxResultMES.error("materialCode 为空");
623
624
        }
        try {
625
            return mesService.searchInventoryByQC(mesSearchRequestByQCDto);
626
627
628
629
        } catch (Exception e) {
            return AjaxResultMES.error(e.getMessage());
        }
    }
630
631
632
633
634
635
636
637
638
639

    /**
     * MES质检抽样出库
     */
    @PostMapping("/shipmentByQC")
    @ApiOperation("MES质检抽样出库")
    @ApiLogger(apiName = "MES质检抽样出库", from = "MES")
    public AjaxResultMES shipmentByQC(@RequestBody MesShipmentByQCDto mesShipmentByQCDto) {
        String taskNo = mesShipmentByQCDto.getTaskNo();
        String orderCode = mesShipmentByQCDto.getOrderCode();
640
        //String shipmentReferCode = mesShipmentByQCDto.getShipmentReferCode();
641
642
        List<String> locationCode = mesShipmentByQCDto.getLocationCodeList();
        String toPort = mesShipmentByQCDto.getToPort();
643
        Integer sampleType = mesShipmentByQCDto.getSampleType();
644
645
646
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResultMES.error("taskNo 为空");
        }
647
        /*if (StringUtils.isEmpty(shipmentReferCode)) {
648
            return AjaxResultMES.error("shipmentReferCode 为空");
649
        }*/
650
651
652
653
654
655
656
657
658
        if (StringUtils.isEmpty(locationCode)) {
            return AjaxResultMES.error("locationCode 为空");
        }
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResultMES.error("orderCode 为空");
        }
        if (StringUtils.isEmpty(toPort)) {
            return AjaxResultMES.error("toPort 为空");
        }
659
660
661
        if (StringUtils.isNull(sampleType)) {
            return AjaxResultMES.error("SIPType 为空");
        }
662
663
664
665
666
667
        try {
            return mesService.shipmentByQC(mesShipmentByQCDto);
        } catch (Exception e) {
            return AjaxResultMES.error(e.getMessage());
        }
    }
668
669

    /**
670
     * MES质检抽样余料回库
671
672
673
674
675
676
     */
    @PostMapping("/receiptByQC")
    @ApiOperation("MES质检抽样余料回库")
    @ApiLogger(apiName = "MES质检抽样余料回库", from = "MES")
    public AjaxResultMES receiptByQC(@RequestBody MesReceiptByQCDto mesReceiptByQCDto) {
        String taskNo = mesReceiptByQCDto.getTaskNo();
677
        Integer materialInspectStatus = mesReceiptByQCDto.getMaterialInspectStatus();
678
679
680
681
682
683
684
685
686
687
        String fromPort = mesReceiptByQCDto.getFromPort();
        String orderCode = mesReceiptByQCDto.getOrderCode();
        String containerCode = mesReceiptByQCDto.getContainerCode();
        String containerTypeCode = mesReceiptByQCDto.getContainerTypeCode();
        String vehicleCode = mesReceiptByQCDto.getVehicleCode();
        String vehicleTypeCode = mesReceiptByQCDto.getVehicleTypeCode();
        List<MaterialData> materialDataList = mesReceiptByQCDto.getMaterialDataList();
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResultMES.error("taskNo 为空");
        }
688
689
        if (StringUtils.isNull(materialInspectStatus)) {
            return AjaxResultMES.error("materialInspectStatus 为空");
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
        }
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResultMES.error("fromPort 为空");
        }
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResultMES.error("orderCode 为空");
        }
        if (StringUtils.isEmpty(containerCode)) {
            return AjaxResultMES.error("containerCode 为空");
        }
        if (StringUtils.isEmpty(containerTypeCode)) {
            return AjaxResultMES.error("toPort 为空");
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResultMES.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResultMES.error("vehicleTypeCode 为空");
        }
        if (StringUtils.isEmpty(materialDataList)) {
            return AjaxResultMES.error("materialDataList 为空");
        }
        try {
            return mesService.receiptByQC(mesReceiptByQCDto);
        } catch (Exception e) {
            return AjaxResultMES.error(e.getMessage());
        }
    }
pengyongcheng authored
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750

    /**
     * 挪料
     */
    @PostMapping("/movingMaterial")
    @ApiOperation("MES挪料")
    @ApiLogger(apiName = "MES挪料", from = "MES")
    public AjaxResultMES movingMaterial(@RequestBody MesMovingMaterialDto mesMovingMaterialDto) {
        if (Objects.isNull(mesMovingMaterialDto)) {
            return AjaxResultMES.error("挪料对象 mesMovingMaterialDto 为空");
        }
        String sourceOrderCode = mesMovingMaterialDto.getSourceOrderCode();
        String targetOrderCode = mesMovingMaterialDto.getTargetOrderCode();
        String materialCode = mesMovingMaterialDto.getMaterialCode();
        BigDecimal qty = mesMovingMaterialDto.getQty();
        if (StringUtils.isEmpty(sourceOrderCode)) {
            return AjaxResultMES.error("sourceOrderCode 为空");
        }
        if (StringUtils.isNull(targetOrderCode)) {
            return AjaxResultMES.error("targetOrderCode 为空");
        }
        if (StringUtils.isEmpty(materialCode)) {
            return AjaxResultMES.error("materialCode 为空");
        }
        if (Objects.isNull(qty) || qty.compareTo(BigDecimal.ZERO) <= 0) {
            return AjaxResultMES.error("qty 为空或 qty小于等于0");
        }
        try {
            return mesService.movingMaterial(mesMovingMaterialDto);
        } catch (Exception e) {
            return AjaxResultMES.error(e.getMessage());
        }
    }
肖超群 authored
751
}