parent
82a3137f0f
commit
8f36a77d2b
@ -0,0 +1,24 @@
|
||||
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.RemoteWebmagic36wallpaperFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* 内部 调用 36壁纸网 爬虫定时任务
|
||||
*
|
||||
* @author xiejs
|
||||
* @since 2022-02-20
|
||||
*/
|
||||
@FeignClient(contextId = "remoteWebmagic36wallpaperFeign",
|
||||
value = ServiceNameConstants.BUSINESS_WEBMAGIC_SERVICE,
|
||||
fallbackFactory = RemoteWebmagic36wallpaperFactory.class)
|
||||
public interface RemoteWebmagic36wallpaperFeign {
|
||||
|
||||
@GetMapping("/_36wallpaper/taskForPRC")
|
||||
public R _36wallpaperControllerTaskForPRC();
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.xjs.business.webmagic.factory;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.business.webmagic.RemoteWebmagic36wallpaperFeign;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 内部 调用 36壁纸网 爬虫定时任务降级
|
||||
* @author xiejs
|
||||
* @since 2022-02-20
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class RemoteWebmagic36wallpaperFactory implements FallbackFactory<RemoteWebmagic36wallpaperFeign> {
|
||||
@Override
|
||||
public RemoteWebmagic36wallpaperFeign create(Throwable cause) {
|
||||
return new RemoteWebmagic36wallpaperFeign() {
|
||||
@Override
|
||||
public R _36wallpaperControllerTaskForPRC() {
|
||||
log.error("新浪 爬虫定时任务 降级------服务可能正在运行");
|
||||
return R.fail("降级处理------服务可能正在运行");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.xjs.job.task.webmagic;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.xjs.business.webmagic.RemoteWebmagic36wallpaperFeign;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
/**
|
||||
* 爬虫 36壁纸网 定时任务
|
||||
* @author xiejs
|
||||
* @since 2022-02-20
|
||||
*/
|
||||
@Component("Wallpaper_36Task")
|
||||
@Log4j2
|
||||
public class _36wallpaperTask {
|
||||
|
||||
@Resource
|
||||
private RemoteWebmagic36wallpaperFeign remoteWebmagic36wallpaperFeign;
|
||||
|
||||
/**
|
||||
* 爬虫 36壁纸网 定时任务执行
|
||||
*/
|
||||
public void _36wallpaper() {
|
||||
log.info("---------------爬虫-36壁纸网定时任务Start-------------------");
|
||||
LocalDateTime localDateTime1 = DateUtil.date().toLocalDateTime();
|
||||
|
||||
R r = remoteWebmagic36wallpaperFeign._36wallpaperControllerTaskForPRC();
|
||||
|
||||
log.info("爬虫-36壁纸网定时任务结果:code={},msg={},data={}",r.getCode(),r.getMsg(),r.getData());
|
||||
LocalDateTime localDateTime2 = DateUtil.date().toLocalDateTime();
|
||||
long between = ChronoUnit.MILLIS.between(localDateTime1, localDateTime2);
|
||||
log.info("爬虫-36壁纸网定时任务Job耗费时间:{}ms", between);
|
||||
log.info("---------------爬虫-36壁纸网定时任务end---------------------");
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue