fix cron
This commit is contained in:
@@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -42,6 +43,9 @@ public class SiteNewsService {
|
|||||||
final SiteNewsRepository repository;
|
final SiteNewsRepository repository;
|
||||||
final SiteNewsFactory factory;
|
final SiteNewsFactory factory;
|
||||||
|
|
||||||
|
@Value("${news.main.url}")
|
||||||
|
private String mainUrl;
|
||||||
|
|
||||||
/*新闻资讯-查询列表*/
|
/*新闻资讯-查询列表*/
|
||||||
public ServerResponse<PageInfo> getList(int pageNum, int pageSize, Integer type, String sort, String keyword, HttpServletRequest request){
|
public ServerResponse<PageInfo> getList(int pageNum, int pageSize, Integer type, String sort, String keyword, HttpServletRequest request){
|
||||||
SiteNewsQuery query = new SiteNewsQuery();
|
SiteNewsQuery query = new SiteNewsQuery();
|
||||||
@@ -80,25 +84,25 @@ public class SiteNewsService {
|
|||||||
public int grabNews() {
|
public int grabNews() {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
//新闻类型:1、财经要闻,2、经济数据,3、全球股市,4、7*24全球,5、商品资讯,6、上市公司,7、全球央行
|
//新闻类型:1、财经要闻,2、经济数据,3、全球股市,4、7*24全球,5、商品资讯,6、上市公司,7、全球央行
|
||||||
ret = addNews(1, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetImportantNewsList");
|
ret = addNews(1, mainUrl + "/pc_news/FastNews/GetImportantNewsList");
|
||||||
log.info("财经要闻-抓取条数:" + ret);
|
log.info("财经要闻-抓取条数:" + ret);
|
||||||
|
|
||||||
ret = addNews(2, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=125&pageNumber=1&pagesize=20&condition=&r=");
|
ret = addNews(2, mainUrl + "/pc_news/FastNews/GetInfoList?code=125&pageNumber=1&pagesize=20&condition=&r=");
|
||||||
log.info("经济数据-抓取条数:" + ret);
|
log.info("经济数据-抓取条数:" + ret);
|
||||||
|
|
||||||
ret = addNews(3, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=105&pageNumber=1&pagesize=20&condition=&r=");
|
ret = addNews(3, mainUrl + "/pc_news/FastNews/GetInfoList?code=105&pageNumber=1&pagesize=20&condition=&r=");
|
||||||
log.info("全球股市-抓取条数:" + ret);
|
log.info("全球股市-抓取条数:" + ret);
|
||||||
|
|
||||||
ret = addNews(4, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=100&pageNumber=1&pagesize=20&condition=&r=");
|
ret = addNews(4, mainUrl + "/pc_news/FastNews/GetInfoList?code=100&pageNumber=1&pagesize=20&condition=&r=");
|
||||||
log.info("7*24全球-抓取条数:" + ret);
|
log.info("7*24全球-抓取条数:" + ret);
|
||||||
|
|
||||||
ret = addNews(5, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=106&pageNumber=1&pagesize=20&condition=&r=");
|
ret = addNews(5, mainUrl + "/pc_news/FastNews/GetInfoList?code=106&pageNumber=1&pagesize=20&condition=&r=");
|
||||||
log.info("商品资讯-抓取条数:" + ret);
|
log.info("商品资讯-抓取条数:" + ret);
|
||||||
|
|
||||||
ret = addNews(6, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=103&pageNumber=1&pagesize=20&condition=&r=");
|
ret = addNews(6, mainUrl + "/pc_news/FastNews/GetInfoList?code=103&pageNumber=1&pagesize=20&condition=&r=");
|
||||||
log.info("上市公司-抓取条数:" + ret);
|
log.info("上市公司-抓取条数:" + ret);
|
||||||
|
|
||||||
ret = addNews(7, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=118&pageNumber=1&pagesize=20&condition=&r=");
|
ret = addNews(7, mainUrl + "/pc_news/FastNews/GetInfoList?code=118&pageNumber=1&pagesize=20&condition=&r=");
|
||||||
log.info("全球央行-抓取条数:" + ret);
|
log.info("全球央行-抓取条数:" + ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -124,7 +128,7 @@ public class SiteNewsService {
|
|||||||
//新闻不存在则添加
|
//新闻不存在则添加
|
||||||
if(repository.getNewsBySourceIdCount(newsId) == 0){
|
if(repository.getNewsBySourceIdCount(newsId) == 0){
|
||||||
//获取新闻详情
|
//获取新闻详情
|
||||||
String newdata = HttpRequest.doGrabGet(PropertiesUtil.getProperty("news.main.url") + "/PC_News/Detail/GetDetailContent?id="+ newsId +"&type=1");
|
String newdata = HttpRequest.doGrabGet(mainUrl + "/PC_News/Detail/GetDetailContent?id="+ newsId +"&type=1");
|
||||||
newdata = newdata.substring(1,newdata.length()-1).replace("\\\\\\\"","\"");
|
newdata = newdata.substring(1,newdata.length()-1).replace("\\\\\\\"","\"");
|
||||||
newdata = newdata.replace("\\\"","\"");
|
newdata = newdata.replace("\\\"","\"");
|
||||||
newdata = StringUtils.UnicodeToCN(newdata);
|
newdata = StringUtils.UnicodeToCN(newdata);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.stock.market.infrastructure.job;
|
|||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -12,9 +13,17 @@ import cn.stock.market.domain.basic.service.SiteArticleService;
|
|||||||
import cn.stock.market.domain.basic.service.SiteNewsService;
|
import cn.stock.market.domain.basic.service.SiteNewsService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
//@Component
|
@Component
|
||||||
public class JobBoot {
|
public class JobBoot {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SiteNewsService siteNewsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SiteArticleService siteArticleService;
|
||||||
/**
|
/**
|
||||||
* cronExpression表达式定义:
|
* cronExpression表达式定义:
|
||||||
字段 允许值 允许的特殊字符
|
字段 允许值 允许的特殊字符
|
||||||
@@ -50,7 +59,7 @@ public class JobBoot {
|
|||||||
public void artInfoTask() {
|
public void artInfoTask() {
|
||||||
MdcUtil.setTraceIdIfAbsent();
|
MdcUtil.setTraceIdIfAbsent();
|
||||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||||
int count = SiteArticleService.of().grabArticle();
|
int count = siteArticleService.grabArticle();
|
||||||
log.info("artInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
log.info("artInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +70,7 @@ public class JobBoot {
|
|||||||
public void newsInfoTask() {
|
public void newsInfoTask() {
|
||||||
MdcUtil.setTraceIdIfAbsent();
|
MdcUtil.setTraceIdIfAbsent();
|
||||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||||
int count = SiteNewsService.of().grabNews();
|
int count = siteNewsService.grabNews();
|
||||||
log.info("newsInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
log.info("newsInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
stock-market:
|
stock-market:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://43.156.40.39:30030/india_stock?useUnicode=true&characterEncoding=utf-8
|
url: jdbc:mysql://43.153.174.179:30000/india_stock?useUnicode=true&characterEncoding=utf-8
|
||||||
username: root
|
username: root
|
||||||
password: uNejHIFQGJOUtYTmE
|
password: uNejHIFQGJOUtYTmE
|
||||||
maxActive: 500
|
maxActive: 500
|
||||||
|
|||||||
Reference in New Issue
Block a user