告警中心的二级详情页面+信息中心的页面+对接机器人接口

This commit is contained in:
2026-06-02 08:40:50 +08:00
parent 9eab402551
commit d8879dad62
48 changed files with 4376 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
/// 机器人数据模型
class RobotDataModel {
final String name;
final String id;
final String type;
final String status;
final double battery;
final String task;
const RobotDataModel({
required this.name,
required this.id,
required this.type,
required this.status,
required this.battery,
required this.task,
});
/// 从 JSON 创建数据模型
factory RobotDataModel.fromJson(Map<String, dynamic> json) {
return RobotDataModel(
name: json['deviceName'] ?? json['name'] ?? '',
id: json['deviceId']?.toString() ?? json['id']?.toString() ?? '',
type: json['deviceTypeName'] ?? json['type'] ?? '未知类型',
status: _getStatusText(json['status'] ?? 0),
battery: (json['battery'] as num?)?.toDouble() ??
(json['capacity_percent'] as num?)?.toDouble() ?? 0.0,
task: json['task'] ?? json['currentTask'] ?? '待机中',
);
}
/// 转换为 JSON
Map<String, dynamic> toJson() {
return {
'name': name,
'id': id,
'type': type,
'status': status,
'battery': battery,
'task': task,
};
}
/// 状态码转换
static String _getStatusText(int status) {
switch (status) {
case 1:
return '在线';
case 2:
return '离线';
case 3:
return '异常';
default:
return '未知';
}
}
}