修改定时任务

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

@ -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);

@ -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("==============过滤审核不通过的事件列表" + "============");

@ -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<Events> 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<String, Object> 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<String> 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<Events> wrapper = new QueryWrapper<>();
wrapper.in("innerEventId", notPassed);
@ -365,8 +369,9 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
}
List<String> 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<Events> wrapper = new QueryWrapper<>();
wrapper.in("innerEventId", disuse);

Loading…
Cancel
Save