zhanghaijun пре 2 година
родитељ
комит
2ad5eb26b3

+ 2 - 2
train-common/train-common-core/src/main/java/top/haijunit/common/utils/LicenseUtil.java

@@ -30,14 +30,14 @@ public class LicenseUtil {
             }
             File file = new File("bin\\msgbox.vbs");
             if (file.exists()) {
-                Runtime.getRuntime().exec(new String[]{"C:\\Windows\\System32\\wscript.exe", file.getAbsolutePath(), "轨道交通插件 & 授权已过期,请联系管理员"});
+                Runtime.getRuntime().exec(new String[]{"C:\\Windows\\System32\\wscript.exe", file.getAbsolutePath(), "产品授权已过期,请联系管理员"});
                 return;
             } else {
                 log.error("vbs 运行异常:文件未找到:{}", file.getAbsolutePath());
             }
             file = new File("src\\assembly\\bin\\msgbox.vbs");
             if (file.exists()) {
-                Runtime.getRuntime().exec(new String[]{"C:\\Windows\\System32\\wscript.exe", file.getAbsolutePath(), "轨道交通插件 & 授权已过期,请联系管理员"});
+                Runtime.getRuntime().exec(new String[]{"C:\\Windows\\System32\\wscript.exe", file.getAbsolutePath(), "产品授权已过期,请联系管理员"});
             } else {
                 log.error("vbs 运行异常:文件未找到:{}", file.getAbsolutePath());
             }

+ 2 - 2
train-server/src/assembly/bin/date.bat

@@ -22,10 +22,10 @@ if "%currentDateTime%" gtr "%targetDateTime%" (
 rem 比较日期和时间
 if "%currentDateTime%" gtr "%targetDateTime%" (
     echo 授权已过期,请联系管理员
-    cscript msgbox.vbs "轨道交通插件 & 授权已过期,请联系管理员"
+    cscript msgbox.vbs "产品授权已过期,请联系管理员"
 ) else (
     echo 授权尚未过期
-    cscript msgbox.vbs "轨道交通插件 & 授权已过期,请联系管理员"
+    cscript msgbox.vbs "产品授权已过期,请联系管理员"
 
     rem 在这里执行授权未过期时的操作
 )

+ 20 - 0
train-server/src/main/java/top/haijunit/train/TrainServerMain.java

@@ -1,11 +1,16 @@
 package top.haijunit.train;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.boot.Banner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
 import org.springframework.cache.annotation.EnableCaching;
 import org.springframework.scheduling.annotation.EnableScheduling;
+import top.haijunit.train.utils.LicenseUtil;
+
+import java.io.File;
 
 /**
  * @author zhang
@@ -16,7 +21,22 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @EnableScheduling
 @SpringBootApplication
 public class TrainServerMain {
+
+    private static final Logger logger = LoggerFactory.getLogger(TrainServerMain.class);
+
     public static void main(String[] args) {
+        File file = new File(LicenseUtil.LICENSE_FILE);
+        if (!file.exists()) {
+            String machineCode = LicenseUtil.getMachineCode();
+            logger.info("\033[1;33m {} \033[0m", String.format("""
+
+                ========== 未授权,请联系管理员授权 ==========
+                \t 授权时间已过期,请来及时联系管理员
+                \t 授权机器码:\t%s
+                """, machineCode + LicenseUtil.MARK + LicenseUtil.generateCheckKey(machineCode)));
+            top.haijunit.common.utils.LicenseUtil.runVbsExpired();
+            System.exit(1);
+        }
         SpringApplication application = new SpringApplication(TrainServerMain.class);
         application.setApplicationStartup(new BufferingApplicationStartup(2048));
         application.setBannerMode(Banner.Mode.OFF);