lyh
3 天以前 3ce27b7faf8850d101a1511a685250fe562dca18
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
package com.lxzn.auth;
 
import com.lxzn.framework.utils.LicenseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import java.util.Map;
import java.util.Set;
 
/**
 * @Description:
 * @Author: zhangherong
 * @Date: Created in 2021/6/23 16:05
 * @Version: 1.0
 * @Modified By:
 */
@Component
@Slf4j
public class LicenseModel {
 
    private static String licensePath;
 
//    @Value("${license.path}")
//    public void setLicensePath(String licensePath) {
//        LicenseModel.licensePath = licensePath;
//    }
 
    //当前服务器cpu序列号
    public static final Set<String> CPU_SERIAL_NUMBER = LicenseUtil.cpuSerialNumber();
 
    //当前配置的序列号
    private static String license;
    //cpu序列号
    private static String cpuSerialNumber;
    //DNC设备点位控制
    private static String dncDeviceNumber;
    //MDC设备点位控制
    private static String mdcDeviceNumber;
    //序列号过期时间
    private static String expiredDate;
 
//    @PostConstruct
//    public static void init(){
//        String license = LicenseUtil.readLicense(licensePath);
//        init(license);
//    }
 
    public static synchronized void init(String tmp){
        license = tmp;
        cpuSerialNumber = "178BFBFF00A40F41";
        dncDeviceNumber = "3000";
        mdcDeviceNumber = "3000";
        expiredDate = "2029-12-30";
//        if(license != null){
//            Map<String, String> map = LicenseUtil.parseLicense(license);
//            if(map != null){
//                if(map.containsKey("cpu")){
//                    cpuSerialNumber = map.get("cpu");
//                }
//                if(map.containsKey("D")) {
//                    dncDeviceNumber = map.get("D");
//                }
//                if(map.containsKey("M")) {
//                    mdcDeviceNumber = map.get("M");
//                }
//                if(map.containsKey("R")) {
//                    expiredDate = map.get("R");
//                }
//            }
//        }
        log.info("机器码:{}", CPU_SERIAL_NUMBER);
        log.info("解析机器码:{}", cpuSerialNumber);
    }
 
 
 
    public static String getLicense() {
        return license;
    }
 
    public static String getCpuSerialNumber() {
        return cpuSerialNumber;
    }
 
    public static String getDncDeviceNumber() {
        return dncDeviceNumber;
    }
 
    public static String getMdcDeviceNumber() {
        return mdcDeviceNumber;
    }
 
    public static String getExpiredDate() {
        return expiredDate;
    }
}