feat: 完善机巢图传、拍摄阶段与任务交互

- 完善双路 RTC 接收、首帧切换及拍摄结束后的本地播放释放
- 对齐无人机状态枚举与正常拍完返航标记,新增到达后本地倒计时
- 补充准备页电量与前往回执,进入任务时移除准备页路由
- 对齐拍摄中和拍摄完成原型布局,移除详情按钮
- 补充隔离测试、接口记录与项目约定

验证:最近 157 项相关模拟器隔离测试通过,Release 无签名编译通过;未调用真实飞控或图传。
This commit is contained in:
2026-11-03 16:43:23 +08:00
parent 0ed0077ec4
commit 54210925f0
33 changed files with 3242 additions and 205 deletions
@@ -70,13 +70,13 @@ struct DroneDockHomeAirport: Decodable, Equatable, Sendable {
let snNumber: String?
/// 后端设备所属景区 ID。
let scenicAreaID: Int?
/// 原始在线状态;尚未取得完整枚举约定。
/// 飞机表在线标记:1 在线,其他已提供整数为离线;忙闲以 workStatus 为准。
let onlineStatus: Int?
/// 原始工作状态;不据此决定设备可否执行任务。
let workStatus: Int?
/// 后端工作状态展示文案。
let workStatusLabel: String?
/// 原始接单配置;不等同于本次起飞许可。
/// 接单配置:1 可接单、2 暂停接单;不等同于本次起飞许可。
let isReceiveOrder: Int?
/// 任务类型原始值;当前样本为 null,暂不假定其枚举或值类型。
let taskType: DroneDockHomeJSONValue?
@@ -1,6 +1,6 @@
import Foundation
/// shoot 业务成功后的原始 data 回执,不假设或构造飞机、任务及飞行阶段字段。
/// 保留 shoot 原始 data,并读取明确的同任务前往回执;不补造飞机或飞行阶段字段。
struct DroneDockShootResponse: Decodable, Equatable, Sendable {
/// 完整 data JSON;nil 表示统一客户端未提供 data,不补造 null 或空对象。
let dataJSON: String?
@@ -15,6 +15,30 @@ struct DroneDockShootResponse: Decodable, Equatable, Sendable {
encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes]
dataJSON = String(decoding: try encoder.encode(DroneDockShootJSONSnapshot(value: raw)), as: UTF8.self)
}
/// 只认同一订单任务明确受理的前往阶段,用于进页过渡;回执不代表已经起飞或到达。
func confirmsTravel(taskID: Int, orderNumber: String?, scenicID: Int) -> Bool {
guard taskID > 0, scenicID > 0, let orderNumber, !orderNumber.isEmpty, let dataJSON,
let receipt = try? JSONDecoder().decode(DroneDockSummonProgressReceipt.self, from: Data(dataJSON.utf8)),
receipt.accepted == true, receipt.ui?.phase == "going_to_spot",
receipt.orderFlightTask?.id == taskID,
receipt.orderFlightTask?.orderNumber == orderNumber,
receipt.orderFlightTask?.scenicID == scenicID else { return false }
return receipt.orderFlightTaskID == nil || receipt.orderFlightTaskID == taskID
}
}
/// 首次召唤的已约定阶段和任务身份,仅支持显示前往中的过渡,不据此开放任何操作。
private struct DroneDockSummonProgressReceipt: Decodable {
let accepted: Bool?
let ui: DroneDockShootingUI?
let orderFlightTaskID: Int?
let orderFlightTask: DroneDockResummonReceiptIdentity.TaskIdentity?
/// 顶层 task_id 是航线任务,不参与订单任务匹配。
private enum CodingKeys: String, CodingKey {
case accepted, ui, orderFlightTaskID = "order_flight_task_id", orderFlightTask = "order_flight_task"
}
}
/// 重新召唤回执中可核对的订单任务身份;顶层 task_id 属于实际航线任务,不作订单任务 ID 使用。
@@ -16,6 +16,8 @@ struct DroneDockShootingResponse: Decodable, Equatable, Sendable {
let metricsUpdatedAt: String?
/// 设备缓存过期时保留数值,但标为非实时读数。
let metricsStale: Bool?
/// 后端确认本批次正常拍完并开始返航;缺失表示旧合同,不能从工作态忙闲推断。
let shootCompleteReturning: Bool?
/// 后端若明确提供订单号则保留,不由请求上下文伪造响应身份。
let orderNumber: String?
/// 实测返回的订单飞行任务身份;存在时必须与请求上下文核对。
@@ -48,6 +50,7 @@ struct DroneDockShootingResponse: Decodable, Equatable, Sendable {
case orderFlightTaskID = "order_flight_task_id", stateVersion = "state_version"
case executionBatch = "execution_batch", snapshotKind = "snapshot_kind"
case stateUpdatedAt = "state_updated_at", metricsUpdatedAt = "metrics_updated_at", metricsStale = "metrics_stale"
case shootCompleteReturning = "shoot_complete_returning"
case orderNumber = "order_number", orderFlightTask = "order_flight_task", task
case scenic, scenicSpot = "scenic_spot", airLine = "air_line"
case header, currentPlane = "current_plane", executeGate = "execute_gate", ui
@@ -64,6 +67,7 @@ struct DroneDockShootingResponse: Decodable, Equatable, Sendable {
stateUpdatedAt = try container.decodeIfPresent(String.self, forKey: .stateUpdatedAt)
metricsUpdatedAt = try container.decodeIfPresent(String.self, forKey: .metricsUpdatedAt)
metricsStale = try container.decodeIfPresent(Bool.self, forKey: .metricsStale)
shootCompleteReturning = try container.decodeIfPresent(Bool.self, forKey: .shootCompleteReturning)
orderNumber = try container.decodeIfPresent(String.self, forKey: .orderNumber)
orderFlightTask = try container.decodeIfPresent(DroneDockShootingTaskIdentity.self, forKey: .orderFlightTask)
task = try container.decodeIfPresent(DroneDockShootingTaskIdentity.self, forKey: .task)
@@ -91,22 +95,25 @@ struct DroneDockShootingTaskIdentity: Decodable, Equatable, Sendable {
let orderNumber: String?
/// 任务所属景区。
let scenicID: Int?
/// 后端原始任务状态,不与订单状态混用。
/// 订单飞行任务状态:10 待执行、20 执行中、30 成功、40 失败、50 取消、60 待确认。
let status: Int?
/// 服务端任务状态文案。
let statusLabel: String?
/// 实测航线任务状态,与订单飞行任务状态分别保留。
/// 航线状态独立保留:29/39/49/91 失败,90 取消,24/30/40 为录制后的素材处理。
let waylineStatus: Int?
/// 服务端航线状态文案;执行失败优先于笼统的订单任务执行中。
let waylineStatusLabel: String?
/// 服务端实际记录的任务结果原因,空值不视为具体失败说明。
let resultMessage: String?
/// 任务结果原因码;return_home 表示手动返航中断,不能展示正常拍完提示。
let resultCode: String?
/// 已确认嵌套任务字段映射。
private enum CodingKeys: String, CodingKey {
case id, orderNumber = "order_number", scenicID = "scenic_id", status, statusLabel = "status_label"
case waylineStatus = "wayline_status", waylineStatusLabel = "wayline_status_label"
case resultMessage = "result_message"
case resultCode = "result_code"
}
}
@@ -169,7 +176,7 @@ struct DroneDockShootingPlane: Decodable, Equatable, Sendable {
let id: Int?
/// 当前设备序列号。
let snNumber: String?
/// 服务端连接状态;实测 2 为离线,不从电量推导连接状态。
/// 飞机表在线标记:1 在线,0/2 等非 1 为离线;不覆盖明确的机巢工作态。
let onlineStatus: Int?
/// 文档工作状态:0 离线、1 空闲、2 拍摄中;不据此推断返航完成。
let workStatus: Int?
@@ -213,15 +220,28 @@ struct DroneDockShootingUI: Decodable, Equatable, Sendable {
let title: String?
/// 服务端阶段说明,不由 GET 请求成功拼造飞行进度。
let message: String?
/// 拍摄环节子阶段,shoot_done_returning 表示正常拍完后开始返航。
let waylineStage: String?
/// 页面层的正常拍完返航标记,和顶层字段共同保留。
let shootCompleteReturning: Bool?
/// 服务端实际提供的安全指令;缺失时保持未知,不据阶段文案自行补齐。
let commands: [DroneDockShootingCommand]?
/// 保留既有展示构造方式,新增动作列表默认为未知。
init(phase: String?, title: String?, message: String?, commands: [DroneDockShootingCommand]? = nil) {
init(phase: String?, title: String?, message: String?, commands: [DroneDockShootingCommand]? = nil,
waylineStage: String? = nil, shootCompleteReturning: Bool? = nil) {
self.phase = phase
self.title = title
self.message = message
self.commands = commands
self.waylineStage = waylineStage
self.shootCompleteReturning = shootCompleteReturning
}
/// 保留现有页面字段,并映射新增返航标记的原始命名。
private enum CodingKeys: String, CodingKey {
case phase, title, message, commands
case waylineStage = "wayline_stage", shootCompleteReturning = "shoot_complete_returning"
}
}
@@ -12,6 +12,8 @@ enum DroneDockTaskDisplayPhase: String, Equatable, Sendable {
case shooting
/// 录制已结束,素材仍在下载、上传或渲染,尚未就绪。
case postShootUploading
/// 录制已结束,但素材上传或渲染失败;可查看素材,不代表可重新召唤。
case postShootUploadFailed
/// 服务端明确已暂停。
case paused
/// 服务端明确正在返航。
@@ -62,10 +64,13 @@ struct DroneDockTaskPresentation: Equatable, Sendable {
let isActionEnabled: Bool
/// 主动作下方的真实设备限制说明,未提供时不展示。
let actionNote: String?
/// 已到达阶段的本地展示倒计时;零秒不表示后端已经开始拍摄。
let countdownSeconds: Int?
/// 创建状态展示;动作提示默认为空,既有非失败状态保持原布局。
init(phase: DroneDockTaskDisplayPhase, title: String, message: String, deviceStatus: String,
action: DroneDockTaskDisplayAction, actionTitle: String?, isActionEnabled: Bool, actionNote: String? = nil) {
action: DroneDockTaskDisplayAction, actionTitle: String?, isActionEnabled: Bool, actionNote: String? = nil,
countdownSeconds: Int? = nil) {
self.phase = phase
self.title = title
self.message = message
@@ -74,5 +79,6 @@ struct DroneDockTaskPresentation: Equatable, Sendable {
self.actionTitle = actionTitle
self.isActionEnabled = isActionEnabled
self.actionNote = actionNote
self.countdownSeconds = countdownSeconds
}
}