Blame view

src/main/java/com/huaheng/api/mes/controller/MesController.java 16.6 KB
肖超群 authored
1
2
3
4
5
6
7
8
9
10
11
12
package com.huaheng.api.mes.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.mes.domain.*;
import com.huaheng.api.mes.service.MesService;
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.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
13
14
import com.huaheng.pc.receipt.workOrder.domain.WorkOrder;
import com.huaheng.pc.receipt.workOrder.service.WorkOrderService;
肖超群 authored
15
16
17
18
19
20
21
22
23
24
25
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskHeader.service.WorkTaskService;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.lang.ref.WeakReference;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
26
import java.util.Objects;
肖超群 authored
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.stream.Collectors;

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

    @Resource
    private WorkTaskService workTaskService;
    @Resource
    private InventoryDetailService inventoryDetailService;
    @Resource
    private MesService mesService;
42
43
    @Resource
    private WorkOrderService workOrderService;
肖超群 authored
44
45
46

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

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

        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = workTaskService.shipmentEmptyContainer(
120
                        taskNo, toPort, vehicleTypeCode);
肖超群 authored
121
122
123
124
125
126
127
128
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

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

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

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

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

    /**
     * MES物料入库
306
     *
肖超群 authored
307
308
309
310
     * @return
     */
    @PostMapping("/receipt")
    @ApiOperation("MES物料入库")
311
    @ApiLogger(apiName = "MES物料入库", from = "MES")
肖超群 authored
312
313
    public AjaxResult receipt(@RequestBody MesReceipt mesReceipt) {
        String taskNo = mesReceipt.getTaskNo();
314
        String orderCode = mesReceipt.getOrderCode();
315
        String contaienrType = mesReceipt.getContainerTypeCode();
肖超群 authored
316
317
        String containerCode = mesReceipt.getContainerCode();
        String toPort = mesReceipt.getToPort();
318
319
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
320
        List<MaterialData> materialData = mesReceipt.getMaterialDataList();
肖超群 authored
321
322
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
323
324
            return AjaxResult.error("taskNo 为空");
        }
325
326
        if (StringUtils.isEmpty(orderCode)) {
            return AjaxResult.error("orderCode 为空");
肖超群 authored
327
        }
328
329
        if (StringUtils.isEmpty(contaienrType)) {
            return AjaxResult.error("contaienrType 为空");
肖超群 authored
330
        }
331
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
332
333
            return AjaxResult.error("containerCode 为空");
        }
334
        if (StringUtils.isEmpty(toPort)) {
肖超群 authored
335
336
            return AjaxResult.error("toPort 为空");
        }
337
338
        if (StringUtils.isEmpty(vehicleCode)) {
            return AjaxResult.error("vehicleCode 为空");
肖超群 authored
339
        }
340
341
342
        if (StringUtils.isEmpty(vehicleTypeCode)) {
            return AjaxResult.error("vehicleTypeCode 为空");
        }
343
        if (StringUtils.isEmpty(materialData) || materialData.size() == 0) {
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
            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();
366
        String contaienrType = mesReceipt.getContainerTypeCode();
367
368
369
370
        String containerCode = mesReceipt.getContainerCode();
        String toPort = mesReceipt.getToPort();
        String vehicleCode = mesReceipt.getVehicleCode();
        String vehicleTypeCode = mesReceipt.getVehicleTypeCode();
371
        List<MaterialData> materialData = mesReceipt.getMaterialDataList();
372
373
374
        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
375
376
        if (StringUtils.isEmpty(contaienrType)) {
            return AjaxResult.error("contaienrType 为空");
377
378
379
380
381
382
383
384
385
386
387
388
        }
        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
389
        }
390
        if (StringUtils.isEmpty(materialData) || materialData.size() == 0) {
肖超群 authored
391
392
393
394
395
396
397
398
399
400
401
            return AjaxResult.error("materialData 为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.receipt(mesReceipt);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
402
403
404
405
406
407
408

    /**
     * 物料出库
     * @return
     */
    @PostMapping("/shipment")
    @ApiOperation("物料出库")
yuxiao authored
409
    @ApiLogger(apiName = "物料出库", from = "MES")
410
411
412
413
414
415
416
417
418
419
420
421
422
    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 为空");
        }
423
424
        if (StringUtils.isEmpty(mesShipment.getSequence())) {
            return AjaxResult.error("sequence 为空");
425
        }
426
427
        if (StringUtils.isEmpty(mesShipment.getVehicleinsert())) {
            return AjaxResult.error("vehicleinsert 为空");
428
        }
429
        if (StringUtils.isEmpty(mesShipment.getMaterialDataList()) || mesShipment.getMaterialDataList().size() == 0) {
430
431
432
433
434
435
436
437
438
439
440
            return AjaxResult.error("materialData 为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.shipment(mesShipment);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
肖超群 authored
441
}