|
|
@@ -0,0 +1,45 @@
|
|
|
+package cn.seecoder.data.server.schedule;
|
|
|
+
|
|
|
+
|
|
|
+import cn.seecoder.data.server.domain.GeneralRecordDao;
|
|
|
+import cn.seecoder.data.server.domain.HelperQuizDao;
|
|
|
+import cn.seecoder.data.server.repository.GeneralRecordRepository;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class HelperSchedule {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GeneralRecordRepository generalRecordRepository;
|
|
|
+
|
|
|
+ @Scheduled(cron = "00 00 00 * * ?")
|
|
|
+ public void HelperQuizExtraction(){
|
|
|
+// HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
|
|
|
+// httpRequestFactory.setConnectionRequestTimeout(10*1000);
|
|
|
+// httpRequestFactory.setConnectTimeout(10*1000);
|
|
|
+// httpRequestFactory.setReadTimeout(10*1000);
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ GeneralRecordDao generalRecordDao = new GeneralRecordDao();
|
|
|
+ HelperQuizDao helperQuizDao = new HelperQuizDao();
|
|
|
+ JSONArray temp;
|
|
|
+ try{
|
|
|
+ temp = restTemplate.getForObject(
|
|
|
+ "http://localhost:8080/api/quiz/quiz-records/all?start={1}&end={2}",
|
|
|
+ JSONArray.class,
|
|
|
+ "2010-01-01 00:00:00",
|
|
|
+ "2020-06-01 00:00:00"
|
|
|
+ );
|
|
|
+ for(int i=0;i<temp.size();i++){
|
|
|
+ JSONObject quiz_record = temp.getJSONObject(i);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ System.out.println(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|