|
|
@ -24,6 +24,7 @@ import java.time.LocalDate;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalTime;
|
|
|
|
import java.time.LocalTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -107,12 +108,13 @@ public class MetaAlarmInfoController extends BaseController {
|
|
|
|
return getDataTable(list);
|
|
|
|
return getDataTable(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/filterByDay")
|
|
|
|
@GetMapping("/filterByDay")
|
|
|
|
@ApiOperation("七天接警信息表")
|
|
|
|
@ApiOperation("七天接警信息表")
|
|
|
|
public AjaxResult filterByDay(MetaAlarmInfo metaAlarmInfo) {
|
|
|
|
public AjaxResult filterByDay(MetaAlarmInfo metaAlarmInfo) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 获取当前日期
|
|
|
|
// 获取当前日期
|
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
|
|
|
|
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
// 循环迭代前7天
|
|
|
|
// 循环迭代前7天
|
|
|
@ -139,6 +141,39 @@ public class MetaAlarmInfoController extends BaseController {
|
|
|
|
return AjaxResult.error("请求失败,请联系管理员");
|
|
|
|
return AjaxResult.error("请求失败,请联系管理员");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/filterByHour")
|
|
|
|
|
|
|
|
@ApiOperation("当天接警信息表")
|
|
|
|
|
|
|
|
public AjaxResult filterByHour(MetaAlarmInfo metaAlarmInfo) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// 获取当前日期和时间
|
|
|
|
|
|
|
|
LocalDateTime currentDateTime = LocalDateTime.now();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前小时数
|
|
|
|
|
|
|
|
int currentHour = currentDateTime.getHour();
|
|
|
|
|
|
|
|
//将分钟和秒数置为零,表示当前时间点的小时的开始
|
|
|
|
|
|
|
|
LocalDateTime startOfCurrentHour = currentDateTime.withMinute(0).withSecond(0);
|
|
|
|
|
|
|
|
//创建一个TreeMap 用于存储每天的数据量
|
|
|
|
|
|
|
|
Map<String, Long> hourlyCountsMap = new TreeMap<>();
|
|
|
|
|
|
|
|
//循环
|
|
|
|
|
|
|
|
for (int i = 0; i < currentHour; i++) {
|
|
|
|
|
|
|
|
//构造查询条件
|
|
|
|
|
|
|
|
LocalDateTime startOfHour = startOfCurrentHour.minusHours(currentHour - i);
|
|
|
|
|
|
|
|
LocalDateTime endOfHour = startOfHour.plusHours(1);
|
|
|
|
|
|
|
|
QueryWrapper<MetaAlarmInfo> queryWrapper = new QueryWrapper<>(metaAlarmInfo);
|
|
|
|
|
|
|
|
queryWrapper.between("alarm_response_time",startOfHour.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")),
|
|
|
|
|
|
|
|
endOfHour.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
|
|
|
|
|
|
|
//查询当前小时的记录数据总数
|
|
|
|
|
|
|
|
long HourCount = metaAlarmInfoService.count(queryWrapper);
|
|
|
|
|
|
|
|
//存
|
|
|
|
|
|
|
|
hourlyCountsMap.put(endOfHour.format(DateTimeFormatter.ofPattern("HH:mm")),HourCount);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(hourlyCountsMap);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
logger.info(StringKit.toString(e));
|
|
|
|
|
|
|
|
return AjaxResult.error("请求失败,请联系管理员");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping
|
|
|
|
@PostMapping
|
|
|
|
@ApiOperation("新增接警信息表")
|
|
|
|
@ApiOperation("新增接警信息表")
|
|
|
|