开放 Release 真实操作并保留 Debug 拦截;恢复前台 shooting 串行轮询;统一打印机巢请求与完整原值响应;优化长点位名称、未拍摄文案、报备失败及已结束任务提示,移除成功回执 UI。补充相关测试、离线策略检查和联调说明。
41 lines
1.9 KiB
Swift
41 lines
1.9 KiB
Swift
import Foundation
|
|
|
|
/// 基于既有订单飞行任务发送单次安全指令;Release 注入真实页面,Debug 仅向本地模拟页面注入。
|
|
protocol DroneDockCommandSending: Sendable {
|
|
/// 提交任务 ID 和白名单指令,不创建任务、不选机,也不自动重试。
|
|
@MainActor
|
|
func sendCommand(taskID: Int, command: DroneDockSafetyCommand) async throws -> DroneDockCommandResponse
|
|
}
|
|
|
|
/// 朱工 command 合同适配,真实传输仍受统一 Debug 禁飞策略阻断。
|
|
@MainActor
|
|
final class DroneDockCommandAPI: DroneDockCommandSending {
|
|
private let client: APIClient
|
|
|
|
/// 注入统一客户端;模拟调试使用完全不转发网络的响应替身。
|
|
init(client: APIClient) { self.client = client }
|
|
|
|
/// 每次仅发送 id 和 command,回执必须对应同一任务及同一指令。
|
|
func sendCommand(taskID: Int, command: DroneDockSafetyCommand) async throws -> DroneDockCommandResponse {
|
|
try Task.checkCancellation()
|
|
guard taskID > 0 else { throw APIError.networkFailed("缺少有效拍摄任务 ID,请返回任务页确认") }
|
|
let response: DroneDockCommandResponse = try await client.send(APIRequest(
|
|
method: .post, path: "/api/app/airport/command",
|
|
body: CommandBody(taskID: taskID, command: command.rawValue)
|
|
))
|
|
guard response.orderFlightTaskID == taskID, response.command == command.rawValue else {
|
|
throw APIError.decodeFailed("安全指令回执的任务或指令不一致,请核对原任务状态")
|
|
}
|
|
return response
|
|
}
|
|
|
|
/// 指令请求只携带任务身份及已确认的指令码。
|
|
private struct CommandBody: Encodable {
|
|
let taskID: Int
|
|
let command: String
|
|
|
|
/// 朱工请求字段映射,不附加飞机或模拟标志。
|
|
private enum CodingKeys: String, CodingKey { case taskID = "id", command }
|
|
}
|
|
}
|