告警中心的二级详情页面+信息中心的页面+对接机器人接口
This commit is contained in:
@@ -0,0 +1,420 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// 摄像头信息
|
||||
class CameraInfo extends Equatable {
|
||||
final String cameraIndex;
|
||||
final List<String>? availableCameraPositions;
|
||||
final String cameraPosition;
|
||||
|
||||
const CameraInfo({
|
||||
required this.cameraIndex,
|
||||
this.availableCameraPositions,
|
||||
required this.cameraPosition,
|
||||
});
|
||||
|
||||
factory CameraInfo.fromJson(Map<String, dynamic> json) {
|
||||
return CameraInfo(
|
||||
cameraIndex: json['camera_index'] ?? '',
|
||||
availableCameraPositions: json['available_camera_positions'] != null
|
||||
? List<String>.from(json['available_camera_positions'])
|
||||
: null,
|
||||
cameraPosition: json['camera_position'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'camera_index': cameraIndex,
|
||||
'available_camera_positions': availableCameraPositions,
|
||||
'camera_position': cameraPosition,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
cameraIndex,
|
||||
availableCameraPositions,
|
||||
cameraPosition,
|
||||
];
|
||||
}
|
||||
|
||||
/// 位置状态
|
||||
class PositionState extends Equatable {
|
||||
final int gpsNumber;
|
||||
final String isFixed;
|
||||
final String quality;
|
||||
final int rtkNumber;
|
||||
|
||||
const PositionState({
|
||||
required this.gpsNumber,
|
||||
required this.isFixed,
|
||||
required this.quality,
|
||||
required this.rtkNumber,
|
||||
});
|
||||
|
||||
factory PositionState.fromJson(Map<String, dynamic> json) {
|
||||
return PositionState(
|
||||
gpsNumber: json['gps_number'] ?? 0,
|
||||
isFixed: json['is_fixed'] ?? '',
|
||||
quality: json['quality'] ?? '',
|
||||
rtkNumber: json['rtk_number'] ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'gps_number': gpsNumber,
|
||||
'is_fixed': isFixed,
|
||||
'quality': quality,
|
||||
'rtk_number': rtkNumber,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [gpsNumber, isFixed, quality, rtkNumber];
|
||||
}
|
||||
|
||||
/// 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 double? latitude;
|
||||
final double? longitude;
|
||||
final double? capacityPercent;
|
||||
final double? windSpeed;
|
||||
final double? height;
|
||||
final double? environmentTemperature;
|
||||
final dynamic networkState;
|
||||
final PositionState? positionState;
|
||||
final double? homeDistance;
|
||||
final double? liveCapacity;
|
||||
final String? rainfall;
|
||||
final List<CameraInfo>? gatewayCameraList;
|
||||
final List<dynamic>? droneCameraList;
|
||||
final int? orgId;
|
||||
final int? siteId;
|
||||
final int? userId;
|
||||
|
||||
const UAVDetailEntity({
|
||||
required this.deviceSn,
|
||||
required this.gatewaySn,
|
||||
required this.callsign,
|
||||
required this.droneCallsign,
|
||||
required this.onlineStatus,
|
||||
required this.droneOnlineStatus,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.capacityPercent,
|
||||
this.windSpeed,
|
||||
this.height,
|
||||
this.environmentTemperature,
|
||||
this.networkState,
|
||||
this.positionState,
|
||||
this.homeDistance,
|
||||
this.liveCapacity,
|
||||
this.rainfall,
|
||||
this.gatewayCameraList,
|
||||
this.droneCameraList,
|
||||
this.orgId,
|
||||
this.siteId,
|
||||
this.userId,
|
||||
});
|
||||
|
||||
factory UAVDetailEntity.fromJson(Map<String, dynamic> json) {
|
||||
return UAVDetailEntity(
|
||||
deviceSn: json['device_sn'] ?? '',
|
||||
gatewaySn: json['gateway_sn'] ?? '',
|
||||
callsign: json['callsign'] ?? '',
|
||||
droneCallsign: json['drone_callsign'] ?? '',
|
||||
onlineStatus: json['onlineStatus'] ?? 0,
|
||||
droneOnlineStatus: json['drone_onlineStatus'] ?? 0,
|
||||
latitude: json['latitude'] != null
|
||||
? (json['latitude'] as num).toDouble()
|
||||
: null,
|
||||
longitude: json['longitude'] != null
|
||||
? (json['longitude'] as num).toDouble()
|
||||
: null,
|
||||
capacityPercent: json['capacity_percent'] != null
|
||||
? (json['capacity_percent'] as num).toDouble()
|
||||
: null,
|
||||
windSpeed: json['wind_speed'] != null
|
||||
? (json['wind_speed'] as num).toDouble()
|
||||
: null,
|
||||
height: json['height'] != null
|
||||
? (json['height'] as num).toDouble()
|
||||
: null,
|
||||
environmentTemperature: json['environment_temperature'] != null
|
||||
? (json['environment_temperature'] as num).toDouble()
|
||||
: null,
|
||||
networkState: json['network_state'],
|
||||
positionState: json['position_state'] != null
|
||||
? PositionState.fromJson(json['position_state'])
|
||||
: null,
|
||||
homeDistance: json['home_distance'] != null
|
||||
? (json['home_distance'] as num).toDouble()
|
||||
: null,
|
||||
liveCapacity: json['live_capacity'] != null
|
||||
? (json['live_capacity'] as num).toDouble()
|
||||
: null,
|
||||
rainfall: json['rainfall']?.toString(),
|
||||
gatewayCameraList: json['gateway_camera_list'] != null
|
||||
? (json['gateway_camera_list'] as List)
|
||||
.map((item) => CameraInfo.fromJson(item))
|
||||
.toList()
|
||||
: null,
|
||||
droneCameraList: json['drone_camera_list'],
|
||||
orgId: json['orgId'],
|
||||
siteId: json['siteId'],
|
||||
userId: json['userId'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'device_sn': deviceSn,
|
||||
'gateway_sn': gatewaySn,
|
||||
'callsign': callsign,
|
||||
'drone_callsign': droneCallsign,
|
||||
'onlineStatus': onlineStatus,
|
||||
'drone_onlineStatus': droneOnlineStatus,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'capacity_percent': capacityPercent,
|
||||
'wind_speed': windSpeed,
|
||||
'height': height,
|
||||
'environment_temperature': environmentTemperature,
|
||||
'network_state': networkState,
|
||||
'position_state': positionState?.toJson(),
|
||||
'home_distance': homeDistance,
|
||||
'live_capacity': liveCapacity,
|
||||
'rainfall': rainfall,
|
||||
'gateway_camera_list': gatewayCameraList?.map((c) => c.toJson()).toList(),
|
||||
'drone_camera_list': droneCameraList,
|
||||
'orgId': orgId,
|
||||
'siteId': siteId,
|
||||
'userId': userId,
|
||||
};
|
||||
}
|
||||
|
||||
bool get isOnline => onlineStatus == 1;
|
||||
bool get isDroneOnline => droneOnlineStatus == 1;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
deviceSn,
|
||||
gatewaySn,
|
||||
callsign,
|
||||
droneCallsign,
|
||||
onlineStatus,
|
||||
droneOnlineStatus,
|
||||
latitude,
|
||||
longitude,
|
||||
capacityPercent,
|
||||
windSpeed,
|
||||
height,
|
||||
environmentTemperature,
|
||||
networkState,
|
||||
positionState,
|
||||
homeDistance,
|
||||
liveCapacity,
|
||||
rainfall,
|
||||
gatewayCameraList,
|
||||
droneCameraList,
|
||||
orgId,
|
||||
siteId,
|
||||
userId,
|
||||
];
|
||||
}
|
||||
|
||||
/// 无人机机场实体
|
||||
class DroneStationEntity extends Equatable {
|
||||
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; // 电量百分比
|
||||
final double? windSpeed; // 风速
|
||||
final double? height; // 高度
|
||||
final double? environmentTemperature; // 环境温度
|
||||
final int? networkState; // 网络状态
|
||||
final int? positionState; // 位置状态
|
||||
final double? homeDistance; // 距离home点距离
|
||||
final double? liveCapacity; // 实时容量
|
||||
final double? rainfall; // 降雨量
|
||||
final List<CameraInfo>? gatewayCameraList; // 网关摄像头列表
|
||||
final List<dynamic>? droneCameraList; // 无人机摄像头列表
|
||||
final int orgId; // 组织ID
|
||||
final int siteId; // 场站ID
|
||||
final int? userId; // 用户ID
|
||||
|
||||
const DroneStationEntity({
|
||||
required this.deviceSn,
|
||||
required this.gatewaySn,
|
||||
required this.callsign,
|
||||
required this.droneCallsign,
|
||||
required this.onlineStatus,
|
||||
required this.droneOnlineStatus,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.capacityPercent,
|
||||
this.windSpeed,
|
||||
this.height,
|
||||
this.environmentTemperature,
|
||||
this.networkState,
|
||||
this.positionState,
|
||||
this.homeDistance,
|
||||
this.liveCapacity,
|
||||
this.rainfall,
|
||||
this.gatewayCameraList,
|
||||
this.droneCameraList,
|
||||
required this.orgId,
|
||||
required this.siteId,
|
||||
this.userId,
|
||||
});
|
||||
|
||||
factory DroneStationEntity.fromJson(Map<String, dynamic> json) {
|
||||
return DroneStationEntity(
|
||||
deviceSn: json['device_sn'] ?? '',
|
||||
gatewaySn: json['gateway_sn'] ?? '',
|
||||
callsign: json['callsign'] ?? '',
|
||||
droneCallsign: json['drone_callsign'] ?? '',
|
||||
onlineStatus: json['onlineStatus'] ?? 0,
|
||||
droneOnlineStatus: json['drone_onlineStatus'] ?? 0,
|
||||
latitude: json['latitude'] != null
|
||||
? (json['latitude'] as num).toDouble()
|
||||
: null,
|
||||
longitude: json['longitude'] != null
|
||||
? (json['longitude'] as num).toDouble()
|
||||
: null,
|
||||
capacityPercent: json['capacity_percent'] != null
|
||||
? (json['capacity_percent'] as num).toDouble()
|
||||
: null,
|
||||
windSpeed: json['wind_speed'] != null
|
||||
? (json['wind_speed'] as num).toDouble()
|
||||
: null,
|
||||
height: json['height'] != null
|
||||
? (json['height'] as num).toDouble()
|
||||
: null,
|
||||
environmentTemperature: json['environment_temperature'] != null
|
||||
? (json['environment_temperature'] as num).toDouble()
|
||||
: null,
|
||||
networkState: json['network_state'],
|
||||
positionState: json['position_state'],
|
||||
homeDistance: json['home_distance'] != null
|
||||
? (json['home_distance'] as num).toDouble()
|
||||
: null,
|
||||
liveCapacity: json['live_capacity'] != null
|
||||
? (json['live_capacity'] as num).toDouble()
|
||||
: null,
|
||||
rainfall: json['rainfall'] != null
|
||||
? (json['rainfall'] as num).toDouble()
|
||||
: null,
|
||||
gatewayCameraList: json['gateway_camera_list'] != null
|
||||
? (json['gateway_camera_list'] as List)
|
||||
.map((item) => CameraInfo.fromJson(item))
|
||||
.toList()
|
||||
: null,
|
||||
droneCameraList: json['drone_camera_list'],
|
||||
orgId: json['orgId'] ?? 0,
|
||||
siteId: json['siteId'] ?? 0,
|
||||
userId: json['userId'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'device_sn': deviceSn,
|
||||
'gateway_sn': gatewaySn,
|
||||
'callsign': callsign,
|
||||
'drone_callsign': droneCallsign,
|
||||
'onlineStatus': onlineStatus,
|
||||
'drone_onlineStatus': droneOnlineStatus,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'capacity_percent': capacityPercent,
|
||||
'wind_speed': windSpeed,
|
||||
'height': height,
|
||||
'environment_temperature': environmentTemperature,
|
||||
'network_state': networkState,
|
||||
'position_state': positionState,
|
||||
'home_distance': homeDistance,
|
||||
'live_capacity': liveCapacity,
|
||||
'rainfall': rainfall,
|
||||
'gateway_camera_list': gatewayCameraList?.map((c) => c.toJson()).toList(),
|
||||
'drone_camera_list': droneCameraList,
|
||||
'orgId': orgId,
|
||||
'siteId': siteId,
|
||||
'userId': userId,
|
||||
};
|
||||
}
|
||||
|
||||
/// 是否在线
|
||||
bool get isOnline => onlineStatus == 1;
|
||||
|
||||
/// 无人机是否在线
|
||||
bool get isDroneOnline => droneOnlineStatus == 1;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
deviceSn,
|
||||
gatewaySn,
|
||||
callsign,
|
||||
droneCallsign,
|
||||
onlineStatus,
|
||||
droneOnlineStatus,
|
||||
latitude,
|
||||
longitude,
|
||||
capacityPercent,
|
||||
windSpeed,
|
||||
height,
|
||||
environmentTemperature,
|
||||
networkState,
|
||||
positionState,
|
||||
homeDistance,
|
||||
liveCapacity,
|
||||
rainfall,
|
||||
gatewayCameraList,
|
||||
droneCameraList,
|
||||
orgId,
|
||||
siteId,
|
||||
userId,
|
||||
];
|
||||
}
|
||||
|
||||
/// 视频流实体
|
||||
class VideoStreamEntity extends Equatable {
|
||||
final String sn;
|
||||
final String cameraIndex;
|
||||
final String url;
|
||||
final int expireTs;
|
||||
final String urlType;
|
||||
|
||||
const VideoStreamEntity({
|
||||
required this.sn,
|
||||
required this.cameraIndex,
|
||||
required this.url,
|
||||
required this.expireTs,
|
||||
required this.urlType,
|
||||
});
|
||||
|
||||
factory VideoStreamEntity.fromJson(Map<String, dynamic> json) {
|
||||
return VideoStreamEntity(
|
||||
sn: json['sn'] ?? '',
|
||||
cameraIndex: json['camera_index'] ?? '',
|
||||
url: json['url'] ?? '',
|
||||
expireTs: json['expire_ts'] ?? 0,
|
||||
urlType: json['url_type'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [sn, cameraIndex, url, expireTs, urlType];
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// 视频流实体
|
||||
class VideoStreamEntity extends Equatable {
|
||||
final String sn;
|
||||
final String cameraIndex;
|
||||
final String
|
||||
url; // 火山引擎 RTC 鉴权参数(包含 app_id、room_id、token、user_id、expire_time)
|
||||
final int expireTs;
|
||||
final String urlType; // 标识是 "rtc" 还是其他类型
|
||||
|
||||
const VideoStreamEntity({
|
||||
required this.sn,
|
||||
required this.cameraIndex,
|
||||
required this.url,
|
||||
required this.expireTs,
|
||||
required this.urlType,
|
||||
});
|
||||
|
||||
factory VideoStreamEntity.fromJson(Map<String, dynamic> json) {
|
||||
return VideoStreamEntity(
|
||||
sn: json['sn'] ?? '',
|
||||
cameraIndex: json['camera_index'] ?? '',
|
||||
url: json['url'] ?? '', // 火山引擎 RTC 鉴权参数
|
||||
expireTs: json['expire_ts'] ?? 0,
|
||||
urlType: json['url_type'] ?? 'rtc', // 默认为 rtc 类型
|
||||
);
|
||||
}
|
||||
|
||||
/// 解析火山引擎 RTC 参数
|
||||
/// url 格式示例: "app_id=xxx&room_id=xxx&token=xxx&user_id=xxx&expire_time=xxx"
|
||||
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) {
|
||||
// 对 URL 编码的字符进行解码(如 %2F -> /, %2B -> +)
|
||||
params[kv[0]] = Uri.decodeComponent(kv[1]);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/// 获取火山引擎 App ID(从 URL 中解析)
|
||||
String get appId => parseRtcParams()['app_id'] ?? '';
|
||||
|
||||
/// 获取房间 ID(从 URL 中解析)
|
||||
String get roomId => parseRtcParams()['room_id'] ?? '';
|
||||
|
||||
/// 获取 Token(从 URL 中解析)
|
||||
String get token => parseRtcParams()['token'] ?? '';
|
||||
|
||||
/// 获取用户 ID(从 URL 中解析)
|
||||
String get userId => parseRtcParams()['user_id'] ?? '';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [sn, cameraIndex, url, expireTs, urlType];
|
||||
}
|
||||
Reference in New Issue
Block a user