新增抓取摄像头截图服务

根据channelId查询摄像头详情信息优化
This commit is contained in:
wuweida 2022-05-11 17:21:39 +08:00
parent f919ae9e51
commit f0e9390e4b
10 changed files with 185 additions and 16 deletions

14
pom.xml
View File

@ -63,17 +63,17 @@
<artifactId>mybatis-plus-generate</artifactId>
<version>2.3</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.bytedeco</groupId>-->
<!-- <artifactId>javacv-platform</artifactId>-->
<!-- <version>1.5.7</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.5.7</version>
</dependency>
<!--<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv</artifactId>
<version>1.5.7</version>
</dependency>
</dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.bytedeco</groupId>-->
<!-- <artifactId>ffmpeg-platform</artifactId>-->

View File

@ -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<CameraChannelDto1> list = cameraChannelMapper.selectByChannelId(channelId);
Result success = Result.success(list);
return success;
}
/**
* 根据标签查询对应摄像头
* @return

View File

@ -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;
}

View File

@ -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;
}

View File

@ -11,5 +11,6 @@ public class Label {
private Long id;
private String labelCode;
private String labelName;
private String capturePatternn;
}

View File

@ -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<CameraChannel> {
List<CameraChannelDto> selectAll(CameraChannel cameraChannel,@Param("page") Integer page,@Param("pageSize") Integer pageSize);
@Select("select * from t_camera_channel where channel_id = #{channelId}")
List<CameraChannel> 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<CameraChannelDto1> selectByChannelId(@Param("channelId") String channelId);
@Select("select * from t_camera_channel where parent_id = #{parentId}")
List<CameraChannel> 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<ChannelLabelDto> 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<CameraChannel> {
@Select("select * from t_camera_channel where channel_name like concat('%',#{channelName},'%')")
List<CameraChannel> 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<ChannelLabelDto> selectLabelAndChannel(@Param("labelCode") String labelCode,@Param("labelCode1") String labelCode1);
}

View File

@ -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<ChannelPicture> {
}

View File

@ -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<ChannelLabelDto> 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<ChannelPicture> 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<ChannelLabelDto> 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<ChannelPicture> 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();
}
}
/**
* 景区人流量识别
*/

View File

@ -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

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hisense.monitormanage.mapper.ChannelPictureMapper">
</mapper>