YYC
2023-10-21 d48d966dfde7a0c31bd81466559e5e8d681dc200
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
package com.ld.igds.sh.util;
 
import com.ld.igds.constant.DepotStatus;
import org.springframework.stereotype.Component;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
 
/**
 * 接口转换工具类
 *
 * @author chen
 **/
@Component
public class ApiShUtil {
 
    /**
     * 仓库状态转为货位状态
     * @param depotStatus
     * @return
     */
    public String getDepotStatus(String depotStatus){
        if(DepotStatus.STATUS_1.getCode().equals(depotStatus)){
            return "1";
        }
        if(DepotStatus.STATUS_3.getCode().equals(depotStatus)){
            return "3";
        }
        if(DepotStatus.STATUS_2.getCode().equals(depotStatus)){
            return "2";
        }
        if(DepotStatus.STATUS_4.getCode().equals(depotStatus)){
            return "4";
        }
        return "9";
    }
 
    public static String getGbDepotId(String depotId){
        switch (depotId) {
            case "0P01":
                return "91310114703439394M0020001001";
            case "0P02":
                return "91310114703439394M0020002001";
            case "0P03":
                return "91310114703439394M0020003001";
            case "0P04":
                return "91310114703439394M0020004001";
            case "0P05":
                return "91310114703439394M0020005001";
            case "0P06":
                return "91310114703439394M0020006001";
            case "0P07":
                return "91310114703439394M0020007001";
            case "0P08":
                return "91310114703439394M0020005001";
            case "0P09":
                return "91310114703439394M0020006001";
            default:
                return depotId;
        }
    }
 
    /**
     * 获取图片的二进制流
     *
     * @param imgPath
     * @return
     */
    public String imgToIo(String imgPath) {
        //图片转化为二进制
        byte[] imageBytes = null;
        try {
 
            FileInputStream fileInputStream = new FileInputStream(new File(imgPath));
            imageBytes = new byte[fileInputStream.available()];
            fileInputStream.read(imageBytes);
        } catch (IOException e) {
 
            System.out.println(e);
            return null;
        }
        return UnicodeByteToStr(imageBytes);
    }
 
    private static String UnicodeByteToStr(byte[] b) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < b.length; i++) {
            sb.append(String.format("%02x", b[i]));
        }
        return sb.toString();
    }
}