develop
Angel 11 months ago
parent 9af22ba0e9
commit 3918aee047

@ -2,7 +2,9 @@ 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;
import io.swagger.annotations.Api;
@ -12,7 +14,11 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@Api(tags = "人口和车辆七天流量记录表")
@RestController
@ -24,10 +30,25 @@ public class PeopleVehicleFlowController extends BaseController {
@GetMapping
@ApiOperation("查询人车记录表")
public TableDataInfo<PeopleVehicleFlow> list(PeopleVehicleFlow peopleVehicleFlow) {
startPage();
//QueryWrapper<PeopleVehicleFlow> queryWrapper = new QueryWrapper<>(peopleVehicleFlow);
public AjaxResult list(PeopleVehicleFlow peopleVehicleFlow) {
try {
// 创建一个 TreeMap 用于存储每天的数据量
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
List<PeopleVehicleFlow> list = peopleVehicleFlowService.list(new QueryWrapper<>(peopleVehicleFlow));
return getDataTable(list);
for (PeopleVehicleFlow flow : list) {
String countString = flow.getStatisticCount();
String timeString = flow.getStatisticTime();
// 将时间字符串转换为 LocalDate
LocalDate time = LocalDate.parse(timeString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// 将计数字符串转换为 Long
Long count = Long.parseLong(countString);
dailyCountsMap.put(time, count);
}
return AjaxResult.success(dailyCountsMap);
} catch (Exception e) {
logger.info(StringKit.toString(e));
return AjaxResult.error("请求失败,请联系管理员");
}
}
}

@ -2,7 +2,9 @@ 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.domain.PeopleVehicleHourFlow;
import com.ruoyi.database.service.PeopleVehicleHourFlowService;
@ -13,7 +15,11 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@Api(tags = "人口和车辆当天流量记录表")
@RestController
@ -25,10 +31,25 @@ public class PeopleVehicleHourFlowController extends BaseController {
@GetMapping
@ApiOperation("查询人车记录表")
public TableDataInfo<PeopleVehicleHourFlow> list(PeopleVehicleHourFlow peopleVehicleHFlow) {
startPage();
//QueryWrapper<PeopleVehicleFlow> queryWrapper = new QueryWrapper<>(peopleVehicleFlow);
public AjaxResult list(PeopleVehicleHourFlow peopleVehicleHFlow) {
try {
// 创建一个 TreeMap 用于存储每天的数据量
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
List<PeopleVehicleHourFlow> list = peopleVehicleHourFlowService.list(new QueryWrapper<>(peopleVehicleHFlow));
return getDataTable(list);
for (PeopleVehicleHourFlow flow : list) {
String countString = flow.getStatisticCount();
String timeString = flow.getStatisticTime();
// 将时间字符串转换为 LocalDate
LocalDate time = LocalDate.parse(timeString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// 将计数字符串转换为 Long
Long count = Long.parseLong(countString);
dailyCountsMap.put(time, count);
}
return AjaxResult.success(dailyCountsMap);
} catch (Exception e) {
logger.info(StringKit.toString(e));
return AjaxResult.error("请求失败,请联系管理员");
}
}
}

Loading…
Cancel
Save