diff --git a/src/main/java/com/hisense/monitormanage/controller/Controller.java b/src/main/java/com/hisense/monitormanage/controller/Controller.java index 1b58036..f3a0a21 100644 --- a/src/main/java/com/hisense/monitormanage/controller/Controller.java +++ b/src/main/java/com/hisense/monitormanage/controller/Controller.java @@ -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 gps = cameraChannelMapper.selectAllByGps(gpsX, gpsX1, gpsY, gpsY1); + + Result success = Result.success(gps); + + return success; + } + /** * 查询所有标签 * @param label diff --git a/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java b/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java index b91a203..6043bb2 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/CameraChannelMapper.java @@ -37,9 +37,14 @@ public interface CameraChannelMapper extends BaseMapper { 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); - + "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 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 selectAllByGps(@Param("gpsX") String gpsX, + @Param("gpsX1") String gpsX1, + @Param("gpsY") String gpsY, + @Param("gpsY1") String gpsY1); } diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index 290dc41..d8d03e8 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -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 labels = cameraChannelMapper.selectLabelAndChannel("1009","1008"); + List 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 queryWrapper = new QueryWrapper<>(); + channelPictureMapper.insert(picture); + /*QueryWrapper 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 labels = cameraChannelMapper.selectLabelAndChannel("1004","1006"); + List 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 queryWrapper = new QueryWrapper<>(); queryWrapper.eq("channel_code",channelCode); + picture.setInsertTime(new Date()); channelPictureMapper.update(picture,queryWrapper); }catch (Exception e){ diff --git a/src/main/java/com/hisense/monitormanage/utils/EhcacheUtil.java b/src/main/java/com/hisense/monitormanage/utils/EhcacheUtil.java index 25e36e6..440d2ad 100644 --- a/src/main/java/com/hisense/monitormanage/utils/EhcacheUtil.java +++ b/src/main/java/com/hisense/monitormanage/utils/EhcacheUtil.java @@ -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); } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3a836e6..acb30db 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -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