From 0e3ac45849f761ecdb3a76700b08c6e7f89d8735 Mon Sep 17 00:00:00 2001 From: Angel <1050374295@qq.com> Date: Sat, 3 Feb 2024 15:41:15 +0800 Subject: [PATCH] DDDDD---jjtyp --- .../controller/BigScreenController.java | 7 +- .../controller/PoachingController.java | 5 -- .../controller/MetaAlarmInfoController.java | 78 +++++++++++++++++-- .../mapper/DevopsVideoInfoMapper.java | 16 ++-- 4 files changed, 84 insertions(+), 22 deletions(-) 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 155b5d4..ebc5dc0 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 @@ -757,11 +757,10 @@ public class BigScreenController extends BaseController { @ApiOperation("警车数据") public AjaxResult policeVehicleList() { try { - - +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.like("devops_video_info.device_name", "苏J") +// .eq("devops_video_status.is_online", 1); List videoInfos = videoInfoService.listPoliceVehicle(new DevopsVideoInfo()); - - return AjaxResult.success(videoInfos); } catch (Exception e) { logger.info(StringKit.toString(e)); diff --git a/gather-app/src/main/java/com/ruoyi/business/controller/PoachingController.java b/gather-app/src/main/java/com/ruoyi/business/controller/PoachingController.java index 85a7cae..7bacdd0 100644 --- a/gather-app/src/main/java/com/ruoyi/business/controller/PoachingController.java +++ b/gather-app/src/main/java/com/ruoyi/business/controller/PoachingController.java @@ -90,11 +90,6 @@ public class PoachingController extends BaseController { ffslaMap.put("value", ffslaCount + ffslbsCount); ffslaMap.put("percentage", ffslaPerceStr); bean.setFfsla(ffslaMap); -// Map ffslbsMap = new HashMap(); -// ffslbsMap.put("name", "非法猎捕杀害珍贵、濒危野生动物案"); -// ffslbsMap.put("value", ffslbsCount); -// ffslbsMap.put("percentage", ffslbsPerceStr); -// bean.setFfslbs(ffslbsMap); return AjaxResult.success(bean); } catch (Exception e) { diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java b/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java index 95ada51..d2177e6 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/MetaAlarmInfoController.java @@ -28,6 +28,7 @@ import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.stream.Collectors; /** * 接警信息表(MetaAlarmInfo)Controller @@ -209,8 +210,8 @@ public class MetaAlarmInfoController extends BaseController { String startDateString = startDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); String endDateString = endDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); - QueryWrapper vehicleQueryWrapper = new QueryWrapper<>(metaAlarmInfo); - vehicleQueryWrapper.between("informant_time", startDateString, endDateString) + QueryWrapper QueryWrapper = new QueryWrapper<>(metaAlarmInfo); + QueryWrapper.between("informant_time", startDateString, endDateString) .and(wrapper -> wrapper.like("alarm_response_unit", "射阳县公安局临海派出所") .or() .like("alarm_response_unit", "射阳县公安局临海派出所第一警务区") @@ -244,7 +245,7 @@ public class MetaAlarmInfoController extends BaseController { .like("alarm_response_unit", "射阳县公安局交通警察大队临海中队")); // 查询当前日期的记录数据总数 - long vehicleCount = metaAlarmInfoService.count(vehicleQueryWrapper); + long vehicleCount = metaAlarmInfoService.count(QueryWrapper); // 存储结果到 TreeMap 中 dailyCountsMap.put(date, vehicleCount); } @@ -289,11 +290,72 @@ public class MetaAlarmInfoController extends BaseController { } } -// @PostMapping("/unit") -// @ApiOperation("根据单位查") -// public AjaxResult selectUnit(){ -// -// } + @GetMapping("filterByType") + @ApiOperation("根据类型来分类,查询每种类型的数量,将每天的类型和数量的格式给前端") + public AjaxResult filterByType(MetaAlarmInfo metaAlarmInfo) { + try { + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + // 创建一个 TreeMap 用于存储每天的数据量 + Map> dailyCountsMap = new TreeMap<>(); + // 循环迭代前7天 + for (int i = 0; i < 7; i++) { + LocalDate date = currentDate.minusDays(i); + LocalDateTime startDateTime = date.atStartOfDay(); + LocalDateTime endDateTime = date.atTime(LocalTime.MAX); + + // 构造查询条件 + String startDateString = startDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); + String endDateString = endDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); + + QueryWrapper queryWrapper = new QueryWrapper<>(metaAlarmInfo); + queryWrapper.between("informant_time", startDateString, endDateString) + .and(wrapper -> wrapper.like("alarm_response_unit", "射阳县公安局临海派出所") + .or() + .like("alarm_response_unit", "射阳县公安局临海派出所第一警务区") + .or() + .like("alarm_response_unit", "射阳县公安局临海派出所第二警务区") + .or() + .like("alarm_response_unit", "射阳县公安局临海派出所第三警务区") + .or() + .like("alarm_response_unit", "射阳县公安局临海派出所第四警务区") + .or() + .like("alarm_response_unit", "射阳县公安局临港派出所") + .or() + .like("alarm_response_unit", "射阳县公安局临港派出所社区警务责任区") + .or() + .like("alarm_response_unit", "射阳县公安局临港派出所第一警务区") + .or() + .like("alarm_response_unit", "射阳县公安局临港派出所第二警务区") + .or() + .like("alarm_response_unit", "射阳县公安局临港派出所第一警务区") + .or() + .like("alarm_response_unit", "射阳县公安局扁担港边防派出所") + .or() + .like("alarm_response_unit", "射阳县公安局扁担港边防派出所第一警务区") + .or() + .like("alarm_response_unit", "射阳县公安局黄沙河边防派出所") + .or() + .like("alarm_response_unit", "射阳县公安局黄沙河边防派出所第一警务区") + .or() + .like("alarm_response_unit", "射阳县公安局黄沙河边防派出所第三警务区") + .or() + .like("alarm_response_unit", "射阳县公安局交通警察大队临海中队")); + List list = metaAlarmInfoService.list(queryWrapper); + + Map typeCountsMap = list.stream() + .collect(Collectors.groupingBy(MetaAlarmInfo::getAlarmResponseTypeName, Collectors.counting())); + + // 存储结果到 TreeMap 中 + dailyCountsMap.put(date, typeCountsMap); + } + return AjaxResult.success(dailyCountsMap); + } catch ( + Exception e) { + logger.info(StringKit.toString(e)); + return AjaxResult.error("请求失败,请联系管理员"); + } + } @PostMapping @ApiOperation("新增接警信息表") diff --git a/gather-app/src/main/java/com/ruoyi/database/mapper/DevopsVideoInfoMapper.java b/gather-app/src/main/java/com/ruoyi/database/mapper/DevopsVideoInfoMapper.java index 0afeeea..7ea87fa 100644 --- a/gather-app/src/main/java/com/ruoyi/database/mapper/DevopsVideoInfoMapper.java +++ b/gather-app/src/main/java/com/ruoyi/database/mapper/DevopsVideoInfoMapper.java @@ -17,10 +17,16 @@ import java.util.List; @Mapper public interface DevopsVideoInfoMapper extends BaseMapper { - @Select(" select " + - " *, " + - " CONCAT('苏',SUBSTRING_INDEX(SUBSTRING_INDEX(device_name, '苏', -1), ' ', 1) ) AS plate_no " + - " from devops_video_info where device_name like '%苏J%' ") - public List listPoliceVehicle(DevopsVideoInfo bean) ; +// @Select(" select " + +// " *, " + +// " CONCAT('苏',SUBSTRING_INDEX(SUBSTRING_INDEX(device_name, '苏', -1), ' ', 1) ) AS plate_no " + +// " from devops_video_info where device_name like '%苏J%' ") +// public List listPoliceVehicle(DevopsVideoInfo bean) ; + @Select("SELECT devops_video_info.*, " + + "CONCAT('苏', SUBSTRING_INDEX(SUBSTRING_INDEX(devops_video_info.device_name, '苏', -1), ' ', 1)) AS plate_no " + + "FROM devops_video_info " + + "JOIN devops_video_status ON devops_video_info.gbs_channel_no = devops_video_status.gbs_channel_no " + + "WHERE devops_video_info.device_name LIKE '%苏J%' AND devops_video_status.is_online = 1") + public List listPoliceVehicle(DevopsVideoInfo bean) ; }