|
|
@@ -41,39 +41,43 @@ public class ArticleSercieImp implements ArticleServiceInterface {
|
|
|
@Resource
|
|
|
private R2dbcEntityTemplate template;
|
|
|
|
|
|
-
|
|
|
- // @Scheduled(fixedDelay = 160000)
|
|
|
- //@Scheduled(cron = "0 0 10 * * ?")
|
|
|
- public Mono<Boolean> refresh(){
|
|
|
- // DateTime yesterday = DateUtil.yesterday();
|
|
|
+ @Scheduled(cron = "0 0 7 * * ?")
|
|
|
+ public void refresh(){
|
|
|
String format = DateUtil.format(new Date(), "yyyy-MM-dd");
|
|
|
- Criteria criteria = Criteria.where("status").is(1)
|
|
|
- .and("crawler_collection_time").greaterThan(format + " 00:00:01")
|
|
|
- .and("crawler_collection_time").lessThan(format + " 23:59:59");
|
|
|
- Query query = Query.query(criteria);
|
|
|
int size=50;
|
|
|
- return template.count(query, ArticleData.class).flatMap(fm -> {
|
|
|
- long page = fm % 50L;
|
|
|
- long page0 = fm / 50L;
|
|
|
- if (page > 0) {
|
|
|
- page0++;
|
|
|
- }
|
|
|
- int i = 0;
|
|
|
- while (i < page0) {
|
|
|
- // 循环体
|
|
|
- refreshInitialization(i, size,criteria).subscribe();
|
|
|
- i++;
|
|
|
+ Mono<Long> count = template.count(Query.query(Criteria.where("date_time_str").is(format)), Article.class);
|
|
|
+ count.flatMap(aLong -> {
|
|
|
+ if(aLong>0){
|
|
|
+ return Mono.just(true);
|
|
|
}
|
|
|
- return Mono.just(true);
|
|
|
- });
|
|
|
+ Criteria criteria = Criteria.where("status").is(1)
|
|
|
+ .and("crawler_collection_time").greaterThan(format + " 00:00:01")
|
|
|
+ .and("crawler_collection_time").lessThan(format + " 23:59:59");
|
|
|
+ Query query = Query.query(criteria);
|
|
|
+ return template.count(query, ArticleData.class).flatMap(fm -> {
|
|
|
+ long page = fm % 50L;
|
|
|
+ long page0 = fm / 50L;
|
|
|
+ if (page > 0) {
|
|
|
+ page0++;
|
|
|
+ }
|
|
|
+ int i = 0;
|
|
|
+ while (i < page0) {
|
|
|
+ // 循环体
|
|
|
+ refreshInitialization(i, size,criteria).subscribe();
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ return Mono.just(true);
|
|
|
+ });
|
|
|
+ }).subscribe();
|
|
|
+
|
|
|
}
|
|
|
@Override
|
|
|
public Mono<Boolean> ArticleData(){
|
|
|
int size=50;
|
|
|
- Query query = Query.query(Criteria.where("status").is(1));
|
|
|
Mono<Long> count = template.select(Article.class).count();
|
|
|
return count.flatMap(aLong ->{
|
|
|
if(aLong==0){
|
|
|
+ Query query = Query.query(Criteria.where("status").is(1));
|
|
|
return template.count(query, ArticleData.class).flatMap(fm -> {
|
|
|
long page = fm % 50L;
|
|
|
long page0 = fm / 50L;
|
|
|
@@ -205,8 +209,8 @@ public class ArticleSercieImp implements ArticleServiceInterface {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Mono<RStatus<LabelManagement>> getArticle(Long id) {
|
|
|
- Mono<LabelManagement> id1 = template.selectOne(Query.query(Criteria.where("id").is(id)), LabelManagement.class)
|
|
|
+ public Mono<RStatus<Article>> getArticle(Long id) {
|
|
|
+ Mono<Article> id1 = template.selectOne(Query.query(Criteria.where("id").is(id)), Article.class)
|
|
|
.onErrorResume(throwable -> Mono.error(new BaseException("查询失败:" + throwable.getMessage())));
|
|
|
return RStatus.success(id1);
|
|
|
}
|
|
|
@@ -619,7 +623,12 @@ public class ArticleSercieImp implements ArticleServiceInterface {
|
|
|
AppidDomain appidDomain = appidDomains.get(i);
|
|
|
AppidDomainRes appidDomainRes = new AppidDomainRes();
|
|
|
appidDomainRes.setAppid(appidDomain.appid());
|
|
|
- appidDomainRes.setDomain(appidDomain.domain());
|
|
|
+ String domain = appidDomain.domain();
|
|
|
+ if (Objects.nonNull(domain)) {
|
|
|
+ String[] split = domain.split(",");
|
|
|
+ int i1 = RandomUtil.randomInt(0, split.length);
|
|
|
+ appidDomainRes.setDomain(split[i1]);
|
|
|
+ }
|
|
|
return Mono.just(appidDomainRes);
|
|
|
});
|
|
|
return RStatus.success(appidDomainResMono);
|