From 3a0da0fd4d19326214650c39015b767ad8631f10 Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Wed, 17 Aug 2022 15:26:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E5=9C=B0=E6=8A=93?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BuildingController.java | 4 +-- .../monitormanage/controller/Controller.java | 2 +- .../monitormanage/entity/BuildingSite.java | 4 +++ .../mapper/BuildingSiteMapper.java | 3 ++ .../monitormanage/service/MonitorService.java | 30 +++++++++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) 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持续更新 */