自动化立体仓库 - WMS系统
dubin
昨天 be554d9e52799a0ee14c98b0959d07ab3847c8e6
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
package com.zy.asrs.service.impl;
 
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.exception.CoolException;
import com.zy.asrs.entity.HalfBarcode;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.MatBarcode;
import com.zy.asrs.entity.WaitPakin;
import com.zy.asrs.mapper.MatBarcodeMapper;
import com.zy.asrs.service.HalfBarcodeService;
import com.zy.asrs.service.MatBarcodeService;
import com.zy.asrs.service.MatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Map;
 
@Service("MatBarcodeService")
public class MatBarcodeServiceImpl extends ServiceImpl<MatBarcodeMapper, MatBarcode> implements MatBarcodeService {
    @Autowired
    private MatBarcodeMapper matBarcodeMapper;
    @Autowired
    private MatBarcodeService matBarcodeService;
    @Autowired
    private MatService matService;
    @Autowired
    private HalfBarcodeService halfBarcodeService;
    @Override
    public MatBarcode selectbyMatnr(String matnr) {
        return this.baseMapper.selectByMatnr(matnr);
    }
 
    @Override
    public void deleteMatBarcode(List<MatBarcode> list) {
        for (MatBarcode matBarcode : list) {
            HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(matBarcode.getZpallet());
            halfBarcode.setAnfme(halfBarcode.getAnfme() - 1);
            halfBarcode.setPrice(halfBarcode.getPrice() + 1);
            if (!halfBarcodeService.half(halfBarcode)){
                throw new CoolException("更新半托信息失败");
            }
            matBarcodeMapper.deleteByMatnr(matBarcode.getMatnr());
        }
    }
 
    @Override
    public void addBarcodeMatnr(WaitPakin waitPakin) {
        Mat mat = matService.selectById(waitPakin.getModiUser());
        if (mat == null){
            throw new CoolException("物料不存在,请先添加物料数据");
        }
        MatBarcode matBarcode = matBarcodeMapper.selectByMatnr(mat.getMatnr());
        if (matBarcode != null){
            throw new CoolException("该物料已经绑定托盘,请勿重复绑定");
        }
        if (mat.getColor().equals("报废")){
            throw new CoolException("该物料已报废,请勿绑定");
        }
        HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(waitPakin.getBarcode());
        if (halfBarcode == null){
            HalfBarcode hb = new HalfBarcode();
            hb.setZpallet(waitPakin.getBarcode());
            hb.setSpecs(waitPakin.getBarcode().substring(0,1));
            hb.setAnfme(1);
            if (Integer.parseInt(waitPakin.getBarcode().substring(0,1))==6){
                hb.setPrice(24-1);
            }else if(Integer.parseInt(waitPakin.getBarcode().substring(0,1))==7){
                hb.setPrice(24-1);
            }else if(Integer.parseInt(waitPakin.getBarcode().substring(0,1))==8){
                hb.setPrice(24-1);
            }
            if (!halfBarcodeService.insert(hb)){
                throw new CoolException("更新半托信息失败");
            }
        }else {
            if (Integer.parseInt(waitPakin.getBarcode().substring(0,1))==6){
                halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                halfBarcode.setPrice(halfBarcode.getPrice()-1);
            }else if(Integer.parseInt(waitPakin.getBarcode().substring(0,1))==7){
                halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                halfBarcode.setPrice(halfBarcode.getPrice()-1);
            }else if(Integer.parseInt(waitPakin.getBarcode().substring(0,1))==8){
                halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                halfBarcode.setPrice(halfBarcode.getPrice()-1);
            }
            if (!halfBarcodeService.half(halfBarcode)){
                throw new CoolException("更新半托信息失败");
            }
        }
        MatBarcode mb=new MatBarcode();
        mb.setZpallet(waitPakin.getBarcode());
        mb.setMatnr(mat.getMatnr());
        mb.setMaktx(mat.getMaktx());
        mb.setSpecs(mat.getSpecs());
        mb.setModel(mat.getModel());
        if (!matBarcodeService.insert(mb)){
            throw new CoolException("物料托盘绑定失败");
        }
    }
 
    @Override
    public void addBarcodeMatnrTwo(Mat mat) {
        Mat m = matService.selectById(mat);
        if (m == null){
            throw new CoolException("物料不存在,请先添加物料数据");
        }
        MatBarcode matBarcode = matBarcodeMapper.selectByMatnr(mat.getMatnr());
        if (matBarcode != null){
            throw new CoolException("该物料已经绑定托盘,请勿重复绑定");
        }
        if (mat.getColor().equals("报废")){
            throw new CoolException("该物料已报废,请勿绑定");
        }
        MatBarcode mb=new MatBarcode();
        mb.setZpallet(mat.getUnit());
        mb.setMatnr(mat.getMatnr());
        mb.setMaktx(mat.getMaktx());
        mb.setSpecs(mat.getSpecs());
        mb.setModel(mat.getModel());
        if (!matBarcodeService.insert(mb)){
            throw new CoolException("物料托盘绑定失败");
        }
    }
 
    @Override
    public String page(Map<String, Object> param) {
        Integer pageNo = Integer.valueOf(param.get("curr").toString());
        Integer pageSize = Integer.valueOf(param.get("limit").toString());
        String barcode = (String) param.get("zpallet");
        Integer spec = Integer.valueOf(param.get("spec").toString());
        return matBarcodeMapper.page(pageNo,pageSize,barcode,spec);
    }
}