liusuyi
2025-12-18 073239cedaab68465e109b1957144f5fca17958d
ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java
@@ -14,7 +14,7 @@
import com.ard.work.component.netty.command.control.SpeedControlCmd;
import com.ard.work.component.netty.command.manual.*;
import com.ard.work.component.netty.command.notice.BoxPowerStatusReplyCmd;
import com.ard.work.component.netty.command.notice.FlyWayEndReplyCmd;
import com.ard.work.component.netty.command.notice.WayLineFinishedReplyCmd;
import com.ard.work.component.netty.command.notice.UavReadyReplyCmd;
import com.ard.work.component.netty.command.real.SignalInfoCmd;
import com.ard.work.component.netty.command.real.UavStateCmd;
@@ -26,6 +26,7 @@
import com.ard.work.component.netty.handler.ErrorCodeEnum;
import com.ard.work.component.netty.protobuf.TelemetryDataPB;
import com.ard.work.component.websocket.utils.WebSocketUtil;
import com.ard.work.config.RouteStateMachineService;
import com.ard.work.domain.cache.UavSignalInfoCache;
import com.ard.work.domain.cache.UavStateCache;
import com.ard.work.domain.cache.UavTelemetryDataCache;
@@ -48,6 +49,7 @@
import com.ard.work.domain.dto.wayline.*;
import com.ard.work.domain.entity.ArdDroneInfo;
import com.ard.work.domain.entity.ArdServerInfo;
import com.ard.work.domain.enums.RouteEvent;
import com.ard.work.domain.message.ServerReplyMessage;
import com.ard.work.domain.message.UavControlType;
import com.ard.work.domain.receiver.*;
@@ -55,6 +57,7 @@
import com.ard.work.service.IArdServerInfoService;
import com.ard.work.service.ITyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -77,6 +80,8 @@
    private IArdDroneInfoService ardDroneService;
    @Resource
    private TyClient tyClient;
    @Autowired
    private RouteStateMachineService stateMachineService;
    /**
     * 获取边缘服务器token信息
@@ -123,8 +128,8 @@
        if (ardDroneInfo == null) {
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        TyHttpCommonReceiver<BoxStreamUrlReceiver> boxLiveUrl = tyClient.getBoxLiveUrl(ardDroneInfo.getServerId(),
                boxSn);
        return boxLiveUrl == null ? null : boxLiveUrl.getContent();
@@ -175,7 +180,7 @@
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        TyHttpCommonReceiver<?> result = tyClient.updateBoxSettings(ardDroneInfo.getServerId(), boxSettingsDTO);
        return result.getState() == 1;
        return result.getState() == 0;
    }
    /**
@@ -554,7 +559,7 @@
     * 方向控制
     */
    @CheckControlRight(UavControlType.FLY)
    @CheckTakeoffAltitude(minAltitude = 30.0)
    @CheckTakeoffAltitude
    @Override
    public Boolean flyControl(FlyControlDTO flyControlDTO) {
        String boxSn = flyControlDTO.getBoxSn();
@@ -571,7 +576,7 @@
     * 指点飞行控制
     */
    @CheckControlRight(UavControlType.FLY)
    @CheckTakeoffAltitude(minAltitude = 30.0)
    @CheckTakeoffAltitude
    @CheckNoFlyZone
    @Override
    public Boolean flyPointControl(FlyPointControlDTO flyPointControlDTO) {
@@ -596,8 +601,8 @@
        if (ardDroneInfo == null) {
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        FlyPointControlCancelCmd flyPointControlCancelCmd = new FlyPointControlCancelCmd(flyPointControlCancelDTO);
        this.sendMessage(ardDroneInfo.getServerId(), flyPointControlCancelCmd);
        return true;
@@ -614,8 +619,8 @@
        if (ardDroneInfo == null) {
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        FlyRoundControlCmd flyPointControlCmd = new FlyRoundControlCmd(flyRoundControlDTO);
        this.sendMessage(ardDroneInfo.getServerId(), flyPointControlCmd);
        FlyRoundControlCmd flyRoundControlCmd = new FlyRoundControlCmd(flyRoundControlDTO);
        this.sendMessage(ardDroneInfo.getServerId(), flyRoundControlCmd);
        return true;
    }
@@ -645,8 +650,8 @@
        if (ardDroneInfo == null) {
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        EmergencyBrakeCmd emergencyBrakeCmd = new EmergencyBrakeCmd(emeragencyBrakeDTO);
        this.sendMessage(ardDroneInfo.getServerId(), emergencyBrakeCmd);
        return true;
@@ -974,10 +979,6 @@
                    CameraModeReplyCmd cameraModeReplyCommand = (CameraModeReplyCmd) tyCommand;
                    logPrint("无人机设置相机模式", cameraModeReplyCommand.getResult(), cameraModeReplyCommand.getErrorCode());
                }
                if (tyCommand instanceof FlyWayEndReplyCmd) {
                    FlyWayEndReplyCmd flyWayEndReplyCmd = (FlyWayEndReplyCmd) tyCommand;
                    logPrint("无人机飞行结束", flyWayEndReplyCmd.getResult(), flyWayEndReplyCmd.getErrorCode());
                }
                //格式化存储卡
                if (tyCommand instanceof FormatSdCardReplyCmd) {
                    FormatSdCardReplyCmd formatSdCardReplyCmd = (FormatSdCardReplyCmd) tyCommand;
@@ -1043,23 +1044,53 @@
                }
                //开始航线回复
                if (tyCommand instanceof WayLineBeginReplyCmd) {
                    WayLineBeginReplyCmd wayLineBeginReplyCmd = (WayLineBeginReplyCmd) tyCommand;
                    logPrint("开始航线", wayLineBeginReplyCmd.getResult(), wayLineBeginReplyCmd.getErrorCode());
                    if (wayLineBeginReplyCmd.getResult() == 0) {
                        byte[] boxSnBytes = tyCommand.getBoxSn();
                        String boxSn = new String(boxSnBytes);
                        stateMachineService.sendEvent(boxSn, RouteEvent.START_SUCCESS);
                    }
                }
                //暂停航线回复
                if (tyCommand instanceof WayLinePauseReplyCmd) {
                    WayLinePauseReplyCmd wayLinePauseReplyCmd = (WayLinePauseReplyCmd) tyCommand;
                    logPrint("暂停航线", wayLinePauseReplyCmd.getResult(), wayLinePauseReplyCmd.getErrorCode());
                    if (wayLinePauseReplyCmd.getResult() == 0) {
                        byte[] boxSnBytes = tyCommand.getBoxSn();
                        String boxSn = new String(boxSnBytes);
                        stateMachineService.sendEvent(boxSn, RouteEvent.PAUSE_SUCCESS);
                    }
                }
                //恢复航线回复
                if (tyCommand instanceof WayLineResumeReplyCmd) {
                    WayLineResumeReplyCmd wayLineResumeReplyCmd = (WayLineResumeReplyCmd) tyCommand;
                    logPrint("恢复航线", wayLineResumeReplyCmd.getResult(), wayLineResumeReplyCmd.getErrorCode());
                    if (wayLineResumeReplyCmd.getResult() == 0) {
                        byte[] boxSnBytes = tyCommand.getBoxSn();
                        String boxSn = new String(boxSnBytes);
                        stateMachineService.sendEvent(boxSn, RouteEvent.RESUME_SUCCESS);
                    }
                }
                //结束航线回复
                if (tyCommand instanceof WayLineEndReplyCmd) {
                    WayLineEndReplyCmd wayLineEndReplyCmd = (WayLineEndReplyCmd) tyCommand;
                    logPrint("结束航线", wayLineEndReplyCmd.getResult(), wayLineEndReplyCmd.getErrorCode());
                    if (wayLineEndReplyCmd.getResult() == 0) {
                        byte[] boxSnBytes = tyCommand.getBoxSn();
                        String boxSn = new String(boxSnBytes);
                        stateMachineService.sendEvent(boxSn, RouteEvent.STOP_SUCCESS);
                    }
                }
                if (tyCommand instanceof WayLineFinishedReplyCmd) {
                    WayLineFinishedReplyCmd wayLineFinishedReplyCmd = (WayLineFinishedReplyCmd) tyCommand;
                    logPrint("航线执行完成", wayLineFinishedReplyCmd.getResult(), wayLineFinishedReplyCmd.getErrorCode());
                    if (wayLineFinishedReplyCmd.getResult() == 0) {
                        byte[] boxSnBytes = tyCommand.getBoxSn();
                        String boxSn = new String(boxSnBytes);
                        stateMachineService.sendEvent(boxSn, RouteEvent.RESET_ROUTE);
                    }
                }
                //设置返航高度回复
                if (tyCommand instanceof ReturnHeightSettingReplyCmd) {