Authored by 张帅

更改成异步执行

... ... @@ -8,6 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@RestController
public class GrassDataSyncController {
... ... @@ -22,21 +25,35 @@ public class GrassDataSyncController {
@RequestMapping("/syncArticle")
public String syncArticle(@RequestParam("startTime") Long startTime, @RequestParam("endTime") Long endTime){
return grassArticleSyncService.syncArticle(startTime, endTime);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(() -> {
grassArticleSyncService.syncArticle(startTime, endTime);
});
executorService.shutdown();
return "success";
}
@RequestMapping("/syncInteractiveData")
public String syncInteractiveData(@RequestParam("startTime") Integer startTime, @RequestParam("endTime") Integer endTime,
@RequestParam("timeType") Integer timeType, @RequestParam("syncType") Integer syncType){
return grassInteractiveDataSyncService.syncInteractiveData(startTime, endTime, timeType, syncType);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(() -> {
grassInteractiveDataSyncService.syncInteractiveData(startTime, endTime, timeType, syncType);
});
executorService.shutdown();
return "success";
}
@RequestMapping("/syncUserData")
public String syncUserData(@RequestParam("startTime") Integer startTime, @RequestParam("endTime") Integer endTime,
@RequestParam("syncType") Integer syncType){
return grassUserDataSyncService.syncGrassUserData(startTime, endTime, syncType);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(() -> {
grassUserDataSyncService.syncGrassUserData(startTime, endTime, syncType);
});
executorService.shutdown();
return "success";
}
}
... ...
... ... @@ -8,6 +8,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by shengguo.cai on 2019/3/19.
... ... @@ -29,7 +31,12 @@ public class YohoNowDataSynController {
@RequestMapping("/synYohoNow/article")
public String synArticle(@RequestParam("begTime") long begTime,@RequestParam("endTime") long endTime){
logger.info("synArticle: begTime is {}, endTime is {}", begTime, endTime);
return yohoNowDataSynService.synArticle(begTime,endTime);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(() -> {
yohoNowDataSynService.synArticle(begTime,endTime);
});
executorService.shutdown();
return "success";
}
/**
... ... @@ -40,6 +47,12 @@ public class YohoNowDataSynController {
*/
@RequestMapping("/synYohoNow/articleAttach")
public String synArticleAttach(@RequestParam("begTime") long begTime,@RequestParam("endTime") long endTime,@RequestParam("type") int type,@RequestParam("isFromArticle") boolean isFromArticle){
return yohoNowDataSynService.synArticleAttach(begTime,endTime,type,isFromArticle);
logger.info("synArticle: begTime is {}, endTime is {}", begTime, endTime);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(() -> {
yohoNowDataSynService.synArticleAttach(begTime,endTime,type,isFromArticle);
});
executorService.shutdown();
return "success";
}
}
... ...
... ... @@ -4,4 +4,4 @@ spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.type=trace
spring.jpa.show-sql=true
logging.level.org.hibernate=TRACE
\ No newline at end of file
logging.level.org.hibernate=INFO
\ No newline at end of file
... ...