7天的接口修改优化

develop
Angel 10 months ago
parent 3f30f6068c
commit dc20967b0a

@ -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<LocalDate, Long> dailyCountsMap = new TreeMap<>();
List<PeopleVehicleFlow> list = peopleVehicleFlowService.list(new QueryWrapper<>(peopleVehicleFlow));
// 查询数据库
List<PeopleVehicleFlow> 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();

@ -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();

@ -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;
}

Loading…
Cancel
Save