王佳豪
2021-06-19 6e781bc28dd55c4bb5c5652ead746d947b7aeafa
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package com.zy.asrs.utils;
 
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.common.model.LocTypeDto;
import com.zy.common.service.erp.entity.M_item;
import com.zy.common.utils.excel.matcode.MatCodeExcel;
 
/**
 * Created by vincent on 2020/7/14
 */
public class VersionUtils {
 
    // 业务 ----------------------------------------------------------------------
 
    public static void setWrkDetl(WrkDetl wrkDetl, MatCode matCode) {
        wrkDetl.setMatnr(matCode.getMatNo()); // 物料编号
        wrkDetl.setMaktx(matCode.getMatName()); // 物料描述
        wrkDetl.setLgnum(matCode.getStr3()); // 规格
        wrkDetl.setType(matCode.getStr2()); // 物料类别
        wrkDetl.setMnemonic(matCode.getStr5()); // 助记码
        wrkDetl.setSupplier(matCode.getStr6()); // 默认供应商
        wrkDetl.setWarehouse(matCode.getStr7()); // 默认仓库
        wrkDetl.setBrand(matCode.getStr8()); // 品牌
        wrkDetl.setAltme(matCode.getStr1()); // 单位
    }
 
    public static void setWrkDetl(WrkDetl wrkDetl, LocDetl locDetl) {
        wrkDetl.setMatnr(locDetl.getMatnr()); // 物料编号
        wrkDetl.setMaktx(locDetl.getMaktx()); // 物料描述
        wrkDetl.setLgnum(locDetl.getLgnum()); // 规格
        wrkDetl.setType(locDetl.getType()); // 物料类别
        wrkDetl.setMnemonic(locDetl.getMnemonic()); // 助记码
        wrkDetl.setSupplier(locDetl.getSupplier()); // 默认供应商
        wrkDetl.setWarehouse(locDetl.getWarehouse()); // 默认仓库
        wrkDetl.setBrand(locDetl.getBrand()); // 品牌
        wrkDetl.setAltme(locDetl.getAltme()); // 单位
        wrkDetl.setZpallet(locDetl.getZpallet()); // 托盘条码
    }
 
    public static void setLocDetl(LocDetl locDetl, MatCode matCode) {
        locDetl.setMatnr(matCode.getMatNo()); // 物料编号
        locDetl.setMaktx(matCode.getMatName()); // 物料描述
        locDetl.setLgnum(matCode.getStr3()); // 规格
        locDetl.setType(matCode.getStr2()); // 物料类别
        locDetl.setMnemonic(matCode.getStr5()); // 助记码
        locDetl.setSupplier(matCode.getStr6()); // 默认供应商
        locDetl.setWarehouse(matCode.getStr7()); // 默认仓库
        locDetl.setBrand(matCode.getStr8()); // 品牌
        locDetl.setAltme(matCode.getStr1()); // 单位
    }
 
    public static void setLocDetl(LocDetl locDetl, WrkDetl wrkDetl) {
        locDetl.setMatnr(wrkDetl.getMatnr()); // 物料编号
        locDetl.setMaktx(wrkDetl.getMaktx()); // 物料描述
        locDetl.setLgnum(wrkDetl.getLgnum()); // 规格
        locDetl.setType(wrkDetl.getType()); // 物料类别
        locDetl.setMnemonic(wrkDetl.getMnemonic()); // 助记码
        locDetl.setSupplier(wrkDetl.getSupplier()); // 默认供应商
        locDetl.setWarehouse(wrkDetl.getWarehouse()); // 默认仓库
        locDetl.setBrand(wrkDetl.getBrand()); // 品牌
        locDetl.setAnfme(wrkDetl.getAnfme()); // 数量
        locDetl.setAltme(wrkDetl.getAltme()); // 单位
        locDetl.setZpallet(wrkDetl.getZpallet()); // 托盘条码
    }
 
    public static void setWaitPakIn(WaitPakin waitPakIn, MatCode matCode) {
        waitPakIn.setMatnr(matCode.getMatNo()); // 物料编号
        waitPakIn.setMaktx(matCode.getMatName()); // 物料描述
        waitPakIn.setLgnum(matCode.getStr3()); // 规格
        waitPakIn.setType(matCode.getStr2()); // 物料类别
        waitPakIn.setMnemonic(matCode.getStr5()); // 助记码
        waitPakIn.setSupplier(matCode.getStr6()); // 默认供应商
        waitPakIn.setWarehouse(matCode.getStr7()); // 默认仓库
        waitPakIn.setBrand(matCode.getStr8()); // 品牌
        waitPakIn.setAltme(matCode.getStr1()); // 单位
    }
 
    public static void setMatCode(MatCode matCode, M_item item) {
        matCode.setMatNo(item.getMnumber()); // 物料编号
        matCode.setMatName(item.getMname()); // 物料描述
        matCode.setStr3(item.getMmodel()); // 物料类别
        matCode.setStr2(item.getMtypename()); // 规格型号
    }
 
    // excel ----------------------------------------------------------------------
 
    public static MatCodeExcel getExcel(MatCode matCode) {
        return new MatCodeExcel(
                matCode.getMatNo(),
                matCode.getBarcode(),
                matCode.getMatName(),
                matCode.getStr1(),
                matCode.getStr2(),
                matCode.getStr3(),
                matCode.getStr4(),
                matCode.getStr5(),
                matCode.getStr6(),
                matCode.getStr7(),
                matCode.getStr8(),
                matCode.getStr9(),
                matCode.getStr10(),
                matCode.getStr11(),
                matCode.getStr12(),
                matCode.getStr13(),
                matCode.getStr14(),
                matCode.getStr15(),
                matCode.getStr16(),
                matCode.getStr17(),
                matCode.getStr18(),
                matCode.getStr19(),
                matCode.getStr20(),
                matCode.getStr21(),
                matCode.getStr22(),
                matCode.getStr23(),
                matCode.getNum1(),
                matCode.getNum2(),
                matCode.getNum3(),
                matCode.getNum4(),
                matCode.getNum5(),
                matCode.getNum6()
        );
    }
 
    public static void setMatCode(MatCode matCode, MatCodeExcel excel) {
        matCode.setMatNo(excel.getMatNo());
        matCode.setMatName(excel.getMatName());
        matCode.setBarcode(excel.getBarcode());
        matCode.setStr1(excel.getStr1());
        matCode.setStr2(excel.getStr2());
        matCode.setStr3(excel.getStr3());
        matCode.setStr4(excel.getStr4());
        matCode.setStr5(excel.getStr5());
        matCode.setStr6(excel.getStr6());
        matCode.setStr7(excel.getStr7());
        matCode.setStr8(excel.getStr8());
        matCode.setStr9(excel.getStr9());
        matCode.setStr10(excel.getStr10());
        matCode.setStr11(excel.getStr11());
        matCode.setStr12(excel.getStr12());
        matCode.setStr13(excel.getStr13());
        matCode.setStr14(excel.getStr14());
        matCode.setStr15(excel.getStr15());
        matCode.setStr16(excel.getStr16());
        matCode.setStr17(excel.getStr17());
        matCode.setStr18(excel.getStr18());
        matCode.setStr19(excel.getStr19());
        matCode.setStr20(excel.getStr20());
        matCode.setStr21(excel.getStr21());
        matCode.setStr22(excel.getStr22());
        matCode.setStr23(excel.getStr23());
        matCode.setNum1(excel.getNum1());
        matCode.setNum2(excel.getNum2());
        matCode.setNum3(excel.getNum3());
        matCode.setNum4(excel.getNum4());
        matCode.setNum5(excel.getNum5());
        matCode.setNum6(excel.getNum6());
    }
 
    /**
     *  库位移转时类型检测
     **/
    public static void locMoveCheckLocType(LocMast sourceLoc, LocMast loc){
        // 如果源库位是高库位,目标库位是低库位
        if (sourceLoc.getLocType1() == 2 && loc.getLocType1() == 1) {
            throw new CoolException("高库位不能移转至低库位");
        }
        // 如果源库位是宽库位,目标库位是窄库位
        if (sourceLoc.getLocType2() == 2 && loc.getLocType2() == 1) {
            throw new CoolException("宽库位不能移转至窄库位");
        }
        // 如果源库位是重库位,目标库位是轻库位
        if (sourceLoc.getLocType3() == 2 && loc.getLocType3() == 1) {
            throw new CoolException("重库位不能移转至轻库位");
        }
    }
 
    /**
     *  库位移转时类型检测
     **/
    public static boolean locMoveCheckLocType(LocMast loc, LocTypeDto dto){
        // 如果源库位是高库位,目标库位是低库位
        if (dto.getLocType1() == 2 && loc.getLocType1() == 1) {
            return false;
        }
        // 如果源库位是宽库位,目标库位是窄库位
        if (dto.getLocType2() == 2 && loc.getLocType2() == 1) {
            return false;
        }
        // 如果源库位是重库位,目标库位是轻库位
        if (dto.getLocType3() == 2 && loc.getLocType3() == 1) {
            return false;
        }
        return true;
    }
 
 
}