修改定时任务;

添加指定eventsId推送消息接口
master
吴顺杰 1 year ago
parent fdfab8c34b
commit 88eff8e120

@ -1,6 +1,5 @@
package com.ruoyi.pt.controller; package com.ruoyi.pt.controller;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.pt.service.CasesImportService; import com.ruoyi.pt.service.CasesImportService;
@ -11,13 +10,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
@ -64,18 +63,6 @@ public class RemoteCallsController extends BaseController {
return success(); return success();
} }
/**
* copy
*
* @return
*/
@ApiOperation(value = "事件进度临时推送接口copy表")
@PostMapping("/temporaryImports")
public AjaxResult temporaryImports() {
remoteCallsService.temporaryImports();
return success();
}
/** /**
* events_import * events_import
* *
@ -96,10 +83,16 @@ public class RemoteCallsController extends BaseController {
@ApiOperation(value = "过滤审核不通过的事件列表") @ApiOperation(value = "过滤审核不通过的事件列表")
@GetMapping("/noPassEventList") @GetMapping("/noPassEventList")
public AjaxResult noPassEventList() { public AjaxResult noPassEventList() {
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 获取当前时间的上一个小时
LocalDateTime lastHour = now.minusHours(1);
// 获取上个小时 // 获取上个小时
String lastHourStr = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime lastHourWholeHour = lastHour.withMinute(0).withSecond(0);
String lastHourStr = lastHourWholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 获取当前时间 // 获取当前时间
String localDateStr = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime wholeHour = now.withMinute(0).withSecond(0);
String localDateStr = wholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
remoteCallsService.noPassEventList(lastHourStr, localDateStr); remoteCallsService.noPassEventList(lastHourStr, localDateStr);
return success(); return success();
} }
@ -112,10 +105,16 @@ public class RemoteCallsController extends BaseController {
@ApiOperation(value = "过滤已办结的事件列表") @ApiOperation(value = "过滤已办结的事件列表")
@GetMapping("/completionEventList") @GetMapping("/completionEventList")
public AjaxResult completionEventList() { public AjaxResult completionEventList() {
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 获取当前时间的上一个小时
LocalDateTime lastHour = now.minusHours(1);
// 获取上个小时 // 获取上个小时
String lastHourStr = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime lastHourWholeHour = lastHour.withMinute(0).withSecond(0);
String lastHourStr = lastHourWholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 获取当前时间 // 获取当前时间
String localDateStr = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime wholeHour = now.withMinute(0).withSecond(0);
String localDateStr = wholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
remoteCallsService.completionEventList(lastHourStr, localDateStr); remoteCallsService.completionEventList(lastHourStr, localDateStr);
return success(); return success();
} }
@ -129,10 +128,16 @@ public class RemoteCallsController extends BaseController {
@ApiOperation(value = "更新算法数据并推送") @ApiOperation(value = "更新算法数据并推送")
@GetMapping("/pushDate") @GetMapping("/pushDate")
public AjaxResult pushData(@RequestParam("type") Integer type) { public AjaxResult pushData(@RequestParam("type") Integer type) {
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 获取当前时间的上一个小时
LocalDateTime lastHour = now.minusHours(1);
// 获取上个小时 // 获取上个小时
String lastHourStr = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime lastHourWholeHour = lastHour.withMinute(0).withSecond(0);
String lastHourStr = lastHourWholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 获取当前时间 // 获取当前时间
String localDateStr = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime wholeHour = now.withMinute(0).withSecond(0);
String localDateStr = wholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 过滤审核不通过的事件列表 // 过滤审核不通过的事件列表
remoteCallsService.noPassEventList(lastHourStr, localDateStr); remoteCallsService.noPassEventList(lastHourStr, localDateStr);
// 过滤已办结的事件列表 // 过滤已办结的事件列表
@ -183,10 +188,16 @@ public class RemoteCallsController extends BaseController {
String lastHourStr = null; String lastHourStr = null;
String localDateStr = null; String localDateStr = null;
if (type == 1) { if (type == 1) {
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 获取当前时间的上一个小时
LocalDateTime lastHour = now.minusHours(1);
// 获取上个小时 // 获取上个小时
lastHourStr = DateUtil.offsetHour(DateUtil.date(), -1).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime lastHourWholeHour = lastHour.withMinute(0).withSecond(0);
lastHourStr = lastHourWholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 获取当前时间 // 获取当前时间
localDateStr = DateUtil.beginOfDay(DateUtil.date()).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime wholeHour = now.withMinute(0).withSecond(0);
localDateStr = wholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
} }
log.info("==============开始调用" + localDateStr + "============"); log.info("==============开始调用" + localDateStr + "============");
@ -196,4 +207,17 @@ public class RemoteCallsController extends BaseController {
remoteCallsService.completionEventList(lastHourStr, localDateStr); remoteCallsService.completionEventList(lastHourStr, localDateStr);
return success(); return success();
} }
/**
* id
*
* @param innerEventId id
* @return
*/
@ApiOperation(value = "事件进度推送接口")
@GetMapping("/pushByInnerEventId/{innerEventId}")
public AjaxResult pushById(@PathVariable("innerEventId") String innerEventId) {
remoteCallsService.pushByInnerEventId(innerEventId);
return success();
}
} }

@ -32,11 +32,16 @@ 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(); // 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 获取当前时间的上一个小时
LocalDateTime lastHour = now.minusHours(1);
// 获取上个小时 // 获取上个小时
String lastHourStr = DateUtil.offsetHour(dataTime, -1).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime lastHourWholeHour = lastHour.withMinute(0).withSecond(0);
String lastHourStr = lastHourWholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// 获取当前时间 // 获取当前时间
String localDateStr = DateUtil.beginOfDay(dataTime).toString("yyyy-MM-dd HH:mm:ss"); LocalDateTime wholeHour = now.withMinute(0).withSecond(0);
String localDateStr = wholeHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
log.info("==============开始定时任务" + localDateStr + "============"); log.info("==============开始定时任务" + localDateStr + "============");
// 过滤审核不通过的事件列表 // 过滤审核不通过的事件列表
log.info("==============过滤审核不通过的事件列表" + "============"); log.info("==============过滤审核不通过的事件列表" + "============");

@ -22,11 +22,6 @@ public interface RemoteCallsService {
*/ */
void imports(Integer allPush); void imports(Integer allPush);
/**
*
*/
void temporaryImports();
/** /**
* events_import * events_import
*/ */
@ -72,4 +67,10 @@ public interface RemoteCallsService {
*/ */
void completionEventList(String lastHourStr, String localDateStr); void completionEventList(String lastHourStr, String localDateStr);
/**
* id
*
* @param innerEventId id
*/
void pushByInnerEventId(String innerEventId);
} }

@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.pt.entity.CasesImport; import com.ruoyi.pt.entity.CasesImport;
import com.ruoyi.pt.entity.Events; import com.ruoyi.pt.entity.Events;
import com.ruoyi.pt.entity.EventsCopy;
import com.ruoyi.pt.entity.dto.RemoteCallsDTO; import com.ruoyi.pt.entity.dto.RemoteCallsDTO;
import com.ruoyi.pt.entity.response.PassEventRequest; import com.ruoyi.pt.entity.response.PassEventRequest;
import com.ruoyi.pt.entity.response.RemoteCallsResponse; import com.ruoyi.pt.entity.response.RemoteCallsResponse;
@ -177,61 +176,6 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
} }
} }
/**
*
*/
@Override
public void temporaryImports() {
log.info("==========临时推送开始=========");
String accessToken = this.getAccessToken();
// 初始化MyBatis-Plus的分页对象 查询第1页每页100条
Page<EventsCopy> page = new Page<>(1, 100);
// 创建查询条件
QueryWrapper<EventsCopy> queryWrapper = new QueryWrapper<>();
queryWrapper.isNotNull("innerEventId").and(wrapper -> wrapper.ne("innerEventId", ""));
// 创建SimpleDateFormat对象指定日期格式为yyyy-MM-dd HH:mm:ss
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 循环获取所有数据
while (true) {
IPage<EventsCopy> dataPage = eventsCopyService.page(page, queryWrapper);
List<EventsCopy> data = dataPage.getRecords();
List<RemoteCallsDTO> dtos = BeanUtil.copyToList(data, RemoteCallsDTO.class);
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.setContent(x.getTitle());
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)) {
x.setEventCreator(casesImport.getCreatorName());
x.setEventCreatorTel(casesImport.getCreatorTel());
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; // 已经获取完所有数据,结束循环
}
}
}
/** /**
* events_import * events_import
*/ */
@ -317,6 +261,62 @@ public class RemoteCallsServiceImpl implements RemoteCallsService {
getTheData("getCompletionEventList", 2, lastHourStr, localDateStr); getTheData("getCompletionEventList", 2, lastHourStr, localDateStr);
} }
/**
* id
*
* @param innerEventId id
*/
@Override
public void pushByInnerEventId(String innerEventId) {
String accessToken = this.getAccessToken();
// 创建查询条件
QueryWrapper<Events> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("innerEventId", innerEventId);
// 创建SimpleDateFormat对象指定日期格式为yyyy-MM-dd HH:mm:ss
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Events event = eventsService.getOne(queryWrapper);
RemoteCallsDTO dtos = BeanUtil.copyProperties(event, RemoteCallsDTO.class);
dtos.setContent(dtos.getTitle());
// 使用SimpleDateFormat对象将Date对象格式化为字符串
String firstWarnTime = sdf.format(dtos.getFirstWarnTimeDate());
String eventTime = sdf.format(dtos.getEventTimeDate());
dtos.setFirstWarnTime(firstWarnTime);
dtos.setEventTime(firstWarnTime);
dtos.setLastWarnTime(eventTime);
// 获取relationNums转成数组
JSONArray jsonArray = JSONUtil.parseArray(dtos.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(dtos.getScenceType())) {
dtos.setContent(casesImport.getCaseContent());
} else {
dtos.setContent(dtos.getTitle());
}
// 如果类型是同人事件,上报⼈姓名和电话不取原始工单,直接从预警因素字段取,顿号分隔。
if ("2".equals(dtos.getScenceType())) {
String warnFactor = dtos.getWarnFactor();
String[] split = warnFactor.split("、");
if (split.length == 2) {
dtos.setEventCreatorTel(split[0]);
dtos.setEventCreator(split[1]);
} else {
dtos.setEventCreatorTel(split[0]);
}
} else {
dtos.setEventCreator(casesImport.getCreatorName());
dtos.setEventCreatorTel(casesImport.getCreatorTel());
}
dtos.setEventPlaceName(casesImport.getCaseAddress());
dtos.setEventCoordinate(casesImport.getCaseLnglat());
}
String jsonStr = JSONUtil.toJsonStr(dtos);
HttpRequest.post(url + "/gateway/event/event/eventData/imports").header("Authorization", "Bearer " + accessToken).body(jsonStr).execute().body();
}
/** /**
* events_import * events_import
* *

Loading…
Cancel
Save