@@ -2,7 +2,6 @@ package cn.stock.market.infrastructure.job;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -13,29 +12,21 @@ import cn.stock.market.domain.basic.service.SiteArticleService;
|
||||
import cn.stock.market.domain.basic.service.SiteNewsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
//@Component
|
||||
public class JobBoot {
|
||||
|
||||
@Autowired
|
||||
private SiteNewsService siteNewsService;
|
||||
|
||||
@Autowired
|
||||
private SiteArticleService siteArticleService;
|
||||
/**
|
||||
* cronExpression表达式定义:
|
||||
字段 允许值 允许的特殊字符
|
||||
秒 0-59 , - * /
|
||||
分 0-59 , - * /
|
||||
小时 0-23 , - * /
|
||||
日期 1-31 , - * ? / L W C
|
||||
月份 1-12 或者 JAN-DEC , - * /
|
||||
星期 1-7 或者 SUN-SAT , - * ? / L C #
|
||||
年(可选) 留空, 1970-2099 , - * /
|
||||
|
||||
https://blog.csdn.net/ClementAD/article/details/42042111
|
||||
字段 允许值 允许的特殊字符
|
||||
秒 0-59 , - * /
|
||||
分 0-59 , - * /
|
||||
小时 0-23 , - * /
|
||||
日期 1-31 , - * ? / L W C
|
||||
月份 1-12 或者 JAN-DEC , - * /
|
||||
星期 1-7 或者 SUN-SAT , - * ? / L C #
|
||||
年(可选) 留空, 1970-2099 , - * /
|
||||
|
||||
https://blog.csdn.net/ClementAD/article/details/42042111
|
||||
*/
|
||||
// @Scheduled(cron="0 0/1 * * * ? ")
|
||||
@Scheduled(cron="0/30 * * * * ? ")
|
||||
@@ -44,33 +35,33 @@ public class JobBoot {
|
||||
// Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
// log.info("batchStockTrust执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
|
||||
@Scheduled(cron="0/30 * * * * ? ")
|
||||
public void batchStockPosition() {
|
||||
MdcUtil.setTraceIdIfAbsent();
|
||||
// Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
// log.info("batchStockPosition执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
/*
|
||||
* 新闻资讯抓取
|
||||
* */
|
||||
|
||||
/*
|
||||
* 新闻资讯抓取
|
||||
* */
|
||||
@Scheduled(cron = "0 0/30 9-20 * * ?")
|
||||
public void artInfoTask() {
|
||||
MdcUtil.setTraceIdIfAbsent();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
int count = siteArticleService.grabArticle();
|
||||
log.info("artInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
/*
|
||||
* 新闻资讯抓取
|
||||
* */
|
||||
@Scheduled(cron = "0 0/30 9-20 * * ?")
|
||||
public void newsInfoTask() {
|
||||
MdcUtil.setTraceIdIfAbsent();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
int count = siteNewsService.grabNews();
|
||||
log.info("newsInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
public void artInfoTask() {
|
||||
MdcUtil.setTraceIdIfAbsent();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
int count = SiteArticleService.of().grabArticle();
|
||||
log.info("artInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
/*
|
||||
* 新闻资讯抓取
|
||||
* */
|
||||
@Scheduled(cron = "0 0/30 9-20 * * ?")
|
||||
public void newsInfoTask() {
|
||||
MdcUtil.setTraceIdIfAbsent();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
int count = SiteNewsService.of().grabNews();
|
||||
log.info("newsInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user