自动化立体仓库 - WMS系统
dubin
1 天以前 edb03c5169709da2e6d39a999328ce9bf92affff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package com.zy.asrs.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.MatBarcode;
import com.zy.asrs.entity.WaitPakin;
import com.zy.asrs.entity.param.CombParam;
import com.zy.asrs.entity.param.MobileAdjustParam;
import com.zy.asrs.service.MatBarcodeService;
import com.zy.asrs.service.MatService;
import com.zy.asrs.service.MobileService;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
@RequestMapping
@RestController
public class BarcodeMatnrController extends BaseController {
    @Autowired
    private MatBarcodeService matBarcodeService;
    @Autowired
    private MobileService mobileService;
    @Autowired
    private MatService matService;
    /*
    * 物料托盘绑定分页查询
    * */
    @RequestMapping(value = "/barcodeMatnr/list/auth")
    @ManagerAuth
    public R list(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam Map<String, Object> param){
        excludeTrash(param);
        EntityWrapper<MatBarcode> wrapper = new EntityWrapper<>();
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        else {
            wrapper.orderBy("modi_time", false);
        }
        return R.ok(matBarcodeService.selectPage(new Page<>(curr, limit), wrapper));
    }
 
    private void convert(Map<String, Object> map, EntityWrapper wrapper){
        for (Map.Entry<String, Object> entry : map.entrySet()){
            String val = String.valueOf(entry.getValue());
            if (val.contains(RANGE_TIME_LINK)){
                String[] dates = val.split(RANGE_TIME_LINK);
                wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
                wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
            } else {
                wrapper.like(entry.getKey(), val);
            }
        }
    }
 
    /*
    * 物料托盘解绑
    * */
    @RequestMapping("/barcodeMatnr/matnrLostBarcode")
    @ManagerAuth(memo = "物料托盘解绑")
    public R matnrLostBarcode(@RequestBody List<MatBarcode> list) {
        matBarcodeService.deleteMatBarcode(list);
        return R.ok();
    }
 
    /*物料托盘绑定
    *
    * */
    @RequestMapping(value = "/barcodeMatnr/add/auth")
    @ManagerAuth
    public R add(WaitPakin waitPakin) {
        if (Cools.isEmpty(waitPakin.getBarcode())||Cools.isEmpty(waitPakin.getModiUser())){
            return R.error(BaseRes.PARAM);
        }
        matBarcodeService.addBarcodeMatnr(waitPakin);
        return R.ok();
    }
 
    /*组托
    *
    * */
    @RequestMapping(value = "/barcodeMatnr/add1/auth")
    @ManagerAuth
    public R comb(WaitPakin waitPakin) {
        Mat mat = matService.selectById(waitPakin.getModiUser());
        MatBarcode matBarcode = matBarcodeService.selectbyMatnr(mat.getMatnr());
        if (matBarcode == null){
            throw new CoolException("该物料未与托盘绑定");
        }else {
            if (!matBarcode.getZpallet().equals(waitPakin.getBarcode())){
                throw new CoolException("该物料与其他托盘绑定,不能与当前托盘"+waitPakin.getBarcode()+"绑定,与该物料绑定的托盘是"+matBarcode.getZpallet());
            }
        }
        if (Cools.isEmpty(waitPakin.getBarcode())||Cools.isEmpty(waitPakin.getModiUser())||Cools.isEmpty(waitPakin.getAnfme())){
            return R.error(BaseRes.PARAM);
        }
        mobileService.combToWms(waitPakin);
        return R.ok("组托成功");
    }
 
    /*并板
    *
    * */
    @RequestMapping(value = "/barcodeMatnr/add2/auth")
    @ManagerAuth
    public R clamp(WaitPakin waitPakin) {
        if (Cools.isEmpty(waitPakin.getBarcode())||Cools.isEmpty(waitPakin.getModiUser())||Cools.isEmpty(waitPakin.getAnfme())){
            return R.error(BaseRes.PARAM);
        }
        Mat mat = matService.selectById(waitPakin.getModiUser());
        MatBarcode matBarcode = matBarcodeService.selectbyMatnr(mat.getMatnr());
        if (matBarcode == null){
            throw new CoolException("该物料未与托盘绑定");
        }else {
            if (!matBarcode.getZpallet().equals(waitPakin.getBarcode())){
            throw new CoolException("该物料与其他托盘绑定,不能与当前托盘"+waitPakin.getBarcode()+"绑定,与该物料绑定的托盘是"+matBarcode.getZpallet());
            }
        }
        MobileAdjustParam combParam=new MobileAdjustParam();
        ArrayList<CombParam.CombMat> combMats=new ArrayList<>();
        CombParam.CombMat combMat=new CombParam.CombMat();
        combMat.setMatnr(mat.getMatnr());
        combMat.setMaktx(mat.getMaktx());
        combMat.setAnfme(waitPakin.getAnfme());
        combMats.add(combMat);
        combParam.setBarcode(waitPakin.getBarcode());
        combParam.setCombMats(combMats);
        mobileService.adjustNew(combParam, Boolean.TRUE, getUserId());
        return R.ok("并板成功");
    }
}