Blame view

src/main/java/com/huaheng/api/mes/controller/MesController.java 15.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 WorkOrder 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.getMaterialCode())) {
178
179
            return AjaxResult.error("materialCode 为空");
        }
180
        if (workOrder.getMaterialQty() == null) {
181
182
            return AjaxResult.error("materialQty 为空");
        }
183
        if (workOrder.getIsMaterial() == null) {
184
185
186
            return AjaxResult.error("isMaterial 为空");
        }
        return AjaxResult.toAjax(workOrderService.save(workOrder));
肖超群 authored
187
188
189
190
    }

    /**
     * MES工单入库单
191
     *
肖超群 authored
192
193
194
195
     * @return
     */
    @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
201
        List<MesOrderMaterial> list = mesOrder.getMesOrderMaterial();
        if (StringUtils.isEmpty(orderCode)) {
肖超群 authored
202
203
            return AjaxResult.error("orderCode 为空");
        }
204
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
205
206
            return AjaxResult.error("taskNo 为空");
        }
207
208
        if (list == null) {
            return AjaxResult.error("mesOrderMaterial 为空");
肖超群 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
        if (orderQty == null) {
肖超群 authored
239
240
            return AjaxResult.error("orderQty 为空");
        }
241
        if (mesOrder.getMesOrderMaterial().size() == 0) {
242
243
            return AjaxResult.error("mesOrderMaterial 为空");
        }
肖超群 authored
244
245
246
247
248
249
250
251
252
253
254
255
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.shipmentOrder(mesOrder);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

    /**
     * MES成品出库
256
     *
肖超群 authored
257
258
259
260
     * @return
     */
    @PostMapping("/shipmentProduct")
    @ApiOperation("MES成品出库")
261
    @ApiLogger(apiName = "MES成品出库", from = "MES")
肖超群 authored
262
263
264
265
266
    public AjaxResult shipmentProduct(@RequestBody MesShipmentProduct mesShipmentProduct) {
        String containerCode = mesShipmentProduct.getContainerCode();
        String fromPort = mesShipmentProduct.getFromPort();
        String toPort = mesShipmentProduct.getToPort();
        String taskNo = mesShipmentProduct.getTaskNo();
267
        if (StringUtils.isEmpty(containerCode)) {
肖超群 authored
268
269
            return AjaxResult.error("containerCode 为空");
        }
270
        if (StringUtils.isEmpty(fromPort)) {
肖超群 authored
271
272
            return AjaxResult.error("fromPort 为空");
        }
273
        if (StringUtils.isEmpty(toPort)) {
肖超群 authored
274
275
            return AjaxResult.error("toPort 为空");
        }
276
        if (StringUtils.isEmpty(taskNo)) {
肖超群 authored
277
278
279
280
281
282
283
284
285
286
287
288
289
290
            return AjaxResult.error("taskNo 为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.shipmentProduct(mesShipmentProduct);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }

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

        if (StringUtils.isEmpty(taskNo)) {
            return AjaxResult.error("taskNo 为空");
        }
361
362
        if (StringUtils.isEmpty(contaienrType)) {
            return AjaxResult.error("contaienrType 为空");
363
364
365
366
367
368
369
370
371
372
373
374
        }
        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
375
        }
376
        if (materialData.size() == 0) {
肖超群 authored
377
378
379
380
381
382
383
384
385
386
387
            return AjaxResult.error("materialData 为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.receipt(mesReceipt);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
388
389
390
391
392
393
394

    /**
     * 物料出库
     * @return
     */
    @PostMapping("/shipment")
    @ApiOperation("物料出库")
yuxiao authored
395
    @ApiLogger(apiName = "物料出库", from = "MES")
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
    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 为空");
        }
        if (StringUtils.isEmpty(mesShipment.getVehicleCode())) {
            return AjaxResult.error("vehicleCode 为空");
        }
        if (StringUtils.isEmpty(mesShipment.getVehicleTypeCode())) {
            return AjaxResult.error("vehicleTypeCode 为空");
        }
        if (mesShipment.getMaterialDataList().size() == 0) {
            return AjaxResult.error("materialData 为空");
        }
        AjaxResult ajaxResult = handleMultiProcess(new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = mesService.shipment(mesShipment);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
肖超群 authored
427
}