七天警情统计---修改

develop
Angel 10 months ago
parent 104bf589c2
commit 6b8e207669

@ -4,8 +4,6 @@ package com.ruoyi.database.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.StringKit; import com.ruoyi.common.utils.StringKit;
import com.ruoyi.database.domain.MetaAlarmInfo; import com.ruoyi.database.domain.MetaAlarmInfo;
import com.ruoyi.database.domain.PeopleVehicleFlow;
import com.ruoyi.database.domain.TransitVehicleRecord;
import com.ruoyi.database.service.MetaAlarmInfoService; import com.ruoyi.database.service.MetaAlarmInfoService;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -22,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -71,16 +70,20 @@ public class MetaAlarmInfoController extends BaseController {
for (int i = 1; i <= 7; i++) { for (int i = 1; i <= 7; i++) {
LocalDate date = currentDate.minusDays(i); LocalDate date = currentDate.minusDays(i);
LocalDateTime startDateTime = date.atStartOfDay(); LocalDateTime startDateTime = date.atStartOfDay();
LocalDateTime endDateTime = date.plusDays(1).atStartOfDay(); LocalDateTime endDateTime = date.atTime(LocalTime.MAX);
// 构造查询条件 // 构造查询条件
String startDateString = startDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
String endDateString = endDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
QueryWrapper<MetaAlarmInfo> vehicleQueryWrapper = new QueryWrapper<>(metaAlarmInfo); QueryWrapper<MetaAlarmInfo> vehicleQueryWrapper = new QueryWrapper<>(metaAlarmInfo);
vehicleQueryWrapper.between("alarm_response_unit", startDateTime, endDateTime); vehicleQueryWrapper.between("alarm_response_time", startDateString, endDateString);
// 查询当前日期的记录数据总数 // 查询当前日期的记录数据总数
long vehicleCount = metaAlarmInfoService.count(vehicleQueryWrapper); long vehicleCount = metaAlarmInfoService.count(vehicleQueryWrapper);
// 存储结果到 TreeMap 中 // 存储结果到 TreeMap 中
dailyCountsMap.put(date, vehicleCount); dailyCountsMap.put(date, vehicleCount);
} }
return AjaxResult.success(dailyCountsMap); return AjaxResult.success(dailyCountsMap);
} catch (Exception e) { } catch (Exception e) {
logger.info(StringKit.toString(e)); logger.info(StringKit.toString(e));

Loading…
Cancel
Save