|
|
@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
|
|
|
import com.utils.SmsUtil;
|
|
|
|
import com.yingji.entity.Alarm;
|
|
|
|
import com.yingji.entity.Alarm;
|
|
|
|
import com.yingji.entity.QuartzLog;
|
|
|
|
import com.yingji.entity.QuartzLog;
|
|
|
|
import com.yingji.entity.dto.request.AlarmRequest;
|
|
|
|
import com.yingji.entity.dto.request.AlarmRequest;
|
|
|
@ -18,6 +19,7 @@ import org.springframework.scheduling.annotation.Async;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
@ -62,14 +64,23 @@ public class AlarmQuartz {
|
|
|
|
addList(idList, token);
|
|
|
|
addList(idList, token);
|
|
|
|
// 110算法接口
|
|
|
|
// 110算法接口
|
|
|
|
if (CollectionUtil.isNotEmpty(idList)) {
|
|
|
|
if (CollectionUtil.isNotEmpty(idList)) {
|
|
|
|
emergencyAlgorithm();
|
|
|
|
try {
|
|
|
|
|
|
|
|
emergencyAlgorithm();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
// 调用短信接口
|
|
|
|
|
|
|
|
SmsUtil.sendSms("110调用算法接口异常", null);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
quartzLog.setStatus(1);
|
|
|
|
quartzLog.setStatus(1);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
quartzLog.setStatus(2);
|
|
|
|
quartzLog.setStatus(2);
|
|
|
|
log.error("============110算法接口获取token失败=============");
|
|
|
|
// 调用短信接口
|
|
|
|
|
|
|
|
SmsUtil.sendSms("110原始接口获取token失败", null);
|
|
|
|
|
|
|
|
log.error("============110原始接口获取token失败=============");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
// 调用短信接口
|
|
|
|
|
|
|
|
SmsUtil.sendSms("110原始接口调用失败", null);
|
|
|
|
quartzLog.setStatus(2);
|
|
|
|
quartzLog.setStatus(2);
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
@ -148,6 +159,17 @@ public class AlarmQuartz {
|
|
|
|
if (StrUtil.isEmpty(token)) {
|
|
|
|
if (StrUtil.isEmpty(token)) {
|
|
|
|
return idList;
|
|
|
|
return idList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取数据库中最新的创建时间
|
|
|
|
|
|
|
|
LocalDateTime newTime = alarmService.findNewTime();
|
|
|
|
|
|
|
|
// 获取当前时间
|
|
|
|
|
|
|
|
LocalDateTime currentTime = LocalDateTime.now();
|
|
|
|
|
|
|
|
// 计算两者之间的持续时间
|
|
|
|
|
|
|
|
Duration duration = Duration.between(newTime, currentTime);
|
|
|
|
|
|
|
|
// 判断时间差是否大于一小时
|
|
|
|
|
|
|
|
if (duration.toHours() > 1) {
|
|
|
|
|
|
|
|
// 调用短信接口
|
|
|
|
|
|
|
|
SmsUtil.sendSms("110原始接口超过1小时无数据", null);
|
|
|
|
|
|
|
|
}
|
|
|
|
// 获取数据库中最新的时间
|
|
|
|
// 获取数据库中最新的时间
|
|
|
|
LocalDateTime nowTime = alarmService.findNowTime();
|
|
|
|
LocalDateTime nowTime = alarmService.findNowTime();
|
|
|
|
log.info("==========================获取数据库中最新的时间{}", nowTime);
|
|
|
|
log.info("==========================获取数据库中最新的时间{}", nowTime);
|
|
|
@ -167,7 +189,9 @@ public class AlarmQuartz {
|
|
|
|
req.setPageIndex(pageIndex);
|
|
|
|
req.setPageIndex(pageIndex);
|
|
|
|
req.setPageSize(pageSize);
|
|
|
|
req.setPageSize(pageSize);
|
|
|
|
List<String> data = alarmService.findDataIdList(req, token);
|
|
|
|
List<String> data = alarmService.findDataIdList(req, token);
|
|
|
|
idList.addAll(data);
|
|
|
|
if (CollectionUtil.isNotEmpty(data)) {
|
|
|
|
|
|
|
|
idList.addAll(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
/* while (true) {
|
|
|
|
/* while (true) {
|
|
|
|
List<String> data = alarmService.findDataIdList(req, token);
|
|
|
|
List<String> data = alarmService.findDataIdList(req, token);
|
|
|
|
if (data == null) {
|
|
|
|
if (data == null) {
|
|
|
|