2048社区定时任务
This commit is contained in:
parent
bf1561d092
commit
7a535d9dd2
|
|
@ -0,0 +1,25 @@
|
|||
package com.xjs.business.webmagic;
|
||||
|
||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.business.webmagic.factory.RemoteWebmagicWeiXinSouGouFactory;
|
||||
import com.xjs.business.webmagic.factory.RemoteWebmagicY2048communityFactory;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* 2048远程调用
|
||||
*
|
||||
* @author xiejs
|
||||
* @since 2022-06-20
|
||||
*/
|
||||
@FeignClient(contextId = "remoteWebmagicY2048communityFeign",
|
||||
value = ServiceNameConstants.BUSINESS_WEBMAGIC_SERVICE,
|
||||
fallbackFactory = RemoteWebmagicY2048communityFactory.class)
|
||||
public interface RemoteWebmagicY2048communityFeign {
|
||||
|
||||
@GetMapping("/y2048community/taskForPRC")
|
||||
R y2048communityTaskForPRC();
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.xjs.business.webmagic.factory;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.business.webmagic.RemoteWebmagicY2048communityFeign;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 2048降级
|
||||
* @author xiejs
|
||||
* @since 2022-06-20
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class RemoteWebmagicY2048communityFactory implements FallbackFactory<RemoteWebmagicY2048communityFeign> {
|
||||
@Override
|
||||
public RemoteWebmagicY2048communityFeign create(Throwable cause) {
|
||||
return new RemoteWebmagicY2048communityFeign() {
|
||||
@Override
|
||||
public R y2048communityTaskForPRC() {
|
||||
log.error("2048 爬虫定时任务 降级------服务可能正在运行");
|
||||
return R.fail("降级处理------服务可能正在运行");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.xjs.job.task.webmagic;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.business.webmagic.RemoteWebmagicY2048communityFeign;
|
||||
import com.xjs.job.aop.TaskLog;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 2048定时任务
|
||||
* @author xiejs
|
||||
* @since 2022-06-20
|
||||
*/
|
||||
@Component("Y2048communityTask")
|
||||
@Log4j2
|
||||
public class Y2048communityTask {
|
||||
@Resource
|
||||
private RemoteWebmagicY2048communityFeign remoteWebmagicY2048communityFeign;
|
||||
|
||||
@TaskLog(name = "2048社区爬虫任务")
|
||||
public void execute() {
|
||||
log.info("---------------爬虫-2048定时任务Start-------------------");
|
||||
|
||||
R r = remoteWebmagicY2048communityFeign.y2048communityTaskForPRC();
|
||||
|
||||
log.info("爬虫-2048定时任务结果:code={},msg={},data={}",r.getCode(),r.getMsg(),r.getData());
|
||||
log.info("---------------爬虫-2048定时任务end---------------------");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.map.MapUtil;
|
|||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.security.annotation.RequiresLogin;
|
||||
import com.ruoyi.system.api.RemoteLogService;
|
||||
import com.ruoyi.system.api.RemoteUserService;
|
||||
import com.ruoyi.system.api.domain.SysOperLog;
|
||||
|
|
@ -82,7 +81,6 @@ public class IndexController {
|
|||
|
||||
@GetMapping("showData")
|
||||
@ApiOperation("展示数据")
|
||||
@RequiresLogin
|
||||
public AjaxResult showWbSearch() throws ExecutionException, InterruptedException {
|
||||
CompletableFuture<List<ApiTopsearchWeibo>> weiboListFuture = CompletableFuture.supplyAsync(() ->
|
||||
apiTopsearchWeiboService.showWbSearch(), executor);
|
||||
|
|
|
|||
|
|
@ -22,8 +22,12 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
|
|||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
log.info("获取天气数据中...");
|
||||
weatherService.saveNowWeather();
|
||||
weatherService.cacheForecastWeather();
|
||||
try {
|
||||
weatherService.saveNowWeather();
|
||||
weatherService.cacheForecastWeather();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log.info("获取天气数据完成...");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class InitConst {
|
|||
/**
|
||||
* 控制开关,true开 false关
|
||||
*/
|
||||
public static final Boolean CONTROL = true;
|
||||
public static final Boolean CONTROL = false;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class Y2048communityProcessor implements PageProcessor {
|
|||
|
||||
// 根据每天日期获取最新
|
||||
|
||||
// todo 网络情况好的时候爬取所有页面
|
||||
// 网络情况好的时候爬取所有页面
|
||||
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue