| | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.ExecutionException; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | //region 处理通用光电报警 |
| | | ArdAlarmCamera ardAlarmCamera = JSONObject.parseObject(message, ArdAlarmCamera.class); |
| | | ardAlarmCamera.setId(IdUtils.simpleUUID()); |
| | | ardAlarmCamera.setCreateTime(new Date()); |
| | | int aac = ardAlarmCameraMapper.insertArdAlarmCamera(ardAlarmCamera); |
| | | if (aac > 0) { |
| | | log.debug("camera入库成功:" + ardAlarmCamera); |
| | |
| | | log.info("相机:" + cameraId + "未开启报警引导功能"); |
| | | return; |
| | | } |
| | | |
| | | SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); |
| | | GuideTask guideTask = new GuideTask(); |
| | | //相机ID |
| | |
| | | */ |
| | | private String getNearbyCamera(double[] targetPosition) { |
| | | String minDistanceCameraId = ""; |
| | | //获取所有大光电 |
| | | List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(new ArdCameras("1")); |
| | | //统计所有大光电可视范围内与报警点的距离 |
| | | Map<String, Double> distanceMap = new HashMap<>(); |
| | | Map<String, Integer> guideMap = new HashMap<>(); |
| | | for (ArdCameras camera : ardCamerasList) { |
| | | double[] camPosition = new double[]{camera.getLongitude(), camera.getLatitude()}; |
| | | double distance = GisTool.getDistance(targetPosition, camPosition); |
| | | if (distance != 0.0 && distance <= camera.getCamMaxVisibleDistance()) { |
| | | distanceMap.put(camera.getId(), distance); |
| | | if (StringUtils.isNull(camera.getCamAlarmGuideEnable())) { |
| | | camera.setCamAlarmGuideEnable(0); |
| | | try { |
| | | //获取所有大光电 |
| | | List<ArdCameras> ardCamerasList = ardCamerasMapper.selectArdCamerasList(new ArdCameras("1")); |
| | | //统计所有大光电可视范围内与报警点的距离 |
| | | Map<String, Double> distanceMap = new HashMap<>(); |
| | | Map<String, Integer> guideMap = new HashMap<>(); |
| | | for (ArdCameras camera : ardCamerasList) { |
| | | if (camera.getCamMaxVisibleDistance() == null) { |
| | | continue; |
| | | } |
| | | guideMap.put(camera.getId(), camera.getCamAlarmGuideEnable()); |
| | | double[] camPosition = new double[]{camera.getLongitude(), camera.getLatitude()}; |
| | | double distance = GisTool.getDistance(targetPosition, camPosition); |
| | | if (distance != 0.0 && distance <= camera.getCamMaxVisibleDistance()) { |
| | | distanceMap.put(camera.getId(), distance); |
| | | if (StringUtils.isNull(camera.getCamAlarmGuideEnable())) { |
| | | camera.setCamAlarmGuideEnable(0); |
| | | } |
| | | guideMap.put(camera.getId(), camera.getCamAlarmGuideEnable()); |
| | | } |
| | | } |
| | | if (distanceMap.size() > 0) { |
| | | log.debug("尝试查找最近光电"); |
| | | //获取距离字典中最近的一个相机ID |
| | | minDistanceCameraId = ArdTool.getKeyByMinValue(distanceMap); |
| | | log.debug("查找到最近光电:" + minDistanceCameraId); |
| | | if (guideMap.get(minDistanceCameraId).equals(0)) { |
| | | log.debug("该光电未开启报警引导"); |
| | | return " "; |
| | | } |
| | | } |
| | | } |
| | | if (distanceMap.size() > 0) { |
| | | log.debug("尝试查找最近光电"); |
| | | //获取距离字典中最近的一个相机ID |
| | | minDistanceCameraId = ArdTool.getKeyByMinValue(distanceMap); |
| | | log.debug("查找到最近光电:" + minDistanceCameraId); |
| | | if (guideMap.get(minDistanceCameraId).equals(0)) { |
| | | log.debug("该光电未开启报警引导"); |
| | | return " "; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | log.error("获取附近开启报警引导功能光电异常:"+ex.getMessage()); |
| | | } |
| | | return minDistanceCameraId; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 雷达引导入队 |
| | | */ |