From 9f9077d14929f8e70d7b5b8e29327188120616eb Mon Sep 17 00:00:00 2001 From: wu Date: Mon, 15 Jan 2024 22:29:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pt/controller/RemoteCallsController.java | 19 ++++++++++------- .../java/com/ruoyi/pt/quartz/PushQuartz.java | 6 ++++-- .../service/impl/RemoteCallsServiceImpl.java | 21 ++++++++++++------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/pt/controller/RemoteCallsController.java b/ruoyi-admin/src/main/java/com/ruoyi/pt/controller/RemoteCallsController.java index ecac240..e611c8e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/pt/controller/RemoteCallsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/pt/controller/RemoteCallsController.java @@ -155,7 +155,7 @@ public class RemoteCallsController extends BaseController { // 同人事件接口 remoteCallsService.onepersonAlgorithm(); // 推送 - remoteCallsService.imports(null); + remoteCallsService.imports(1); return success(); } @@ -178,12 +178,17 @@ public class RemoteCallsController extends BaseController { * @return 响应类 */ @ApiOperation(value = "调用过滤办结和作废接口") - @GetMapping("/callTheAPI") - public AjaxResult callTheAPI() { - // 获取上个小时 - String lastHourStr = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH:mm:ss"); - // 获取当前时间 - String localDateStr = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss"); + @GetMapping("/callTheAPI/{type}") + public AjaxResult callTheAPI(@PathVariable("type") Integer type) { + String lastHourStr = null; + String localDateStr = null; + if (type == 1) { + // 获取上个小时 + 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 + "============"); // 过滤审核不通过的事件列表 remoteCallsService.noPassEventList(lastHourStr, localDateStr); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/pt/quartz/PushQuartz.java b/ruoyi-admin/src/main/java/com/ruoyi/pt/quartz/PushQuartz.java index 5d0c204..14fbbf7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/pt/quartz/PushQuartz.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/pt/quartz/PushQuartz.java @@ -1,5 +1,6 @@ package com.ruoyi.pt.quartz; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import com.ruoyi.pt.service.RemoteCallsService; import org.slf4j.Logger; @@ -31,10 +32,11 @@ public class PushQuartz { @Scheduled(cron = "0 0 */1 * * ?") 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("==============过滤审核不通过的事件列表" + "============"); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/RemoteCallsServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/RemoteCallsServiceImpl.java index e61b4e1..76bf7d6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/RemoteCallsServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/pt/service/impl/RemoteCallsServiceImpl.java @@ -3,6 +3,7 @@ package com.ruoyi.pt.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONUtil; @@ -103,12 +104,12 @@ public class RemoteCallsServiceImpl implements RemoteCallsService { // 创建查询条件 QueryWrapper queryWrapper = new QueryWrapper<>(); if (allPush != null && allPush == 1) { - // 获取昨天的日期 + // 获取当天的日期 // LocalDate localDate = LocalDate.now(); -// LocalDate yesterday = localDate.minusDays(1); // 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"); queryWrapper.and(wrapper -> wrapper.gt("eventTime", eventTime)); } @@ -336,8 +337,10 @@ public class RemoteCallsServiceImpl implements RemoteCallsService { String accessToken = this.getAccessToken(); Map form = new HashMap<>(); form.put("size", 1000); - form.put("startTime", lastHourStr); - form.put("endTime", localDateStr); + if (StrUtil.isNotEmpty(lastHourStr) && StrUtil.isNotEmpty(localDateStr)) { + form.put("startTime", lastHourStr); + form.put("endTime", localDateStr); + } int current = 1; // 循环获取所有数据 while (true) { @@ -354,8 +357,9 @@ public class RemoteCallsServiceImpl implements RemoteCallsService { if (state == 1) { List notPassed = list.stream() .filter(x -> x.getIfInstruct().equals("2")) - .map(PassEventRequest::getId) + .map(PassEventRequest::getInnerEventId) .collect(Collectors.toList()); + log.info("IfInstruct=2的数据条数=====================" + notPassed.size() + "========================="); if (CollectionUtil.isNotEmpty(notPassed)) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.in("innerEventId", notPassed); @@ -365,8 +369,9 @@ public class RemoteCallsServiceImpl implements RemoteCallsService { } List disuse = list.stream() .filter(x -> x.getIfInstruct().equals("4")) - .map(PassEventRequest::getId) + .map(PassEventRequest::getInnerEventId) .collect(Collectors.toList()); + log.info("IfInstruct=4的数据条数=====================" + disuse.size() + "========================="); if (CollectionUtil.isNotEmpty(disuse)) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.in("innerEventId", disuse);