From f0e9390e4bb05cbcda30c9cb4fee36549006f7c3 Mon Sep 17 00:00:00 2001
From: wuweida <2918581207@qq.com>
Date: Wed, 11 May 2022 17:21:39 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8A=93=E5=8F=96=E6=91=84?=
=?UTF-8?q?=E5=83=8F=E5=A4=B4=E6=88=AA=E5=9B=BE=E6=9C=8D=E5=8A=A1=20?=
=?UTF-8?q?=E6=A0=B9=E6=8D=AEchannelId=E6=9F=A5=E8=AF=A2=E6=91=84=E5=83=8F?=
=?UTF-8?q?=E5=A4=B4=E8=AF=A6=E6=83=85=E4=BF=A1=E6=81=AF=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 14 ++--
.../monitormanage/controller/Controller.java | 22 ++++-
.../monitormanage/dto/CameraChannelDto1.java | 28 +++++++
.../monitormanage/entity/ChannelPicture.java | 25 ++++++
.../hisense/monitormanage/entity/Label.java | 1 +
.../mapper/CameraChannelMapper.java | 13 +--
.../mapper/ChannelPictureMapper.java | 8 ++
.../monitormanage/service/MonitorService.java | 83 +++++++++++++++++++
src/main/resources/application.properties | 2 +
src/main/resources/mapper/ChannelPicture.xml | 5 ++
10 files changed, 185 insertions(+), 16 deletions(-)
create mode 100644 src/main/java/com/hisense/monitormanage/dto/CameraChannelDto1.java
create mode 100644 src/main/java/com/hisense/monitormanage/entity/ChannelPicture.java
create mode 100644 src/main/java/com/hisense/monitormanage/mapper/ChannelPictureMapper.java
create mode 100644 src/main/resources/mapper/ChannelPicture.xml
diff --git a/pom.xml b/pom.xml
index 3558a4b..ff52262 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,17 +63,17 @@
mybatis-plus-generate
2.3
-
-
-
-
-
-
+ org.bytedeco
+ javacv-platform
+ 1.5.7
+
+
+
diff --git a/src/main/java/com/hisense/monitormanage/controller/Controller.java b/src/main/java/com/hisense/monitormanage/controller/Controller.java
index bb6b8df..227ef5f 100644
--- a/src/main/java/com/hisense/monitormanage/controller/Controller.java
+++ b/src/main/java/com/hisense/monitormanage/controller/Controller.java
@@ -1,9 +1,6 @@
package com.hisense.monitormanage.controller;
-import com.hisense.monitormanage.dto.CameraChannelDto;
-import com.hisense.monitormanage.dto.ChannelLabelDto;
-import com.hisense.monitormanage.dto.ChengguanDto;
-import com.hisense.monitormanage.dto.ScenicCameraDto;
+import com.hisense.monitormanage.dto.*;
import com.hisense.monitormanage.entity.*;
import com.hisense.monitormanage.mapper.*;
import com.hisense.monitormanage.service.MonitorService;
@@ -150,6 +147,23 @@ public class Controller {
}
+ /**
+ * 根据channelId查询摄像头详细信息
+ * @param channelId
+ * @return
+ */
+ @RequestMapping("selectByChannelId")
+ public Result selectByChannelId(String channelId){
+
+ List list = cameraChannelMapper.selectByChannelId(channelId);
+
+ Result success = Result.success(list);
+
+ return success;
+
+
+ }
+
/**
* 根据标签查询对应摄像头
* @return
diff --git a/src/main/java/com/hisense/monitormanage/dto/CameraChannelDto1.java b/src/main/java/com/hisense/monitormanage/dto/CameraChannelDto1.java
new file mode 100644
index 0000000..3e908f0
--- /dev/null
+++ b/src/main/java/com/hisense/monitormanage/dto/CameraChannelDto1.java
@@ -0,0 +1,28 @@
+package com.hisense.monitormanage.dto;
+
+import lombok.Data;
+
+@Data
+public class CameraChannelDto1 {
+ private Long idtCameraChannel;
+
+ private String channelCode;
+
+ private String channelId;
+
+ private String channelName;
+
+ private String gpsX;
+
+ private String gpsY;
+
+ private Integer status;//1在线;0离线
+
+ private String nodeName;
+
+ private Integer checkStatus;//1正常;0异常
+
+ private String parentId;
+
+ private String picUrl;
+}
diff --git a/src/main/java/com/hisense/monitormanage/entity/ChannelPicture.java b/src/main/java/com/hisense/monitormanage/entity/ChannelPicture.java
new file mode 100644
index 0000000..5fbeabe
--- /dev/null
+++ b/src/main/java/com/hisense/monitormanage/entity/ChannelPicture.java
@@ -0,0 +1,25 @@
+package com.hisense.monitormanage.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName("t_channel_picture")
+public class ChannelPicture {
+ @TableId
+ private String id;
+
+ private String channelCode;
+
+ private String PicUrl;
+
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date insertTime;
+
+}
diff --git a/src/main/java/com/hisense/monitormanage/entity/Label.java b/src/main/java/com/hisense/monitormanage/entity/Label.java
index c65d9cc..048e2a1 100644
--- a/src/main/java/com/hisense/monitormanage/entity/Label.java
+++ b/src/main/java/com/hisense/monitormanage/entity/Label.java
@@ -11,5 +11,6 @@ public class Label {
private Long id;
private String labelCode;
private String labelName;
+ private String capturePatternn;
}
diff --git a/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java b/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java
index b2ab11b..be4c053 100644
--- a/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java
+++ b/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java
@@ -2,13 +2,12 @@ package com.hisense.monitormanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hisense.monitormanage.dto.CameraChannelDto;
+import com.hisense.monitormanage.dto.CameraChannelDto1;
import com.hisense.monitormanage.dto.ChannelLabelDto;
-import com.hisense.monitormanage.dto.ChengguanDto;
import com.hisense.monitormanage.entity.CameraChannel;
import com.hisense.monitormanage.entity.Label;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Update;
import java.util.List;
@@ -16,14 +15,14 @@ public interface CameraChannelMapper extends BaseMapper {
List selectAll(CameraChannel cameraChannel,@Param("page") Integer page,@Param("pageSize") Integer pageSize);
- @Select("select * from t_camera_channel where channel_id = #{channelId}")
- List selectByChannelId(@Param("channelId") String channelId);
+ @Select("select cc.*,cp.pic_url from t_camera_channel cc JOIN t_channel_picture cp ON cc.channel_code=cp.channel_code where cc.channel_id = #{channelId}")
+ List selectByChannelId(@Param("channelId") String channelId);
@Select("select * from t_camera_channel where parent_id = #{parentId}")
List selectByParentId(@Param("parentId") String parentId);
@Select("select * from (select a.*,c.* from t_channel_mtm_label b JOIN t_label a JOIN t_camera_channel c " +
- "ON a.label_code = b.label_code AND b.channel_code = c.channel_code ) m where m.label_code = #{labelCode} ")
+ "ON a.label_code = b.label_code AND b.channel_code = c.channel_code where c.`status`!= 0) m where m.label_code = #{labelCode} ")
List selectLabel(@Param("labelCode") String labelCode);
//@Update("update t_camera_channel set state = list")
void updateState(@Param("list") List list);
@@ -37,5 +36,9 @@ public interface CameraChannelMapper extends BaseMapper {
@Select("select * from t_camera_channel where channel_name like concat('%',#{channelName},'%')")
List selectByChannelName(String channelName);
+ @Select("select * from (select a.label_code,a.label_name,c.channel_code,c.channel_name from t_channel_mtm_label b JOIN t_label a JOIN t_camera_channel c " +
+ "ON a.label_code = b.label_code AND b.channel_code = c.channel_code where c.`status`!= 0) m where m.label_code in (#{labelCode},#{labelCode1}) ")
+ List selectLabelAndChannel(@Param("labelCode") String labelCode,@Param("labelCode1") String labelCode1);
+
}
diff --git a/src/main/java/com/hisense/monitormanage/mapper/ChannelPictureMapper.java b/src/main/java/com/hisense/monitormanage/mapper/ChannelPictureMapper.java
new file mode 100644
index 0000000..58eeac4
--- /dev/null
+++ b/src/main/java/com/hisense/monitormanage/mapper/ChannelPictureMapper.java
@@ -0,0 +1,8 @@
+package com.hisense.monitormanage.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.hisense.monitormanage.entity.ChannelPicture;
+
+public interface ChannelPictureMapper extends BaseMapper {
+
+}
diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java
index fe96641..a650d6b 100644
--- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java
+++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java
@@ -4,7 +4,9 @@ import cn.hutool.core.collection.ListUtil;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
+import com.hisense.monitormanage.dto.ChannelLabelDto;
import com.hisense.monitormanage.entity.*;
import com.hisense.monitormanage.mapper.*;
import lombok.extern.log4j.Log4j2;
@@ -58,10 +60,17 @@ public class MonitorService {
@Autowired
private CameraOrgenizationMapper cameraOrgenMapper;
+ @Autowired
+ private ChannelPictureMapper channelPictureMapper;
+
@Value("${hwx.file.work-path}")
private String fileDir;
@Value("${hwx.file.pic-host}")
private String picHost;
+ @Value("${wwd.file.work-path}")
+ private String fileDir1;
+ @Value("${wwd.file.pic-host}")
+ private String picHost1;
@Value("iOgQotfgfyLvhj6WgfDTpq7F")
private String key;
@@ -198,6 +207,80 @@ public class MonitorService {
}
}
+ @Scheduled(cron = "0 0 8 1/1 * ?")
+ public void start1() {
+
+ try {
+
+ log.info("[monitor-capture]: start capture");
+
+ List labels = cameraChannelMapper.selectLabelAndChannel("1009","1008");
+ labels.forEach(label -> {
+ String channelCode = label.getChannelCode();
+ try {
+ BufferedImage bufferedImage = capturecreenshot(channelCode);
+ String fileName = channelCode + ".jpg";
+ ImageIO.write(bufferedImage, "jpg", new File(fileDir1 + "/images/" + fileName));
+
+ String picUrl = picHost1 + "/images/" + fileName;
+
+ ChannelPicture picture = new ChannelPicture();
+ picture.setChannelCode(channelCode);
+ picture.setPicUrl(picUrl);
+ picture.setInsertTime(new Date());
+ /*channelPictureMapper.insert(picture);*/
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("channel_code",channelCode);
+ channelPictureMapper.update(picture,queryWrapper);
+ }catch (Exception e){
+
+ log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
+ }
+ });
+
+ log.info("[monitor-capture]: end capture");
+ }catch (Exception exception){
+ exception.printStackTrace();
+ }
+ }
+
+ @Scheduled(cron = "0 0 8/1 * * ?")
+ public void start2() {
+
+ try {
+
+ log.info("[monitor-capture]: start capture");
+
+ List labels = cameraChannelMapper.selectLabelAndChannel("1004","1006");
+ labels.forEach(label -> {
+ String channelCode = label.getChannelCode();
+ try {
+ BufferedImage bufferedImage = capturecreenshot(channelCode);
+ String fileName = channelCode + ".jpg";
+ ImageIO.write(bufferedImage, "jpg", new File(fileDir1 + "/images/" + fileName));
+
+ String picUrl = picHost1 + "/images/" + fileName;
+
+ ChannelPicture picture = new ChannelPicture();
+ picture.setChannelCode(channelCode);
+ picture.setPicUrl(picUrl);
+ picture.setInsertTime(new Date());
+ /*channelPictureMapper.insert(picture);*/
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("channel_code",channelCode);
+ channelPictureMapper.update(picture,queryWrapper);
+ }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/application.properties b/src/main/resources/application.properties
index 1e7e95e..3a836e6 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -18,7 +18,9 @@ spring.datasource.password=w@CmM1mBVQkPhdrc
#spring.datasource.password=123456
hwx.file.work-path=/Users/huangweixiong/Downloads/
+wwd.file.work-path=C:/Users/szkingdom/.m2
hwx.file.pic-host=http://127.0.0.1:7009
+wwd.file.pic-host=http://15.72.183.90:7009
spring.resources.static-locations=classpath:/static,classpath:/public,file:${hwx.file.work-path}
mybatis-plus.mapper-locations=classpath*:/mapper/*.xml
diff --git a/src/main/resources/mapper/ChannelPicture.xml b/src/main/resources/mapper/ChannelPicture.xml
new file mode 100644
index 0000000..9872a60
--- /dev/null
+++ b/src/main/resources/mapper/ChannelPicture.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file