无人机视频对接+支持无人机未在线时候5S执行一下查询操作。便于视频正常展示。
无人机视频的摄像头切换功能和参数切换功能(广角和红外 和等) 无人机航线任务创建页面的开发和接口对接 无人机航线任务搜索接口(支持时间过滤) 无人机执行航线任务功能开发和接口对接 无人机暂停执行任务功能开发和接口对接 无人机返航任务和取消返航功能开发和接口对接 无人机机场详情页中的展示信息的更正。
This commit is contained in:
@@ -76,12 +76,12 @@ class PositionState extends Equatable {
|
||||
|
||||
/// UAV详情实体(用于详情页面API返回的数据)
|
||||
class UAVDetailEntity extends Equatable {
|
||||
final String deviceSn;
|
||||
final String gatewaySn;
|
||||
final String callsign;
|
||||
final String droneCallsign;
|
||||
final int onlineStatus;
|
||||
final int droneOnlineStatus;
|
||||
final String deviceSn; // 设备序列号(无人机序列号)
|
||||
final String gatewaySn; // 网关序列号
|
||||
final String callsign; // 机场呼号/名称
|
||||
final String droneCallsign; // 无人机呼号
|
||||
final int onlineStatus; // 机场在线状态 (1:在线, 0:离线)
|
||||
final int droneOnlineStatus; // 无人机在线状态
|
||||
final double? latitude;
|
||||
final double? longitude;
|
||||
final double? capacityPercent;
|
||||
@@ -94,7 +94,7 @@ class UAVDetailEntity extends Equatable {
|
||||
final double? liveCapacity;
|
||||
final String? rainfall;
|
||||
final List<CameraInfo>? gatewayCameraList;
|
||||
final List<dynamic>? droneCameraList;
|
||||
final List<CameraInfo>? droneCameraList;
|
||||
final int? orgId;
|
||||
final int? siteId;
|
||||
final int? userId;
|
||||
@@ -126,7 +126,12 @@ class UAVDetailEntity extends Equatable {
|
||||
|
||||
factory UAVDetailEntity.fromJson(Map<String, dynamic> json) {
|
||||
return UAVDetailEntity(
|
||||
deviceSn: json['device_sn'] ?? '',
|
||||
deviceSn:
|
||||
json['device_sn'] ??
|
||||
json['drone_sn'] ??
|
||||
json['droneSn'] ??
|
||||
json['droneDeviceSn'] ??
|
||||
'',
|
||||
gatewaySn: json['gateway_sn'] ?? '',
|
||||
callsign: json['callsign'] ?? '',
|
||||
droneCallsign: json['drone_callsign'] ?? '',
|
||||
@@ -166,7 +171,11 @@ class UAVDetailEntity extends Equatable {
|
||||
.map((item) => CameraInfo.fromJson(item))
|
||||
.toList()
|
||||
: null,
|
||||
droneCameraList: json['drone_camera_list'],
|
||||
droneCameraList: json['drone_camera_list'] != null
|
||||
? (json['drone_camera_list'] as List)
|
||||
.map((item) => CameraInfo.fromJson(item as Map<String, dynamic>))
|
||||
.toList()
|
||||
: null,
|
||||
orgId: json['orgId'],
|
||||
siteId: json['siteId'],
|
||||
userId: json['userId'],
|
||||
@@ -322,7 +331,11 @@ class DroneStationEntity extends Equatable {
|
||||
.map((item) => CameraInfo.fromJson(item))
|
||||
.toList()
|
||||
: null,
|
||||
droneCameraList: json['drone_camera_list'],
|
||||
droneCameraList: json['drone_camera_list'] != null
|
||||
? (json['drone_camera_list'] as List)
|
||||
.map((item) => CameraInfo.fromJson(item as Map<String, dynamic>))
|
||||
.toList()
|
||||
: null,
|
||||
orgId: json['orgId'] ?? 0,
|
||||
siteId: json['siteId'] ?? 0,
|
||||
userId: json['userId'],
|
||||
@@ -387,4 +400,4 @@ class DroneStationEntity extends Equatable {
|
||||
siteId,
|
||||
userId,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
/// 飞行任务详情实体(专门用于详情接口)
|
||||
class FlightTaskDetailEntity {
|
||||
final String name;
|
||||
final String uuid;
|
||||
final String taskType;
|
||||
final String status;
|
||||
final String sn;
|
||||
final String droneSn; // 无人机序列号
|
||||
final String waylineUuid;
|
||||
final String beginAt;
|
||||
final String endAt;
|
||||
final String outOfControlAction; // 失控动作
|
||||
final int rthAltitude; // 返航高度(米)
|
||||
final String rthMode; // 返航模式
|
||||
final String resumableStatus; // 断点续飞状态
|
||||
final int folderId; // 文件夹ID(从folder_info中获取)
|
||||
final int expectedFileCount; // 期望文件数
|
||||
final int uploadedFileCount; // 已上传文件数
|
||||
final String repeatType; // 重复类型
|
||||
final int interval; // 间隔
|
||||
final int weekOfMonth; // 每月第几周
|
||||
final int minBatteryCapacity; // 最低电量(百分比)
|
||||
|
||||
FlightTaskDetailEntity({
|
||||
required this.name,
|
||||
required this.uuid,
|
||||
required this.taskType,
|
||||
required this.status,
|
||||
required this.sn,
|
||||
required this.droneSn,
|
||||
required this.waylineUuid,
|
||||
required this.beginAt,
|
||||
required this.endAt,
|
||||
required this.outOfControlAction,
|
||||
required this.rthAltitude,
|
||||
required this.rthMode,
|
||||
required this.resumableStatus,
|
||||
required this.folderId,
|
||||
required this.expectedFileCount,
|
||||
required this.uploadedFileCount,
|
||||
required this.repeatType,
|
||||
required this.interval,
|
||||
required this.weekOfMonth,
|
||||
required this.minBatteryCapacity,
|
||||
});
|
||||
|
||||
factory FlightTaskDetailEntity.fromJson(Map<String, dynamic> json) {
|
||||
// 安全处理 folder_info 嵌套结构
|
||||
final rawFolderInfo = json['folder_info'];
|
||||
final Map<String, dynamic> folderInfo = (rawFolderInfo is Map)
|
||||
? Map<String, dynamic>.from(rawFolderInfo)
|
||||
: <String, dynamic>{};
|
||||
print(
|
||||
'🔍 [FlightTaskDetailEntity] folder_info 类型: ${rawFolderInfo.runtimeType}',
|
||||
);
|
||||
print('🔍 [FlightTaskDetailEntity] folder_info 值: $rawFolderInfo');
|
||||
|
||||
return FlightTaskDetailEntity(
|
||||
name: json['name'] ?? '',
|
||||
uuid: json['uuid'] ?? '',
|
||||
taskType: json['task_type'] ?? '',
|
||||
status: json['status'] ?? '',
|
||||
sn: json['sn'] ?? '',
|
||||
droneSn:
|
||||
json['drone_sn'] ??
|
||||
json['device_sn'] ??
|
||||
json['droneSn'] ??
|
||||
json['deviceSn'] ??
|
||||
'',
|
||||
waylineUuid: json['wayline_uuid'] ?? '',
|
||||
beginAt: json['begin_at'] ?? '',
|
||||
endAt: json['end_at'] ?? '',
|
||||
outOfControlAction: json['out_of_control_action_in_flight'] ?? '',
|
||||
rthAltitude: _parseInt(json['rth_altitude']),
|
||||
rthMode: json['rth_mode'] ?? '',
|
||||
resumableStatus: json['resumable_status'] ?? '',
|
||||
folderId: _parseInt(folderInfo['folder_id']),
|
||||
expectedFileCount: _parseInt(folderInfo['expected_file_count']),
|
||||
uploadedFileCount: _parseInt(folderInfo['uploaded_file_count']),
|
||||
repeatType: json['repeat_type'] ?? '',
|
||||
interval: _parseInt(json['interval']),
|
||||
weekOfMonth: _parseInt(json['week_of_month']),
|
||||
minBatteryCapacity: _parseInt(json['min_battery_capacity']),
|
||||
);
|
||||
}
|
||||
|
||||
// 辅助方法:安全解析整数
|
||||
static int _parseInt(dynamic value) {
|
||||
if (value == null) return 0;
|
||||
if (value is int) return value;
|
||||
if (value is String) return int.tryParse(value) ?? 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'name': name,
|
||||
'uuid': uuid,
|
||||
'task_type': taskType,
|
||||
'status': status,
|
||||
'sn': sn,
|
||||
'drone_sn': droneSn,
|
||||
'wayline_uuid': waylineUuid,
|
||||
'begin_at': beginAt,
|
||||
'end_at': endAt,
|
||||
'out_of_control_action_in_flight': outOfControlAction,
|
||||
'rth_altitude': rthAltitude,
|
||||
'rth_mode': rthMode,
|
||||
'resumable_status': resumableStatus,
|
||||
'folder_info': {
|
||||
'folder_id': folderId,
|
||||
'expected_file_count': expectedFileCount,
|
||||
'uploaded_file_count': uploadedFileCount,
|
||||
},
|
||||
'repeat_type': repeatType,
|
||||
'interval': interval,
|
||||
'week_of_month': weekOfMonth,
|
||||
'min_battery_capacity': minBatteryCapacity,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
/// 飞行任务列表实体(专门用于列表接口)
|
||||
class FlightTaskEntity {
|
||||
final String name;
|
||||
final String uuid;
|
||||
@@ -54,9 +55,9 @@ class FlightTaskEntity {
|
||||
runAt: json['run_at'] ?? '',
|
||||
completedAt: json['completed_at'] ?? '',
|
||||
waylineUuid: json['wayline_uuid'] ?? '',
|
||||
folderId: json['folder_id'] ?? 0,
|
||||
currentWaypointIndex: json['current_waypoint_index'] ?? 0,
|
||||
totalWaypoints: json['total_waypoints'] ?? 0,
|
||||
folderId: _parseInt(json['folder_id']),
|
||||
currentWaypointIndex: _parseInt(json['current_waypoint_index']),
|
||||
totalWaypoints: _parseInt(json['total_waypoints']),
|
||||
mediaUploadStatus: json['media_upload_status'] ?? '',
|
||||
resumableStatus: json['resumable_status'] ?? '',
|
||||
isBreakPointResume: json['is_break_point_resume'] ?? false,
|
||||
@@ -65,6 +66,14 @@ class FlightTaskEntity {
|
||||
);
|
||||
}
|
||||
|
||||
// 辅助方法:安全解析整数
|
||||
static int _parseInt(dynamic value) {
|
||||
if (value == null) return 0;
|
||||
if (value is int) return value;
|
||||
if (value is String) return int.tryParse(value) ?? 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'name': name,
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// 无人机镜头类型枚举
|
||||
enum UavLensType {
|
||||
wide, // 广角镜头
|
||||
zoom, // 变焦镜头
|
||||
ir, // 红外镜头
|
||||
}
|
||||
|
||||
/// 视频质量类型枚举
|
||||
enum VideoQualityType {
|
||||
adaptive, // 自适应
|
||||
low, // 低清晰度
|
||||
medium, // 中清晰度
|
||||
high, // 高清晰度
|
||||
}
|
||||
|
||||
/// 无人机实时视频流实体
|
||||
class UavVideoStreamEntity extends Equatable {
|
||||
final String sn; // 设备序列号
|
||||
final String cameraIndex; // 摄像头编号
|
||||
final String url; // 视频流URL(含RTC参数)
|
||||
final int expireTs; // Token过期时间戳
|
||||
final String urlType; // URL类型:volc(火山引擎)或 agora
|
||||
|
||||
const UavVideoStreamEntity({
|
||||
required this.sn,
|
||||
required this.cameraIndex,
|
||||
required this.url,
|
||||
required this.expireTs,
|
||||
required this.urlType,
|
||||
});
|
||||
|
||||
factory UavVideoStreamEntity.fromJson(Map<String, dynamic> json) {
|
||||
return UavVideoStreamEntity(
|
||||
sn: json['sn'] ?? '',
|
||||
cameraIndex: json['camera_index'] ?? '',
|
||||
url: json['url'] ?? '',
|
||||
expireTs: json['expire_ts'] ?? 0,
|
||||
urlType: json['url_type'] ?? 'volc',
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, String> toMap() {
|
||||
return {
|
||||
'sn': sn,
|
||||
'cameraIndex': cameraIndex,
|
||||
'url': url,
|
||||
'expireTs': expireTs.toString(),
|
||||
'urlType': urlType,
|
||||
};
|
||||
}
|
||||
|
||||
/// 解析RTC参数(从URL中提取)
|
||||
Map<String, String> parseRtcParams() {
|
||||
final params = <String, String>{};
|
||||
final pairs = url.split('&');
|
||||
for (final pair in pairs) {
|
||||
final kv = pair.split('=');
|
||||
if (kv.length == 2) {
|
||||
params[kv[0]] = Uri.decodeComponent(kv[1]);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/// 获取 AppId
|
||||
String get appId {
|
||||
final params = parseRtcParams();
|
||||
return params['app_id'] ?? params['appid'] ?? '';
|
||||
}
|
||||
|
||||
/// 获取 RoomId
|
||||
String get roomId {
|
||||
final params = parseRtcParams();
|
||||
return params['room_id'] ?? params['roomid'] ?? params['channel'] ?? '';
|
||||
}
|
||||
|
||||
/// 获取 Token
|
||||
String get token {
|
||||
final params = parseRtcParams();
|
||||
return params['token'] ?? '';
|
||||
}
|
||||
|
||||
/// 获取 UserId
|
||||
String get userId {
|
||||
final params = parseRtcParams();
|
||||
return params['user_id'] ?? params['uid'] ?? '';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [sn, cameraIndex, url, expireTs, urlType];
|
||||
}
|
||||
@@ -2,6 +2,8 @@ import 'package:fpdart/fpdart.dart';
|
||||
import '../../../../../core/error/failure.dart';
|
||||
import '../entities/drone_station_entity.dart';
|
||||
import '../entities/video_stream_entity.dart';
|
||||
import '../entities/flight_task_entity.dart';
|
||||
import '../entities/uav_video_stream_entity.dart';
|
||||
|
||||
abstract class DroneStationRepository {
|
||||
Future<Either<Failure, List<DroneStationEntity>>> getDroneStationList(
|
||||
@@ -16,4 +18,23 @@ abstract class DroneStationRepository {
|
||||
required String cameraIndex,
|
||||
required String cameraPosition,
|
||||
});
|
||||
Future<Either<Failure, Map<String, List<FlightTaskEntity>?>>> getFlightTasks({
|
||||
required List<String> sns,
|
||||
required int beginAt,
|
||||
required int endAt,
|
||||
});
|
||||
Future<Either<Failure, FlightTaskEntity>> getFlightTaskDetail(String taskId);
|
||||
Future<Either<Failure, Map<String, dynamic>>> updateFlightTaskStatus({
|
||||
required String taskId,
|
||||
required String status,
|
||||
});
|
||||
|
||||
/// 获取无人机实时视频流
|
||||
Future<Either<Failure, UavVideoStreamEntity>> getUavVideoStream({
|
||||
required String sn,
|
||||
required String cameraIndex,
|
||||
UavLensType? lensType,
|
||||
VideoQualityType qualityType,
|
||||
int videoExpire,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import '../../../../../core/error/failure.dart';
|
||||
import '../entities/uav_video_stream_entity.dart';
|
||||
import '../repositories/drone_station_repository.dart';
|
||||
|
||||
/// 获取无人机实时视频流用例
|
||||
class GetUavVideoStreamUseCase {
|
||||
final DroneStationRepository repository;
|
||||
|
||||
GetUavVideoStreamUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, UavVideoStreamEntity>> call({
|
||||
required String sn,
|
||||
required String cameraIndex,
|
||||
UavLensType? lensType,
|
||||
VideoQualityType qualityType = VideoQualityType.adaptive,
|
||||
int videoExpire = 720000000,
|
||||
}) async {
|
||||
return await repository.getUavVideoStream(
|
||||
sn: sn,
|
||||
cameraIndex: cameraIndex,
|
||||
lensType: lensType,
|
||||
qualityType: qualityType,
|
||||
videoExpire: videoExpire,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import '../../../../../core/error/failure.dart';
|
||||
import '../repositories/drone_station_repository.dart';
|
||||
|
||||
class UpdateFlightTaskStatusUseCase {
|
||||
final DroneStationRepository repository;
|
||||
|
||||
UpdateFlightTaskStatusUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, Map<String, dynamic>>> execute({
|
||||
required String taskId,
|
||||
required String status,
|
||||
}) async {
|
||||
return await repository.updateFlightTaskStatus(
|
||||
taskId: taskId,
|
||||
status: status,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user