91 lines
2.2 KiB
Dart
91 lines
2.2 KiB
Dart
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,
|
|
];
|
|
}
|