| | |
| | | |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.hiksdk.common.GlobalVariable; |
| | | import com.ruoyi.scheduling.domian.SchedulingParam; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.utils.tools.ArdTool; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.utils.tools.GisTool; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Override |
| | | public int deleteArdCamerasByIds(String[] ids) { |
| | | int res = ardCamerasMapper.deleteArdCamerasByIds(ids); |
| | | if(res>0) |
| | | { |
| | | for(String id:ids) |
| | | { |
| | | if (res > 0) { |
| | | for (String id : ids) { |
| | | redisCache.deleteObject(getCacheKey(id)); |
| | | } |
| | | } |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取监控圈内所有在线光电 |
| | | * 刘苏义 |
| | | * 2023/8/17 13:57:21 |
| | | */ |
| | | @Override |
| | | public List<ArdCameras> getNearCameras(SchedulingParam param) { |
| | | try { |
| | | Double longitude = param.getLongitude(); |
| | | Double latitude = param.getLatitude(); |
| | | if (longitude == null && latitude == null) { |
| | | log.debug("原点坐标为空"); |
| | | return null; |
| | | } |
| | | Integer radius = param.getMonitoringRadius(); |
| | | if (radius == null) { |
| | | log.debug("监控圈半径距离为空"); |
| | | return null; |
| | | } |
| | | String dayNightTime = redisCache.getCacheObject("sys_config:dayNightTime"); |
| | | //获取所有光电 |
| | | List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(new ArdCameras()); |
| | | //统计所有光电可视范围内与报警点的距离 |
| | | List<ArdCameras> ardCameras = new ArrayList<>(); |
| | | for (ArdCameras camera : ardCamerasList) { |
| | | if (camera.getLongitude() == null && camera.getLatitude() == null) { |
| | | continue; |
| | | } |
| | | double[] camPosition = new double[]{camera.getLongitude(), camera.getLatitude()}; |
| | | double distance = GisTool.getDistance(new double[]{longitude, latitude}, camPosition); |
| | | if (distance <= radius) { |
| | | camera.setChannel(ArdTool.getChannelBydayNightTime(dayNightTime)); |
| | | 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; |
| | | } |
| | | |
| | | } |