开放 Release 真实操作并保留 Debug 拦截;恢复前台 shooting 串行轮询;统一打印机巢请求与完整原值响应;优化长点位名称、未拍摄文案、报备失败及已结束任务提示,移除成功回执 UI。补充相关测试、离线策略检查和联调说明。
61 lines
2.5 KiB
Swift
61 lines
2.5 KiB
Swift
import Foundation
|
|
|
|
/// 对已创建的订单飞行任务请求召唤,复用该任务及服务端锁定的飞机。
|
|
protocol DroneDockShootServing: Sendable {
|
|
/// 只提交已有任务 ID;调用方负责防止重复提交及核对不确定结果。
|
|
@MainActor
|
|
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, DroneDockResummonServing {
|
|
private let client: APIClient
|
|
|
|
/// 注入统一网络客户端,沿用登录凭证、HTTP 与业务码处理。
|
|
init(client: APIClient) { self.client = client }
|
|
|
|
/// 仅发送一次召唤 POST;不创建任务、不重试、不修改任务已选航线。
|
|
func shoot(taskID: Int) async throws -> DroneDockShootResponse {
|
|
try await send(taskID: taskID, restart: false)
|
|
}
|
|
|
|
/// 复用同一订单飞行任务请求重启;Release 真实入口及隔离模拟入口按策略注入。
|
|
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, restart: restart)
|
|
))
|
|
} catch APIError.emptyData {
|
|
// 统一客户端仅在 HTTP 和业务码均成功后抛 emptyData;此接口尚未约定成功 data 结构。
|
|
return DroneDockShootResponse(dataJSON: nil)
|
|
}
|
|
}
|
|
|
|
/// 仅发送任务身份和重启标记,完全省略 plane_id 与航线覆盖字段。
|
|
private struct ShootBody: Encodable {
|
|
let taskID: Int
|
|
let restart: Bool
|
|
|
|
/// 朱工已建任务召唤参数映射。
|
|
private enum CodingKeys: String, CodingKey {
|
|
case taskID = "id", restart
|
|
}
|
|
}
|
|
}
|