自动化立体仓库 - WMS系统
13
zhang
2 天以前 82de5a307466894bbb0258f8a63a26a7bb96d80d
src/main/java/com/zy/system/controller/LicenseCreatorController.java
@@ -3,7 +3,7 @@
import com.core.common.Cools;
import com.core.common.R;
import com.zy.system.entity.license.*;
import de.schlichtherle.license.LicenseContent;
import com.zy.system.timer.LicenseTimer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
@@ -14,10 +14,8 @@
import java.io.File;
import java.io.IOException;
import java.util.Date;
/**
 *
 * 用于生成证书文件,不能放在给客户部署的代码里
 */
@RestController
@@ -26,18 +24,20 @@
    @Value("${license.licensePath}")
    private String licensePath;
    @Autowired
    private LicenseCheckListener licenseCheckListener;
    @Autowired
    private LicenseTimer licenseTimer;
    /**
     * 获取服务器硬件信息
     *
     * @param osName 操作系统类型,如果为空则自动判断
     */
    @RequestMapping(value = "/getServerInfos",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public LicenseCheck getServerInfos(@RequestParam(value = "osName",required = false) String osName) {
    @RequestMapping(value = "/getServerInfos", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public LicenseCheck getServerInfos(@RequestParam(value = "osName", required = false) String osName) {
        //操作系统类型
        if(Cools.isEmpty(osName)){
        if (Cools.isEmpty(osName)) {
            osName = System.getProperty("os.name");
        }
        osName = osName.toLowerCase();
@@ -48,8 +48,8 @@
        if (osName.startsWith("windows")) {
            abstractServerInfos = new WindowsServerInfos();
        } else if (osName.startsWith("linux")) {
//            abstractServerInfos = new LinuxServerInfos();
        }else{//其他服务器类型
            abstractServerInfos = new LinuxServerInfos();
        } else {//其他服务器类型
            abstractServerInfos = new WindowsServerInfos();
        }
@@ -61,23 +61,11 @@
     */
    @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(licenseTimer.getLicenseDays());
    }
    @RequestMapping(value = "/updateLicense")
    public R updateLicense(@RequestParam("file") MultipartFile[] files){
    public R updateLicense(@RequestParam("file") MultipartFile[] files) {
        MultipartFile file = files[0];
        String licensePathFileName = this.getClass().getClassLoader().getResource(licensePath).getPath();
@@ -109,4 +97,10 @@
        return R.error("许可证更新失败");
    }
    @RequestMapping(value = "/activate")
    public R activate() {
        licenseTimer.timer();
        return R.ok();
    }
}