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 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 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; } }