diff --git a/gather-app/src/main/java/com/ruoyi/business/controller/BigScreenController.java b/gather-app/src/main/java/com/ruoyi/business/controller/BigScreenController.java index 8547969..6784cec 100644 --- a/gather-app/src/main/java/com/ruoyi/business/controller/BigScreenController.java +++ b/gather-app/src/main/java/com/ruoyi/business/controller/BigScreenController.java @@ -21,6 +21,8 @@ import lombok.RequiredArgsConstructor; import org.apache.ibatis.annotations.Param; import org.springframework.web.bind.annotation.*; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -295,13 +297,35 @@ public class BigScreenController extends BaseController { try { List metaAlarmInfos = alarmInfoService.listAlarmAndHandleAlarm(); - return AjaxResult.success(metaAlarmInfos); + ArrayList alarmVos = new ArrayList<>(); + for (MetaAlarmInfoAndHandleAlarmVo metaAlarmInfoAndHandleAlarmVo : metaAlarmInfos){ + SimpleDateFormat outputSdf = new SimpleDateFormat("yyyyMMddHHmmss"); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (metaAlarmInfoAndHandleAlarmVo.getCjxxHandleAlarmTime()!=null) { + String cjxxHandleAlarmTime = metaAlarmInfoAndHandleAlarmVo.getCjxxHandleAlarmTime(); + Date cjxxHandleAlarm = outputSdf.parse(cjxxHandleAlarmTime); + metaAlarmInfoAndHandleAlarmVo.setCjxxHandleAlarmTime(dateFormat.format(cjxxHandleAlarm)); + } + if (metaAlarmInfoAndHandleAlarmVo.getJjxxInformantTime()!=null) { + String jjxxInformantTime = metaAlarmInfoAndHandleAlarmVo.getJjxxInformantTime(); + Date jjxxInformant = outputSdf.parse(jjxxInformantTime); + metaAlarmInfoAndHandleAlarmVo.setJjxxInformantTime(dateFormat.format(jjxxInformant)); + } + if (metaAlarmInfoAndHandleAlarmVo.getJjxxAlarmResponseTime()!=null) { + String jjxxAlarmResponseTime = metaAlarmInfoAndHandleAlarmVo.getJjxxAlarmResponseTime(); + Date jjxxAlarmResponse = outputSdf.parse(jjxxAlarmResponseTime); + metaAlarmInfoAndHandleAlarmVo.setJjxxAlarmResponseTime(dateFormat.format(jjxxAlarmResponse)); + } + alarmVos.add(metaAlarmInfoAndHandleAlarmVo); + } + return AjaxResult.success(alarmVos); } catch (Exception e) { logger.info(StringKit.toString(e)); return AjaxResult.error("请求失败,请联系管理员"); } } + @PostMapping("/realTimeAlarmSituation") @ApiOperation("实时警情") public AjaxResult realTimeAlarmSituation(@ApiParam("时间") @RequestParam String time) { diff --git a/gather-app/src/main/java/com/ruoyi/business/controller/PerceptionDeviceController.java b/gather-app/src/main/java/com/ruoyi/business/controller/PerceptionDeviceController.java index ad0c25b..5149ad6 100644 --- a/gather-app/src/main/java/com/ruoyi/business/controller/PerceptionDeviceController.java +++ b/gather-app/src/main/java/com/ruoyi/business/controller/PerceptionDeviceController.java @@ -116,6 +116,10 @@ public class PerceptionDeviceController extends BaseController { @ApiOperation("人流量统计(前7天)(全数)") public AjaxResult allHumanTrafficStatistics(TransitUserRecord transitUserRecord) { try { + List deviceInfos = devopsDeviceInfoService.lambdaQuery() + .eq(DevopsDeviceInfo::getParentMonitoringType, 1) + .eq(DevopsDeviceInfo::getDeviceType,1).list(); + List collect = deviceInfos.stream().map(devopsDeviceInfo -> devopsDeviceInfo.getGbsChannelNo()).collect(Collectors.toList()); // 获取当前日期 LocalDate currentDate = LocalDate.now(); // 创建一个 TreeMap 用于存储每天的数据量 @@ -124,25 +128,22 @@ public class PerceptionDeviceController extends BaseController { for (int i = 1; i <= 7; i++) { LocalDate date = currentDate.minusDays(i); // 构造查询条件 - QueryWrapper deviceInfoQueryWrapper = new QueryWrapper<>(); - deviceInfoQueryWrapper.eq("parent_monitoring_type", 1); - List list = devopsDeviceInfoService.list(deviceInfoQueryWrapper); - - - long totalUserCount = 0; - - for (DevopsDeviceInfo info : list) { - String channelNo = info.getGbsChannelNo(); - QueryWrapper userQueryWrapper = new QueryWrapper<>(transitUserRecord); - userQueryWrapper.eq("device_code", channelNo) - .between("partition_field", date, date.plusDays(1)); - long userCount = transitUserRecordService.count(userQueryWrapper); - // 累加到总数据量 - totalUserCount += userCount; - } + QueryWrapper userRecordQueryWrapper = new QueryWrapper<>(); + userRecordQueryWrapper.in("device_code",collect); + userRecordQueryWrapper.between("partition_field", date, date.plusDays(1)); + // 查询当前日期的记录数据总数 + long totalUserCount = transitUserRecordService.count(userRecordQueryWrapper); dailyCountsMap.put(date, totalUserCount); } - return AjaxResult.success(dailyCountsMap); + Optional> max = dailyCountsMap.entrySet() + .stream() + .max(Comparator.comparing(Map.Entry::getValue)); + Map.Entry localDateLongEntry = max.get(); + Long value = localDateLongEntry.getValue(); + value = value + value/4; + Map> map = new HashMap<>(); + map.put(value,dailyCountsMap); + return AjaxResult.success(map); } catch (Exception e) { logger.info(StringKit.toString(e)); return AjaxResult.error("请求失败,请联系管理员"); @@ -152,6 +153,10 @@ public class PerceptionDeviceController extends BaseController { @ApiOperation("车流量统计(前7天)(全数)") public AjaxResult allVehicleTrafficStatistics(TransitVehicleRecord transitVehicleRecord) { try { + List deviceInfos = devopsDeviceInfoService.lambdaQuery() + .eq(DevopsDeviceInfo::getParentMonitoringType, 1) + .eq(DevopsDeviceInfo::getDeviceType,2).list(); + List collect = deviceInfos.stream().map(devopsDeviceInfo -> devopsDeviceInfo.getGbsChannelNo()).collect(Collectors.toList()); // 获取当前日期 LocalDate currentDate = LocalDate.now(); // 创建一个 TreeMap 用于存储每天的数据量 @@ -160,35 +165,38 @@ public class PerceptionDeviceController extends BaseController { for (int i = 1; i <= 7; i++) { LocalDate date = currentDate.minusDays(i); // 构造查询条件 - QueryWrapper deviceInfoQueryWrapper = new QueryWrapper<>(); - deviceInfoQueryWrapper.eq("parent_monitoring_type", 1); - List list = devopsDeviceInfoService.list(deviceInfoQueryWrapper); - - long totalUserCount = 0; - - for (DevopsDeviceInfo info:list) { - String channelNo = info.getGbsChannelNo(); - QueryWrapper 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); + QueryWrapper vehicleQueryWrapper = new QueryWrapper<>(); + vehicleQueryWrapper.in("doorway_code",collect); + vehicleQueryWrapper.between("partition_field", date, date.plusDays(1)); + // 查询当前日期的记录数据总数 + long vehicleCount = transitVehicleRecordService.count(vehicleQueryWrapper); + dailyCountsMap.put(date, vehicleCount); } - - return AjaxResult.success(dailyCountsMap); + Optional> max = dailyCountsMap.entrySet() + .stream() + .max(Comparator.comparing(Map.Entry::getValue)); + Map.Entry localDateLongEntry = max.get(); + Long value = localDateLongEntry.getValue(); + value = value + value/4; + Map> map = new HashMap<>(); + map.put(value,dailyCountsMap); + return AjaxResult.success(map); } catch (Exception e) { logger.info(StringKit.toString(e)); return AjaxResult.error("请求失败,请联系管理员"); } } + + + @PostMapping("/vehicleTrafficStatistics") @ApiOperation("车流量统计(前7天)(重点人员)") public AjaxResult vehicleTrafficStatistics() { try { - List deviceInfos = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getParentMonitoringType, 1).list(); + List deviceInfos = devopsDeviceInfoService.lambdaQuery() + .eq(DevopsDeviceInfo::getParentMonitoringType, 1) + .eq(DevopsDeviceInfo::getDeviceType,2).list(); List collect = deviceInfos.stream().map(devopsDeviceInfo -> devopsDeviceInfo.getGbsChannelNo()).collect(Collectors.toList()); // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -206,8 +214,16 @@ public class PerceptionDeviceController extends BaseController { // 存储结果到 TreeMap 中 dailyCountsMap.put(date, vehicleCount); } + Optional> max = dailyCountsMap.entrySet() + .stream() + .max(Comparator.comparing(Map.Entry::getValue)); + Map.Entry localDateLongEntry = max.get(); + Long value = localDateLongEntry.getValue(); + value = value + value/4; + Map> map = new HashMap<>(); + map.put(value,dailyCountsMap); + return AjaxResult.success(map); - return AjaxResult.success(dailyCountsMap); } catch (Exception e) { logger.info(StringKit.toString(e)); return AjaxResult.error("请求失败,请联系管理员"); @@ -218,7 +234,9 @@ public class PerceptionDeviceController extends BaseController { @ApiOperation("人流量统计(前7天)(重点人员)") public AjaxResult humanTrafficStatistics() { try { - List deviceInfos = devopsDeviceInfoService.lambdaQuery().eq(DevopsDeviceInfo::getParentMonitoringType, 1).list(); + List deviceInfos = devopsDeviceInfoService.lambdaQuery() + .eq(DevopsDeviceInfo::getParentMonitoringType, 1) + .eq(DevopsDeviceInfo::getDeviceType,1).list(); List collect = deviceInfos.stream().map(devopsDeviceInfo -> devopsDeviceInfo.getGbsChannelNo()).collect(Collectors.toList()); // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -236,8 +254,15 @@ public class PerceptionDeviceController extends BaseController { // 存储结果到 TreeMap 中 dailyCountsMap.put(date, userCount); } - - return AjaxResult.success(dailyCountsMap); + Optional> max = dailyCountsMap.entrySet() + .stream() + .max(Comparator.comparing(Map.Entry::getValue)); + Map.Entry localDateLongEntry = max.get(); + Long value = localDateLongEntry.getValue(); + value = value + value/4; + Map> map = new HashMap<>(); + map.put(value,dailyCountsMap); + return AjaxResult.success(map); } catch (Exception e) { logger.info(StringKit.toString(e)); return AjaxResult.error("请求失败,请联系管理员"); diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/TransitUserRecordController.java b/gather-app/src/main/java/com/ruoyi/database/controller/TransitUserRecordController.java index bb81e49..a64f46f 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/TransitUserRecordController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/TransitUserRecordController.java @@ -48,27 +48,17 @@ public class TransitUserRecordController extends BaseController { @GetMapping @ApiOperation("查询人脸记录表") - public TableDataInfo list(TransitUserRecord transitUserRecord) throws Exception{ + public TableDataInfo list(TransitUserRecord transitUserRecord) throws Exception { startPage(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime now = LocalDateTime.now(); LocalDateTime minusDay = now.minusDays(1); - QueryWrapper impUserRecordQueryWrapper = new QueryWrapper<>(); - impUserRecordQueryWrapper.eq("device_code",transitUserRecord.getDeviceCode()); - impUserRecordQueryWrapper.between("partition_field", formatter.format(minusDay), formatter.format(now)); - impUserRecordQueryWrapper.orderByDesc("partition_field"); - List list1 = transitImpUserRecordService.list(impUserRecordQueryWrapper); + QueryWrapper queryWrapper = new QueryWrapper<>(transitUserRecord); + queryWrapper.between("partition_field", formatter.format(minusDay), formatter.format(now)); + queryWrapper.orderByDesc("partition_field"); + List list = transitUserRecordService.list(queryWrapper); + return getDataTable(list); - if (list1.isEmpty()) { - PageUtils.startPage(); - QueryWrapper queryWrapper = new QueryWrapper<>(transitUserRecord); - queryWrapper.between("partition_field", formatter.format(minusDay), formatter.format(now)); - queryWrapper.orderByDesc("partition_field"); - List list = transitUserRecordService.list(queryWrapper); - return getDataTable(list); - } - - return getDataTable(list1); } diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/TransitVehicleRecordController.java b/gather-app/src/main/java/com/ruoyi/database/controller/TransitVehicleRecordController.java index 3fd48fb..b1f96cd 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/TransitVehicleRecordController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/TransitVehicleRecordController.java @@ -54,20 +54,11 @@ public class TransitVehicleRecordController extends BaseController { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime now = LocalDateTime.now(); LocalDateTime minusDay = now.minusDays(1); - QueryWrapper vehicleRecordQueryWrapper = new QueryWrapper<>(); - vehicleRecordQueryWrapper.eq("device_code",transitVehicleRecord.getDoorwayCode()); - vehicleRecordQueryWrapper.between("partition_field",formatter.format(minusDay),formatter.format(now)); - vehicleRecordQueryWrapper.orderByDesc("partition_field"); - List list1 = transitImpVehicleRecordService.list(vehicleRecordQueryWrapper); - if (list1.isEmpty()) { - PageUtils.startPage(); - QueryWrapper queryWrapper = new QueryWrapper<>(transitVehicleRecord); - queryWrapper.between("partition_field", formatter.format(minusDay), formatter.format(now)); - queryWrapper.orderByDesc("partition_field"); - List list = transitVehicleRecordService.list(queryWrapper); - return getDataTable(list); - } - return getDataTable(list1); + QueryWrapper queryWrapper = new QueryWrapper<>(transitVehicleRecord); + queryWrapper.between("partition_field", formatter.format(minusDay), formatter.format(now)); + queryWrapper.orderByDesc("partition_field"); + List list = transitVehicleRecordService.list(queryWrapper); + return getDataTable(list); } @PostMapping @@ -123,5 +114,4 @@ public class TransitVehicleRecordController extends BaseController { } - }