develop
Angel 10 months ago
parent 41e54f557b
commit c595bcc90d

@ -3,21 +3,26 @@ package com.ruoyi.business.controller;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.business.domain.vo.HumanVehicleStatisticsVo;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.StringKit; import com.ruoyi.common.utils.StringKit;
import com.ruoyi.database.domain.*; import com.ruoyi.database.domain.*;
import com.ruoyi.database.service.*; import com.ruoyi.database.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Field;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@ -44,22 +49,6 @@ public class PerceptionDeviceController extends BaseController {
@ApiOperation("人车统计") @ApiOperation("人车统计")
public AjaxResult overviewResources() { public AjaxResult overviewResources() {
try { 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 userCount = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getDeviceType, 1).count();
Integer vehicleCount = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getDeviceType, 2).count(); Integer vehicleCount = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getDeviceType, 2).count();
Map<String, Integer> map = new HashMap<>(); Map<String, Integer> map = new HashMap<>();
@ -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") @GetMapping("/allHumanTrafficStatistics")
@ApiOperation("人流量统计前7天(全数)") @ApiOperation("人流量统计前7天(全数)")
public AjaxResult allHumanTrafficStatistics(TransitUserRecord transitUserRecord) { public AjaxResult allHumanTrafficStatistics(TransitUserRecord transitUserRecord) {

@ -1,7 +1,6 @@
package com.ruoyi.database.controller; package com.ruoyi.database.controller;
import cn.hutool.core.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.PageUtils; import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.StringKit; import com.ruoyi.common.utils.StringKit;

@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@ -37,19 +38,21 @@ public class PeopleVehicleHourFlowController extends BaseController {
// 获取当前日期和时间 // 获取当前日期和时间
LocalDateTime currentDateTime = LocalDateTime.now(); LocalDateTime currentDateTime = LocalDateTime.now();
// 将分钟和秒数置为零,表示当前时间点的小时的开始 // 构建日期时间范围从当天的00:00到当前小时
LocalDateTime startDateTime = currentDateTime.withMinute(0).withSecond(0); LocalDateTime startDateTime = currentDateTime.toLocalDate().atStartOfDay();
LocalDateTime endDateTime = currentDateTime.truncatedTo(ChronoUnit.HOURS);
// 构建查询条件 // 构建查询条件
PeopleVehicleHourFlow queryFlow = new PeopleVehicleHourFlow(); PeopleVehicleHourFlow queryFlow = new PeopleVehicleHourFlow();
queryFlow.setStartTimeRange(startDateTime); queryFlow.setStartTimeRange(startDateTime);
queryFlow.setEndTimeRange(currentDateTime); queryFlow.setEndTimeRange(endDateTime);
queryFlow.setStatisticType(statistictype); queryFlow.setStatisticType(statistictype);
// 查询数据库 // 查询数据库
List<PeopleVehicleHourFlow> list = peopleVehicleHourFlowService.list(new QueryWrapper<>(queryFlow) List<PeopleVehicleHourFlow> list = peopleVehicleHourFlowService.list(new QueryWrapper<>(queryFlow)
.between("statistic_time", startDateTime, currentDateTime).eq("statistic_type", statistictype)); // 添加日期范围条件 .between("statistic_time", startDateTime, endDateTime)
.eq("statistic_type", statistictype)); // 添加日期范围条件
// 处理查询结果 // 处理查询结果
Map<String, Long> hourlyCountsMap = new TreeMap<>(); Map<String, Long> hourlyCountsMap = new TreeMap<>();

Loading…
Cancel
Save