| | |
| | | package com.ruoyi.device.camera.service.impl; |
| | | |
| | | import java.awt.geom.Point2D; |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Override |
| | | public List<ArdCameras> getNearCameras(SchedulingParam param) { |
| | | try { |
| | | Long deptId=SecurityUtils.getLoginUser().getUser().getDeptId(); |
| | | Double longitude = param.getLongitude(); |
| | | Double latitude = param.getLatitude(); |
| | | if (longitude == null && latitude == null) { |
| | |
| | | return null; |
| | | } |
| | | String dayNightTime = redisCache.getCacheObject("sys_config:dayNightTime"); |
| | | //获取所有光电 |
| | | List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(new ArdCameras()); |
| | | //获取所有光电(按部门) |
| | | ArdCameras cameras= new ArdCameras(); |
| | | cameras.setDeptId(deptId); |
| | | List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(cameras); |
| | | //统计所有光电可视范围内与报警点的距离 |
| | | List<ArdCameras> ardCameras = new ArrayList<>(); |
| | | for (ArdCameras camera : ardCamerasList) { |
| | |
| | | double[] camPosition = new double[]{camera.getLongitude(), camera.getLatitude()}; |
| | | double distance = GisTool.getDistance(new double[]{longitude, latitude}, camPosition); |
| | | if (distance <= radius) { |
| | | camera.setChanNo(ArdTool.getChannelBydayNightTime(dayNightTime)); |
| | | /*获取通道列表*/ |
| | | ArdChannel ardChannel=new ArdChannel(); |
| | | ardChannel.setDeviceId(camera.getId()); |
| | | List<ArdChannel> ardChannels = ardChannelMapper.selectArdChannelList(ardChannel); |
| | | camera.setChannelList(ardChannels); |
| | | ardCameras.add(camera); |
| | | } |
| | | } |
| | | //过滤在线相机 |
| | | List<ArdCameras> onlineList = ardCameras.stream() |
| | | .filter(ardCamera -> (!ardCamera.getLoginId().equals(-1))) |
| | | .collect(Collectors.toList()); |
| | | return onlineList; |
| | | } catch (Exception ex) { |
| | | log.error("获取附近相机异常:" + ex.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | * 获取监控圈内所有在线光电 |
| | | * 刘苏义 |
| | | * 2023/8/17 13:57:21 |
| | | */ |
| | | @Override |
| | | public List<ArdCameras> getNearCamerasWithPolygon(SchedulingParam param) { |
| | | try { |
| | | Long deptId=SecurityUtils.getLoginUser().getUser().getDeptId(); |
| | | List<Point2D> partitionLocation = param.getPartitionLocation(); |
| | | if(partitionLocation==null) |
| | | { |
| | | log.debug("多边形坐标集合为空"); |
| | | return null; |
| | | } |
| | | String dayNightTime = redisCache.getCacheObject("sys_config:dayNightTime"); |
| | | //获取所有光电(按部门) |
| | | ArdCameras cameras= new ArdCameras(); |
| | | cameras.setDeptId(deptId); |
| | | List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(cameras); |
| | | List<ArdCameras> ardCameras = new ArrayList<>(); |
| | | for (ArdCameras camera : ardCamerasList) { |
| | | if (camera.getLongitude() == null && camera.getLatitude() == null) { |
| | | continue; |
| | | } |
| | | /*判断坐标是否在多边形范围内*/ |
| | | Point2D camPosition=new Point2D.Double(camera.getLongitude(), camera.getLatitude()); |
| | | boolean inPolygon = GisTool.isInPolygon(camPosition, partitionLocation); |
| | | if (inPolygon) { |
| | | /*获取通道列表*/ |
| | | ArdChannel ardChannel=new ArdChannel(); |
| | | ardChannel.setDeviceId(camera.getId()); |
| | | List<ArdChannel> ardChannels = ardChannelMapper.selectArdChannelList(ardChannel); |
| | | camera.setChannelList(ardChannels); |
| | | ardCameras.add(camera); |
| | | } |
| | | } |