Blame view

src/main/java/com/huaheng/api/mes/controller/MesController.java 29.5 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
     */
192
193

    @Deprecated
肖超群 authored
194
195
    @PostMapping("/receiptOrder")
    @ApiOperation("MES工单入库单")
196
    @ApiLogger(apiName = "MES工单入库单", from = "MES")
肖超群 authored
197
    public AjaxResult receiptOrder(@RequestBody MesOrder mesOrder) {
198
        String orderCode = mesOrder.getOrderCode();
肖超群 authored
199
        String taskNo = mesOrder.getTaskNo();
200
        List<MesOrderMaterial> list = mesOrder.getMaterialDataList();
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())) {
208
209
            return AjaxResult.error("chidOrderCode 为空");
        }
210
        if (mesOrder.getOrderStatus() == null) {
211
212
            return AjaxResult.error("orderStatus 为空");
        }
213
        if (StringUtils.isEmpty(mesOrder.getReceiptReferCode())) {
214
215
            return AjaxResult.error("receiptReferCode 为空");
        }
216
        if (StringUtils.isEmpty(list) || list.isEmpty()) {
217
            return AjaxResult.error("materialDataList 为空");
肖超群 authored
218
        }
219
        return handleMultiProcess(() -> mesService.receiptOrder(mesOrder));
肖超群 authored
220
221
222
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
669
     * MES质检抽样余料回库
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
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
     */
    @PostMapping("/receiptByQC")
    @ApiOperation("MES质检抽样余料回库")
    @ApiLogger(apiName = "MES质检抽样余料回库", from = "MES")
    public AjaxResultMES receiptByQC(@RequestBody MesReceiptByQCDto mesReceiptByQCDto) {
        String taskNo = mesReceiptByQCDto.getTaskNo();
        Integer sipType = mesReceiptByQCDto.getSipType();
        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 为空");
        }
        if (StringUtils.isNull(sipType)) {
            return AjaxResultMES.error("sipType 为空");
        }
        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
717
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

    /**
     * 挪料
     */
    @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
750
}