|
|
|
@ -4,12 +4,14 @@ 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.HttpException;
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
|
|
|
import com.ruoyi.pt.entity.CasesImport;
|
|
|
|
|
import com.ruoyi.pt.entity.Events;
|
|
|
|
|
import com.ruoyi.pt.entity.dto.RemoteCallsDTO;
|
|
|
|
@ -62,6 +64,9 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
|
|
|
|
|
@Resource
|
|
|
|
|
private CasesImportService casesImportService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取填充信息后的map
|
|
|
|
|
*
|
|
|
|
@ -106,74 +111,87 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
|
|
|
|
|
QueryWrapper<Events> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
if (allPush != null && allPush == 1) {
|
|
|
|
|
// 获取当天的日期
|
|
|
|
|
// LocalDate localDate = LocalDate.now();
|
|
|
|
|
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
// // 当天
|
|
|
|
|
// String eventTime = localDate.format(formatter);
|
|
|
|
|
//获取上个小时
|
|
|
|
|
String eventTime = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH");
|
|
|
|
|
queryWrapper.and(wrapper -> wrapper.gt("eventTime", eventTime));
|
|
|
|
|
// LocalDate localDate = LocalDate.now();
|
|
|
|
|
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
// // 当天
|
|
|
|
|
// String eventTime = localDate.format(formatter);
|
|
|
|
|
String eventTime;
|
|
|
|
|
// 获取redis上次异常的时间
|
|
|
|
|
Object obj = redisCache.getCacheObject("eventTime");
|
|
|
|
|
if (BeanUtil.isNotEmpty(obj)) {
|
|
|
|
|
eventTime = (String) obj;
|
|
|
|
|
redisCache.deleteObject("eventTime");
|
|
|
|
|
} else {
|
|
|
|
|
//获取上个小时
|
|
|
|
|
eventTime = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH");
|
|
|
|
|
}
|
|
|
|
|
queryWrapper.and(wrapper -> wrapper.ge("eventTime", eventTime));
|
|
|
|
|
}
|
|
|
|
|
queryWrapper.and(wrapper -> wrapper.isNotNull("innerEventId").ne("innerEventId", "")).isNull("state");
|
|
|
|
|
// 创建SimpleDateFormat对象,指定日期格式为yyyy-MM-dd HH:mm:ss
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// 循环获取所有数据
|
|
|
|
|
while (true) {
|
|
|
|
|
IPage<Events> dataPage = eventsService.page(page, queryWrapper);
|
|
|
|
|
List<Events> data = dataPage.getRecords();
|
|
|
|
|
List<RemoteCallsDTO> dtos = BeanUtil.copyToList(data, RemoteCallsDTO.class);
|
|
|
|
|
num += dtos.size();
|
|
|
|
|
log.info("==========推送数据条数=========> " + dtos.size());
|
|
|
|
|
dtos.forEach(x -> {
|
|
|
|
|
x.setContent(x.getTitle());
|
|
|
|
|
// 使用SimpleDateFormat对象将Date对象格式化为字符串
|
|
|
|
|
String firstWarnTime = sdf.format(x.getFirstWarnTimeDate());
|
|
|
|
|
String eventTime = sdf.format(x.getEventTimeDate());
|
|
|
|
|
x.setFirstWarnTime(firstWarnTime);
|
|
|
|
|
x.setEventTime(firstWarnTime);
|
|
|
|
|
x.setLastWarnTime(eventTime);
|
|
|
|
|
// 获取relationNums转成数组
|
|
|
|
|
JSONArray jsonArray = JSONUtil.parseArray(x.getRelationNums());
|
|
|
|
|
List<String> list = jsonArray.toList(String.class);
|
|
|
|
|
QueryWrapper<CasesImport> wrapper = new QueryWrapper<>();
|
|
|
|
|
wrapper.eq("CASE_SERIAL", list.get(0));
|
|
|
|
|
CasesImport casesImport = casesImportService.getOne(wrapper);
|
|
|
|
|
if (BeanUtil.isNotEmpty(casesImport)) {
|
|
|
|
|
// 如果是紧急事件content使用原始工单的content
|
|
|
|
|
if ("3".equals(x.getScenceType())) {
|
|
|
|
|
x.setContent(casesImport.getCaseContent());
|
|
|
|
|
} else {
|
|
|
|
|
x.setContent(x.getTitle());
|
|
|
|
|
}
|
|
|
|
|
// 如果类型是同人事件,上报⼈姓名和电话不取原始工单,直接从预警因素字段取,顿号分隔。
|
|
|
|
|
if ("2".equals(x.getScenceType())) {
|
|
|
|
|
String warnFactor = x.getWarnFactor();
|
|
|
|
|
String[] split = warnFactor.split("、");
|
|
|
|
|
if (split.length == 2) {
|
|
|
|
|
x.setEventCreatorTel(split[0]);
|
|
|
|
|
x.setEventCreator(split[1]);
|
|
|
|
|
try {
|
|
|
|
|
queryWrapper.and(wrapper -> wrapper.isNotNull("innerEventId").ne("innerEventId", "")).isNull("state");
|
|
|
|
|
// 创建SimpleDateFormat对象,指定日期格式为yyyy-MM-dd HH:mm:ss
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// 循环获取所有数据
|
|
|
|
|
while (true) {
|
|
|
|
|
IPage<Events> dataPage = eventsService.page(page, queryWrapper);
|
|
|
|
|
List<Events> data = dataPage.getRecords();
|
|
|
|
|
List<RemoteCallsDTO> dtos = BeanUtil.copyToList(data, RemoteCallsDTO.class);
|
|
|
|
|
num += dtos.size();
|
|
|
|
|
log.info("==========推送数据条数=========> " + dtos.size());
|
|
|
|
|
dtos.forEach(x -> {
|
|
|
|
|
x.setContent(x.getTitle());
|
|
|
|
|
// 使用SimpleDateFormat对象将Date对象格式化为字符串
|
|
|
|
|
String firstWarnTime = sdf.format(x.getFirstWarnTimeDate());
|
|
|
|
|
String eventTime = sdf.format(x.getEventTimeDate());
|
|
|
|
|
x.setFirstWarnTime(firstWarnTime);
|
|
|
|
|
x.setEventTime(firstWarnTime);
|
|
|
|
|
x.setLastWarnTime(eventTime);
|
|
|
|
|
// 获取relationNums转成数组
|
|
|
|
|
JSONArray jsonArray = JSONUtil.parseArray(x.getRelationNums());
|
|
|
|
|
List<String> list = jsonArray.toList(String.class);
|
|
|
|
|
QueryWrapper<CasesImport> wrapper = new QueryWrapper<>();
|
|
|
|
|
wrapper.eq("CASE_SERIAL", list.get(0));
|
|
|
|
|
CasesImport casesImport = casesImportService.getOne(wrapper);
|
|
|
|
|
if (BeanUtil.isNotEmpty(casesImport)) {
|
|
|
|
|
// 如果是紧急事件content使用原始工单的content
|
|
|
|
|
if ("3".equals(x.getScenceType())) {
|
|
|
|
|
x.setContent(casesImport.getCaseContent());
|
|
|
|
|
} else {
|
|
|
|
|
x.setContent(x.getTitle());
|
|
|
|
|
}
|
|
|
|
|
// 如果类型是同人事件,上报⼈姓名和电话不取原始工单,直接从预警因素字段取,顿号分隔。
|
|
|
|
|
if ("2".equals(x.getScenceType())) {
|
|
|
|
|
String warnFactor = x.getWarnFactor();
|
|
|
|
|
String[] split = warnFactor.split("、");
|
|
|
|
|
if (split.length == 2) {
|
|
|
|
|
x.setEventCreatorTel(split[0]);
|
|
|
|
|
x.setEventCreator(split[1]);
|
|
|
|
|
} else {
|
|
|
|
|
x.setEventCreatorTel(split[0]);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
x.setEventCreatorTel(split[0]);
|
|
|
|
|
x.setEventCreator(casesImport.getCreatorName());
|
|
|
|
|
x.setEventCreatorTel(casesImport.getCreatorTel());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
x.setEventCreator(casesImport.getCreatorName());
|
|
|
|
|
x.setEventCreatorTel(casesImport.getCreatorTel());
|
|
|
|
|
x.setEventPlaceName(casesImport.getCaseAddress());
|
|
|
|
|
x.setEventCoordinate(casesImport.getCaseLnglat());
|
|
|
|
|
}
|
|
|
|
|
x.setEventPlaceName(casesImport.getCaseAddress());
|
|
|
|
|
x.setEventCoordinate(casesImport.getCaseLnglat());
|
|
|
|
|
});
|
|
|
|
|
String jsonStr = JSONUtil.toJsonStr(dtos);
|
|
|
|
|
HttpRequest.post(url + "/gateway/event/event/eventData/imports").header("Authorization", "Bearer " + accessToken).body(jsonStr).execute().body();
|
|
|
|
|
// 判断是否还有下一页
|
|
|
|
|
if (dataPage.getPages() > dataPage.getCurrent()) {
|
|
|
|
|
// 设置下一页的页码
|
|
|
|
|
page.setCurrent(page.getCurrent() + 1);
|
|
|
|
|
} else {
|
|
|
|
|
log.info("==========推送完成=========");
|
|
|
|
|
// 已经获取完所有数据,结束循环
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
String jsonStr = JSONUtil.toJsonStr(dtos);
|
|
|
|
|
HttpRequest.post(url + "/gateway/event/event/eventData/imports").header("Authorization", "Bearer " + accessToken).body(jsonStr).execute().body();
|
|
|
|
|
// 判断是否还有下一页
|
|
|
|
|
if (dataPage.getPages() > dataPage.getCurrent()) {
|
|
|
|
|
// 设置下一页的页码
|
|
|
|
|
page.setCurrent(page.getCurrent() + 1);
|
|
|
|
|
} else {
|
|
|
|
|
log.info("==========推送完成=========");
|
|
|
|
|
// 已经获取完所有数据,结束循环
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
} catch (HttpException e) {
|
|
|
|
|
redisCache.setCacheObject("eventTime", DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -362,9 +380,7 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
|
|
|
|
|
log.info("一共获取" + list.size() + "条数据");
|
|
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
|
|
// 过滤数据
|
|
|
|
|
List<CasesImport> filteredList = list.stream()
|
|
|
|
|
.filter(casesImport -> !casesImport.getEventExt().contains("12345便民-咨询"))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
List<CasesImport> filteredList = list.stream().filter(casesImport -> !casesImport.getEventExt().contains("12345便民-咨询")).collect(Collectors.toList());
|
|
|
|
|
log.info("=======================================");
|
|
|
|
|
log.info("过滤后剩下" + filteredList.size() + "条数据");
|
|
|
|
|
num += filteredList.size();
|
|
|
|
|