Junjie
2024-07-18 59b0c86e2af6b86796e2becf627e07e675e71980
#许可证优化
3个文件已修改
37 ■■■■■ 已修改文件
zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/LicenseCheckListener.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/controller/LicenseCreatorController.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/timer/LicenseTimer.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/LicenseCheckListener.java
@@ -15,6 +15,7 @@
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.Date;
/**
 * 在项目启动时安装证书
@@ -91,6 +92,15 @@
                logger.info("++++++++ 许可证加载结束 ++++++++");
                licenseTimer.setSystemSupport(install != null);
                if (install != null) {
                    Date start = new Date();
                    Date end = install.getNotAfter();
                    Long starTime = start.getTime();
                    Long endTime = end.getTime();
                    Long num = endTime - starTime;//时间戳相差的毫秒数
                    int day = (int) (num / 24 / 60 / 60 / 1000);
                    licenseTimer.setLicenseDays(day);
                }
                return install != null;
            } catch (Exception e) {
zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/controller/LicenseCreatorController.java
@@ -4,6 +4,7 @@
import com.zy.asrs.wms.system.license.entity.license.*;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.wms.system.license.timer.LicenseTimer;
import de.schlichtherle.license.LicenseContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -27,9 +28,10 @@
    @Value("${license.licensePath}")
    private String licensePath;
    @Autowired
    private LicenseCheckListener licenseCheckListener;
    @Autowired
    private LicenseTimer licenseTimer;
    /**
     * 获取服务器硬件信息
@@ -62,19 +64,7 @@
     */
    @RequestMapping(value = "/getLicenseDays")
    public R getLicenseDays() {
        LicenseVerify licenseVerify = new LicenseVerify();
        LicenseContent verifyInfo = licenseVerify.getVerifyInfo();
        if (verifyInfo == null) {
            return R.error();
        }
        Date start = new Date();
        Date end = verifyInfo.getNotAfter();
        Long starTime = start.getTime();
        Long endTime = end.getTime();
        Long num = endTime - starTime;//时间戳相差的毫秒数
        int day = (int) (num / 24 / 60 / 60 / 1000);
        return R.ok().add(day);
        return R.ok().add(licenseTimer.getLicenseDays());
    }
    @RequestMapping(value = "/updateLicense")
zy-asrs-wms/src/main/java/com/zy/asrs/wms/system/license/timer/LicenseTimer.java
@@ -9,6 +9,8 @@
    private static boolean SYSTEM_SUPPORT = false;//系统激活状态,默认关闭
    private static int LICENSE_DAYS = 0;//许可证天数
    //每天晚上11点更新系统激活状态
    @Scheduled(cron = "0 0 23 * * ? ")
    public void timer() {
@@ -27,4 +29,11 @@
        SYSTEM_SUPPORT = systemSupport;
    }
    public int getLicenseDays() {
        return LICENSE_DAYS;
    }
    public void setLicenseDays(int licenseDays) {
        LICENSE_DAYS = licenseDays;
    }
}