diff --git a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java index 45a04a7..f09c5c4 100644 --- a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java +++ b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java @@ -432,11 +432,12 @@ public class BuildingController { @GetMapping("selectRoadDataCountEvent") @ApiOperation("查询走航监测top5全部道路污染事件") public Result selectRoadDataCountEvent(){ - List roadDataDtos = buildingRecordsMapper.selectRoadDataCountEvent(); - - Result success = Result.success(roadDataDtos); - + Integer integer = roadDataMapper.selectCountRoadData(); + Map map = new HashMap<>(); + map.put("sum",integer); + map.put("roadDataDtos",roadDataDtos); + Result success = Result.success(map); return success; } @@ -447,11 +448,12 @@ public class BuildingController { @GetMapping("selectRoadDataWeekEvent") @ApiOperation("查询走航监测top5近7天道路污染事件") public Result selectRoadDataWeekEvent(){ - List roadDataDtos = buildingRecordsMapper.selectRoadDataWeekEvent(); - - Result success = Result.success(roadDataDtos); - + Integer integer = roadDataMapper.selectCountWeekRoadData(); + Map map = new HashMap<>(); + map.put("sum",integer); + map.put("roadDataDtos",roadDataDtos); + Result success = Result.success(map); return success; } @@ -462,11 +464,12 @@ public class BuildingController { @GetMapping("selectRoadDataMonthEvent") @ApiOperation("查询走航监测top5近30天道路污染事件") public Result selectRoadDataMonthEvent(){ - List roadDataDtos = buildingRecordsMapper.selectRoadDataMonthEvent(); - - Result success = Result.success(roadDataDtos); - + Integer integer = roadDataMapper.selectCountMonthRoadData(); + Map map = new HashMap<>(); + map.put("sum",integer); + map.put("roadDataDtos",roadDataDtos); + Result success = Result.success(map); return success; } diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java index b2a3a73..893fa40 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java @@ -91,13 +91,13 @@ public interface BuildingRecordsMapper extends BaseMapper { List selectMonthCurrentByEvent(); - @Select("select rd.road_name,rd.`start`,rd.`end`,COUNT(*) number from t_road_data rd where pm10 > 150 GROUP BY rd.road_name,rd.`start`,rd.`end` ORDER BY number DESC limit 5") + @Select("select rd.road_name,rd.`start`,rd.`end`,COUNT(*) number from t_road_data rd where pm10 > 150 GROUP BY rd.road_name,rd.`start`,rd.`end` ORDER BY number DESC") List selectRoadDataCountEvent(); - @Select("select rd.road_name,rd.`start`,rd.`end`,COUNT(*) number from t_road_data rd where pm10 > 150 AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) < DATE(rd.dt) GROUP BY rd.road_name,rd.`start`,rd.`end` ORDER BY number DESC limit 5") + @Select("select rd.road_name,rd.`start`,rd.`end`,COUNT(*) number from t_road_data rd where pm10 > 150 AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) < DATE(rd.dt) GROUP BY rd.road_name,rd.`start`,rd.`end` ORDER BY number DESC") List selectRoadDataWeekEvent(); - @Select("select rd.road_name,rd.`start`,rd.`end`,COUNT(*) number from t_road_data rd where pm10 > 150 AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) < DATE(rd.dt) GROUP BY rd.road_name,rd.`start`,rd.`end` ORDER BY number DESC limit 5") + @Select("select rd.road_name,rd.`start`,rd.`end`,COUNT(*) number from t_road_data rd where pm10 > 150 AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) < DATE(rd.dt) GROUP BY rd.road_name,rd.`start`,rd.`end` ORDER BY number DESC") List selectRoadDataMonthEvent(); List selectMonthCurrentByRoadData(); diff --git a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java index f698058..46fe71a 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java @@ -27,5 +27,11 @@ public interface RoadDataMapper extends BaseMapper { @Select("select count(*) from t_road_data where pm10 > 150") Integer selectCountRoadData(); + @Select("select count(*) from t_road_data where pm10 > 150 and DATE_SUB(CURDATE(), INTERVAL 7 DAY) < DATE(dt)") + Integer selectCountWeekRoadData(); + + @Select("select count(*) from t_road_data where pm10 > 150 and DATE_SUB(CURDATE(), INTERVAL 30 DAY) < DATE(dt)") + Integer selectCountMonthRoadData(); + RoadData getByMaxId(); } diff --git a/src/main/resources/mapper/BuildingRecordsMapper.xml b/src/main/resources/mapper/BuildingRecordsMapper.xml index 2a1ed80..450c768 100644 --- a/src/main/resources/mapper/BuildingRecordsMapper.xml +++ b/src/main/resources/mapper/BuildingRecordsMapper.xml @@ -57,7 +57,7 @@