适配上传中订单并完善机巢操作与订阅兜底

支持订单状态 25 和持续拍摄、交付确认;安全指令点击后直接提交;鉴权超时保留 HTTP 兜底并退避换票重连。补充对应隔离回归测试。
This commit is contained in:
2026-11-05 12:35:58 +08:00
parent 34ee60b8b2
commit cd90c3648b
18 changed files with 373 additions and 71 deletions
@@ -53,7 +53,7 @@ final class DroneDockCompactOrderCell: UICollectionViewCell {
customerLabel.text = order.touristTitle
orderNumberLabel.isHidden = false
orderNumberLabel.text = "订单号 \(order.orderNumberText)"
statusLabel.apply(title: order.statusTitle, tone: order.statusTitle == "待拍摄" ? .blue : .gray)
statusLabel.apply(title: order.statusTitle, tone: order.statusTone)
packageLabel.text = order.packageTitle
packageLabel.numberOfLines = 0
countsLabel.numberOfLines = 0
@@ -39,13 +39,7 @@ final class DroneDockMaterialOrderCell: UICollectionViewCell {
/// 不根据任务数量或素材上传状态推导订单拍摄履约状态。
func apply(order: DroneDockHomeOrder) {
customerLabel.text = order.touristTitle
let tone: DroneDockStatusTone = switch order.shootStatus {
case "completed": .green
case "processing": .blue
case "pending": .orange
default: .gray
}
statusLabel.apply(title: order.statusTitle, tone: tone)
statusLabel.apply(title: order.statusTitle, tone: order.statusTone)
numberLabel.text = order.orderNumberText
let total = order.shotTotal.map(String.init) ?? "—"
let used = order.shotUsed.map(String.init) ?? "—"
@@ -670,7 +670,7 @@ final class DroneDockShootingTaskViewController: GlobalLoadingPageViewController
feedPlaceholder.apply(liveViewModel)
}
/// 返航会中断任务,先明确展示其含义再提交一次。
/// 安全动作点击后直接提交,沿用当前任务的权限与防重校验。
private func safetyCommandTriggered(_ command: DroneDockSafetyCommand) {
logEvent("action.safety", fields: ["command": command.rawValue, "enabled": viewModel.canSendCommand(command)])
guard isPageVisible, isApplicationActive,
@@ -679,24 +679,7 @@ final class DroneDockShootingTaskViewController: GlobalLoadingPageViewController
logSafetyRejection(command, stage: "tap")
return
}
if command == .returnHome {
let simulated = simulationRecordsProvider != nil
let alert = UIAlertController(title: simulated ? "立即返航(本地模拟)" : "立即返航",
message: simulated
? "模拟返航会中断本次任务。取消返航也不会恢复已经中断的任务。\n仅验证本地请求与回执,不向无人机发送指令。"
: "返航会中断本次任务。取消返航也不会恢复已经中断的任务。确定立即返航?", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "取消", style: .cancel) { [weak self] _ in
self?.logEvent("action.return_confirmation.cancelled")
})
alert.addAction(UIAlertAction(title: simulated ? "模拟返航" : "立即返航", style: .destructive) { [weak self] _ in
self?.logEvent("action.return_confirmation.confirmed")
self?.sendSafetyCommand(command)
})
logEvent("action.return_confirmation.shown")
present(alert, animated: true)
} else {
sendSafetyCommand(command)
}
sendSafetyCommand(command)
}
/// 同步锁只覆盖同一按钮;不同安全动作可各自等待,设备确认由 ViewModel 和快照处理。
@@ -86,13 +86,7 @@ final class DroneShootingOrderCardView: UIView {
metadataLabel.text = "订单号 \(order.orderNumberText) · \(createdAt)"
packageLabel.text = order.packageTitle
statusLabel.text = order.statusTitle
let tone: DroneDockStatusTone = switch order.shootStatus {
case "pending": .blue
case "processing": .orange
case "completed": .green
default: .gray
}
applyStatusAppearance(tone: tone)
applyStatusAppearance(tone: order.statusTone)
let used = order.shotUsed.map(String.init) ?? "—"
let total = order.shotTotal.map(String.init) ?? "—"