|
|
|
@ -77,8 +77,8 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前7天
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
|
// 循环迭代前6天
|
|
|
|
|
for (int i = 1; i <=7 ; i++) {
|
|
|
|
|
LocalDate date = currentDate.minusDays(i);
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<TransitUserRecord> userQueryWrapper = new QueryWrapper<>(transitUserRecord);
|
|
|
|
@ -88,7 +88,6 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
// 存储结果到 TreeMap 中
|
|
|
|
|
dailyCountsMap.put(date, userCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(dailyCountsMap);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.toString(e));
|
|
|
|
@ -105,7 +104,7 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前7天
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
|
for (int i = 0; i <7; i++) {
|
|
|
|
|
LocalDate date = currentDate.minusDays(i);
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<TransitImpVehicleRecord> vehicleQueryWrapper = new QueryWrapper<>();
|
|
|
|
@ -132,7 +131,7 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前7天
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
|
for (int i = 0; i <7; i++) {
|
|
|
|
|
LocalDate date = currentDate.minusDays(i);
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<TransitImpUserRecord> userQueryWrapper = new QueryWrapper<>();
|
|
|
|
@ -159,7 +158,7 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前7天
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
|
for (int i = 1; i <= 7; i++) {
|
|
|
|
|
LocalDate date = currentDate.minusDays(i);
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<TransitVehicleRecord> vehicleQueryWrapper = new QueryWrapper<>(transitVehicleRecord);
|
|
|
|
@ -183,23 +182,39 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
try {
|
|
|
|
|
// 获取当前日期
|
|
|
|
|
LocalDateTime currentDateTime = LocalDateTime.now();
|
|
|
|
|
LocalDateTime startOfDay = currentDateTime.withHour(0).withMinute(0).withSecond(0);
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String formattedDateTime = startOfDay.format(formatter);
|
|
|
|
|
// 获取当前小时数
|
|
|
|
|
int currentHour = currentDateTime.getHour();
|
|
|
|
|
// 将分钟和秒数置为零,表示当前时间点的小时的开始
|
|
|
|
|
LocalDateTime startOfCurrentHour = currentDateTime.withMinute(0).withSecond(0);
|
|
|
|
|
|
|
|
|
|
// LocalDateTime startOfDay = currentDateTime.withHour(0).withMinute(0).withSecond(0);
|
|
|
|
|
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// String formattedDateTime = startOfDay.format(formatter);
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<String, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
|
Map<String, Long> hourlyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前7天
|
|
|
|
|
for (int i = 0; i < 24; i++) {
|
|
|
|
|
for (int i = 0; i < currentHour; i++) {
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
LocalDateTime startOfHour = startOfCurrentHour.minusHours(currentHour - i);
|
|
|
|
|
LocalDateTime endOfHour = startOfHour.plusHours(1);
|
|
|
|
|
QueryWrapper<TransitUserRecord> userQueryWrapper = new QueryWrapper<>(transitUserRecord);
|
|
|
|
|
userQueryWrapper.between("partition_field", startOfDay.plusHours(i).format(formatter), startOfDay.plusHours(i+1).format(formatter));
|
|
|
|
|
// 查询当前日期的记录数据总数
|
|
|
|
|
userQueryWrapper.between("partition_field", startOfHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
|
|
|
|
|
endOfHour.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
|
// 查询当前小时的记录数据总数
|
|
|
|
|
long userCount = transitUserRecordService.count(userQueryWrapper);
|
|
|
|
|
|
|
|
|
|
// 存储结果到 TreeMap 中
|
|
|
|
|
dailyCountsMap.put(startOfDay.plusHours(i+1).format(formatter), userCount);
|
|
|
|
|
hourlyCountsMap.put(endOfHour.format(DateTimeFormatter.ofPattern("HH:mm")), userCount);
|
|
|
|
|
// // 构造查询条件
|
|
|
|
|
// QueryWrapper<TransitUserRecord> userQueryWrapper = new QueryWrapper<>(transitUserRecord);
|
|
|
|
|
// userQueryWrapper.between("partition_field", startOfDay.plusHours(i).format(formatter), startOfDay.plusHours(i+1).format(formatter));
|
|
|
|
|
// // 查询当前日期的记录数据总数
|
|
|
|
|
// long userCount = transitUserRecordService.count(userQueryWrapper);
|
|
|
|
|
// // 存储结果到 TreeMap 中
|
|
|
|
|
// dailyCountsMap.put(startOfDay.plusHours(i+1).format(formatter), userCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(dailyCountsMap);
|
|
|
|
|
return AjaxResult.success(hourlyCountsMap);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.toString(e));
|
|
|
|
|
return AjaxResult.error("请求失败,请联系管理员");
|
|
|
|
@ -217,7 +232,7 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
String formattedDateTime = startOfDay.format(formatter);
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<String, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前7天
|
|
|
|
|
// 循环迭代前24小时
|
|
|
|
|
for (int i = 0; i < 24; i++) {
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<TransitVehicleRecord> vehicleQueryWrapper = new QueryWrapper<>(transitVehicleRecord);
|
|
|
|
|