接入设备故障告警和场站实时任务进度
This commit is contained in:
90
lib/features/device_alarms/domain/entities/device_alarm.dart
Normal file
90
lib/features/device_alarms/domain/entities/device_alarm.dart
Normal file
@@ -0,0 +1,90 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// 设备故障与预警记录;关闭是业务处理状态,不代表设备故障已经恢复。
|
||||
class DeviceAlarm extends Equatable {
|
||||
const DeviceAlarm({
|
||||
required this.id,
|
||||
this.alarmNo = '',
|
||||
this.title = '',
|
||||
this.content = '',
|
||||
this.deviceId = '',
|
||||
this.deviceName = '',
|
||||
this.sourceSn = '',
|
||||
this.level = '',
|
||||
this.type = '',
|
||||
this.timeValues = '',
|
||||
this.alarmTime,
|
||||
this.recoverTime,
|
||||
this.handleStatus = 1,
|
||||
this.rootCause = '',
|
||||
this.handleSuggestion = '',
|
||||
});
|
||||
|
||||
final int id;
|
||||
final String alarmNo;
|
||||
final String title;
|
||||
final String content;
|
||||
final String deviceId;
|
||||
final String deviceName;
|
||||
|
||||
/// 由订阅 Topic 标记来源;后端 deviceId 可能是数据库 ID。
|
||||
final String sourceSn;
|
||||
final String level;
|
||||
final String type;
|
||||
final String timeValues;
|
||||
final DateTime? alarmTime;
|
||||
final DateTime? recoverTime;
|
||||
final int handleStatus;
|
||||
final String rootCause;
|
||||
final String handleSuggestion;
|
||||
|
||||
bool get isClosed => handleStatus == 2;
|
||||
|
||||
/// 无服务端 ID 的推送仍可展示,按来源/故障码/发生时间标识,避免多条 id:null 互相覆盖。
|
||||
String get recordKey => id > 0
|
||||
? 'id:$id'
|
||||
: 'push:${sourceSn.isEmpty ? deviceId : sourceSn}|$alarmNo|${alarmTime?.toIso8601String() ?? ''}';
|
||||
|
||||
DeviceAlarm closed() => copyWith(handleStatus: 2);
|
||||
|
||||
DeviceAlarm copyWith({
|
||||
String? sourceSn,
|
||||
String? deviceName,
|
||||
int? handleStatus,
|
||||
}) => DeviceAlarm(
|
||||
id: id,
|
||||
alarmNo: alarmNo,
|
||||
title: title,
|
||||
content: content,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName ?? this.deviceName,
|
||||
sourceSn: sourceSn ?? this.sourceSn,
|
||||
level: level,
|
||||
type: type,
|
||||
timeValues: timeValues,
|
||||
alarmTime: alarmTime,
|
||||
recoverTime: recoverTime,
|
||||
handleStatus: handleStatus ?? this.handleStatus,
|
||||
rootCause: rootCause,
|
||||
handleSuggestion: handleSuggestion,
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
alarmNo,
|
||||
title,
|
||||
content,
|
||||
deviceId,
|
||||
deviceName,
|
||||
sourceSn,
|
||||
level,
|
||||
type,
|
||||
timeValues,
|
||||
alarmTime,
|
||||
recoverTime,
|
||||
handleStatus,
|
||||
rootCause,
|
||||
handleSuggestion,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/// Topic 使用设备 SN,与告警记录里的设备数据库 ID 分开。
|
||||
class DeviceAlarmTarget {
|
||||
const DeviceAlarmTarget({
|
||||
required this.sn,
|
||||
required this.name,
|
||||
this.deviceId = '',
|
||||
});
|
||||
final String sn;
|
||||
final String name;
|
||||
final String deviceId;
|
||||
}
|
||||
Reference in New Issue
Block a user