2023年6月22日 新增自动刷新智慧教室是否在线的定时任务
This commit is contained in:
parent
553b68ae45
commit
29a64bfa85
|
@ -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<String, Object> param){
|
||||||
|
List<KcZhihuijiaoshi> list = kcZhihuijiaoshiService.list();
|
||||||
|
// Map<Integer,Boolean> liveOnMap = Maps.newHashMap();
|
||||||
|
Set<Integer> onList = Sets.newHashSet();
|
||||||
|
Set<Integer> 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<KcZhihuijiaoshi> onUw = new UpdateWrapper();
|
||||||
|
onUw.set("sfyx",0);
|
||||||
|
onUw.in("id",onList);
|
||||||
|
kcZhihuijiaoshiService.update(onUw);
|
||||||
|
|
||||||
|
UpdateWrapper<KcZhihuijiaoshi> outUw = new UpdateWrapper();
|
||||||
|
outUw.set("sfyx",1);
|
||||||
|
outUw.in("id",outList);
|
||||||
|
kcZhihuijiaoshiService.update(outUw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无参定时任务实现
|
||||||
|
*/
|
||||||
|
public void run(){
|
||||||
|
run(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue