From 6b8e207669abf349a0478503ce63790691017037 Mon Sep 17 00:00:00 2001 From: Angel <1050374295@qq.com> Date: Fri, 12 Jan 2024 09:29:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=83=E5=A4=A9=E8=AD=A6=E6=83=85=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1---=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MetaAlarmInfoController.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java b/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java index c75521f..a798373 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java @@ -4,8 +4,6 @@ package com.ruoyi.database.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.utils.StringKit; 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.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; @@ -22,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Map; @@ -71,16 +70,20 @@ public class MetaAlarmInfoController extends BaseController { for (int i = 1; i <= 7; i++) { LocalDate date = currentDate.minusDays(i); 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 vehicleQueryWrapper = new QueryWrapper<>(metaAlarmInfo); - vehicleQueryWrapper.between("alarm_response_unit", startDateTime, endDateTime); + vehicleQueryWrapper.between("alarm_response_time", startDateString, endDateString); + // 查询当前日期的记录数据总数 long vehicleCount = metaAlarmInfoService.count(vehicleQueryWrapper); // 存储结果到 TreeMap 中 dailyCountsMap.put(date, vehicleCount); } - return AjaxResult.success(dailyCountsMap); } catch (Exception e) { logger.info(StringKit.toString(e));