| | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.alarm.radar.service.ArdRadarService; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.camera.service.ICameraSdkService; |
| | | import com.ruoyi.device.radar.mapper.ArdEquipRadarMapper; |
| | | import com.ruoyi.storage.minio.domain.jsonbean.JsonsRootBean; |
| | | import com.ruoyi.utils.gis.GisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.gavaghan.geodesy.GlobalCoordinates; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | if (msgMap != null) { |
| | | Double p = Double.parseDouble(msgMap.get("p").toString()); |
| | | Double t = Double.parseDouble(msgMap.get("t").toString()); |
| | | Double z = Double.parseDouble(msgMap.get("z").toString()); |
| | | Long distance = Long.parseLong(msgMap.get("distance").toString()); |
| | | String radarId = msgMap.get("radarId").toString(); |
| | | //获取雷达所在塔上的大光电 |
| | | String cameraIdWithTower = ardEquipRadarMapper.getCameraByRadar(radarId); |
| | | if (StringUtils.isNotNull(cameraIdWithTower) && StringUtils.isNotEmpty(cameraIdWithTower)) { |
| | | log.debug("获取到雷达塔上的光电:" + cameraIdWithTower); |
| | | ArdCameras camera = ardEquipRadarMapper.getCameraByRadar(radarId); |
| | | if (StringUtils.isNotNull(camera)) { |
| | | log.debug("获取到雷达塔上的光电:" + camera.getId()); |
| | | //计算目标点坐标 |
| | | GlobalCoordinates cameraCoordinates = new GlobalCoordinates(camera.getLatitude(), camera.getLongitude()); |
| | | GlobalCoordinates targetCoordinates = GisUtil.getGlobalCoordinates(cameraCoordinates, p, distance); |
| | | //获取ptz |
| | | double[] cameraPoint = new double[]{ camera.getLongitude(), camera.getLatitude(),camera.getAltitude()}; |
| | | double[] targetPoint = new double[]{targetCoordinates.getLongitude(), targetCoordinates.getLatitude()}; |
| | | double[] cameraPTZ = GisUtil.getCameraPTZ(cameraPoint, targetPoint, 20, 150); |
| | | //如果雷达塔上有光电 |
| | | CameraCmd cmd = new CameraCmd(cameraIdWithTower, 1); |
| | | CameraCmd cmd = new CameraCmd(camera.getId(), 1); |
| | | cmd.setOperator("sys_radar_force"); |
| | | Map<String, Double> ptzMap = new HashMap<>(); |
| | | ptzMap.put("p", p); |
| | | ptzMap.put("t", t); |
| | | ptzMap.put("z", z); |
| | | ptzMap.put("z", cameraPTZ[2]); |
| | | cmd.setPtzMap(ptzMap); |
| | | boolean res = iCameraSdkService.setPtz(cmd); |
| | | if (res) { |
| | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("强制引导异常:"+ ex.getMessage()); |
| | | log.error("强制引导异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 异步雷达追踪引导 |
| | | * 刘苏义 |
| | | * 2023/11/2 9:00:55 |
| | | */ |
| | | @Override |
| | | @Async |
| | | public void followGuide(String msg) { |
| | | try { |
| | | Map<String, Object> msgMap = JSONObject.parseObject(msg, Map.class); |
| | | if (msgMap != null) { |
| | | Double p = Double.parseDouble(msgMap.get("p").toString()); |
| | | Double t = Double.parseDouble(msgMap.get("t").toString()); |
| | | Long distance = Long.parseLong(msgMap.get("distance").toString()); |
| | | String radarId = msgMap.get("radarId").toString(); |
| | | //获取雷达所在塔上的大光电 |
| | | ArdCameras camera = ardEquipRadarMapper.getCameraByRadar(radarId); |
| | | if (StringUtils.isNotNull(camera)) { |
| | | log.debug("获取到雷达塔上的光电:" + camera.getId()); |
| | | //计算目标点坐标 |
| | | GlobalCoordinates cameraCoordinates = new GlobalCoordinates(camera.getLatitude(), camera.getLongitude()); |
| | | GlobalCoordinates targetCoordinates = GisUtil.getGlobalCoordinates(cameraCoordinates, p, distance); |
| | | //获取ptz |
| | | double[] cameraPoint = new double[]{ camera.getLongitude(), camera.getLatitude(),camera.getAltitude()}; |
| | | double[] targetPoint = new double[]{targetCoordinates.getLongitude(), targetCoordinates.getLatitude()}; |
| | | double[] cameraPTZ = GisUtil.getCameraPTZ(cameraPoint, targetPoint, 20, 150); |
| | | //如果雷达塔上有光电 |
| | | CameraCmd cmd = new CameraCmd(camera.getId(), 1); |
| | | cmd.setOperator("sys_radar_follow"); |
| | | Map<String, Double> ptzMap = new HashMap<>(); |
| | | ptzMap.put("p", p); |
| | | ptzMap.put("t", t); |
| | | ptzMap.put("z", cameraPTZ[2]); |
| | | cmd.setPtzMap(ptzMap); |
| | | boolean res = iCameraSdkService.setPtz(cmd); |
| | | if (res) { |
| | | log.debug("雷达追踪引导成功"); |
| | | } else { |
| | | log.debug("雷达追踪引导失败"); |
| | | } |
| | | } else { |
| | | log.debug("未获取到雷达塔上的光电"); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("达追踪引导异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | } |