SAPUtils.java
4.99 KB
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
package com.huaheng.api.utils;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.pc.sap.domain.Zarsh;
import com.huaheng.pc.sap.service.ZarshService;
import com.huaheng.pc.sap.service.ZarsiService;
public class SAPUtils {
@Resource
private ZarshService zarshService;
@Resource
private ZarsiService zarsiService;
/**
* 通过SAP仓库编码 获取WMS库区编码
* @return
*/
public static String getZoneCode(Zarsh zarsh) {
return getZoneCode(zarsh.getWerks(), zarsh.getLgort(), zarsh.getLgnum(), zarsh.getCrnIn(), "SAP录入参数错误");
}
/**
* 通过SAP仓库编码 获取WMS库区编码
* @param werks SAP工厂
* @param lgort SAP库存地点
* @param lgnum SAP仓库号
* @return
*/
public static String getZoneCode(String werks, String lgort, String lgnum) {
return getZoneCode(werks, lgort, lgnum, "SAP录入参数错误");
}
public static String getArea(Zarsh zarsh) {
return getArea(zarsh.getWerks(), zarsh.getLgort(), zarsh.getLgnum(), "SAP录入参数错误");
}
public static String getArea(String werks, String lgort, String lgnum) {
return getArea(werks, lgort, lgnum, "SAP录入参数错误");
}
public static String getArea(String werks, String lgort, String lgnum, String errorMsg) {
String area = null;
Map<String, String> map = new HashMap<>();
map.put("BBC", "1");
map.put("SP2", "2");
map.put("TBC", "3");
map.put("PPC", "4");
map.put("PLC", "5");
map.put("WJC", "6");
map.put("BC2", "7");
if (StringUtils.isEmpty(werks) || StringUtils.isEmpty(lgort) || StringUtils.isEmpty(lgnum)) {
throw new SecurityException(errorMsg);
}
if (!"SC00".equals(werks)) {
throw new SecurityException(errorMsg);
}
switch (lgort) {
case "SF28":
case "SC01":
case "SF22":
case "SF21":
area = map.get(lgnum);
break;
default:
throw new SecurityException(errorMsg);
}
return area;
}
public static String getZoneCode(String werks, String lgort, String lgnum, String errorMsg) {
return getZoneCode(werks, lgort, lgnum, null, errorMsg);
}
public static String getZoneCode(String werks, String lgort, String lgnum, String crnIn, String errorMsg) {
String zoneCode = null;
Map<String, String> map = new HashMap<>();
map.put("BBC", "A");
map.put("SP2", "B");
map.put("TBC", "C");
map.put("PPC", "D");
map.put("PLC", "E");
map.put("WJC", "F");
map.put("BC2", "G");
map.put("AX", "AX");
map.put("BX", "BX");
map.put("CX", "CX");
map.put("DX", "DX");
map.put("EX", "EX");
map.put("FX", "FX");
map.put("GX", "GX");
if (StringUtils.isEmpty(werks) || StringUtils.isEmpty(lgort) || StringUtils.isEmpty(lgnum)) {
throw new SecurityException(errorMsg);
}
if (!"SC00".equals(werks)) {
throw new SecurityException(errorMsg);
}
if (StringUtils.isNotEmpty(crnIn)) {
lgnum = crnIn;
}
switch (lgort) {
case "SF28":
case "SC01":
case "SF22":
case "SF21":
zoneCode = map.get(lgnum);
break;
default:
throw new SecurityException(errorMsg);
}
return zoneCode;
}
public static String convertSAPByZoneCode(String zoneCode) {
String lgort = null;
switch (zoneCode) {
case "A":
case "C":
case "AX":
case "CX":
lgort = "SF28";
break;
case "G":
case "B":
lgort = "SC01";
break;
case "D":
case "E":
case "DX":
lgort = "SF22";
break;
case "F":
lgort = "SF21";
break;
}
return lgort;
}
public static String convertSAPByPort(String zoneCode) {
String port = null;
Map<String, String> map = new HashMap<>();
map.put("A", "BBC");
map.put("AX", "BBC");
map.put("B", "SP2");
map.put("C", "TBC");
map.put("CX", "TBC");
map.put("D", "PPC");
map.put("DX", "PPC");
map.put("E", "PLC");
map.put("F", "WJC");
map.put("G", "BC2");
switch (zoneCode) {
case "A":
case "B":
case "C":
case "D":
case "E":
case "F":
case "G":
case "AX":
case "CX":
case "DX":
port = map.get(zoneCode);
break;
}
return port;
}
}