Blame view

src/main/java/com/huaheng/api/utils/SAPUtils.java 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.huaheng.api.utils;

import com.huaheng.common.exception.service.ServiceException;
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;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

public class SAPUtils {

    @Resource
    private ZarshService zarshService;
    @Resource
    private ZarsiService zarsiService;
tongzhonghao authored
19
20
21
    /**
     * 通过SAP仓库编码 获取WMS库区编码
tongzhonghao authored
22
     *
23
24
25
26
27
     * @param werks SAP工厂
     * @param lgort SAP库存地点
     * @param lgnum SAP仓库号
     * @return
     */
tongzhonghao authored
28
    public static void checkSAPArea(String werks, String lgort, String lgnum) {
29
        String zoneCodeBySAP = getZoneCode(werks, lgort, lgnum);
tongzhonghao authored
30
31
        if (StringUtils.isEmpty(zoneCodeBySAP)) {
            throw new ServiceException("未找到对应库区 参数[" + werks + "," + lgort + "," + lgnum + "]");
32
33
34
35
36
37
        }

    }

    /**
     * 通过SAP仓库编码 获取WMS库区编码
tongzhonghao authored
38
     *
39
40
     * @return
     */
tongzhonghao authored
41
42
    public static String getZoneCode(Zarsh zarsh) {
        return getZoneCode(zarsh.getWerks(), zarsh.getLgort(), zarsh.getLgnum(), "SAP录入参数错误");
43
44
45
46
    }

    /**
     * 通过SAP仓库编码 获取WMS库区编码
tongzhonghao authored
47
     *
48
49
50
51
52
     * @param werks SAP工厂
     * @param lgort SAP库存地点
     * @param lgnum SAP仓库号
     * @return
     */
tongzhonghao authored
53
54
    public static String getZoneCode(String werks, String lgort, String lgnum) {
        return getZoneCode(werks, lgort, lgnum, "SAP录入参数错误");
55
56
    }
tongzhonghao authored
57
    public static String getZoneCode(String werks, String lgort, String lgnum, String errorMsg) {
58
        String zoneCode = null;
tongzhonghao authored
59
60
61
62
63
64
65
66
67
        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");
        if (StringUtils.isEmpty(werks) || StringUtils.isEmpty(lgort) || StringUtils.isEmpty(lgnum)) {
68
69
            throw new SecurityException(errorMsg);
        }
tongzhonghao authored
70
        if (!"SC00".equals(werks)) {
71
72
            throw new SecurityException(errorMsg);
        }
tongzhonghao authored
73
        switch (lgort) {
74
75
76
77
            case "SF28":
            case "SC01":
            case "SF22":
            case "SF21":
tongzhonghao authored
78
                zoneCode = map.get(lgnum);
79
80
81
82
83
84
85
                break;
            default:
                throw new SecurityException(errorMsg);
        }
        return zoneCode;
    }
tongzhonghao authored
86
    public static void checkTaskType(Zarsh zarsh) {
87
88
89

    }
tongzhonghao authored
90
    public static String checkTaskType(String mFlag) {
91
92
        return null;
    }
tongzhonghao authored
93
tongzhonghao authored
94
    public static String convertSAPByZoneCode(String zoneCode) {
tongzhonghao authored
95
        String lgort = null;
tongzhonghao authored
96
97
98
        switch (zoneCode) {
            case "A":
            case "C":
tongzhonghao authored
99
100
                lgort = "SF28";
                break;
tongzhonghao authored
101
            case "G":
102
            case "B":
tongzhonghao authored
103
104
                lgort = "SC01";
                break;
tongzhonghao authored
105
            case "D":
tongzhonghao authored
106
            case "E":
tongzhonghao authored
107
                lgort = "SF22";
tongzhonghao authored
108
109
                break;
            case "F":
tongzhonghao authored
110
                lgort = "SF21";
tongzhonghao authored
111
                break;
tongzhonghao authored
112
113
114
        }
        return lgort;
    }
tongzhonghao authored
115
116

    public static String convertSAPByPort(String zoneCode) {
tongzhonghao authored
117
        String port = null;
tongzhonghao authored
118
119
120
121
122
123
124
125
126
        Map<String, String> map = new HashMap<>();
        map.put("A", "BBC");
        map.put("B", "SP2");
        map.put("C", "TBC");
        map.put("D", "PPC");
        map.put("E", "PLC");
        map.put("F", "WJC");
        map.put("G", "BC2");
        switch (zoneCode) {
tongzhonghao authored
127
128
129
130
131
132
133
            case "A":
            case "B":
            case "C":
            case "D":
            case "E":
            case "F":
            case "G":
tongzhonghao authored
134
                port = map.get(zoneCode);
tongzhonghao authored
135
136
137
138
                break;
        }
        return port;
    }
139
}