Blame view

src/main/java/com/huaheng/api/erp/controller/CodingController.java 16.4 KB
1
2
package com.huaheng.api.erp.controller;
lty authored
3
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
import com.baomidou.mybatisplus.core.metadata.IPage;
lty authored
5
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
6
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
8
import com.huaheng.api.erp.domain.BoxInfo;
import com.huaheng.api.erp.domain.ERPReceipt;
yangxiaoping authored
9
import com.huaheng.api.erp.domain.EmptyZu;
10
11
import com.huaheng.api.erp.domain.ShipmentRecord;
import com.huaheng.api.erp.service.CodingService;
12
import com.huaheng.common.constant.QuantityConstant;
13
import com.huaheng.common.utils.StringUtils;
14
15
16
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
17
18
19
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
lty authored
20
21
22
import com.huaheng.pc.config.proPackaging.domain.ProPackaging;
import com.huaheng.pc.config.proPackaging.service.IProPackagingService;
import com.huaheng.pc.config.proPackaging.service.impl.ProPackagingServiceImpl;
23
24
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
lty authored
25
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
26
27
28
29
30
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
lty authored
31
import java.math.BigDecimal;
lty authored
32
import java.util.ArrayList;
33
import java.util.List;
lty authored
34
import java.util.Map;
35
36
37
38
39
40
41
42
43
44
45

/**
WMS和赋码系统交互
 * @author 游杰
 */
@RestController
@RequestMapping("/API/WMS/v2")
public class CodingController extends BaseController {

    @Resource
    private CodingService codingService;
lty authored
46
47
    @Resource
    private IProPackagingService proPackagingService;
48
49
    @Resource
    private ShipmentHeaderService shipmentHeaderService;
lty authored
50
51
52
53
54
55
56
57
58
59

    @PostMapping("/receipt")
    @ApiOperation("入库组盘信息")
    @ResponseBody
    @ApiLogger(apiName = "入库组盘信息", from="码垛系统")
    public AjaxResult receipt(@RequestBody ERPReceipt erpReceipt) {
        if(erpReceipt == null) {
            return AjaxResult.error("入库组盘信息为空");
        }
lty authored
60
61
        String Pack="";
        Integer so = 0;
lty authored
62
        List<String> Box=new ArrayList<>();
lty authored
63
64
        for(int i = 0;i<erpReceipt.getListBoxInfo().size();i++)
        {
lty authored
65
66
67
68
69
70
            if(Box.contains(erpReceipt.getListBoxInfo().get(i).getBoxCode()))
            {
                return AjaxResult.error("箱码不能重复!!"+erpReceipt.getListBoxInfo().get(i).getBoxCode());
            }
            Box.add(erpReceipt.getListBoxInfo().get(i).getBoxCode());
xcq authored
71
            if (Pack.equals(erpReceipt.getListBoxInfo().get(i).getProPackaging())==false)
lty authored
72
            {
xcq authored
73
74
75
                if (StringUtils.isNotEmpty(erpReceipt.getListBoxInfo().get(i).getProPackaging())){
                    Pack=erpReceipt.getListBoxInfo().get(i).getProPackaging();
                }
lty authored
76
77
78
                LambdaQueryWrapper<ProPackaging> proPackagingLambdaQueryWrapper = Wrappers.lambdaQuery();
                proPackagingLambdaQueryWrapper.eq(ProPackaging::getName,Pack);
                ProPackaging packagingServiceOne = proPackagingService.getOne(proPackagingLambdaQueryWrapper);
xcq authored
79
80
81
82
                if (packagingServiceOne != null){
                    so=packagingServiceOne.getPieceBox();
                }
lty authored
83
84
85
86
87
88
            }
            Integer integer = Integer.valueOf(String.valueOf(erpReceipt.getListBoxInfo().get(i).getQty()));


            if (erpReceipt.getTotalBoxes()==0)
            {
89
                return AjaxResult.error("箱数错误,不该为0");
lty authored
90
91
92
93
            }

            if (erpReceipt.getTotalChips()==0)
            {
94
                return AjaxResult.error("片数错误,不该为0");
lty authored
95
96
97
98
            }

            if (!Integer.valueOf(String.valueOf(erpReceipt.getListBoxInfo().get(i).getQty())).equals(so))
            {
99
                return AjaxResult.error("片数给的与发来的不对");
lty authored
100
101
102
103
            }

            if (erpReceipt.getListBoxInfo().get(i).getChipInfos().size()!=so)
            {
104
                return AjaxResult.error("箱码"+erpReceipt.getListBoxInfo().get(i).getBoxCode()+"所对应的片码不相符合");
lty authored
105
106
107
108
109
            }


        }
110
111
112
113
114
        String containerCode = erpReceipt.getContainerCode();
        String receiptCode = erpReceipt.getReceiptCode();
        String position = erpReceipt.getRequestInCode();
        String orderCode = erpReceipt.getOrderCode();
        String orderName = erpReceipt.getOrderName();
115
        Integer toalCases= erpReceipt.getTotalChips();
116
        BigDecimal weight = erpReceipt.getPieceWeight();
117
        List<BoxInfo> boxInfoList = erpReceipt.getListBoxInfo();
肖超群 authored
118
        int stack = erpReceipt.getStack();
119
120
        int qc = erpReceipt.getQc();
        int orderFinish = erpReceipt.getOrderFinish();
121
        int type = erpReceipt.getType();
122
        String k3Code = erpReceipt.getK3Code();
123
        String inType = erpReceipt.getInType();
124
125
126
        String operatorName = erpReceipt.getOperatorName();
        String qualityorName = erpReceipt.getQualityorName();
127
128
129
130
        if(toalCases==0) {
            return AjaxResult.error("入库组盘信息,总箱数为空");
        }
131
        if(StringUtils.isEmpty(receiptCode)) {
132
133
            return AjaxResult.error("入库组盘信息,排产订单编码为空");
        }
134
        if(StringUtils.isEmpty(containerCode)) {
135
136
            return AjaxResult.error("入库组盘信息,托盘号为空");
        }
137
        if(StringUtils.isEmpty(position)) {
138
139
            return AjaxResult.error("入库组盘信息,码垛站台位置为空");
        }
140
        if(StringUtils.isEmpty(orderCode)) {
141
142
            return AjaxResult.error("入库组盘信息,订单信息为空");
        }
143
        if(StringUtils.isEmpty(orderName)) {
144
145
146
147
148
149
            return AjaxResult.error("入库组盘信息,订单名称为空");
        }
        if(boxInfoList == null) {
            return AjaxResult.error("入库组盘信息,箱信息为空");
        }
150
        AjaxResult ajaxResult = handleMultiProcess("innerReceipt",new MultiProcessListener() {
151
152
            @Override
            public AjaxResult doProcess() {
肖超群 authored
153
                AjaxResult ajaxResult = codingService.innerReceipt(containerCode,
154
                        position, receiptCode, orderCode, orderName, boxInfoList,
155
                        stack, qc, orderFinish,weight, type, k3Code, inType, operatorName, qualityorName,toalCases);
156
157
158
159
160
161
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
lty authored
162
163
164
165
166
167
168
169
170


    @PostMapping("/brickFalling")
    @ApiOperation("掉砖pda接口")
    @ResponseBody
    @ApiLogger(apiName = "掉砖pda接口", from="掉砖pda接口")
    public AjaxResult brickFalling(@RequestBody Map<String,String> map) {
        String boxCode =  map.get("boxCode");
        String containerCode =  map.get("containerCode");
肖超群 authored
171
172
173
174
175
        if(StringUtils.isEmpty(boxCode)) {
            return AjaxResult.error("箱码不为空");
        }
        if(StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("托盘号不为空");
lty authored
176
177
178
179
180
181
182
183
184
185
186
187
188
189
        }
        AjaxResult ajaxResult = handleMultiProcess("brickFalling",new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = codingService.brickFalling(boxCode,containerCode);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
190
191
192
193
    /**
     * 替换备货区的 其他地方不能替换 而且在追溯里面也一并替换
     */
    @PostMapping("/codeSubstitution")
194
    @ApiOperation("备货区箱码补充")
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
    @ResponseBody
    @ApiLogger(apiName = "备货区箱码替换", from="备货区箱码替换")
    public AjaxResult codeSubstitution(@RequestBody Map<String,String> map) {
        //要被替换掉的初始箱码
        String boxCode =  map.get("boxCode");
        //要替换的箱码
        String toBoxCode =  map.get("toBoxCode");
        //容器号
        String containerCode =  map.get("containerCode");
        if(StringUtils.isEmpty(boxCode)) {
            return AjaxResult.error("待箱码不为空");
        }
        if(StringUtils.isEmpty(toBoxCode)) {
            return AjaxResult.error("箱码不为空");
        }
        if(StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("托盘号不为空");
        }
        AjaxResult ajaxResult = handleMultiProcess("codeSubstitution",new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = codingService.codeSubstitution(boxCode,toBoxCode,containerCode);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
225
226
227
228
229
230
231
232
    /**
     * 备货区插入
     */
    @PostMapping("/boxCodeInsert")
    @ApiOperation("备货区插入")
    @ResponseBody
    @ApiLogger(apiName = "备货区插入", from="备货区插入")
    public AjaxResult boxCodeInsert(@RequestBody Map<String,String> map) {
lty authored
233
        //备货区要插那一箱的箱码 根据箱码找组织
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
        String boxCode =  map.get("boxCode");
        //库里面出来的箱码
        String toBoxCode =  map.get("toBoxCode");
        if(StringUtils.isEmpty(boxCode)) {
            return AjaxResult.error("备货区要插那一箱的箱码不为空");
        }
        if(StringUtils.isEmpty(toBoxCode)) {
            return AjaxResult.error("库里面出来的箱码不为空");
        }
        AjaxResult ajaxResult = handleMultiProcess("codeSubstitution",new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = codingService.boxCodeInsert(boxCode,toBoxCode);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
lty authored
254
255
256
257
258
259
260
261
262
263
    /**
     * PDA散片出库功能
     */
    @PostMapping("/bulkDelivery")
    @ApiOperation("PDA散片出库功能")
    @ResponseBody
    @ApiLogger(apiName = "PDA散片出库功能", from="PDA散片出库功能")
    public AjaxResult bulkDelivery(@RequestBody Map<String,String> map) {
        //片码
        String chipCode =  map.get("chipCode");
李泰瑜 authored
264
265
266
267
268
269
270
271
        //箱码
        String boxCode =  map.get("boxCode");
        //
        String shipmentCode =  map.get("shipmentCode");

        if(StringUtils.isEmpty(boxCode)) {
            return AjaxResult.error("箱码不能为空");
        }
lty authored
272
273
274
        if(StringUtils.isEmpty(chipCode)) {
            return AjaxResult.error("片码不能为空");
        }
李泰瑜 authored
275
        if(StringUtils.isEmpty(shipmentCode)) {
lty authored
276
277
278
279
280
            return AjaxResult.error("容器号不能为空");
        }
        AjaxResult ajaxResult = handleMultiProcess("bulkDelivery",new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
李泰瑜 authored
281
282
283
284
285
286
287
288
289
290
291
292
293
294
                AjaxResult ajaxResult = codingService.bulkDelivery(chipCode,boxCode,shipmentCode);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }


    /**
     * 盘点显示订单列表
     */
    @PostMapping("/orderList")
    @ApiOperation("盘点显示订单列表")
    @ResponseBody
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
    public TableDataInfo orderList() {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();


        LambdaQueryWrapper<ShipmentHeader> shipmentHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
        shipmentHeaderLambdaQueryWrapper.eq(ShipmentHeader::getShipmentType, QuantityConstant.SHIPMENT_TYPE_DELIVERY).orderByDesc(ShipmentHeader::getCreated);

        if (com.huaheng.common.utils.StringUtils.isNotNull(pageNum) && com.huaheng.common.utils.StringUtils.isNotNull(pageSize)){

            Page<ShipmentHeader> page = new Page<>(pageNum, pageSize);
            IPage<ShipmentHeader> iPage = shipmentHeaderService.page(page, shipmentHeaderLambdaQueryWrapper);
            List<ShipmentHeader> iPages = iPage.getRecords();
            return getMpDataTable(iPages, iPage.getTotal());
        }else
        {
        List<ShipmentHeader> shipmentHeaders= shipmentHeaderService.list(shipmentHeaderLambdaQueryWrapper);
        return getDataTable(shipmentHeaders);
        }
lty authored
316
    }
lty authored
317
318
319
lty authored
320
321
322
323
324
325
326
    @PostMapping("/inventory")
    @ApiOperation("盘点接口")
    @ResponseBody
    @ApiLogger(apiName = "盘点接口", from="盘点接口")
    public AjaxResult inventory(@RequestBody Map<String,String> map) {
        String boxCode =  map.get("boxCode");
        String containerCode =  map.get("containerCode");
327
        String chipCode =  map.get("chipCode");
lty authored
328
329
330
331
332
333
334
335
336
        if(StringUtils.isEmpty(boxCode)) {
            return AjaxResult.error("箱码不为空");
        }
        if(StringUtils.isEmpty(containerCode)) {
            return AjaxResult.error("托盘号不为空");
        }
        AjaxResult ajaxResult = handleMultiProcess("inventory",new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
337
                AjaxResult ajaxResult = codingService.inventory(boxCode,containerCode,chipCode);
lty authored
338
339
340
341
342
343
344
345
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
李泰瑜 authored
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376



    @PostMapping("/goOnline")
    @ApiOperation("人工位上线通知wcs")
    @ResponseBody
    @ApiLogger(apiName = "人工位上线通知wcs", from="人工位上线通知wcs")
    public AjaxResult goOnline(@RequestBody Map<String,String> map) {
        String port =  map.get("port");
        String barcode =  map.get("barcode");
        if(StringUtils.isEmpty(port)) {
            return AjaxResult.error("站台");
        }
        if(StringUtils.isEmpty(barcode)) {
            return AjaxResult.error("托盘号不为空");
        }
        AjaxResult ajaxResult = handleMultiProcess("inventory",new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = codingService.goOnline(port,barcode);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
李泰瑜 authored
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
    @PostMapping("/chipCode")
    @ApiOperation("根据箱码查询片码")
    @ResponseBody
    @ApiLogger(apiName = "根据箱码查询片码", from="根据箱码查询片码")
    public AjaxResult chipCode(@RequestBody Map<String,String> map) {
        String boxCode =  map.get("boxCode");
        if(StringUtils.isEmpty(boxCode)) {
            return AjaxResult.error("箱码不为空");
        }
        AjaxResult ajaxResult = handleMultiProcess("inventory",new MultiProcessListener() {
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = codingService.chipCode(boxCode);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
lty authored
398
肖超群 authored
399
400
    @PostMapping("/searchFleeingGoodsInfo")
    @ApiOperation("防串信息查询")
401
    @ResponseBody
肖超群 authored
402
    @ApiLogger(apiName = "防串信息查询", from="查询历史库存记录")
lty authored
403
404
405
406
407
    public AjaxResult searchFleeingGoodsInfo(@RequestBody Map<String,String> map) {
        String boxCode =  map.get("boxCode");
        String chipCode =  map.get("chipCode");
        if(StringUtils.isEmpty(boxCode)&&StringUtils.isEmpty(chipCode)) {
            return AjaxResult.error("箱码跟片码信息不能都为空");
408
        }
409
        AjaxResult ajaxResult = handleMultiProcess("findShipmentRecord",new MultiProcessListener() {
410
411
            @Override
            public AjaxResult doProcess() {
tan authored
412
                AjaxResult ajaxResult = codingService.findShipmentRecord(boxCode,chipCode);
413
414
415
416
417
418
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
肖超群 authored
419
    @PostMapping("/requestEmptyContainer")
肖超群 authored
420
    @ApiOperation("申请空托盘组")
yangxiaoping authored
421
422
423
424
425
426
427
    @ResponseBody
    @ApiLogger(apiName = "申请空托盘组", from="申请空托盘组")
    public AjaxResult requestEmptyContainer(@RequestBody EmptyZu emptyZu) {
        String requestInCode = emptyZu.getRequestInCode();
        if (requestInCode == null) {
            return AjaxResult.error("空托盘组信息,申请位置为空");
        }
tan authored
428
429
        if (!requestInCode.equals("P3") && !requestInCode.equals("P6")){
            return AjaxResult.error("目标站台错误");
tan authored
430
        }
431
432
        AjaxResult ajaxResult = handleMultiProcess("requestEmptyContainer",new MultiProcessListener() {
yangxiaoping authored
433
434
435
436
437
438
439
440
441
            @Override
            public AjaxResult doProcess() {
                AjaxResult ajaxResult = codingService.requestEmptyContainer(requestInCode);
                return ajaxResult;
            }
        });
        return ajaxResult;
    }
442
443
444


}