Blame view

src/main/java/com/huaheng/api/mes/controller/MesController.java 26.9 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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.List;

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

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

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

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

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

    /**
162
     * MES工单入库单(弃用)
163
164
     * 已经取消该接口 9
     *
肖超群 authored
165
166
     * @return
     */
pengyongcheng authored
167
    /*@Deprecated
肖超群 authored
168
169
    @PostMapping("/receiptOrder")
    @ApiOperation("MES工单入库单")
170
    @ApiLogger(apiName = "MES工单入库单", from = "MES")
肖超群 authored
171
    public AjaxResult receiptOrder(@RequestBody MesOrder mesOrder) {
172
        String orderCode = mesOrder.getOrderCode();
肖超群 authored
173
        String taskNo = mesOrder.getTaskNo();
174
        List<MesOrderMaterial> list = mesOrder.getMaterialDataList();
175
        if (StringUtils.isEmpty(orderCode)) {
肖超群 authored
176
177
            return AjaxResult.error("orderCode 为空");
        }
178
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
179
180
            return AjaxResult.error("taskNo 为空");
        }
181
        if (StringUtils.isEmpty(mesOrder.getChidOrderCode())) {
182
183
            return AjaxResult.error("chidOrderCode 为空");
        }
184
        if (mesOrder.getOrderStatus() == null) {
185
186
            return AjaxResult.error("orderStatus 为空");
        }
187
        if (StringUtils.isEmpty(mesOrder.getReceiptReferCode())) {
188
189
            return AjaxResult.error("receiptReferCode 为空");
        }
190
        if (StringUtils.isEmpty(list) || list.isEmpty()) {
191
            return AjaxResult.error("materialDataList 为空");
肖超群 authored
192
        }
193
        return handleMultiProcess(() -> mesService.receiptOrder(mesOrder));
pengyongcheng authored
194
    }*/
肖超群 authored
195
196

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

    /**
pengyongcheng authored
236
     * MES成品出库(弃用)
237
     *
肖超群 authored
238
239
     * @return
     */
pengyongcheng authored
240
    /*@PostMapping("/shipmentProduct")
肖超群 authored
241
    @ApiOperation("MES成品出库")
242
    @ApiLogger(apiName = "MES成品出库", from = "MES")
243
    public AjaxResult shipmentProduct(@RequestBody MesShipmentProduct mesShipmentProduct) {
肖超群 authored
244
        String containerCode = mesShipmentProduct.getContainerCode();
245
246
        String fromPort = mesShipmentProduct.getFromPort();
        String toPort = mesShipmentProduct.getToPort();
肖超群 authored
247
        String taskNo = mesShipmentProduct.getTaskNo();
248
249
        String vehicleCode = mesShipmentProduct.getVehicleCode();
        String orderCode = mesShipmentProduct.getOrderCode();
250
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
251
252
            return AjaxResult.error("containerCode 为空");
        }
253
254
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
肖超群 authored
255
        }
256
257
        if (StringUtils.isEmpty(toPort)) {
            return AjaxResult.error("toPort 为空");
肖超群 authored
258
        }
259
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
260
261
            return AjaxResult.error("taskNo 为空");
        }
262
263
264
265
266
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
267
        }
268
        return handleMultiProcess(() -> mesService.shipmentProduct(mesShipmentProduct));
pengyongcheng authored
269
    }*/
肖超群 authored
270
271

    /**
272
273
274
275
276
277
278
279
280
     * 工位之间载具流转 11
     *
     * @return
     */
    @PostMapping("/overStation")
    @ApiOperation("MES载具流转")
    @ApiLogger(apiName = "MES载具流转", from = "MES")
    public AjaxResult overStation(@RequestBody MesOverStationDto mesOverStationDto) {
        String containerCode = mesOverStationDto.getContainerCode();
281
282
        String fromPort = mesOverStationDto.getFromPort();
        String toPort = mesOverStationDto.getToPort();
283
284
285
286
287
288
        String taskNo = mesOverStationDto.getTaskNo();
        String vehicleCode = mesOverStationDto.getVehicleCode();
        String orderCode = mesOverStationDto.getOrderCode();
        if (StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("containerCode 为空");
        }
289
        if (StringUtils.isEmpty(fromPort)) {
290
            return AjaxResult.error("fromPort 为空");
291
        }
292
        if (StringUtils.isEmpty(toPort)) {
293
            return AjaxResult.error("toPort 为空");
294
295
296
297
298
299
300
301
302
303
        }
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
        }
304
305
306
        // 交换载具盛具的值,MES给的与WMS的是反的
        mesOverStationDto.setContainerCode(vehicleCode);
        mesOverStationDto.setVehicleCode(containerCode);
307
308
309
310
        return handleMultiProcess(() -> mesService.createOverStation(mesOverStationDto));
    }

    /**
肖超群 authored
311
     * MES物料入库
312
313
     * 6 料点呼叫移走物料
     *
肖超群 authored
314
315
316
317
     * @return
     */
    @PostMapping("/receipt")
    @ApiOperation("MES物料入库")
周峰 authored
318
    @ApiLogger(apiName = "6 MES物料入库", from = "MES")
肖超群 authored
319
320
    public AjaxResult receipt(@RequestBody MesReceipt mesReceipt) {
        String taskNo = mesReceipt.getTaskNo();
周峰 authored
321
322
        //设置入库单类型为半成品入库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_SEMI);
323
        String orderCode = mesReceipt.getOrderCode();
肖超群 authored
324
        String containerCode = mesReceipt.getContainerCode();
pengyongcheng authored
325
        String fromPort = mesReceipt.getFromPort();
326
        String vehicleCode = mesReceipt.getVehicleCode();
pengyongcheng authored
327
        List<ReceiptMaterialData> materialDataList = mesReceipt.getReceiptMaterialDataList();
肖超群 authored
328
329
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
330
331
            return AjaxResult.error("taskNo 为空");
        }
332
333
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
肖超群 authored
334
        }
335
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
336
337
            return AjaxResult.error("containerCode 为空");
        }
pengyongcheng authored
338
339
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
肖超群 authored
340
        }
341
342
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
肖超群 authored
343
        }
344
345
        if (StringUtils.isEmpty(materialDataList)) {
            return AjaxResult.error("materialDataList 为空");
346
        }
347
        HashMap<String, String> quTest = new HashMap<>();
pengyongcheng authored
348
        for (ReceiptMaterialData data : mesReceipt.getReceiptMaterialDataList()) {
349
350
351
            if (data.getLocationNoX() == null || data.getLocationNoY() == null) {
                return AjaxResult.error("物料信息坐标为空");
            }
352
            if (data.getLocationNoX() == -1 || data.getLocationNoY() == -1) {
353
                return AjaxResult.error("物料信息坐标错误");
354
355
356
357
358
359
360
361
            }
            String key = data.getLocationNoX() + "  " + data.getLocationNoY();
            if (quTest.get(key) == null) {
                quTest.put(key, key);
            } else {
                return AjaxResult.error("坐标重复: " + key);
            }
        }
362
363
364
        // 交换载具盛具的值,MES给的与WMS的是反的
        mesReceipt.setContainerCode(vehicleCode);
        mesReceipt.setVehicleCode(containerCode);
365
        return handleMultiProcess(() -> mesService.receipt(mesReceipt));
366
367
368
    }

    /**
周峰 authored
369
     * 10余料回库
370
371
372
373
     *
     * @return
     */
    @PostMapping("/rawReceipt")
374
    @ApiOperation("余料回库")
周峰 authored
375
    @ApiLogger(apiName = "10 余料回库", from = "MES")
376
    public AjaxResult rawReceipt(@RequestBody MesReceipt mesReceipt) {
377
378
379
        //mes调用接口时,代表入库单类型为余料退库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_BACK);
380
381
        String taskNo = mesReceipt.getTaskNo();
382
        String containerCode = mesReceipt.getContainerCode();
pengyongcheng authored
383
        String fromPort = mesReceipt.getFromPort();
384
        String vehicleCode = mesReceipt.getVehicleCode();
pengyongcheng authored
385
        List<ReceiptMaterialData> materialData = mesReceipt.getReceiptMaterialDataList();
386
        HashMap<String, String> quTest = new HashMap<>();
pengyongcheng authored
387
        for (ReceiptMaterialData data : mesReceipt.getReceiptMaterialDataList()) {
388
389
390
            Integer locationNoY = data.getLocationNoY();
            Integer locationNoX = data.getLocationNoX();
            if (locationNoX == null || locationNoY == null) {
391
392
                return AjaxResult.error("物料信息坐标为空");
            }
393
            if (locationNoX == -1 || locationNoY == -1) {
394
                return AjaxResult.error("物料信息坐标错误");
395
            }
396
            String key = locationNoX + "  " + locationNoY;
397
398
399
400
401
402
403
404
405
406
407
408
            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
409
410
        if (StringUtils.isEmpty(fromPort)) {
            return AjaxResult.error("fromPort 为空");
411
412
413
414
415
416
417
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(materialData)) {
            return AjaxResult.error("materialData 为空");
        }
418
419
420
421

        // 交换载具盛具的值,MES给的与WMS的是反的
        mesReceipt.setContainerCode(vehicleCode);
        mesReceipt.setVehicleCode(containerCode);
422
423
424
425
426
427
428
429
430
431
432
433
        return handleMultiProcess(() -> mesService.receipt(mesReceipt));
    }

    /**
     * 原材料入库
     *
     * @return
     */
    @PostMapping("/wmsReceipt")
    @ApiOperation("原材料入库")
    @ApiLogger(apiName = "原材料入库", from = "wms-pc")
    public AjaxResult wmsReceipt(@RequestBody MesReceipt mesReceipt) {
434
435
        //wms调用接口时,代表入库单类型为原材料入库
        mesReceipt.setReceiptType(QuantityConstant.RECEIPT_TYPE_RAW);
436
437
        String taskNo = mesReceipt.getTaskNo();
438
        String orderCode = mesReceipt.getOrderCode();
439
440
        String orderNumber = mesReceipt.getOrderNumber();
        String batchNumber = mesReceipt.getBatchNumber();
441
442
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
pengyongcheng authored
443
        List<ReceiptMaterialData> materialData = mesReceipt.getReceiptMaterialDataList();
444
        HashMap<String, String> quTest = new HashMap<>();
445
446
        // 通用盛具不做校验
        if (!QuantityConstant.VEHICLE_TYPE_COMMON.equals(vehicleTypeCode)) {
pengyongcheng authored
447
            for (ReceiptMaterialData data : mesReceipt.getReceiptMaterialDataList()) {
448
449
450
                if (data.getLocationNoX() == null || data.getLocationNoY() == null) {
                    return AjaxResult.error("物料信息坐标为空");
                }
451
                if (data.getLocationNoX() == -1 || data.getLocationNoY() == -1) {
452
                    return AjaxResult.error("物料信息坐标错误");
453
454
455
456
457
458
459
                }
                String key = data.getLocationNoX() + "  " + data.getLocationNoY();
                if (quTest.get(key) == null) {
                    quTest.put(key, key);
                } else {
                    return AjaxResult.error("坐标重复: " + key);
                }
460
461
            }
        }
462
463
464
465
466
467
468
469
        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
470
        }
周鸿 authored
471
        if (StringUtils.isEmpty(materialData)) {
肖超群 authored
472
473
            return AjaxResult.error("materialData 为空");
        }
474
475
476
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
        }
477
478
479
480
481
482
        if (StringUtils.isEmpty(orderNumber)) {
            return AjaxResult.error("orderNumber 为空");
        }
        if (StringUtils.isEmpty(batchNumber)) {
            return AjaxResult.error("batchNumber 为空");
        }
483
        return handleMultiProcess(() -> mesService.wmsReceipt(mesReceipt));
肖超群 authored
484
    }
485
486
487

    /**
     * 物料出库
周峰 authored
488
     * 4 料点呼叫送物料
489
     *
490
491
492
493
     * @return
     */
    @PostMapping("/shipment")
    @ApiOperation("物料出库")
周峰 authored
494
    @ApiLogger(apiName = "4 物料出库", from = "MES")
495
496
497
498
499
500
501
    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
502
        /*if (StringUtils.isEmpty(mesShipment.getShipmentReferCode())) {
503
            return AjaxResult.error("shipmentReferCode 为空");
pengyongcheng authored
504
        }*/
505
506
507
        if (StringUtils.isEmpty(mesShipment.getToPort())) {
            return AjaxResult.error("toPort 为空");
        }
pengyongcheng authored
508
        /*if (mesShipment.getVehicleinsert() == null) {
509
            return AjaxResult.error("vehicleinsert 为空");
pengyongcheng authored
510
511
        }*/
        if (StringUtils.isEmpty(mesShipment.getShipmentMaterialDataList())) {
512
513
            return AjaxResult.error("materialData 为空");
        }
周峰 authored
514
515
516
517
        if (mesShipment.getSequenceCount() <= 0) {
            return AjaxResult.error("sequenceCount 为空");
        }
518
        if (StringUtils.isEmpty(mesShipment.getSequenceGroup())) {
周峰 authored
519
520
            return AjaxResult.error("sequenceGroup 为空");
        }
521
        return handleMultiProcess(() -> mesService.shipment(mesShipment));
522
    }
523
524

    /**
525
     * 入库回传
526
527
528
     */
    @PostMapping("/backReceipt")
    @ApiLogger(from = "WMS", to = "MES", apiName = "入库回传")
529
530
    public AjaxResult backReceipt(Integer id) {
        if (StringUtils.isNull(id)) {
531
532
533
534
535
536
            return AjaxResult.error("id不能为空");
        }
        return mesService.backReceipt(id);
    }

    /**
537
     * 出库回传
538
     */
539
    @PostMapping("/backShipment")
540
    @ApiLogger(from = "WMS", to = "MES", apiName = "出库回传")
541
    public AjaxResult backShipment(String id) {
542
543
544
545
546
547
548
        if (StringUtils.isEmpty(id)) {
            return AjaxResult.error("id不能为空");
        }
        return mesService.backShipment(id);
    }

    /**
549
     * 工位之间载具流转回传
550
     */
551
552
    @PostMapping("/backChangeStation")
    @ApiLogger(from = "WMS", to = "MES", apiName = "工位之间载具流转回传")
553
    public AjaxResult backEmpty(String id) {
554
        if (StringUtils.isEmpty(id)) {
555
            return AjaxResult.error("任务id不能为空");
556
        }
557
        return mesService.backChangeStation(id);
558
    }
559
560
561
562
563

    /**
     * MES质检查询
     */
    @PostMapping("/searchInventoryByQC")
564
565
    @ApiOperation("MES质检抽样查询")
    @ApiLogger(apiName = "MES质检抽样查询", from = "MES")
566
    public AjaxResult searchInventoryByQC(@RequestBody MesSearchRequestByQCDto mesSearchRequestByQCDto) {
567
568
569
        String taskNo = mesSearchRequestByQCDto.getTaskNo();
        String orderCode = mesSearchRequestByQCDto.getOrderCode();
        String materialCode = mesSearchRequestByQCDto.getMaterialCode();
570
        if (StringUtils.isEmpty(taskNo)) {
571
            return AjaxResult.error("taskNo 为空");
572
573
        }
        if (StringUtils.isEmpty(orderCode)) {
574
            return AjaxResult.error("orderCode 为空");
575
        }
576
        if (StringUtils.isEmpty(materialCode)) {
577
            return AjaxResult.error("materialCode 为空");
578
579
        }
        try {
580
            return mesService.searchInventoryByQC(mesSearchRequestByQCDto);
581
        } catch (Exception e) {
582
            return AjaxResult.error(e.getMessage());
583
584
        }
    }
585
586
587
588
589
590
591

    /**
     * MES质检抽样出库
     */
    @PostMapping("/shipmentByQC")
    @ApiOperation("MES质检抽样出库")
    @ApiLogger(apiName = "MES质检抽样出库", from = "MES")
592
    public AjaxResult shipmentByQC(@RequestBody MesShipmentByQCDto mesShipmentByQCDto) {
593
594
595
596
        String taskNo = mesShipmentByQCDto.getTaskNo();
        String orderCode = mesShipmentByQCDto.getOrderCode();
        List<String> locationCode = mesShipmentByQCDto.getLocationCodeList();
        String toPort = mesShipmentByQCDto.getToPort();
pengyongcheng authored
597
        Integer materialInspectStatus = mesShipmentByQCDto.getMaterialInspectStatus();
598
        if (StringUtils.isEmpty(taskNo)) {
599
            return AjaxResult.error("taskNo 为空");
600
601
        }
        if (StringUtils.isEmpty(locationCode)) {
602
            return AjaxResult.error("locationCode 为空");
603
604
        }
        if (StringUtils.isEmpty(orderCode)) {
605
            return AjaxResult.error("orderCode 为空");
606
607
        }
        if (StringUtils.isEmpty(toPort)) {
608
            return AjaxResult.error("toPort 为空");
609
        }
pengyongcheng authored
610
        if (StringUtils.isNull(materialInspectStatus)) {
611
            return AjaxResult.error("materialStatus 为空");
612
        }
613
614
615
        try {
            return mesService.shipmentByQC(mesShipmentByQCDto);
        } catch (Exception e) {
616
            return AjaxResult.error(e.getMessage());
617
618
        }
    }
619
620

    /**
621
     * MES质检抽样余料回库
622
623
624
625
     */
    @PostMapping("/receiptByQC")
    @ApiOperation("MES质检抽样余料回库")
    @ApiLogger(apiName = "MES质检抽样余料回库", from = "MES")
626
    public AjaxResult receiptByQC(@RequestBody MesReceiptByQCDto mesReceiptByQCDto) {
627
        String taskNo = mesReceiptByQCDto.getTaskNo();
628
        Integer materialInspectStatus = mesReceiptByQCDto.getMaterialInspectStatus();
629
630
631
632
633
634
        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)) {
635
            return AjaxResult.error("taskNo 为空");
636
        }
637
        if (StringUtils.isNull(materialInspectStatus)) {
638
            return AjaxResult.error("materialStatus 为空");
639
640
        }
        if (StringUtils.isEmpty(fromPort)) {
641
            return AjaxResult.error("fromPort 为空");
642
643
        }
        if (StringUtils.isEmpty(orderCode)) {
644
            return AjaxResult.error("orderCode 为空");
645
646
        }
        if (StringUtils.isEmpty(containerCode)) {
647
            return AjaxResult.error("containerCode 为空");
648
649
        }
        if (StringUtils.isEmpty(vehicleCode)) {
650
            return AjaxResult.error("vehicleCode 为空");
651
652
        }
        if (StringUtils.isEmpty(materialDataList)) {
653
            return AjaxResult.error("materialDataList 为空");
654
655
656
657
        }
        try {
            return mesService.receiptByQC(mesReceiptByQCDto);
        } catch (Exception e) {
658
            return AjaxResult.error(e.getMessage());
659
660
        }
    }
pengyongcheng authored
661
662

    /**
663
     * 挪料(弃用)
pengyongcheng authored
664
     */
665
    /*@PostMapping("/movingMaterial")
pengyongcheng authored
666
667
    @ApiOperation("MES挪料")
    @ApiLogger(apiName = "MES挪料", from = "MES")
668
    public AjaxResult movingMaterial(@RequestBody MesMovingMaterialDto mesMovingMaterialDto) {
pengyongcheng authored
669
        if (Objects.isNull(mesMovingMaterialDto)) {
670
            return AjaxResult.error("挪料对象 mesMovingMaterialDto 为空");
pengyongcheng authored
671
672
673
674
675
676
        }
        String sourceOrderCode = mesMovingMaterialDto.getSourceOrderCode();
        String targetOrderCode = mesMovingMaterialDto.getTargetOrderCode();
        String materialCode = mesMovingMaterialDto.getMaterialCode();
        BigDecimal qty = mesMovingMaterialDto.getQty();
        if (StringUtils.isEmpty(sourceOrderCode)) {
677
            return AjaxResult.error("sourceOrderCode 为空");
pengyongcheng authored
678
679
        }
        if (StringUtils.isNull(targetOrderCode)) {
680
            return AjaxResult.error("targetOrderCode 为空");
pengyongcheng authored
681
682
        }
        if (StringUtils.isEmpty(materialCode)) {
683
            return AjaxResult.error("materialCode 为空");
pengyongcheng authored
684
685
        }
        if (Objects.isNull(qty) || qty.compareTo(BigDecimal.ZERO) <= 0) {
686
            return AjaxResult.error("qty 为空或 qty小于等于0");
pengyongcheng authored
687
688
689
690
        }
        try {
            return mesService.movingMaterial(mesMovingMaterialDto);
        } catch (Exception e) {
691
            return AjaxResult.error(e.getMessage());
pengyongcheng authored
692
        }
693
    }*/
肖超群 authored
694
}