Просмотр исходного кода

cron表达式时间统一调整为凌晨两点

sky 5 лет назад
Родитель
Сommit
6043322c39

+ 1 - 1
seec-data-server/src/main/java/cn/seecoder/data/server/schedule/CoderSchedule.java

@@ -42,7 +42,7 @@ public class CoderSchedule {
 
     private final String source = "coder";
 
-//    @Scheduled(cron = "00 00 00 * * ?")
+    @Scheduled(cron = "0 0 2 * * ? *")
     @DataExtractor(source)
     @Transactional(rollbackFor = Exception.class)
     public void coderDataExtraction() throws Exception {

+ 1 - 1
seec-data-server/src/main/java/cn/seecoder/data/server/schedule/EvaluateSchedule.java

@@ -37,7 +37,7 @@ public class EvaluateSchedule {
 
 
     @DataExtractor("evaluate")
-    @Scheduled(cron = "00 00 00 * * ?")
+//    @Scheduled(cron = "0 0 2 * * ? *")
     public void evaluateDataExtration(){
         Date date = new Date();
         Calendar calendar = Calendar.getInstance();

+ 1 - 1
seec-data-server/src/main/java/cn/seecoder/data/server/schedule/HelperSchedule.java

@@ -36,7 +36,7 @@ public class HelperSchedule {
         this.helperEventRepository = helperEventRepository;
     }
 
-    @Scheduled(cron = "00 00 00 * * ?")
+//    @Scheduled(cron = "0 0 2 * * ? *")
     public void helperQuizExtraction(){
         RestTemplate restTemplate = new RestTemplate();
         JSONArray temp;

+ 1 - 1
seec-data-server/src/main/java/cn/seecoder/data/server/schedule/PlaygroundSchedule.java

@@ -42,7 +42,7 @@ public class PlaygroundSchedule {
 
     private final String source = "playground";
 
-//    @Scheduled(cron = "00 00 00 * * ?")
+    @Scheduled(cron = "0 0 2 * * ? *")
     @DataExtractor(source)
     @Transactional(rollbackFor = Exception.class)
     public void playGroundDataExtraction() throws Exception {

+ 2 - 1
seec-data-server/src/main/java/cn/seecoder/data/server/schedule/SonarSchedule.java

@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.ParameterizedTypeReference;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
 
@@ -39,7 +40,7 @@ public class SonarSchedule {
     @Autowired
     private RestTemplate restTemplate;
 
-    //    @Scheduled(cron = "00 00 00 * * ?")
+    @Scheduled(cron = "0 0 2 * * ? *")
     @DataExtractor(source)
     @Transactional(rollbackFor = Exception.class)
     public void coderSoanrDataExtraction() throws Exception {

+ 22 - 0
seec-data-server/src/test/java/cn/seecoder/data/server/schedule/PlaygroundScheduleTest.java

@@ -0,0 +1,22 @@
+package cn.seecoder.data.server.schedule;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.*;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest
+public class PlaygroundScheduleTest {
+
+    @Autowired
+    PlaygroundSchedule playgroundSchedule;
+
+    @Test
+    public void playGroundDataExtraction() throws Exception {
+        playgroundSchedule.playGroundDataExtraction();
+    }
+}