截图优化

This commit is contained in:
wuweida 2022-05-12 17:12:43 +08:00
parent bd038a0c22
commit 3876c5834b
5 changed files with 65 additions and 38 deletions

View File

@ -106,6 +106,13 @@ public class Controller {
return "startScenic finish";
}
@RequestMapping("capture1")
public Object capture1(){
monitorService.start1();
return "finish capture";
}
/**
* 查询所有摄像头
@ -187,6 +194,24 @@ public class Controller {
return Result.success(channelLabelDtos);
}
/**
* 根据两个点查询范围内的摄像头
* @param gpsX
* @param gpsX1
* @param gpsY
* @param gpsY1
* @return
*/
@RequestMapping("selectAllByGps")
public Result selectAllByGps(String gpsX,String gpsX1,String gpsY,String gpsY1){
List<CameraChannelDto> gps = cameraChannelMapper.selectAllByGps(gpsX, gpsX1, gpsY, gpsY1);
Result success = Result.success(gps);
return success;
}
/**
* 查询所有标签
* @param label

View File

@ -37,9 +37,14 @@ public interface CameraChannelMapper extends BaseMapper<CameraChannel> {
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);
"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> selectLabelAndChannel(@Param("labelCode") String labelCode);
@Select("select cc.channel_code,cc.gps_x,cc.gps_y from t_camera_channel cc " +
"where (gps_x between #{gpsX} and #{gpsX1}) and (gps_y between #{gpsY} and #{gpsY1} )")
List<CameraChannelDto> selectAllByGps(@Param("gpsX") String gpsX,
@Param("gpsX1") String gpsX1,
@Param("gpsY") String gpsY,
@Param("gpsY1") String gpsY1);
}

View File

@ -67,10 +67,7 @@ public class MonitorService {
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;
@ -214,24 +211,25 @@ public class MonitorService {
log.info("[monitor-capture]: start capture");
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1009","1008");
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1009");
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));
ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName));
String picUrl = picHost1 + "/images/" + fileName;
String picUrl = picHost + "/images/" + fileName;
ChannelPicture picture = new ChannelPicture();
picture.setChannelCode(channelCode);
picture.setPicUrl(picUrl);
picture.setInsertTime(new Date());
/*channelPictureMapper.insert(picture);*/
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
channelPictureMapper.insert(picture);
/*QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code",channelCode);
channelPictureMapper.update(picture,queryWrapper);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture,queryWrapper);*/
}catch (Exception e){
log.info( "[monitor-capture] " +channelCode + " 截图图片失败 " + e.getMessage());
@ -251,23 +249,24 @@ public class MonitorService {
log.info("[monitor-capture]: start capture");
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1004","1006");
List<ChannelLabelDto> labels = cameraChannelMapper.selectLabelAndChannel("1004");
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));
ImageIO.write(bufferedImage, "jpg", new File(fileDir + "/images/" + fileName));
String picUrl = picHost1 + "/images/" + fileName;
String picUrl = picHost + "/images/" + fileName;
ChannelPicture picture = new ChannelPicture();
picture.setChannelCode(channelCode);
picture.setPicUrl(picUrl);
picture.setInsertTime(new Date());
/*channelPictureMapper.insert(picture);*/
/*picture.setInsertTime(new Date());
channelPictureMapper.insert(picture);*/
QueryWrapper<ChannelPicture> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("channel_code",channelCode);
picture.setInsertTime(new Date());
channelPictureMapper.update(picture,queryWrapper);
}catch (Exception e){

View File

@ -22,31 +22,31 @@ public class EhcacheUtil {
manager = CacheManager.create(url);
}
public static EhcacheUtil getInstance() {
if (ehCache== null) {
ehCache= new EhcacheUtil(path);
}
return ehCache;
public static EhcacheUtil getInstance() {
if (ehCache== null) {
ehCache= new EhcacheUtil(path);
}
return ehCache;
}
public void put(String cacheName, String key, Object value) {
Cache cache = manager.getCache(cacheName);
Element element = new Element(key, value);
cache.put(element);
Cache cache = manager.getCache(cacheName);
Element element = new Element(key, value);
cache.put(element);
}
public Object get(String cacheName, String key) {
Cache cache = manager.getCache(cacheName);
Element element = cache.get(key);
return element == null ? null : element.getObjectValue();
public Object get(String cacheName, String key) {
Cache cache = manager.getCache(cacheName);
Element element = cache.get(key);
return element == null ? null : element.getObjectValue();
}
public Cache get(String cacheName) {
return manager.getCache(cacheName);
}
return manager.getCache(cacheName);
}
public void remove(String cacheName, String key) {
Cache cache = manager.getCache(cacheName);
cache.remove(key);
public void remove(String cacheName, String key) {
Cache cache = manager.getCache(cacheName);
cache.remove(key);
}
}

View File

@ -17,10 +17,8 @@ spring.datasource.username=root
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.work-path=D:/tupian/
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