Xiajijian
2026-05-27 402fe914957546a820c60731181501c554826fa4
ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java
@@ -1,6 +1,7 @@
package com.ard.work.service.impl;
import com.ard.common.exception.ControlException;
import com.ard.vtdu.config.MediamtxConfig;
import com.ard.work.aspect.annotation.CheckControlRight;
import com.ard.work.aspect.annotation.CheckDroneStatus;
import com.ard.work.aspect.annotation.CheckNoFlyZone;
@@ -33,6 +34,7 @@
import com.ard.work.domain.dto.BoxHistoryDTO;
import com.ard.work.domain.dto.BoxPhotosDTO;
import com.ard.work.domain.dto.BoxSettingsDTO;
import com.ard.work.domain.dto.BoxVideosDTO;
import com.ard.work.domain.dto.camera.*;
import com.ard.work.domain.dto.control.AbsAngleControlDTO;
import com.ard.work.domain.dto.control.AngleControlDTO;
@@ -44,6 +46,7 @@
import com.ard.work.domain.dto.settings.VideoStreamSettingDTO;
import com.ard.work.domain.dto.signal.SignalInfo;
import com.ard.work.domain.dto.speaker.*;
import com.ard.work.domain.dto.state.PointData;
import com.ard.work.domain.dto.state.UavState;
import com.ard.work.domain.dto.telemetry.TelemetryData;
import com.ard.work.domain.dto.wayline.*;
@@ -84,9 +87,10 @@
    private TyClient tyClient;
    @Autowired
    private RouteStateMachineService stateMachineService;
    @Autowired
    private IArdFlightTaskPartService ardFlightTaskPartService;
    @Resource
    private UavPositionChangeService uavPositionChangeService;
    @Resource
    private UavRegionDetectService uavRegionDetectService;
    /**
     * 获取边缘服务器token信息
     *
@@ -157,7 +161,7 @@
    }
    /**
     * 获取盒子图片
     * 获取任务图片
     *
     * @return List<BoxPhotosReceiver>
     */
@@ -172,7 +176,22 @@
                boxPhotosDTO);
        return boxPhotos == null ? null : boxPhotos.getContent();
    }
    /**
     * 获取任务视频
     *
     * @return List<BoxVideosReceiver>
     */
    @Override
    public List<BoxVideosReceiver> getBoxVideos(BoxVideosDTO boxVideosDTO) {
        String boxSn = boxVideosDTO.getBoxSn();
        ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn);
        if (ardDroneInfo == null) {
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        TyHttpCommonReceiver<List<BoxVideosReceiver>> boxVideos = tyClient.getBoxVideos(ardDroneInfo.getServerId(),
                boxVideosDTO);
        return boxVideos == null ? null : boxVideos.getContent();
    }
    /**
     * 修改云盒设置
     */
@@ -336,9 +355,10 @@
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        //设置相机模式为拍照模式
        updateCameraMode(CameraModeDTO.builder().boxSn(capturePicDto.getBoxSn()).actionParam((byte) 0x01).build());
        //updateCameraMode(CameraModeDTO.builder().boxSn(capturePicDto.getBoxSn()).actionParam((byte) 0x01).build());
        //设置拍照回传
        photoReturnToggle(PhotoReturnToggleDTO.builder().boxSn(capturePicDto.getBoxSn()).actionParam((byte) 0x01).build());
        //photoReturnToggle(PhotoReturnToggleDTO.builder().boxSn(capturePicDto.getBoxSn()).actionParam((byte) 0x01)
        // .build());
        CapturePicCmd capturePicCommand = new CapturePicCmd(capturePicDto);
        this.sendMessage(ardDroneInfo.getServerId(), capturePicCommand);
@@ -358,7 +378,7 @@
        }
        BaseCmd baseCmd;
        if (recordDto.getIsRecord()) {
            updateCameraMode(CameraModeDTO.builder().boxSn(recordDto.getBoxSn()).actionParam((byte) 0x02).build());
            //updateCameraMode(CameraModeDTO.builder().boxSn(recordDto.getBoxSn()).actionParam((byte) 0x02).build());
            baseCmd = new RecordStartCmd(recordDto);
        } else {
            baseCmd = new RecordStopCmd(recordDto);
@@ -589,6 +609,10 @@
        if (ardDroneInfo == null) {
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        //打点之前先停止打点
        FlyPointControlCancelCmd flyPointControlCancelCmd = new FlyPointControlCancelCmd(FlyPointControlCancelDTO.builder().boxSn(boxSn).build());
        this.sendMessage(ardDroneInfo.getServerId(), flyPointControlCancelCmd);
        FlyPointControlCmd flyPointControlCmd = new FlyPointControlCmd(flyPointControlDTO);
        this.sendMessage(ardDroneInfo.getServerId(), flyPointControlCmd);
        return true;
@@ -616,6 +640,9 @@
    /**
     * 环绕飞行控制
     */
//    @CheckControlRight(UavControlType.FLY)
//    @CheckTakeoffAltitude
//    @CheckNoFlyZone
    @Override
    public Boolean FlyRoundControl(FlyRoundControlDTO flyRoundControlDTO) {
        String boxSn = flyRoundControlDTO.getBoxSn();
@@ -801,13 +828,33 @@
        if (ardDroneInfo == null) {
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        if ("3".equals(wayLineUploadDTO.getWayLineData().getRouteType())){
            CreateWayLineUploadDTO(wayLineUploadDTO);
        }
        //wayLineUploadDTO.setWayLineData(this.CreatePlanLineData());//设置航线数据
        System.out.println("wayLineUploadDTO:-----------------" + wayLineUploadDTO);
        log.info("打印数据 ++++ wayLineUploadDTO:-----------------" + wayLineUploadDTO);
        log.info("打印航线上传数据 ++++++++ wayLineUploadDTO:~~~~~~~~~~~~~~~" + wayLineUploadDTO);
        WayLineUploadCmd wayLineUploadCmd = new WayLineUploadCmd(wayLineUploadDTO);
        System.out.println("wayLineUploadCmd:-----------------" + wayLineUploadCmd);
        this.sendMessage(ardDroneInfo.getServerId(), wayLineUploadCmd);
        return true;
    }
    /**
     * 根据航线类型重新加工每个行点的高度
     * 如果行点类型是精细化巡检
     */
    private void CreateWayLineUploadDTO(WayLineUploadDTO wayLineUploadDTO) {
        // 先获取遥测数据
        String boxSn = wayLineUploadDTO.getBoxSn();
        TelemetryData telemetryData = getUavTelemetryData(boxSn);
        if (telemetryData == null) {
            throw new ControlException("获取遥测数据失败, boxSn:{}" + boxSn);
        }
        float altitude = telemetryData.getAltitude();
        for (PointData interest : wayLineUploadDTO.getWayLineData().getInterests()) {
            interest.setHeight(interest.getHeight() - altitude);
        }
    }
    //创建航线
@@ -957,6 +1004,16 @@
                // 处理无人机遥测消息
                UavTelemetryDataCmd uavTelemetryDataCmd = (UavTelemetryDataCmd) tyCommand;
                TelemetryData telemetryData = uavTelemetryDataCmd.getTelemetryData();
                // 判断是否需要触发区域检测
                if (uavPositionChangeService.shouldTriggerRegionCheck(telemetryData)) {
                    log.debug("无人机 {} 位置变化,触发区域检测", telemetryData.getBoxSn());
                    // 异步触发区域检测(不阻塞)
                    uavRegionDetectService.detectRegionAsync(telemetryData);
                } else {
                    log.debug("无人机 {} 位置未变化,跳过区域检测", telemetryData.getBoxSn());
                }
                UavTelemetryDataCache.put(telemetryData);
                //logPrint("无人机遥测", uavTelemetryDataCmd.getTelemetryData().getBoxSn());
                //WebSocketUtil.sendMessageAll(uavTelemetryDataCmd.getTelemetryData());
@@ -1146,6 +1203,30 @@
    }
    /**
     * 开启爆闪灯
     */
    @Override
    public Boolean turnOnLight() {
        return null;
    }
    /**
     * 关闭爆闪灯
     */
    @Override
    public Boolean turnOffLight() {
        return null;
    }
    /**
     * 亮度调节
     */
    @Override
    public Boolean adjustBrightness() {
        return null;
    }
    /**
     * 根据[服务器id]查询无人机盒子列表
     */
    private List<ArdDroneInfo> getDroneLs(String serverId) {