From a073250f6f4f8c32888bc60b24ff6984e29af51e Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期四, 01 八月 2024 17:04:01 +0800 Subject: [PATCH] #增加弃车功能 --- src/main/java/com/zy/system/entity/license/LicenseVerify.java | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/zy/system/entity/license/LicenseVerify.java b/src/main/java/com/zy/system/entity/license/LicenseVerify.java index 9f91d36..597648a 100644 --- a/src/main/java/com/zy/system/entity/license/LicenseVerify.java +++ b/src/main/java/com/zy/system/entity/license/LicenseVerify.java @@ -3,8 +3,11 @@ import de.schlichtherle.license.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.poi.util.IOUtils; import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; import java.text.DateFormat; import java.text.MessageFormat; import java.text.SimpleDateFormat; @@ -28,7 +31,12 @@ LicenseManager licenseManager = LicenseManagerHolder.getInstance(initLicenseParam(param)); licenseManager.uninstall(); - result = licenseManager.install(new File(param.getLicensePath())); + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(param.getLicensePath()); + File file = new File(param.getLicensePath()); + try (FileOutputStream out = new FileOutputStream(file)) { + IOUtils.copy(inputStream, out); + } + result = licenseManager.install(file); logger.info(MessageFormat.format("璁稿彲璇佸姞杞芥垚鍔燂紝璁稿彲璇佹湁鏁堟湡锛歿0} - {1}",format.format(result.getNotBefore()),format.format(result.getNotAfter()))); }catch (Exception e){ logger.error("璁稿彲璇佸姞杞藉け璐ワ紒",e); @@ -41,19 +49,16 @@ * 鏍¢獙License璇佷功 */ public boolean verify(){ - LicenseManager licenseManager = LicenseManagerHolder.getInstance(null); - DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - if (!updateSystemTime()) { - //鏃堕棿鏇存柊澶辫触锛岀郴缁熸椂闂磋鏇存敼 - return false; - } - - //2. 鏍¢獙璇佷功 try { - LicenseContent licenseContent = licenseManager.verify(); -// System.out.println(licenseContent.getSubject()); + LicenseManager licenseManager = LicenseManagerHolder.getInstance(null); + DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (!updateSystemTime()) { + //鏃堕棿鏇存柊澶辫触锛岀郴缁熸椂闂磋鏇存敼 + return false; + } + + LicenseContent licenseContent = licenseManager.verify(); logger.info(MessageFormat.format("璁稿彲璇佹牎楠岄�氳繃锛岃鍙瘉鏈夋晥鏈燂細{0} - {1}",format.format(licenseContent.getNotBefore()),format.format(licenseContent.getNotAfter()))); return true; }catch (Exception e){ -- Gitblit v1.9.1