From 29a64bfa8588a611bc83455ce9c6e6a7d78150d3 Mon Sep 17 00:00:00 2001 From: bai <1643359946@qq.com> Date: Thu, 22 Jun 2023 23:01:46 +0800 Subject: [PATCH] =?UTF-8?q?2023=E5=B9=B46=E6=9C=8822=E6=97=A5=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0=E6=99=BA=E6=85=A7?= =?UTF-8?q?=E6=95=99=E5=AE=A4=E6=98=AF=E5=90=A6=E5=9C=A8=E7=BA=BF=E7=9A=84?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RefreshLiveServer.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/RefreshLiveServer.java diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/RefreshLiveServer.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/RefreshLiveServer.java new file mode 100644 index 00000000..0b3f21c0 --- /dev/null +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/RefreshLiveServer.java @@ -0,0 +1,76 @@ +package org.jeecg.modules.kc.grab.SynchronizationService; + +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.beust.jcommander.internal.Sets; +import com.google.common.collect.Maps; +import com.xkcoding.http.HttpUtil; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.modules.kc.grab.SynchronizationService.base.BaseSync; +import org.jeecg.modules.kc.jiaoshi.entity.KcZhihuijiaoshi; +import org.jeecg.modules.kc.jiaoshi.service.IKcZhihuijiaoshiService; +import org.quartz.JobExecutionContext; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +@Slf4j +public class RefreshLiveServer extends BaseSync { + + @Autowired + private IKcZhihuijiaoshiService kcZhihuijiaoshiService; + + + /** + * 若参数变量名修改 QuartzJobController中也需对应修改 + */ + + @Override + public void execute(JobExecutionContext jobExecutionContext) { + start(); + run(getParamMap()); + end(); + } + + + /** + * 有参定时任务实现 + * @param param + */ + public void run(Map param){ + List list = kcZhihuijiaoshiService.list(); +// Map liveOnMap = Maps.newHashMap(); + Set onList = Sets.newHashSet(); + Set outList = Sets.newHashSet(); + list.forEach(x -> { + try{ + String res = HttpUtil.get(x.getPullUrl()); +// liveOnMap.put(x.getId(),true); + onList.add(x.getId()); + log.info("返回内容:" + res);//live_setParam_ret=ok + } catch (Exception e){ +// liveOnMap.put(x.getId(),false); + outList.add(x.getId()); + log.error(e.getMessage(),e); + } + }); + UpdateWrapper onUw = new UpdateWrapper(); + onUw.set("sfyx",0); + onUw.in("id",onList); + kcZhihuijiaoshiService.update(onUw); + + UpdateWrapper outUw = new UpdateWrapper(); + outUw.set("sfyx",1); + outUw.in("id",outList); + kcZhihuijiaoshiService.update(outUw); + } + + /** + * 无参定时任务实现 + */ + public void run(){ + run(null); + } + +}