| package com.ruoyi.alarm.radar.service.impl; | 
|   | 
| import com.alibaba.fastjson2.JSONObject; | 
| import com.ruoyi.alarm.global.domain.GuidePoint; | 
| import com.ruoyi.alarm.radar.domain.ArdAlarmRadar; | 
| import com.ruoyi.alarm.radar.domain.RadarAlarmData; | 
| import com.ruoyi.alarm.radar.service.ArdRadarService; | 
| import com.ruoyi.common.core.domain.AjaxResult; | 
| 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; | 
|   | 
| import javax.annotation.Resource; | 
| import java.util.HashMap; | 
| import java.util.List; | 
| import java.util.Map; | 
|   | 
| /** | 
|  * @Description: 雷达业务 | 
|  * @ClassName: ArdRadarServiceImpl | 
|  * @Author: 刘苏义 | 
|  * @Date: 2023年11月02日9:00:08 | 
|  **/ | 
| @Slf4j(topic = "guideQueue") | 
| @Service | 
| public class ArdRadarServiceImpl implements ArdRadarService { | 
|     @Resource | 
|     ICameraSdkService iCameraSdkService; | 
|     @Resource | 
|     ArdEquipRadarMapper ardEquipRadarMapper; | 
|   | 
|     /** | 
|      * 异步执行强制引导 | 
|      * 刘苏义 | 
|      * 2023/11/2 9:00:55 | 
|      */ | 
|     @Override | 
|     @Async | 
|     public void forceGuide(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_force"); | 
|                     Map<String, Double> ptzMap = new HashMap<>(); | 
|                     ptzMap.put("p", p); | 
|                     ptzMap.put("t", t); | 
|                     ptzMap.put("z", cameraPTZ[2]); | 
|                     cmd.setPtzMap(ptzMap); | 
|                     iCameraSdkService.setPtz(cmd); | 
|                 } else { | 
|                     log.debug("未获取到雷达塔上的光电"); | 
|                 } | 
|             } | 
|         } catch (Exception ex) { | 
|             log.error("强制引导异常:" + ex.getMessage()); | 
|         } | 
|     } | 
|     /** | 
|      * 异步雷达追踪引导 | 
|      * 刘苏义 | 
|      * 2023/11/2 9:00:55 | 
|      */ | 
|     @Override | 
|     @Async | 
|     public void followGuide(String msg) { | 
|         try { | 
|             RadarAlarmData radarFollowData = JSONObject.parseObject(msg, RadarAlarmData.class); | 
|             if (radarFollowData != null) { | 
|                 List<ArdAlarmRadar> ardFollowRadars = radarFollowData.getArdFollowRadars(); | 
|                 if (ardFollowRadars.size()>0) { | 
|                     //当每次上报只上报一个追踪信息,认为不太可能雷达扫描一次会跟踪多个目标 | 
|                     ArdAlarmRadar ardFollowRadar = ardFollowRadars.get(0); | 
|                     String radarId = radarFollowData.getRadarId();//雷达id | 
|                     //这里追踪的坐标为雷达经过计算上传的经纬度 | 
|                     Double longitude = ardFollowRadar.getLongitude(); | 
|                     Double latitude = ardFollowRadar.getLatitude(); | 
|                     GuidePoint guidePoint=new GuidePoint().setLongitude(longitude).setLatitude(latitude); | 
|                     //获取雷达所在塔上的大光电 | 
|                     ArdCameras camera = ardEquipRadarMapper.getCameraByRadar(radarId); | 
|                     if (StringUtils.isNotNull(camera)) { | 
|                         log.debug("获取到雷达塔上的大光电:" + camera.getId()); | 
|                         //如果雷达塔上有光电,引导光电的1通道到追踪的坐标 | 
|                         CameraCmd cmd = new CameraCmd(camera.getId(), 1); | 
|                         cmd.setOperator("sys_radar_follow"); | 
|                         cmd.setCameraId(camera.getId()); | 
|                         cmd.setChanNo(1); | 
|                         cmd.setTargetPosition(new double[]{guidePoint.getLongitude(), guidePoint.getLatitude()}); | 
|                         boolean res = iCameraSdkService.guideTargetPosition(cmd).get("code").equals(200); | 
|                         if (res) { | 
|                             log.debug("雷达追踪引导成功"); | 
|                         } else { | 
|                             log.debug("雷达追踪引导失败"); | 
|                         } | 
|                     } else { | 
|                         log.debug("未获取到雷达塔上的大光电"); | 
|                     } | 
|                 } | 
|             } | 
|         } catch (Exception ex) { | 
|             log.error("雷达追踪引导异常:" + ex.getMessage()); | 
|         } | 
|     } | 
| } |