feat(drone-dock): 接入图传与重召唤的本地模拟流程
新增 live 接口、状态展示和本地视频预览;支持同任务重新召唤、单次回查和防重,保留禁飞拦截。同步测试、模拟证据、后端接口确认文档及景区空境库范围约定。 验证:168 个相关用例最终均通过;最后复跑 38 项零失败。真实设备指令未发送。
This commit is contained in:
@@ -7,9 +7,16 @@ protocol DroneDockShootServing: Sendable {
|
||||
func shoot(taskID: Int) async throws -> DroneDockShootResponse
|
||||
}
|
||||
|
||||
/// 为已有失败任务提交重新召唤,不创建新任务或更换锁定飞机。
|
||||
protocol DroneDockResummonServing: Sendable {
|
||||
/// 发送一次 restart=true 的召唤请求,调用方负责防重及受理后的状态核对。
|
||||
@MainActor
|
||||
func resummon(taskID: Int) async throws -> DroneDockShootResponse
|
||||
}
|
||||
|
||||
/// 朱工 shoot 接口适配,业务成功仅表示接口受理结果,不推断飞机已经到达。
|
||||
@MainActor
|
||||
final class DroneDockShootAPI: DroneDockShootServing {
|
||||
final class DroneDockShootAPI: DroneDockShootServing, DroneDockResummonServing {
|
||||
private let client: APIClient
|
||||
|
||||
/// 注入统一网络客户端,沿用登录凭证、HTTP 与业务码处理。
|
||||
@@ -17,13 +24,22 @@ final class DroneDockShootAPI: DroneDockShootServing {
|
||||
|
||||
/// 仅发送一次召唤 POST;不创建任务、不重试、不修改任务已选航线。
|
||||
func shoot(taskID: Int) async throws -> DroneDockShootResponse {
|
||||
try await send(taskID: taskID, restart: false)
|
||||
}
|
||||
|
||||
/// 复用同一订单飞行任务请求重启;当前仅由隔离模拟入口注入,真实传输仍受禁飞保护。
|
||||
func resummon(taskID: Int) async throws -> DroneDockShootResponse {
|
||||
try await send(taskID: taskID, restart: true)
|
||||
}
|
||||
|
||||
private func send(taskID: Int, restart: Bool) async throws -> DroneDockShootResponse {
|
||||
try Task.checkCancellation()
|
||||
guard taskID > 0 else { throw APIError.networkFailed("缺少有效拍摄任务 ID,请先创建任务") }
|
||||
do {
|
||||
return try await client.send(APIRequest(
|
||||
method: .post,
|
||||
path: "/api/app/airport/shoot",
|
||||
body: ShootBody(taskID: taskID)
|
||||
body: ShootBody(taskID: taskID, restart: restart)
|
||||
))
|
||||
} catch APIError.emptyData {
|
||||
// 统一客户端仅在 HTTP 和业务码均成功后抛 emptyData;此接口尚未约定成功 data 结构。
|
||||
@@ -31,10 +47,10 @@ final class DroneDockShootAPI: DroneDockShootServing {
|
||||
}
|
||||
}
|
||||
|
||||
/// 本轮联调仅发送任务身份和非重启标记,完全省略 plane_id 与航线覆盖字段。
|
||||
/// 仅发送任务身份和重启标记,完全省略 plane_id 与航线覆盖字段。
|
||||
private struct ShootBody: Encodable {
|
||||
let taskID: Int
|
||||
let restart = false
|
||||
let restart: Bool
|
||||
|
||||
/// 朱工已建任务召唤参数映射。
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
|
||||
Reference in New Issue
Block a user