liusuyi
2024-06-25 7556c19ef999f51d07d85cb5d13eba27d9efa41e
ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java
@@ -16,6 +16,7 @@
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.camera.service.IArdCamerasService;
import com.ruoyi.device.camera.service.ICameraSdkService;
import com.ruoyi.device.channel.domain.ArdChannel;
import com.ruoyi.device.channel.service.IArdChannelService;
import com.ruoyi.media.domain.Vtdu;
@@ -74,6 +75,9 @@
    private IArdChannelService ardChannelService;
    @Resource
    private IVtduService vtduService;
    @Resource
    ICameraSdkService cameraSdkService;
    @Value("${minio.endpoint}")
    private String minioEndPoint;
    @Resource
@@ -407,9 +411,9 @@
        float t = (float) dh_ptz_location_info.nPTZTilt / 10 * -1;
        String nPTZTilt = df.format(t < 0 ? t + 360 : t);
        String nPTZZoom = df.format((float) dh_ptz_location_info.nPTZZoom);
        ptzMap.put("p", nPTZPan);
        ptzMap.put("t", nPTZTilt);
        ptzMap.put("z", nPTZZoom);
        ptzMap.put("p" , nPTZPan);
        ptzMap.put("t" , nPTZTilt);
        ptzMap.put("z" , nPTZZoom);
        return AjaxResult.success(ptzMap);
    }
@@ -557,6 +561,7 @@
    @Override
    public AjaxResult localRecordStart(CameraCmd cmd) {
        try {
            String operator = cmd.getOperator();
            String cameraId = cmd.getCameraId();
            Integer chanNo = cmd.getChanNo();
@@ -573,7 +578,7 @@
            // 本地临时录像地址
            String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX;
            String path = FileUtils.createFile(tempPath + "/" + cameraId + ".mp4");
            String path = FileUtils.createFile(tempPath + "/" + operator + "/" + cameraId + ".mp4");
            LLong lRealHandle = RealPlayModule.startRealPlay(loginId, chanNo - 1, path);
            if (lRealHandle.longValue() <= 0) {
                log.error("取流失败" + getErrorCodePrint());
@@ -586,7 +591,7 @@
            //    return false;
            //}
            log.debug("本地录像开始");
            return AjaxResult.success("本地录像开始", lRealHandle);
            return AjaxResult.success("本地录像开始" , lRealHandle);
        } catch (Exception ex) {
            log.error("本地录像开始异常" + ex.getMessage());
            return AjaxResult.error("本地录像开始异常" + ex.getMessage());
@@ -597,6 +602,7 @@
    @Override
    public AjaxResult localRecordStop(CameraCmd cmd) {
        try {
            String operator = cmd.getOperator();
            String cameraId = cmd.getCameraId();
            LLong lRealHandle = new LLong(cmd.getRecordId());
            if (!GlobalVariable.loginMap.containsKey(cameraId)) {
@@ -606,7 +612,7 @@
            log.debug("本地录像停止");
            // 本地临时录像地址
            String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX;
            String recordPath = FileUtils.createFile(tempPath + "/" + cameraId + ".mp4");
            String recordPath = FileUtils.createFile(tempPath + "/" + operator + "/" + cameraId + ".mp4");
            byte[] imageBytes = Files.readAllBytes(Paths.get(recordPath));
            return AjaxResult.success(imageBytes);
        } catch (Exception ex) {
@@ -779,15 +785,18 @@
            double[] cameraPositon = new double[]{cameras.getLongitude(), cameras.getLatitude(), cameras.getAltitude()};
            double[] targetPositions = cmd.getTargetPosition();
            double[] cameraPTZ = GisUtil.getCameraPTZ(cameraPositon, targetPositions, 20, 150);
            //修正俯仰
            double correctPitch = cameraSdkService.correctPitch(cmd);
            double newt = cameraPTZ[1] + correctPitch;
            int p = (int) (cameraPTZ[0] * 10);
            int t = (int) (cameraPTZ[1] * 10);
            int t = (int) (newt * 10);
            int z = (int) (cameraPTZ[2]);
            boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0);
            if (!bool) {
                log.error("设置ptz失败:" + getErrorCodePrint());
                return AjaxResult.warn("设置ptz失败:" + getErrorCodePrint());
            }
            return AjaxResult.success("引导目标位置成功");
            return AjaxResult.success("引导目标位置成功",correctPitch);
        } catch (Exception ex) {
            log.error("引导目标位置异常:" + ex.getMessage());
            return AjaxResult.error("引导目标位置异常:" + ex.getMessage());
@@ -1101,10 +1110,10 @@
                int nHeight = cfg_encode_info.stuMainStream[0].stuVideoFormat.nHeight;
                String resolution = nWidth + "*" + nHeight;
                float nFrameRate = cfg_encode_info.stuMainStream[0].stuVideoFormat.nFrameRate;
                map.put("resolution", resolution);//分辨率
                map.put("videoBitrate", String.valueOf(nBitRate));//比特率
                map.put("videoEncType", videoEncType);//编码
                map.put("nFrameRate", String.valueOf(nFrameRate));//帧率
                map.put("resolution" , resolution);//分辨率
                map.put("videoBitrate" , String.valueOf(nBitRate));//比特率
                map.put("videoEncType" , videoEncType);//编码
                map.put("nFrameRate" , String.valueOf(nFrameRate));//帧率
            }
        } catch (Exception ex) {
            log.error("取码流压缩参数异常:" + ex.getMessage());
@@ -1131,8 +1140,8 @@
            float nAngelH = (float) dh_out_ptz_view_range_status.nAngelH / 10;
            float nAngelV = (float) dh_out_ptz_view_range_status.nAngelV / 10;
            Map<String, Object> map = getPtz(cmd);//获取ptz
            map.put("fHorFieldAngle", nAngelH);// 水平视场角
            map.put("fVerFieldAngle", nAngelV);// 垂直视场角
            map.put("fHorFieldAngle" , nAngelH);// 水平视场角
            map.put("fVerFieldAngle" , nAngelV);// 垂直视场角
            return AjaxResult.success(map);
        } catch (Exception ex) {
            log.error("获取云台可视域异常" + ex.getMessage());