diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/PeopleVehicleFlowController.java b/gather-app/src/main/java/com/ruoyi/database/controller/PeopleVehicleFlowController.java index 1ddb1eb..a9aa01e 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/PeopleVehicleFlowController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/PeopleVehicleFlowController.java @@ -3,7 +3,6 @@ package com.ruoyi.database.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.utils.StringKit; import com.ruoyi.database.domain.PeopleVehicleFlow; import com.ruoyi.database.service.PeopleVehicleFlowService; @@ -12,6 +11,7 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.time.LocalDate; @@ -30,11 +30,23 @@ public class PeopleVehicleFlowController extends BaseController { @GetMapping @ApiOperation("查询人车记录表") - public AjaxResult list(PeopleVehicleFlow peopleVehicleFlow) { + public AjaxResult list(@RequestParam int statistictype) { try { - // 创建一个 TreeMap 用于存储每天的数据量 + + // 获取当前日期和计算日期范围 + LocalDate currentDate = LocalDate.now(); + LocalDate startDate = currentDate.minusDays(6); // 包括今天在内的前6天 + LocalDate endDate = currentDate; + + + // 处理查询结果 Map dailyCountsMap = new TreeMap<>(); - List list = peopleVehicleFlowService.list(new QueryWrapper<>(peopleVehicleFlow)); + + // 查询数据库 + List list = peopleVehicleFlowService.list(new QueryWrapper<>(new PeopleVehicleFlow()) + .between("statistic_time", startDate.toString(), endDate.toString()) + .eq("statistic_type", statistictype)); + for (PeopleVehicleFlow flow : list) { String countString = flow.getStatisticCount(); String timeString = flow.getStatisticTime(); diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/PeopleVehicleHourFlowController.java b/gather-app/src/main/java/com/ruoyi/database/controller/PeopleVehicleHourFlowController.java index ce36fe4..b43fae6 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/PeopleVehicleHourFlowController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/PeopleVehicleHourFlowController.java @@ -31,7 +31,7 @@ public class PeopleVehicleHourFlowController extends BaseController { @GetMapping @ApiOperation("查询人车记录表") - public AjaxResult list( @RequestParam int statistictype) { + public AjaxResult list(@RequestParam int statistictype) { try { // 获取当前日期 LocalDate currentDate = LocalDate.now(); diff --git a/gather-app/src/main/java/com/ruoyi/database/domain/PeopleVehicleFlow.java b/gather-app/src/main/java/com/ruoyi/database/domain/PeopleVehicleFlow.java index 86eed5a..168fdd2 100644 --- a/gather-app/src/main/java/com/ruoyi/database/domain/PeopleVehicleFlow.java +++ b/gather-app/src/main/java/com/ruoyi/database/domain/PeopleVehicleFlow.java @@ -10,6 +10,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import java.time.LocalDate; +import java.time.LocalDateTime; + @Data @EqualsAndHashCode(callSuper = false) @TableName(value = "statistics_user_vehicle_day_info") @@ -42,4 +45,10 @@ public class PeopleVehicleFlow extends BaseEntity { @ApiModelProperty("日期") @TableField(value = "statistic_time") private String statisticTime; + // 瞬时字段,不映射到数据库 + @TableField(exist = false) + private LocalDate startDayRange; + + @TableField(exist = false) + private LocalDate endDayRange; }