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