From f39d0f71655b8d342cefb2908b104fd8ecc907fd Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Wed, 13 Jul 2022 17:32:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=AF=E6=B0=B4=E7=82=B9=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=8A=93=E5=9B=BE=20=E7=A7=AF=E6=B0=B4=E7=82=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96=20=E6=91=84=E5=83=8F=E5=A4=B4?= =?UTF-8?q?=E6=8A=93=E5=9B=BEsql=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitormanage/controller/Controller.java | 4 +- .../controller/EventController.java | 14 ++++-- .../monitormanage/entity/TestCode.java | 11 +++++ .../hisense/monitormanage/entity/WCamera.java | 18 +++++++ .../mapper/CameraChannelMapper.java | 2 +- .../monitormanage/mapper/TestCodeMapper.java | 9 ++++ .../monitormanage/mapper/WCameraMapper.java | 9 ++++ .../mapper/WaterPointMapper.java | 2 +- .../monitormanage/service/MonitorService.java | 47 +++++++++++++++---- src/main/resources/mapper/TestCodeMapper.xml | 5 ++ src/main/resources/mapper/WCameraMapper.xml | 5 ++ 11 files changed, 107 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/hisense/monitormanage/entity/TestCode.java create mode 100644 src/main/java/com/hisense/monitormanage/entity/WCamera.java create mode 100644 src/main/java/com/hisense/monitormanage/mapper/TestCodeMapper.java create mode 100644 src/main/java/com/hisense/monitormanage/mapper/WCameraMapper.java create mode 100644 src/main/resources/mapper/TestCodeMapper.xml create mode 100644 src/main/resources/mapper/WCameraMapper.xml diff --git a/src/main/java/com/hisense/monitormanage/controller/Controller.java b/src/main/java/com/hisense/monitormanage/controller/Controller.java index abc2693..d67ca0b 100644 --- a/src/main/java/com/hisense/monitormanage/controller/Controller.java +++ b/src/main/java/com/hisense/monitormanage/controller/Controller.java @@ -92,7 +92,7 @@ public class Controller { @GetMapping("capture") public Object capture(){ - monitorService.construction(); + monitorService.CameraScreenshot(); return "finish capture"; } @@ -106,7 +106,7 @@ public class Controller { @GetMapping("capture1") public Object capture1(){ - monitorService.scenicSpotAndBathing(); + monitorService.WaterPointService(); return "finish capture"; } diff --git a/src/main/java/com/hisense/monitormanage/controller/EventController.java b/src/main/java/com/hisense/monitormanage/controller/EventController.java index 3a78eb0..6a6a175 100644 --- a/src/main/java/com/hisense/monitormanage/controller/EventController.java +++ b/src/main/java/com/hisense/monitormanage/controller/EventController.java @@ -94,12 +94,16 @@ public class EventController { } } JSONObject camera = jsonObject.getJSONObject("camera"); - event.setCameraName(camera.getString("cameraName")); - event.setDistrict(camera.getString("district")); - event.setLatitude(camera.getBigDecimal("latitude")); - event.setLongitude(camera.getBigDecimal("longitude")); + if (camera!=null){ + event.setCameraName(camera.getString("cameraName")); + event.setDistrict(camera.getString("district")); + event.setLatitude(camera.getBigDecimal("latitude")); + event.setLongitude(camera.getBigDecimal("longitude")); + } JSONObject image = jsonObject.getJSONObject("image"); - event.setImageUrl(image.getString("imageUrl")); + if (image!=null){ + event.setImageUrl(image.getString("imageUrl")); + } event.setTaskId(jsonObject.getString("taskId")); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式 Date date; diff --git a/src/main/java/com/hisense/monitormanage/entity/TestCode.java b/src/main/java/com/hisense/monitormanage/entity/TestCode.java new file mode 100644 index 0000000..29281e5 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/entity/TestCode.java @@ -0,0 +1,11 @@ +package com.hisense.monitormanage.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName("t_test_code") +public class TestCode { + private String channelCode; +} diff --git a/src/main/java/com/hisense/monitormanage/entity/WCamera.java b/src/main/java/com/hisense/monitormanage/entity/WCamera.java new file mode 100644 index 0000000..b0113ac --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/entity/WCamera.java @@ -0,0 +1,18 @@ +package com.hisense.monitormanage.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName("w_camera") +public class WCamera { + private Integer waterId; + private String ChannelCode; + private String channelName; + private String gpsX; + private String gpsY; + private String illustrate; + private String videoCapture; + +} diff --git a/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java b/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java index abf3e89..d390b87 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 > '404_37020348001325000037' ORDER BY channel_code DESC" ) + @Select("SELECT * FROM t_camera_channel WHERE channel_code < '404_37020323541317325139' AND channel_code > '404_37020300001310016729' ORDER BY channel_code DESC" ) List selectCameraChannel(); } diff --git a/src/main/java/com/hisense/monitormanage/mapper/TestCodeMapper.java b/src/main/java/com/hisense/monitormanage/mapper/TestCodeMapper.java new file mode 100644 index 0000000..bd94365 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/mapper/TestCodeMapper.java @@ -0,0 +1,9 @@ +package com.hisense.monitormanage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hisense.monitormanage.entity.TestCode; +import org.springframework.stereotype.Repository; + +@Repository +public interface TestCodeMapper extends BaseMapper { +} diff --git a/src/main/java/com/hisense/monitormanage/mapper/WCameraMapper.java b/src/main/java/com/hisense/monitormanage/mapper/WCameraMapper.java new file mode 100644 index 0000000..d10db21 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/mapper/WCameraMapper.java @@ -0,0 +1,9 @@ +package com.hisense.monitormanage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hisense.monitormanage.entity.WCamera; +import org.springframework.stereotype.Repository; + +@Repository +public interface WCameraMapper extends BaseMapper { +} diff --git a/src/main/java/com/hisense/monitormanage/mapper/WaterPointMapper.java b/src/main/java/com/hisense/monitormanage/mapper/WaterPointMapper.java index e2ef358..9fc7093 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/WaterPointMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/WaterPointMapper.java @@ -15,7 +15,7 @@ public interface WaterPointMapper extends BaseMapper { @Select("select * from water_point wp LEFT JOIN water_point_report wpr ON wp.water_point_id = wpr.water_point_id WHERE wp.audit_flag = '2' and wp.disp_flag in (0,1)") List selectWaterPoint(); - @Select("select * from water_point where audit_flag = '2' and disp_flag in (0,1) and report_origin = #{reportOrigin}") + @Select("select * from water_point wp LEFT JOIN water_point_report wpr ON wp.water_point_id = wpr.water_point_id where audit_flag = '2' and disp_flag in (0,1) and report_origin = #{reportOrigin}") List selectReportOrigin(String reportOrigin); @Select("SELECT * FROM w_camera w RIGHT JOIN water_camera wc ON w.water_id = wc.water_id where wc.water_point_name = #{waterPointName}") diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index a81c5b1..fb215ce 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -70,6 +70,12 @@ public class MonitorService { @Autowired private PeopleRecognizeMapper peopleRecognizeMapper; + @Autowired + private TestCodeMapper testCodeMapper; + + @Autowired + private WCameraMapper wCameraMapper; + @Value("${hwx.file.work-path}") private String fileDir; @@ -292,6 +298,7 @@ public class MonitorService { } } + @Scheduled(cron = "0 0 7 * * ?") public void CameraScreenshot () { try { log.info("[monitor-capture]: start capture"); @@ -317,16 +324,9 @@ public class MonitorService { log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); i--; if (i == 0){ - QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.eq("channel_code",channelCode); - CameraChannel cameraChannel = cameraChannelMapper.selectOne(queryWrapper); - cameraChannel.setCheckStatus(0); - cameraChannelMapper.update(cameraChannel,queryWrapper); - } - try { - Thread.sleep(500); - } catch (InterruptedException interruptedException) { - interruptedException.printStackTrace(); + TestCode testCode = new TestCode(); + testCode.setChannelCode(channelCode); + testCodeMapper.insert(testCode); } } } @@ -1038,6 +1038,33 @@ public class MonitorService { } } + @Scheduled(cron = "0 0 8 * * ?") + public void WaterPointService() { + try { + log.info("[monitor-capture]: start capture"); + QueryWrapper queryWrapper = new QueryWrapper<>(); + List wCameras = wCameraMapper.selectList(queryWrapper); + wCameras.forEach(camera -> { + String channelCode = camera.getChannelCode(); + try { + BufferedImage bufferedImage = capturecreenshot(channelCode); + String fileName = channelCode + ".jpg"; + ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName)); + String picUrl = picHost + "/images/" + fileName; + WCamera wCamera = new WCamera(); + wCamera.setVideoCapture(picUrl); + QueryWrapper queryWrapper1 = new QueryWrapper<>(); + queryWrapper1.eq("channel_code", channelCode); + wCameraMapper.update(wCamera, queryWrapper1); + }catch (Exception e){ + log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage()); + } + }); + log.info("[monitor-capture]: end capture"); + }catch (Exception exception){ + exception.printStackTrace(); + } + } } diff --git a/src/main/resources/mapper/TestCodeMapper.xml b/src/main/resources/mapper/TestCodeMapper.xml new file mode 100644 index 0000000..f2138db --- /dev/null +++ b/src/main/resources/mapper/TestCodeMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/WCameraMapper.xml b/src/main/resources/mapper/WCameraMapper.xml new file mode 100644 index 0000000..f2e7b19 --- /dev/null +++ b/src/main/resources/mapper/WCameraMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file