修改定时任务

master
吴顺杰 1 year ago
parent a6a1868831
commit 9f9077d149

@ -155,7 +155,7 @@ public class RemoteCallsController extends BaseController {
// 同人事件接口 // 同人事件接口
remoteCallsService.onepersonAlgorithm(); remoteCallsService.onepersonAlgorithm();
// 推送 // 推送
remoteCallsService.imports(null); remoteCallsService.imports(1);
return success(); return success();
} }
@ -178,12 +178,17 @@ public class RemoteCallsController extends BaseController {
* @return * @return
*/ */
@ApiOperation(value = "调用过滤办结和作废接口") @ApiOperation(value = "调用过滤办结和作废接口")
@GetMapping("/callTheAPI") @GetMapping("/callTheAPI/{type}")
public AjaxResult callTheAPI() { public AjaxResult callTheAPI(@PathVariable("type") Integer type) {
// 获取上个小时 String lastHourStr = null;
String lastHourStr = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH:mm:ss"); String localDateStr = null;
// 获取当前时间 if (type == 1) {
String localDateStr = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss"); // 获取上个小时
lastHourStr = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH:mm:ss");
// 获取当前时间
localDateStr = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss");
}
log.info("==============开始调用" + localDateStr + "============"); log.info("==============开始调用" + localDateStr + "============");
// 过滤审核不通过的事件列表 // 过滤审核不通过的事件列表
remoteCallsService.noPassEventList(lastHourStr, localDateStr); remoteCallsService.noPassEventList(lastHourStr, localDateStr);

@ -1,5 +1,6 @@
package com.ruoyi.pt.quartz; package com.ruoyi.pt.quartz;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.ruoyi.pt.service.RemoteCallsService; import com.ruoyi.pt.service.RemoteCallsService;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -31,10 +32,11 @@ public class PushQuartz {
@Scheduled(cron = "0 0 */1 * * ?") @Scheduled(cron = "0 0 */1 * * ?")
public synchronized void pushData() { public synchronized void pushData() {
DateTime dataTime = DateUtil.date();
// 获取上个小时 // 获取上个小时
String lastHourStr = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH:mm:ss"); String lastHourStr = DateUtil.offsetHour(dataTime, -1).toString("yyyy-MM-dd HH:mm:ss");
// 获取当前时间 // 获取当前时间
String localDateStr = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss"); String localDateStr = DateUtil.beginOfDay(dataTime).toString("yyyy-MM-dd HH:mm:ss");
log.info("==============开始定时任务" + localDateStr + "============"); log.info("==============开始定时任务" + localDateStr + "============");
// 过滤审核不通过的事件列表 // 过滤审核不通过的事件列表
log.info("==============过滤审核不通过的事件列表" + "============"); log.info("==============过滤审核不通过的事件列表" + "============");

@ -3,6 +3,7 @@ package com.ruoyi.pt.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
@ -103,12 +104,12 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
// 创建查询条件 // 创建查询条件
QueryWrapper<Events> queryWrapper = new QueryWrapper<>(); QueryWrapper<Events> queryWrapper = new QueryWrapper<>();
if (allPush != null && allPush == 1) { if (allPush != null && allPush == 1) {
// 获取天的日期 // 获取天的日期
// LocalDate localDate = LocalDate.now(); // LocalDate localDate = LocalDate.now();
// LocalDate yesterday = localDate.minusDays(1);
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// String eventTime = yesterday.format(formatter); // // 当天
// 获取上个小时 // String eventTime = localDate.format(formatter);
//获取上个小时
String eventTime = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH"); String eventTime = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH");
queryWrapper.and(wrapper -> wrapper.gt("eventTime", eventTime)); queryWrapper.and(wrapper -> wrapper.gt("eventTime", eventTime));
} }
@ -336,8 +337,10 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
String accessToken = this.getAccessToken(); String accessToken = this.getAccessToken();
Map<String, Object> form = new HashMap<>(); Map<String, Object> form = new HashMap<>();
form.put("size", 1000); form.put("size", 1000);
form.put("startTime", lastHourStr); if (StrUtil.isNotEmpty(lastHourStr) && StrUtil.isNotEmpty(localDateStr)) {
form.put("endTime", localDateStr); form.put("startTime", lastHourStr);
form.put("endTime", localDateStr);
}
int current = 1; int current = 1;
// 循环获取所有数据 // 循环获取所有数据
while (true) { while (true) {
@ -354,8 +357,9 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
if (state == 1) { if (state == 1) {
List<String> notPassed = list.stream() List<String> notPassed = list.stream()
.filter(x -> x.getIfInstruct().equals("2")) .filter(x -> x.getIfInstruct().equals("2"))
.map(PassEventRequest::getId) .map(PassEventRequest::getInnerEventId)
.collect(Collectors.toList()); .collect(Collectors.toList());
log.info("IfInstruct=2的数据条数=====================" + notPassed.size() + "=========================");
if (CollectionUtil.isNotEmpty(notPassed)) { if (CollectionUtil.isNotEmpty(notPassed)) {
QueryWrapper<Events> wrapper = new QueryWrapper<>(); QueryWrapper<Events> wrapper = new QueryWrapper<>();
wrapper.in("innerEventId", notPassed); wrapper.in("innerEventId", notPassed);
@ -365,8 +369,9 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
} }
List<String> disuse = list.stream() List<String> disuse = list.stream()
.filter(x -> x.getIfInstruct().equals("4")) .filter(x -> x.getIfInstruct().equals("4"))
.map(PassEventRequest::getId) .map(PassEventRequest::getInnerEventId)
.collect(Collectors.toList()); .collect(Collectors.toList());
log.info("IfInstruct=4的数据条数=====================" + disuse.size() + "=========================");
if (CollectionUtil.isNotEmpty(disuse)) { if (CollectionUtil.isNotEmpty(disuse)) {
QueryWrapper<Events> wrapper = new QueryWrapper<>(); QueryWrapper<Events> wrapper = new QueryWrapper<>();
wrapper.in("innerEventId", disuse); wrapper.in("innerEventId", disuse);

Loading…
Cancel
Save