2023年11月8日 减慢请求速度,增加自动更改上下课开关

This commit is contained in:
bai 2023-11-08 02:23:07 +08:00
parent 6a63f1043f
commit ffe83dbff0
2 changed files with 43 additions and 30 deletions

View File

@ -8,6 +8,7 @@ import cn.hutool.http.HttpUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.beust.jcommander.internal.Sets;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -28,6 +29,7 @@ import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@Slf4j
@ -69,6 +71,8 @@ public class RefreshLiveServer extends BaseSync {
queryWrapper.eq("xm","教师近景");
queryWrapper.eq("changshang","奥威亚");
IPage<KcZhihuijiaoshi> pageList = kcZhihuijiaoshiController.queryPageListN(jiaoshi, 1,-1,queryWrapper);
Set<String> onList = Sets.newHashSet();
Set<String> outList = Sets.newHashSet();
if(pageList != null){
List<KcZhihuijiaoshi> list = pageList.getRecords();
//正在上课的数据
@ -93,7 +97,9 @@ public class RefreshLiveServer extends BaseSync {
log.info("返回内容:" + res);//live_setParam_ret=ok
//记录日志
mnitorLog.setLogType(1);//播放成功
onList.add(x.getJsbh());
} catch (Exception e){
outList.add(x.getJsbh());
//播放失败
//开启
log.error(e.getMessage(),e);
@ -135,6 +141,20 @@ public class RefreshLiveServer extends BaseSync {
});
}
if(!onList.isEmpty()){
UpdateWrapper<KcZhihuijiaoshi> onUw = new UpdateWrapper<>();
onUw.set("sfyx",0);
onUw.in("jsbh",onList);
kcZhihuijiaoshiService.update(onUw);
}
if(!outList.isEmpty()) {
UpdateWrapper<KcZhihuijiaoshi> outUw = new UpdateWrapper<>();
outUw.set("sfyx", 1);
outUw.in("jsbh", outList);
kcZhihuijiaoshiService.update(outUw);
}
}
/**

View File

@ -4,10 +4,8 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -20,7 +18,6 @@ import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.kc.grab.SynchronizationService.RefreshLiveServer;
import org.jeecg.modules.kc.jiaoshi.entity.KcJiaoxuelouInfo;
import org.jeecg.modules.kc.jiaoshi.entity.KcZhihuijiaoshi;
@ -40,19 +37,11 @@ import org.jeecg.modules.kc.ktgl.service.IKcKetangbiaoService;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.jeecg.modules.tools.DictUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
@ -115,24 +104,6 @@ public class KcZhihuijiaoshiController extends JeecgController<KcZhihuijiaoshi,
starTime = DateUtil.endOfDay(starTime);//校正为今天末尾
String nowStr = starTime.toString("yyyy-MM-dd");
QueryWrapper<KcKetangbiao> ktqw = new QueryWrapper<>();
ktqw.eq("skrq",nowStr);
// ktqw.apply("skrq >= STR_TO_DATE('"+nowStr+"', '%Y-%m-%d')");
// ktqw.apply("skrq < DATE_ADD(STR_TO_DATE('"+nowStr+"','%Y-%m-%d'),INTERVAL 1 DAY)");
ktqw.isNotNull("jsbh");
List<KcKetangbiao> kcKetangbiaoList = kcKetangbiaoService.list(ktqw);
starTime = starTime.offset(DateField.DAY_OF_MONTH,1);//明天
String nowStr2 = starTime.toString("yyyy-MM-dd");
QueryWrapper<KcKetangbiao> nextDayKtqw = new QueryWrapper<>();
nextDayKtqw.eq("hh","01、02");//明天的只查0102这个节次的
// nextDayKtqw.apply("skrq >= STR_TO_DATE('"+nowStr2+"', '%Y-%m-%d')");
// nextDayKtqw.apply("skrq < DATE_ADD(STR_TO_DATE('"+nowStr2+"','%Y-%m-%d'),INTERVAL 1 DAY)");
ktqw.eq("skrq",nowStr);
ktqw.isNotNull("jsbh");
List<KcKetangbiao> nextDayKcKetangbiaoList = kcKetangbiaoService.list(nextDayKtqw);
//查询全部的教学楼
//QueryWrapper<KcKetangbiao> jxlqw = new QueryWrapper<>();
List<KcJiaoxuelouInfo> jiaoxuelouInfoList = kcJiaoxuelouInfoService.list();
@ -148,6 +119,8 @@ public class KcZhihuijiaoshiController extends JeecgController<KcZhihuijiaoshi,
nextJcMap.put("09、10","11、12");
nextJcMap.put("11、12","01、02");
AtomicReference<String> jieci = new AtomicReference<>();
//查询节次时间
QueryWrapper<KcJieci> jcqw = new QueryWrapper<>();
jcqw.like("jieci","");
@ -162,6 +135,7 @@ public class KcZhihuijiaoshiController extends JeecgController<KcZhihuijiaoshi,
if(jieciIntTime.getKsTime() <= nowTimeNum && nowTimeNum <= jieciIntTime.getJsTime()){
//符合当前节
kcJieciMap.put(x.getJieci(), jieciIntTime);
jieci.set(x.getJieci());
}
//下一节次
@ -176,6 +150,25 @@ public class KcZhihuijiaoshiController extends JeecgController<KcZhihuijiaoshi,
}
});
QueryWrapper<KcKetangbiao> ktqw = new QueryWrapper<>();
ktqw.eq("skrq",nowStr);
ktqw.eq(StringUtils.isNotBlank(jieci.get()),"hh",jieci.get());
// ktqw.apply("skrq >= STR_TO_DATE('"+nowStr+"', '%Y-%m-%d')");
// ktqw.apply("skrq < DATE_ADD(STR_TO_DATE('"+nowStr+"','%Y-%m-%d'),INTERVAL 1 DAY)");
ktqw.isNotNull("jsbh");
List<KcKetangbiao> kcKetangbiaoList = kcKetangbiaoService.list(ktqw);
starTime = starTime.offset(DateField.DAY_OF_MONTH,1);//明天
// String nowStr2 = starTime.toString("yyyy-MM-dd");
QueryWrapper<KcKetangbiao> nextDayKtqw = new QueryWrapper<>();
nextDayKtqw.eq("hh","01、02");//明天的只查0102这个节次的
// nextDayKtqw.apply("skrq >= STR_TO_DATE('"+nowStr2+"', '%Y-%m-%d')");
// nextDayKtqw.apply("skrq < DATE_ADD(STR_TO_DATE('"+nowStr2+"','%Y-%m-%d'),INTERVAL 1 DAY)");
ktqw.eq("skrq",nowStr);
ktqw.isNotNull("jsbh");
List<KcKetangbiao> nextDayKcKetangbiaoList = kcKetangbiaoService.list(nextDayKtqw);
//根据节次信息包装进Map
Map<String, String> kcKetangbiaoNowSet = Maps.newHashMap();
Map<String, String> kcKetangbiaoNextSet = Maps.newHashMap();