Explorar el Código

按时调用功能方法提取

nahida hace 1 año
padre
commit
8f9bbe8040

+ 15 - 18
data-service/src/main/java/com/zksy/data/schedule/CollectDataSchedule.java

@@ -110,15 +110,7 @@ public class CollectDataSchedule {
         List<String> serviceList = List.of(
                 "xcrEnvironmentalPenaltyDecisionServiceImpl"
         );
-        serviceList.parallelStream().forEach((q)->{
-            try {
-                Object bean = applicationContext.getBean(q);
-                ((IBaseSaveDataInterface) bean).saveDataByUniCode(serviceMap.get(q));
-            } catch (BeansException e) {
-                log.error("获取name为:{}的bean失败",q);
-                throw new RuntimeException(e);
-            }
-        });
+        commonHandler(serviceList);
     }
 
     @Scheduled(cron = "0 0 2 * * ?")
@@ -136,15 +128,7 @@ public class CollectDataSchedule {
         List<String> serviceList = List.of(
                 "xcrEnterprisePollutionPermitInfoServiceImpl"
         );
-        serviceList.parallelStream().forEach((q)->{
-            try {
-                Object bean = applicationContext.getBean(q);
-                ((IBaseSaveDataInterface) bean).saveDataByUniCode(serviceMap.get(q));
-            } catch (BeansException e) {
-                log.error("获取name为:{}的bean失败",q);
-                throw new RuntimeException(e);
-            }
-        });
+        commonHandler(serviceList);
 
     }
     @Scheduled(cron = "0 0 5 ? * SUN")
@@ -155,4 +139,17 @@ public class CollectDataSchedule {
     public void getDataByWeek3() {
 
     }
+
+
+    private void commonHandler(List<String> serviceList) {
+        serviceList.parallelStream().forEach((q)->{
+            try {
+                Object bean = applicationContext.getBean(q);
+                ((IBaseSaveDataInterface) bean).saveDataByUniCode(serviceMap.get(q));
+            } catch (BeansException e) {
+                log.error("获取name为:{}的bean失败",q);
+                throw new RuntimeException(e);
+            }
+        });
+    }
 }