|
|
|
@ -1,30 +1,25 @@
|
|
|
|
|
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.business.controller.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.checkerframework.checker.units.qual.A;
|
|
|
|
|
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;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 大屏感知设备查询接口
|
|
|
|
@ -106,9 +101,10 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
return modifiedDeviceInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/allHumanTrafficStatistics")
|
|
|
|
|
@ApiOperation("人流量统计(前7天)(全数)")
|
|
|
|
|
public AjaxResult allHumanTrafficStatistics(TransitUserRecord transitUserRecord) {
|
|
|
|
|
public AjaxResult allHumanTrafficStatistics(TransitUserRecord transitUserRecord, DevopsDeviceInfo devopsDeviceInfo) {
|
|
|
|
|
try {
|
|
|
|
|
// 获取当前日期
|
|
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
|
@ -118,13 +114,59 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
for (int i = 1; i <= 7; i++) {
|
|
|
|
|
LocalDate date = currentDate.minusDays(i);
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<DevopsDeviceInfo> deviceInfoQueryWrapper = new QueryWrapper<>(devopsDeviceInfo);
|
|
|
|
|
deviceInfoQueryWrapper.eq("parent_monitoring_type", 1);
|
|
|
|
|
List<DevopsDeviceInfo> list = devopsDeviceInfoService.list(deviceInfoQueryWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long totalUserCount = 0;
|
|
|
|
|
|
|
|
|
|
for (DevopsDeviceInfo info : list) {
|
|
|
|
|
String channelNo = info.getGbsChannelNo();
|
|
|
|
|
QueryWrapper<TransitUserRecord> userQueryWrapper = new QueryWrapper<>(transitUserRecord);
|
|
|
|
|
userQueryWrapper.between("partition_field", date, date.plusDays(1));
|
|
|
|
|
// 查询当前日期的记录数据总数
|
|
|
|
|
userQueryWrapper.eq("device_code", channelNo)
|
|
|
|
|
.between("partition_field", date, date.plusDays(1));
|
|
|
|
|
long userCount = transitUserRecordService.count(userQueryWrapper);
|
|
|
|
|
// 存储结果到 TreeMap 中
|
|
|
|
|
dailyCountsMap.put(date, userCount);
|
|
|
|
|
// 累加到总数据量
|
|
|
|
|
totalUserCount += userCount;
|
|
|
|
|
}
|
|
|
|
|
dailyCountsMap.put(date, totalUserCount);
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success(dailyCountsMap);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.toString(e));
|
|
|
|
|
return AjaxResult.error("请求失败,请联系管理员");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@GetMapping("/allVehicleTrafficStatistics")
|
|
|
|
|
@ApiOperation("车流量统计(前7天)(全数)")
|
|
|
|
|
public AjaxResult allVehicleTrafficStatistics(TransitVehicleRecord transitVehicleRecord,DevopsDeviceInfo devopsDeviceInfo) {
|
|
|
|
|
try {
|
|
|
|
|
// 获取当前日期
|
|
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前7天
|
|
|
|
|
for (int i = 1; i <= 7; i++) {
|
|
|
|
|
LocalDate date = currentDate.minusDays(i);
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<DevopsDeviceInfo> deviceInfoQueryWrapper = new QueryWrapper<>(devopsDeviceInfo);
|
|
|
|
|
deviceInfoQueryWrapper.eq("parent_monitoring_type", 1);
|
|
|
|
|
List<DevopsDeviceInfo> list = devopsDeviceInfoService.list(deviceInfoQueryWrapper);
|
|
|
|
|
|
|
|
|
|
long totalUserCount = 0;
|
|
|
|
|
|
|
|
|
|
for (DevopsDeviceInfo info:list) {
|
|
|
|
|
String channelNo = info.getGbsChannelNo();
|
|
|
|
|
QueryWrapper<TransitVehicleRecord> vehicleQueryWrapper = new QueryWrapper<>(transitVehicleRecord);
|
|
|
|
|
vehicleQueryWrapper.eq("doorway_code",channelNo)
|
|
|
|
|
.between("partition_field", date, date.plusDays(1));
|
|
|
|
|
long userCount = transitVehicleRecordService.count(vehicleQueryWrapper);
|
|
|
|
|
totalUserCount += userCount;
|
|
|
|
|
}
|
|
|
|
|
dailyCountsMap.put(date, totalUserCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(dailyCountsMap);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.toString(e));
|
|
|
|
@ -186,32 +228,7 @@ public class PerceptionDeviceController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/allVehicleTrafficStatistics")
|
|
|
|
|
@ApiOperation("车流量统计(前7天)(全数)")
|
|
|
|
|
public AjaxResult allVehicleTrafficStatistics(TransitVehicleRecord transitVehicleRecord) {
|
|
|
|
|
try {
|
|
|
|
|
// 获取当前日期
|
|
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
|
|
// 创建一个 TreeMap 用于存储每天的数据量
|
|
|
|
|
Map<LocalDate, Long> dailyCountsMap = new TreeMap<>();
|
|
|
|
|
// 循环迭代前7天
|
|
|
|
|
for (int i = 1; i <= 7; i++) {
|
|
|
|
|
LocalDate date = currentDate.minusDays(i);
|
|
|
|
|
// 构造查询条件
|
|
|
|
|
QueryWrapper<TransitVehicleRecord> vehicleQueryWrapper = new QueryWrapper<>(transitVehicleRecord);
|
|
|
|
|
vehicleQueryWrapper.between("partition_field", date, date.plusDays(1));
|
|
|
|
|
// 查询当前日期的记录数据总数
|
|
|
|
|
long vehicleCount = transitVehicleRecordService.count(vehicleQueryWrapper);
|
|
|
|
|
// 存储结果到 TreeMap 中
|
|
|
|
|
dailyCountsMap.put(date, vehicleCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(dailyCountsMap);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info(StringKit.toString(e));
|
|
|
|
|
return AjaxResult.error("请求失败,请联系管理员");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/allHumanTrafficStatisticsHour")
|
|
|
|
|
@ApiOperation("人流量统计(当天)(全数)")
|
|
|
|
|