|
|
|
@ -3,21 +3,26 @@ package com.ruoyi.business.controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
|
|
import com.ruoyi.business.domain.vo.HumanVehicleStatisticsVo;
|
|
|
|
|
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.*;
|
|
|
|
|
import com.ruoyi.database.service.*;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.aspectj.weaver.loadtime.Aj;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.TreeMap;
|
|
|
|
|
|
|
|
|
@ -44,27 +49,11 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
@ApiOperation("人车统计")
|
|
|
|
|
public AjaxResult overviewResources() {
|
|
|
|
|
try {
|
|
|
|
|
// // 人流量统计
|
|
|
|
|
// String todayDateString = DateUtil.today();
|
|
|
|
|
// QueryWrapper<TransitImpUserRecord> userQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
// userQueryWrapper.eq("DATE(partition_field)", todayDateString);
|
|
|
|
|
// int userCount = userRecordService.count(userQueryWrapper);
|
|
|
|
|
// //车流量统计
|
|
|
|
|
// QueryWrapper<TransitImpVehicleRecord> vehicleQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
// vehicleQueryWrapper.eq("DATE(partition_field)", todayDateString);
|
|
|
|
|
// int vehicleCount = vehicleRecordService.count(vehicleQueryWrapper);
|
|
|
|
|
//
|
|
|
|
|
// HumanVehicleStatisticsVo bean = new HumanVehicleStatisticsVo();
|
|
|
|
|
// bean.setUserCount(StringKit.toString(userCount));
|
|
|
|
|
// bean.setVehicleCount(StringKit.toString(vehicleCount));
|
|
|
|
|
//
|
|
|
|
|
// return AjaxResult.success(bean);
|
|
|
|
|
|
|
|
|
|
Integer userCount = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getDeviceType, 1).count();
|
|
|
|
|
Integer vehicleCount = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getDeviceType, 2).count();
|
|
|
|
|
Map<String, Integer> map = new HashMap<>();
|
|
|
|
|
map.put("userCount",userCount);
|
|
|
|
|
map.put("vehicleCount",vehicleCount);
|
|
|
|
|
map.put("userCount", userCount);
|
|
|
|
|
map.put("vehicleCount", vehicleCount);
|
|
|
|
|
return AjaxResult.success(map);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.toString(e));
|
|
|
|
@ -72,6 +61,51 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/peoplelist")
|
|
|
|
|
@ApiOperation("人设备列表")
|
|
|
|
|
public TableDataInfo<DevopsDeviceInfo> PeopleList() {
|
|
|
|
|
startPage();
|
|
|
|
|
List<DevopsDeviceInfo> list = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getDeviceType, 1).list();
|
|
|
|
|
return getDataTable(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/vehiclelist")
|
|
|
|
|
@ApiOperation("车设备列表")
|
|
|
|
|
public TableDataInfo<DevopsDeviceInfo> VehicleList() {
|
|
|
|
|
startPage();
|
|
|
|
|
List<DevopsDeviceInfo> list = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getDeviceType, 2).list();
|
|
|
|
|
return getDataTable(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/PeopleOrVehiclelist")
|
|
|
|
|
@ApiOperation("人车设备列表")
|
|
|
|
|
public TableDataInfo<DevopsDeviceInfo> OVehicleList(DevopsDeviceInfo devopsDeviceInfo) {
|
|
|
|
|
startPage();
|
|
|
|
|
DevopsDeviceInfo filteredDeviceInfo = removeEmptyFields(devopsDeviceInfo);
|
|
|
|
|
LambdaQueryChainWrapper<DevopsDeviceInfo> lambdaQueryWrapper = devopsDeviceInfoService.lambdaQuery()
|
|
|
|
|
.eq(DevopsDeviceInfo::getDeviceType, filteredDeviceInfo.getDeviceType());
|
|
|
|
|
List<DevopsDeviceInfo> list = lambdaQueryWrapper
|
|
|
|
|
.eq(DevopsDeviceInfo::getDeviceType, filteredDeviceInfo.getDeviceType())
|
|
|
|
|
.list();
|
|
|
|
|
return getDataTable(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DevopsDeviceInfo removeEmptyFields(DevopsDeviceInfo deviceInfo) {
|
|
|
|
|
DevopsDeviceInfo modifiedDeviceInfo = new DevopsDeviceInfo();
|
|
|
|
|
Field[] fields = DevopsDeviceInfo.class.getDeclaredFields();
|
|
|
|
|
for (Field field : fields) {
|
|
|
|
|
try {
|
|
|
|
|
field.setAccessible(true);
|
|
|
|
|
Object value = field.get(deviceInfo);
|
|
|
|
|
if (value != null && !(value instanceof String && ((String) value).isEmpty())) {
|
|
|
|
|
field.set(modifiedDeviceInfo, value);
|
|
|
|
|
}
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return modifiedDeviceInfo;
|
|
|
|
|
}
|
|
|
|
|
@GetMapping("/allHumanTrafficStatistics")
|
|
|
|
|
@ApiOperation("人流量统计(前7天)(全数)")
|
|
|
|
|
public AjaxResult allHumanTrafficStatistics(TransitUserRecord transitUserRecord) {
|
|
|
|
@ -81,7 +115,7 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前6天
|
|
|
|
|
for (int i = 1; i <=7 ; i++) {
|
|
|
|
|
for (int i = 1; i <= 7; i++) {
|
|
|
|
|
LocalDate date = currentDate.minusDays(i);
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<TransitUserRecord> userQueryWrapper = new QueryWrapper<>(transitUserRecord);
|
|
|
|
@ -107,7 +141,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<>();
|
|
|
|
@ -134,7 +168,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<>();
|
|
|
|
@ -194,7 +228,7 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// String formattedDateTime = startOfDay.format(formatter);
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<String, Long> hourlyCountsMap = new TreeMap<>();
|
|
|
|
|
Map<String, Long> hourlyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前7天
|
|
|
|
|
for (int i = 0; i < currentHour; i++) {
|
|
|
|
|
// 构造查询条件
|
|
|
|
@ -239,11 +273,11 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
for (int i = 0; i < 24; i++) {
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<TransitVehicleRecord> vehicleQueryWrapper = new QueryWrapper<>(transitVehicleRecord);
|
|
|
|
|
vehicleQueryWrapper.between("partition_field", startOfDay.plusHours(i).format(formatter), startOfDay.plusHours(i+1).format(formatter));
|
|
|
|
|
vehicleQueryWrapper.between("partition_field", startOfDay.plusHours(i).format(formatter), startOfDay.plusHours(i + 1).format(formatter));
|
|
|
|
|
// 查询当前日期的记录数据总数
|
|
|
|
|
long vehicleCount = transitVehicleRecordService.count(vehicleQueryWrapper);
|
|
|
|
|
// 存储结果到 TreeMap 中
|
|
|
|
|
dailyCountsMap.put(startOfDay.plusHours(i+1).format(formatter), vehicleCount);
|
|
|
|
|
dailyCountsMap.put(startOfDay.plusHours(i + 1).format(formatter), vehicleCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(dailyCountsMap);
|
|
|
|
|