From ec821744db3f03ef4974317b0f25888b11197178 Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Thu, 21 Jul 2022 11:27:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=93=E5=A4=A9=E9=81=93?= =?UTF-8?q?=E8=B7=AF=E6=B1=A1=E6=9F=93=E4=BA=8B=E4=BB=B6=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BD=93=E5=A4=A9=E6=89=AC=E5=B0=98=E5=92=8C=E5=99=AA?= =?UTF-8?q?=E5=A3=B0=E4=BA=8B=E4=BB=B6=20=E4=BC=98=E5=8C=96=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BuildingController.java | 81 +++++++++++++++---- .../controller/EventController.java | 27 +++---- .../monitormanage/entity/RoadData.java | 2 +- .../mapper/BuildingRecordsMapper.java | 18 +++-- .../mapper/CameraChannelMapper.java | 2 +- .../monitormanage/mapper/EventMapper.java | 3 - .../monitormanage/mapper/RoadDataMapper.java | 3 + .../monitormanage/service/MonitorService.java | 2 +- src/main/resources/mapper/RoadDataMapper.xml | 4 + 9 files changed, 95 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java index 44bdff6..4665521 100644 --- a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java +++ b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java @@ -4,7 +4,9 @@ import com.hisense.monitormanage.dto.BuildingRecordsDto; import com.hisense.monitormanage.dto.BuildingRecordsDtos; import com.hisense.monitormanage.entity.BuildingRecords; import com.hisense.monitormanage.entity.Result; +import com.hisense.monitormanage.entity.RoadData; import com.hisense.monitormanage.mapper.BuildingRecordsMapper; +import com.hisense.monitormanage.mapper.RoadDataMapper; import com.hisense.monitormanage.service.BuildingRecordsService; import com.hisense.monitormanage.utils.LongLatUtil; import io.swagger.annotations.Api; @@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.time.LocalDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -39,6 +42,9 @@ public class BuildingController { @Autowired private BuildingRecordsMapper buildingRecordsMapper; + @Autowired + private RoadDataMapper roadDataMapper; + @GetMapping("/getRecords") @ApiOperation("测试,获取工地实时数据--调用接口") public List getRecords(){ @@ -73,8 +79,8 @@ public class BuildingController { @GetMapping("selectAllBuilding") @ApiOperation("查询所有工地") public Result selectAllBuilding(){ - List recordsDtos = buildingRecordsMapper.selectAllBuilding(); - Result success = Result.success(recordsDtos); + List records = buildingRecordsMapper.selectAllBuilding(); + Result success = Result.success(records); return success; } @@ -103,14 +109,14 @@ public class BuildingController { @GetMapping("selectMonthPmAndNoice") @ApiOperation("查询近30天工地噪声和扬尘的信息") public Result selectMonthPmAndNoice(String buildLicense){ - List recordsDtos = buildingRecordsMapper.selectMonthPmAndNoice(buildLicense); - recordsDtos.forEach(record ->{ + List records = buildingRecordsMapper.selectMonthPmAndNoice(buildLicense); + records.forEach(record ->{ if (record.getPm10() == null && record.getNoice() == null){ record.setPm10(0); record.setNoice(0); } }); - Result success = Result.success(recordsDtos); + Result success = Result.success(records); return success; } @@ -121,11 +127,10 @@ public class BuildingController { @GetMapping("selectRaise") @ApiOperation("查询工地扬尘事件") public Result selectRaise(Integer page,Integer pageSize){ - List recordsDtos = buildingRecordsMapper.selectRaise(page,pageSize); - Integer integer = buildingRecordsMapper.selectCountRaise(); + List records = buildingRecordsMapper.selectRaise(page,pageSize); Map map = new HashMap<>(); - map.put("sum",integer); - map.put("data",recordsDtos); + map.put("sum",records.size()); + map.put("data",records); Result success = Result.success(map); return success; } @@ -137,11 +142,10 @@ public class BuildingController { @GetMapping("selectNoiceEvent") @ApiOperation("查询工地噪声事件") public Result selectNoiceEvent(Integer page,Integer pageSize){ - List recordsDtos = buildingRecordsMapper.selectNoiceEvent(page,pageSize); - Integer integer = buildingRecordsMapper.selectCountNoice(); + List records = buildingRecordsMapper.selectNoiceEvent(page,pageSize); Map map = new HashMap<>(); - map.put("sum",integer); - map.put("data",recordsDtos); + map.put("sum",records.size()); + map.put("data",records); Result success = Result.success(map); return success; } @@ -155,8 +159,8 @@ public class BuildingController { @ApiOperation("根据工地名称搜索工地") @ApiImplicitParam(name = "projectName", value = "工地名称",required = true,dataType ="String") public Result selectByProjectName(String projectName){ - List recordsDtos = buildingRecordsMapper.selectByProjectName(projectName); - Result success = Result.success(recordsDtos); + List records = buildingRecordsMapper.selectByProjectName(projectName); + Result success = Result.success(records); return success; } @@ -181,5 +185,52 @@ public class BuildingController { return success; } + /** + * 查询当天扬尘事件 + * @return + */ + @GetMapping("selectByDayRaise") + @ApiOperation("查询当天扬尘事件") + public Result selectByDayRaise(){ + List records = buildingRecordsMapper.selectByDayRaise(); + Map map = new HashMap<>(); + map.put("sum",records.size()); + map.put("data",records); + Result success = Result.success(map); + return success; + } + + /** + * 查询当天噪声事件 + * @return + */ + @GetMapping("selectByDayNoice") + @ApiOperation("查询当天噪声事件") + public Result selectByDayNoice(){ + List records = buildingRecordsMapper.selectByDayNoice(); + Map map = new HashMap<>(); + map.put("sum",records.size()); + map.put("data",records); + Result success = Result.success(map); + return success; + } + + /** + * 查询当天道路污染事件 + * @return + */ + @GetMapping("selectByDayRoadData") + @ApiOperation("查询当天道路污染事件") + public Result selectByDayRoadData(){ + RoadData byMaxId = roadDataMapper.getByMaxId(); + String dt = byMaxId.getDt(); + List roadData = buildingRecordsMapper.selectByDayRoadData(dt); + Map map = new HashMap<>(); + map.put("sum",roadData.size()); + map.put("data",roadData); + Result success = Result.success(map); + return success; + } + } diff --git a/src/main/java/com/hisense/monitormanage/controller/EventController.java b/src/main/java/com/hisense/monitormanage/controller/EventController.java index 7fbb5f8..410ccf7 100644 --- a/src/main/java/com/hisense/monitormanage/controller/EventController.java +++ b/src/main/java/com/hisense/monitormanage/controller/EventController.java @@ -208,9 +208,8 @@ public class EventController { for (EventDto list: lists) { list.setEventNewName("环境卫生"); } - Integer integer = eventMapper.selectCountByName("'塑料篮子','纸箱','街头散落垃圾'"); Map map = new HashMap<>(); - map.put("sum",integer); + map.put("sum",lists.size()); map.put("events",lists); Result success = Result.success(map); return success; @@ -219,9 +218,8 @@ public class EventController { for (EventDto list: lists) { list.setEventNewName("占道经营"); } - Integer integer = eventMapper.selectCountByName("'街头伞篷','水果和食品摊','地摊','户外桌椅'"); Map map = new HashMap<>(); - map.put("sum",integer); + map.put("sum",lists.size()); map.put("events",lists); Result success = Result.success(map); return success; @@ -230,9 +228,8 @@ public class EventController { for (EventDto list: lists) { list.setEventNewName("沿街晾晒"); } - Integer integer = eventMapper.selectCountByName("'沿街晾晒衣物被单'"); Map map = new HashMap<>(); - map.put("sum",integer); + map.put("sum",lists.size()); map.put("events",lists); Result success = Result.success(map); return success; @@ -241,9 +238,8 @@ public class EventController { for (EventDto list: lists) { list.setEventNewName("违章停车"); } - Integer integer = eventMapper.selectCountByName("'机动车违停'"); Map map = new HashMap<>(); - map.put("sum",integer); + map.put("sum",lists.size()); map.put("events",lists); Result success = Result.success(map); return success; @@ -252,9 +248,8 @@ public class EventController { for (EventDto list : lists) { list.setEventNewName("渣土车发现"); } - Integer integer = eventMapper.selectCountByName("'渣土车发现'"); Map map = new HashMap<>(); - map.put("sum",integer); + map.put("sum",lists.size()); map.put("events",lists); Result success = Result.success(map); return success; @@ -263,9 +258,8 @@ public class EventController { for (EventDto list : lists) { list.setEventNewName("安保区域人员滞留"); } - Integer integer = eventMapper.selectCountByName("'安保区域人员滞留'"); Map map = new HashMap<>(); - map.put("sum",integer); + map.put("sum",lists.size()); map.put("events",lists); Result success = Result.success(map); return success; @@ -274,9 +268,8 @@ public class EventController { for (EventDto list : lists) { list.setEventNewName("安保区域人员徘徊"); } - Integer integer = eventMapper.selectCountByName("'安保区域人员徘徊'"); Map map = new HashMap<>(); - map.put("sum",integer); + map.put("sum",lists.size()); map.put("events",lists); Result success = Result.success(map); return success; @@ -285,9 +278,8 @@ public class EventController { for (EventDto list : lists) { list.setEventNewName("渣土车未密闭"); } - Integer integer = eventMapper.selectCountByName("'渣土车未密闭'"); Map map = new HashMap<>(); - map.put("sum",integer); + map.put("sum",lists.size()); map.put("events",lists); Result success = Result.success(map); return success; @@ -296,9 +288,8 @@ public class EventController { for (EventDto list : lists) { list.setEventNewName("道路积水事件"); } - Integer integer = eventMapper.selectCountByName("'道路积水事件'"); Map map = new HashMap<>(); - map.put("sum",integer); + map.put("sum",lists.size()); map.put("events",lists); Result success = Result.success(map); return success; diff --git a/src/main/java/com/hisense/monitormanage/entity/RoadData.java b/src/main/java/com/hisense/monitormanage/entity/RoadData.java index b466874..eb8e003 100644 --- a/src/main/java/com/hisense/monitormanage/entity/RoadData.java +++ b/src/main/java/com/hisense/monitormanage/entity/RoadData.java @@ -54,6 +54,6 @@ public class RoadData { private String points; @JsonFormat(pattern="yyyy-MM-dd mm:HH:ss",timezone = "GMT+8") - private LocalDateTime dt; + private String dt; } diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java index c6b482a..11736d1 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hisense.monitormanage.dto.BuildingRecordsDto; import com.hisense.monitormanage.dto.BuildingRecordsDtos; import com.hisense.monitormanage.entity.BuildingRecords; +import com.hisense.monitormanage.entity.RoadData; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; @@ -21,7 +22,7 @@ import java.util.Map; @Repository public interface BuildingRecordsMapper extends BaseMapper { - public void batchSave(@Param("list") List list); + void batchSave(@Param("list") List list); void batchUpdate(@Param("list") List list); @@ -37,13 +38,6 @@ public interface BuildingRecordsMapper extends BaseMapper { List selectNoiceEvent(@Param("page") Integer page,@Param("pageSize") Integer pageSize); - @Select("select COUNT(*) from (select br.pm10 from t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc where br.pm10 > 80) a ") - Integer selectCountRaise(); - - @Select("SELECT COUNT(*) FROM (SELECT br.noice,br.push_time FROM t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc WHERE (hour(br.push_time)>=22 or 6 > hour(br.push_time)) AND br.noice > 55 " + - "UNION SELECT br.noice,br.push_time FROM t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc WHERE DATE_FORMAT(br.push_time,'%H')>=6 AND DATE_FORMAT(br.push_time,'%H')<=22 AND br.noice > 70) a") - Integer selectCountNoice(); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq,bs.yjsg from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + " where br.project_name like concat('%',#{projectName},'%')") List selectByProjectName(String projectName); @@ -55,4 +49,12 @@ public interface BuildingRecordsMapper extends BaseMapper { @Param("jd1") Double jd1, @Param("wd") Double wd, @Param("wd1") Double wd1); + @Select("select * from t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc where TO_DAYS(push_time) = TO_DAYS(NOW()) AND br.pm10 > 80") + List selectByDayRaise(); + + @Select("SELECT a.* FROM (SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq FROM t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc WHERE (hour(br.push_time)>=22 or 6 > hour(br.push_time)) AND br.noice > 55 AND TO_DAYS(br.push_time) = TO_DAYS(NOW()) UNION SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq FROM t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc WHERE DATE_FORMAT(br.push_time,'%H')>=6 AND DATE_FORMAT(br.push_time,'%H') < 22 AND br.noice > 70 AND TO_DAYS(br.push_time) = TO_DAYS(NOW())) a") + List selectByDayNoice(); + + @Select("select * from t_road_data where pm10 > 150 AND dt = #{dt}") + List selectByDayRoadData(String dt); } diff --git a/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java b/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java index 0963fcf..284090a 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java @@ -58,6 +58,6 @@ public interface CameraChannelMapper extends BaseMapper { List selectNLAll(@Param("page") Integer page,@Param("pageSize") Integer pageSize); - @Select("SELECT * FROM t_camera_channel WHERE channel_code < '183_37028301831321232723' AND channel_code > '183_37028301831321231067' ORDER BY channel_code DESC" ) + @Select("SELECT * FROM t_camera_channel WHERE channel_code < '183_37028301831321231117' AND channel_code > '183_37028301001328630804' ORDER BY channel_code DESC") List selectCameraChannel(); } diff --git a/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java b/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java index 9c5bb67..ee9e09d 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/EventMapper.java @@ -22,9 +22,6 @@ public interface EventMapper extends BaseMapper { List selectByName(@Param("eventNewName") String eventNewName,@Param("page") Integer page,@Param("pageSize") Integer pageSize); - @Select("select count(*) from t_event where track_event = 'START' and event_cn_name in (${eventNewName})") - Integer selectCountByName(@Param("eventNewName")String eventNewName); - @Select("SELECT * FROM t_event where TO_DAYS(capture_time) = TO_DAYS(NOW()) AND event_cn_name in (${eventNewName}) AND track_event = 'START'") List selectByTimeAndName(@Param("eventNewName") String eventNewName); } diff --git a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java index 894ca69..f698058 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java @@ -1,6 +1,7 @@ package com.hisense.monitormanage.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hisense.monitormanage.entity.PassengerFlow; import com.hisense.monitormanage.entity.RoadData; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -25,4 +26,6 @@ public interface RoadDataMapper extends BaseMapper { @Select("select count(*) from t_road_data where pm10 > 150") Integer selectCountRoadData(); + + RoadData getByMaxId(); } diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index 9e907b3..81ef856 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -307,7 +307,7 @@ public class MonitorService { /** * 所有摄像头抓图 sql持续更新 */ - //@Scheduled(cron = "0 0 6 * * ?") + @Scheduled(cron = "0 0 6 * * ?") public void CameraScreenshot () { try { log.info("[monitor-capture]: start capture"); diff --git a/src/main/resources/mapper/RoadDataMapper.xml b/src/main/resources/mapper/RoadDataMapper.xml index c95ab67..fb58716 100644 --- a/src/main/resources/mapper/RoadDataMapper.xml +++ b/src/main/resources/mapper/RoadDataMapper.xml @@ -22,4 +22,8 @@ limit #{page},#{pageSize} + + \ No newline at end of file