Kaynağa Gözat

导出定时执行

wangyunpeng 10 ay önce
ebeveyn
işleme
ca0fd1f1be

+ 11 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/config/SchedulingConfig.java

@@ -0,0 +1,11 @@
+package com.tzld.longarticle.recommend.server.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@Configuration(proxyBeanMethods = false)
+@EnableScheduling
+@Profile("prod")
+public class SchedulingConfig {
+}

+ 7 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/DataDashboardService.java

@@ -21,6 +21,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.util.Pair;
 import org.springframework.http.*;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 import org.springframework.web.client.RestTemplate;
@@ -54,6 +55,12 @@ public class DataDashboardService {
         exportFeishuNewSortStrategy(dateStrList, sheetToken, "7d4e12");
     }
 
+    @Scheduled(cron = "0 0 9 * * ?")
+    public void scheduledExport() {
+        List<String> dateStrList = getBeforeThreeDays(null);
+        exportFeishuNewSortStrategy(dateStrList, sheetToken, "7d4e12");
+    }
+
     private List<String> getBeforeThreeDays(String dateStr) {
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
         // 获取今天的日期