按前端要求修改

develop
Angel 10 months ago
parent 5ed5749746
commit 18eecf0a36

@ -31,14 +31,14 @@ public class PeopleVehicleHourFlowController extends BaseController {
@GetMapping
@ApiOperation("查询人车记录表")
public AjaxResult list(@RequestParam String statisticTime, @RequestParam int statistictype) {
public AjaxResult list( @RequestParam int statistictype) {
try {
// 解析前端传递的日期参数
LocalDate date = LocalDate.parse(statisticTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 构建日期时间范围从当天的00:00到23:59:59
LocalDateTime startDateTime = date.atStartOfDay();
LocalDateTime endDateTime = date.plusDays(1).atStartOfDay().minusSeconds(1);
LocalDateTime startDateTime = currentDate.atStartOfDay();
LocalDateTime endDateTime = currentDate.plusDays(1).atStartOfDay().minusSeconds(1);
// 构建查询条件
PeopleVehicleHourFlow queryFlow = new PeopleVehicleHourFlow();
@ -47,14 +47,17 @@ public class PeopleVehicleHourFlowController extends BaseController {
queryFlow.setStatisticType(statistictype);
// 查询数据库
List<PeopleVehicleHourFlow> list = peopleVehicleHourFlowService.list(new QueryWrapper<>(queryFlow) .between("statistic_time", startDateTime, endDateTime)); // 添加日期范围条件
List<PeopleVehicleHourFlow> list = peopleVehicleHourFlowService.list(new QueryWrapper<>(queryFlow)
.between("statistic_time", startDateTime, endDateTime).eq("statistic_type", statistictype)); // 添加日期范围条件
// 处理查询结果
Map<LocalDateTime, Long> hourlyCountsMap = new TreeMap<>();
Map<String, Long> hourlyCountsMap = new TreeMap<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
for (PeopleVehicleHourFlow flow : list) {
LocalDateTime time = LocalDateTime.parse(flow.getStatisticTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
String formattedTime = time.format(formatter);
Long count = Long.parseLong(flow.getStatisticCount());
hourlyCountsMap.put(time, count);
hourlyCountsMap.put(formattedTime, count);
}
return AjaxResult.success(hourlyCountsMap);
} catch (Exception e) {

Loading…
Cancel
Save