diff --git a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java index cd8dd5b..a3cb4ae 100644 --- a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java +++ b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java @@ -286,10 +286,10 @@ public class BuildingController { return success; } - /*@GetMapping("exportEvent") + @GetMapping("exportEvent") public void exportRaiseEvent() throws Exception { buildingRecordsService.testHSSF(); - }*/ + } /** * 查询近7天噪声事件 diff --git a/src/main/java/com/hisense/monitormanage/controller/Controller.java b/src/main/java/com/hisense/monitormanage/controller/Controller.java index ea8a051..bdbb486 100644 --- a/src/main/java/com/hisense/monitormanage/controller/Controller.java +++ b/src/main/java/com/hisense/monitormanage/controller/Controller.java @@ -106,7 +106,7 @@ public class Controller { @GetMapping("capture1") public Object capture1(){ - monitorService.WaterPointService(); + monitorService.buildingImage(); return "finish capture"; } diff --git a/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java b/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java index 9c46e46..d021d15 100644 --- a/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java +++ b/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java @@ -34,4 +34,8 @@ public class BuildingSite { private String yjsg; + private String channelCode; + + private String channelName; + } diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java index 3d040b6..904401a 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java @@ -19,4 +19,7 @@ public interface BuildingSiteMapper extends BaseMapper { @Select("select * from t_building_new_site") List selectBuildSite(); + + @Select("select * from t_building_new_site where channel_code is not null") + List selectByList(); } diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index f298cec..cf275e6 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -76,6 +76,8 @@ public class MonitorService{ @Autowired private WCameraMapper wCameraMapper; + @Autowired + private BuildingSiteMapper buildingSiteMapper; @Value("${hwx.file.work-path}") private String fileDir; @@ -304,6 +306,34 @@ public class MonitorService{ } } + @Scheduled(cron = "0 30 8 * * ?") + public void buildingImage() { + try { + List buildingSites = buildingSiteMapper.selectByList(); + + buildingSites.forEach(building -> { + String channelCode = building.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + String picUrl = picHost + "/images/" + fileName; + ChannelPicture channelPicture = new ChannelPicture(); + channelPicture.setChannelCode(channelCode); + channelPicture.setPicUrl(picUrl); + channelPicture.setInsertTime(new Date()); + channelPictureMapper.insert(channelPicture); + }catch (Exception e){ + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + log.info("[monitor-capture]: end capture"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } + + /** * 所有摄像头抓图 sql持续更新 */