Blame view

src/main/java/com/huaheng/api/mes/controller/MesController.java 18 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.exception.service.MesServiceException;
肖超群 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
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
12
import com.huaheng.pc.receipt.workOrder.service.WorkOrderService;
肖超群 authored
13
14
15
16
17
18
import com.huaheng.pc.task.taskHeader.service.WorkTaskService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
19
import java.util.HashMap;
肖超群 authored
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 InventoryDetailService inventoryDetailService;
    @Resource
    private MesService mesService;
35
36
    @Resource
    private WorkOrderService workOrderService;
肖超群 authored
37
38
39

    /**
     * 生成空托盘入库任务
40
     *
肖超群 authored
41
42
43
44
     * @return
     */
    @PostMapping("/receiptEmptyContainer")
    @ApiOperation("生成空托盘入库任务")
45
    @ApiLogger(apiName = "生成空托盘入库任务", from = "mes")
肖超群 authored
46
    @ResponseBody
47
    public AjaxResult receiptEmptyContainer(@RequestBody MesEmptyContainer mesEmptyContainer) {
48
        String containerTypeCode = mesEmptyContainer.getContainerTypeCode();
49
50
51
        String taskNo = mesEmptyContainer.getTaskNo();
        String toPort = mesEmptyContainer.getToPort();
        String containerCode = mesEmptyContainer.getContainerCode();
52
53
        String vehicleTypeCode = mesEmptyContainer.getVehicleTypeCode();
        String vehicleCode = mesEmptyContainer.getVehicleCode();
54
55
56
        if (StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("containerCode 为空");
        }
57
58
        if (StringUtils.isEmpty(containerTypeCode)) {
            return AjaxResult.error("containerTypeCode 为空");
59
60
61
62
63
64
65
        }
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
        if (StringUtils.isEmpty(toPort)) {
            return AjaxResult.error("toPort 为空");
        }
66
67
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
68
        }
69
70
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
71
72
73
74
75
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = workTaskService.createEmptyIn(
76
                        taskNo, toPort, containerCode, vehicleTypeCode, vehicleCode, null);
77
78
79
80
                return ajaxResult;
            }
        });
        return ajaxResult;
肖超群 authored
81
82
83
84
    }

    /**
     * MES下发空托盘出库
85
     *
肖超群 authored
86
87
88
89
     * @return
     */
    @PostMapping("/shipmentEmptyContainer")
    @ApiOperation("MES下发空托盘出库")
90
    @ApiLogger(apiName = "MES下发空托盘出库", from = "MES")
肖超群 authored
91
    public AjaxResult shipmentEmptyContainer(@RequestBody MesEmptyContainer mesEmptyContainer) {
92
        String containerTypeCode = mesEmptyContainer.getContainerTypeCode();
肖超群 authored
93
94
        String taskNo = mesEmptyContainer.getTaskNo();
        String toPort = mesEmptyContainer.getToPort();
95
96
        String vehicleTypeCode = mesEmptyContainer.getVehicleTypeCode();
        if (StringUtils.isEmpty(containerTypeCode)) {
肖超群 authored
97
98
            return AjaxResult.error("containerTypeNo 为空");
        }
99
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
100
101
            return AjaxResult.error("taskNo 为空");
        }
102
        if (StringUtils.isEmpty(toPort)) {
肖超群 authored
103
104
            return AjaxResult.error("toPort 为空");
        }
105
106
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
肖超群 authored
107
108
109
110
111
112
        }

        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = workTaskService.shipmentEmptyContainer(
113
                        taskNo, toPort, vehicleTypeCode);
肖超群 authored
114
115
116
117
118
119
120
121
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    /**
     * MES查询库存
122
     *
肖超群 authored
123
124
125
126
     * @return
     */
    @PostMapping("/searchInventory")
    @ApiOperation("MES查询库存")
127
    @ApiLogger(apiName = "MES查询库存", from = "MES")
128
    public AjaxResultMES searchInventory(@RequestBody MesSearch mesSearch) {
yuxiao authored
129
130
        String taskNo = mesSearch.getTaskNo();
        List<MaterialDataList> 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
139
140
141
        try {
            return mesService.searchInventory(mesSearch);
        }catch (Exception e){
            return AjaxResultMES.error(e.getMessage());
        }
142
    }
肖超群 authored
143
144
145
    /**
     * MES主工单下发
146
     *
147
148
149
150
     * @return
     */
    @PostMapping("/workOrder")
    @ApiOperation("MES主工单下发")
151
    @ApiLogger(apiName = "MES主工单下发", from = "MES")
152
    public 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
        if (workOrder.getOrderStatus() == null) {
160
161
            return AjaxResult.error("orderStatus 为空");
        }
162
        if (StringUtils.isEmpty(workOrder.getProductCode())) {
163
164
            return AjaxResult.error("productCode 为空");
        }
165
        if (workOrder.getProductQty() == null) {
166
167
            return AjaxResult.error("productQty 为空");
        }
168
        if (StringUtils.isEmpty(workOrder.getPlanStartTime())) {
169
170
            return AjaxResult.error("planStartTime 为空");
        }
171
        if (StringUtils.isEmpty(workOrder.getPlanEndTime())) {
172
173
            return AjaxResult.error("planEndTime 为空");
        }
174
        if (StringUtils.isEmpty(workOrder.getMaterialDataList()) || workOrder.getMaterialDataList().size() == 0 ) {
175
            return AjaxResult.error("materialDataList 为空");
176
        }
177
        return mesService.workOrder(workOrder);
肖超群 authored
178
179
180
181
    }

    /**
     * MES工单入库单
182
     *
肖超群 authored
183
184
185
186
     * @return
     */
    @PostMapping("/receiptOrder")
    @ApiOperation("MES工单入库单")
187
    @ApiLogger(apiName = "MES工单入库单", from = "MES")
肖超群 authored
188
    public AjaxResult receiptOrder(@RequestBody MesOrder mesOrder) {
189
        String orderCode = mesOrder.getOrderCode();
肖超群 authored
190
        String taskNo = mesOrder.getTaskNo();
191
        List<MesOrderMaterial> list = mesOrder.getMaterialDataList();
192
        if (StringUtils.isEmpty(orderCode)) {
肖超群 authored
193
194
            return AjaxResult.error("orderCode 为空");
        }
195
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
196
197
            return AjaxResult.error("taskNo 为空");
        }
198
199
200
201
202
203
204
205
206
        if (StringUtils.isEmpty(mesOrder.getChidOrderCode())){
            return AjaxResult.error("chidOrderCode 为空");
        }
        if (mesOrder.getOrderStatus() == null){
            return AjaxResult.error("orderStatus 为空");
        }
        if (StringUtils.isEmpty(mesOrder.getReceiptReferCode())){
            return AjaxResult.error("receiptReferCode 为空");
        }
207
        if (StringUtils.isEmpty(list) || list.size() == 0) {
208
            return AjaxResult.error("materialDataList 为空");
肖超群 authored
209
210
211
212
213
214
215
216
217
218
219
220
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.receiptOrder(mesOrder);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

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

    /**
     * MES成品出库
268
     *
肖超群 authored
269
270
271
272
     * @return
     */
    @PostMapping("/shipmentProduct")
    @ApiOperation("MES成品出库")
273
    @ApiLogger(apiName = "MES成品出库", from = "MES")
肖超群 authored
274
275
276
277
278
    public AjaxResult shipmentProduct(@RequestBody MesShipmentProduct mesShipmentProduct) {
        String containerCode = mesShipmentProduct.getContainerCode();
        String fromPort = mesShipmentProduct.getFromPort();
        String toPort = mesShipmentProduct.getToPort();
        String taskNo = mesShipmentProduct.getTaskNo();
279
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
280
281
            return AjaxResult.error("containerCode 为空");
        }
282
        if (StringUtils.isEmpty(fromPort)) {
肖超群 authored
283
284
            return AjaxResult.error("fromPort 为空");
        }
285
        if (StringUtils.isEmpty(toPort)) {
肖超群 authored
286
287
            return AjaxResult.error("toPort 为空");
        }
288
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
289
290
291
292
293
294
295
296
297
298
299
300
301
302
            return AjaxResult.error("taskNo 为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.shipmentProduct(mesShipmentProduct);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    /**
     * MES物料入库
303
     *
肖超群 authored
304
305
306
307
     * @return
     */
    @PostMapping("/receipt")
    @ApiOperation("MES物料入库")
308
    @ApiLogger(apiName = "MES物料入库", from = "MES")
肖超群 authored
309
310
    public AjaxResult receipt(@RequestBody MesReceipt mesReceipt) {
        String taskNo = mesReceipt.getTaskNo();
311
        String orderCode = mesReceipt.getOrderCode();
312
        String contaienrType = mesReceipt.getContainerTypeCode();
肖超群 authored
313
314
        String containerCode = mesReceipt.getContainerCode();
        String toPort = mesReceipt.getToPort();
315
316
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
317
        List<MaterialData> materialData = mesReceipt.getMaterialDataList();
肖超群 authored
318
319
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
320
321
            return AjaxResult.error("taskNo 为空");
        }
322
323
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
肖超群 authored
324
        }
325
326
        if (StringUtils.isEmpty(contaienrType)) {
            return AjaxResult.error("contaienrType 为空");
肖超群 authored
327
        }
328
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
329
330
            return AjaxResult.error("containerCode 为空");
        }
331
        if (StringUtils.isEmpty(toPort)) {
肖超群 authored
332
333
            return AjaxResult.error("toPort 为空");
        }
334
335
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
肖超群 authored
336
        }
337
338
339
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
        }
340
        if (StringUtils.isEmpty(materialData) || materialData.size() == 0) {
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
            return AjaxResult.error("materialData 为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.receipt(mesReceipt);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    /**
     * 原材料入库
     *
     * @return
     */
    @PostMapping("/rawReceipt")
    @ApiOperation("原材料入库")
    @ApiLogger(apiName = "原材料入库", from = "MES")
    public AjaxResult rawReceipt(@RequestBody MesReceipt mesReceipt) {
        String taskNo = mesReceipt.getTaskNo();
363
        String contaienrType = mesReceipt.getContainerTypeCode();
364
365
366
367
        String containerCode = mesReceipt.getContainerCode();
        String toPort = mesReceipt.getToPort();
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
368
        List<MaterialData> materialData = mesReceipt.getMaterialDataList();
369
370
371
372
373
374
375
376
377
378
379
380
381
        HashMap<String, String> quTest = new HashMap<>();
        for(MaterialData data : mesReceipt.getMaterialDataList()){
            if(data.getLocationNoX() == -1 || data.getLocationNoY() == -1){
                return AjaxResult.error("请填写xy信息");
            }
            String key =  data.getLocationNoX().toString() + "  " + data.getLocationNoY().toString();
            if(quTest.get(key) == null){
                quTest.put(key, key);
            }else{
                return AjaxResult.error("坐标重复: " + key);
            }
        }
382
383
384
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
385
386
        if (StringUtils.isEmpty(contaienrType)) {
            return AjaxResult.error("contaienrType 为空");
387
388
389
390
391
392
393
394
395
396
397
398
        }
        if (StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("containerCode 为空");
        }
        if (StringUtils.isEmpty(toPort)) {
            return AjaxResult.error("toPort 为空");
        }
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
肖超群 authored
399
        }
400
        if (StringUtils.isEmpty(materialData) || materialData.size() == 0) {
肖超群 authored
401
402
403
404
405
406
407
408
409
410
411
            return AjaxResult.error("materialData 为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.receipt(mesReceipt);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
412
413
414
415
416
417
418

    /**
     * 物料出库
     * @return
     */
    @PostMapping("/shipment")
    @ApiOperation("物料出库")
yuxiao authored
419
    @ApiLogger(apiName = "物料出库", from = "MES")
420
421
422
423
424
425
426
427
428
429
430
431
432
    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 为空");
        }
433
434
435
436
//        if (StringUtils.isEmpty(mesShipment.getSequence())) {
//            return AjaxResult.error("sequence 为空");
//        }
        if (mesShipment.getVehicleinsert() == null) {
437
            return AjaxResult.error("vehicleinsert 为空");
438
        }
439
        if (StringUtils.isEmpty(mesShipment.getMaterialDataList()) || mesShipment.getMaterialDataList().size() == 0) {
440
441
442
443
444
445
446
447
448
449
450
            return AjaxResult.error("materialData 为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.shipment(mesShipment);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482

    /**
     *  入库回传
     */
    @PostMapping("/backReceipt")
    @ResponseBody
    @ApiLogger(from = "WMS", to = "MES", apiName = "入库回传")
    public AjaxResult backReceipt(String id) {
        if (StringUtils.isEmpty(id)){
            return AjaxResult.error("id不能为空");
        }
        return mesService.backReceipt(id);
    }

    /**
     *	出库回传
     */
    @PostMapping( "/backShipment")
    @ResponseBody
    @ApiLogger(from = "WMS", to = "MES", apiName = "出库回传")
    public AjaxResult backShipment(String id){
        if (StringUtils.isEmpty(id)) {
            return AjaxResult.error("id不能为空");
        }
        return mesService.backShipment(id);
    }

    /**
     * 空容器入库出库回传
     */
    @PostMapping( "/backEmpty")
    @ResponseBody
483
    @ApiLogger(from = "WMS", to = "MES", apiName = "空容器任务回传")
484
485
486
487
488
489
    public AjaxResult backEmpty(String id){
        if (StringUtils.isEmpty(id)) {
            return AjaxResult.error("id不能为空");
        }
        return mesService.backEmpty(id);
    }
肖超群 authored
490
}