Преглед на файлове

专门设置一个启动时的服务

wukai преди 3 месеца
родител
ревизия
fde5375e61
променени са 2 файла, в които са добавени 43 реда и са изтрити 17 реда
  1. 0 17
      jjt-biz/src/main/java/com/jjt/biz/service/impl/ApiServiceImpl.java
  2. 43 0
      jjt-biz/src/main/java/com/jjt/utils/InitService.java

+ 0 - 17
jjt-biz/src/main/java/com/jjt/biz/service/impl/ApiServiceImpl.java

@@ -340,21 +340,4 @@ public class ApiServiceImpl implements IApiService {
         redisCache.setCacheObject(CacheConstants.INDEX_GRAM_MASS_DETAIL, gramMassDetails);
         redisCache.setCacheObject(CacheConstants.STOP_DETAIL, stopList);
     }
-
-    @PostConstruct
-    public void init() {
-        String[] activeProfiles = env.getActiveProfiles();
-        System.err.println("================");
-        System.err.println("================");
-        System.err.println("================");
-        System.err.println("================");
-        System.err.println("================");
-        for (String profile : activeProfiles) {
-            System.err.println("Active Profile: " + profile);
-        }
-
-//        twinCalcHourService.calc2Curr();
-////        curr();
-////        today();
-    }
 }

+ 43 - 0
jjt-biz/src/main/java/com/jjt/utils/InitService.java

@@ -0,0 +1,43 @@
+package com.jjt.utils;
+
+import com.jjt.biz.service.IApiService;
+import com.jjt.calc.service.ITwinCalcHourService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
+/**
+ * 初始化启动处理
+ *
+ * @author wukai
+ * @date 2024/5/4 20:35
+ */
+@Service
+@Slf4j
+public class InitService {
+    @Resource
+    private IApiService apiService;
+    @Resource
+    private ITwinCalcHourService twinCalcHourService;
+    @Resource
+    private Environment env;
+
+    @PostConstruct
+    public void init() {
+//        String[] activeProfiles = env.getActiveProfiles();
+//        System.err.println("================");
+//        System.err.println("================");
+//        System.err.println("================");
+//        System.err.println("================");
+//        System.err.println("================");
+//        for (String profile : activeProfiles) {
+//            System.err.println("Active Profile: " + profile);
+//        }
+        twinCalcHourService.calc2Curr();
+        apiService.curr();
+        apiService.today();
+    }
+}