liusuyi
2025-11-24 2a729cd545ddbbab1eae6cbcf819783ef11da4ab
增加格式化存储卡接口
3 files added
4 files modified
125 ■■■■■ changed files
ard-admin/src/main/java/com/ard/web/controller/work/UavCameraController.java 11 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/component/netty/command/camera/FormatSdCardCmd.java 35 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/component/netty/command/camera/FormatSdCardReplyCmd.java 30 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/component/netty/handler/MessageProtocolDecoder.java 8 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/domain/dto/camera/FormatSdCardDTO.java 19 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/service/ITyService.java 5 ●●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java 17 ●●●●● patch | view | raw | blame | history
ard-admin/src/main/java/com/ard/web/controller/work/UavCameraController.java
@@ -73,6 +73,15 @@
        return AjaxResult.success();
    }
    @ApiOperation("格式化存储卡")
    @ApiOperationSupport(order = 9)
    @PostMapping("/formatSdCard")
    public AjaxResult formatSdCard(@RequestBody FormatSdCardDTO formatSdCardDTO) {
        tyService.formatSdCard(formatSdCardDTO);
        return AjaxResult.success();
    }
    @ApiOperation(value = "打开或关闭照片回传", notes = "actionParam值:0-关闭,1-打开")
    @ApiOperationSupport(order = 10)
    @PostMapping("/photoReturnToggle")
@@ -81,4 +90,6 @@
        return AjaxResult.success();
    }
}
ard-work/src/main/java/com/ard/work/component/netty/command/camera/FormatSdCardCmd.java
New file
@@ -0,0 +1,35 @@
package com.ard.work.component.netty.command.camera;
import com.ard.work.component.netty.command.BaseCmd;
import com.ard.work.domain.dto.camera.FormatSdCardDTO;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * Description: 格式化存储卡指令
 * Author: lsy
 * Date: 2025年11月24日9:31
 **/
@Data
@EqualsAndHashCode(callSuper = false)
public class FormatSdCardCmd extends BaseCmd {
    private final byte encryptFlag = 0x00;      // 加密标志
    private final byte actionCode = 0x40;       // 动作编号
    public FormatSdCardCmd(FormatSdCardDTO formatSdCardDTO) {
        setDataHeader((short) 0x7479);
        setDataLength((short) 18);
        setBoxSn(formatSdCardDTO.getBoxSn().getBytes());
        setCmdCode((byte) 0xD1);
    }
    @Override
    public void encode(ByteBuf out) {
        out.writeShort(getDataHeader());    // 写入数据头
        out.writeShort(getDataLength());    // 写入数据长度
        out.writeBytes(getBoxSn());         // 写入盒子SN
        out.writeByte(getCmdCode());        // 写入命令码
        out.writeByte(encryptFlag);         // 写入加密标志
        out.writeByte(actionCode);          // 写入动作编号
    }
}
ard-work/src/main/java/com/ard/work/component/netty/command/camera/FormatSdCardReplyCmd.java
New file
@@ -0,0 +1,30 @@
package com.ard.work.component.netty.command.camera;
import com.ard.work.component.netty.command.BaseCmd;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * Description: 格式化存储卡回复指令
 * Author: lsy
 * Date: 2025年11月24日9:31
 **/
@Data
@EqualsAndHashCode(callSuper = false)
public class FormatSdCardReplyCmd extends BaseCmd {
    private final byte result;             // 执行结果
    private final Integer errorCode;       // 错误码
    public FormatSdCardReplyCmd(String boxSn, Byte result, Integer errorCode) {
        setDataHeader((short) 0x6A77);
        setDataLength((short) 20);
        setBoxSn(boxSn.getBytes());
        setCmdCode((byte) 0xD1);
        this.result = result;
        this.errorCode = errorCode;
    }
    @Override
    public void encode(ByteBuf out) {
    }
}
ard-work/src/main/java/com/ard/work/component/netty/handler/MessageProtocolDecoder.java
@@ -1,6 +1,7 @@
package com.ard.work.component.netty.handler;// MessageProtocolDecoder.java
import com.ard.common.utils.ByteUtils;
import com.ard.work.component.netty.command.camera.*;
import com.ard.work.component.netty.command.manual.*;
import com.ard.work.component.netty.command.wayline.*;
import com.ard.work.domain.dto.converter.realdata.UavSignalInfoConverter;
@@ -10,13 +11,8 @@
import com.ard.work.domain.dto.state.UavState;
import com.ard.work.domain.dto.telemetry.TelemetryData;
import com.ard.work.component.netty.command.BaseCmd;
import com.ard.work.component.netty.command.camera.CameraModeReplyCmd;
import com.ard.work.component.netty.command.camera.CapturePicReplyCmd;
import com.ard.work.component.netty.command.camera.RecordStartReplyCmd;
import com.ard.work.component.netty.command.camera.RecordStopReplyCmd;
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.camera.PicUploadCompletedReplyCmd;
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;
@@ -190,6 +186,8 @@
                return new FlyWayEndReplyCmd(boxSn, result, errorCode);
            // Special cases
            case 0x3D:
            case 0x40:
                return new FormatSdCardReplyCmd(boxSn, result, errorCode);
            case 0x42:
                return processSpecialD1ReplyCmd(in, actionCode, boxSn);
            // Add other cases...
ard-work/src/main/java/com/ard/work/domain/dto/camera/FormatSdCardDTO.java
New file
@@ -0,0 +1,19 @@
package com.ard.work.domain.dto.camera;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
 * Description: 格式化存储卡实体对象
 * Author: lsy
 * Date: 2025年11月24日9:39
 **/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class FormatSdCardDTO {
    private String boxSn;
}
ard-work/src/main/java/com/ard/work/service/ITyService.java
@@ -112,6 +112,11 @@
    Boolean speedControl(SpeedControlDTO speedControlDto);
    /**
     * 格式化存储卡
     */
    Boolean formatSdCard(FormatSdCardDTO formatSdCardDTO);
    /**
     * 设置相机模式
     */
    Boolean updateCameraMode(CameraModeDTO cameraModeDTO);
ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java
@@ -287,6 +287,18 @@
        return true;
    }
    @Override
    public Boolean formatSdCard(FormatSdCardDTO formatSdCardDTO) {
        String boxSn = formatSdCardDTO.getBoxSn();
        ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn);
        if (ardDroneInfo == null) {
            throw new ControlException("未找到对应的飞行器信息,boxSn:{}" + boxSn);
        }
        FormatSdCardCmd formatSdCardCmd = new FormatSdCardCmd(formatSdCardDTO);
        this.sendMessage(ardDroneInfo.getServerId(), formatSdCardCmd);
        return true;
    }
    /**
     * 设置相机模式
     */
@@ -934,6 +946,11 @@
                    FlyWayEndReplyCmd flyWayEndReplyCmd = (FlyWayEndReplyCmd) tyCommand;
                    logPrint("无人机飞行结束", flyWayEndReplyCmd.getResult(), flyWayEndReplyCmd.getErrorCode());
                }
                //格式化存储卡
                if (tyCommand instanceof FormatSdCardReplyCmd) {
                    FormatSdCardReplyCmd formatSdCardReplyCmd = (FormatSdCardReplyCmd) tyCommand;
                    logPrint("格式化存储卡", formatSdCardReplyCmd.getResult(), formatSdCardReplyCmd.getErrorCode());
                }
                if (tyCommand instanceof CapturePicReplyCmd) {
                    CapturePicReplyCmd capturePicReplyCommand = (CapturePicReplyCmd) tyCommand;
                    logPrint("无人机拍照", capturePicReplyCommand.getResult(), capturePicReplyCommand.getErrorCode());