一次大的提交
This commit is contained in:
@@ -1,5 +1,21 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// 告警工单配置实体
|
||||
class AlarmOrderConfigEntity extends Equatable {
|
||||
const AlarmOrderConfigEntity({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.code,
|
||||
});
|
||||
|
||||
final int id;
|
||||
final String name;
|
||||
final String? code;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, name, code];
|
||||
}
|
||||
|
||||
/// 告警统计实体
|
||||
class AlarmCountEntity extends Equatable {
|
||||
const AlarmCountEntity({
|
||||
|
||||
@@ -46,6 +46,24 @@ class AlarmDetailEntity extends Equatable {
|
||||
required this.description,
|
||||
required this.suggestions,
|
||||
required this.historyData,
|
||||
this.alarmNo,
|
||||
this.alarmType,
|
||||
this.deviceId,
|
||||
this.deviceType,
|
||||
this.createTime,
|
||||
this.updateTime,
|
||||
this.handleUserId,
|
||||
this.handleUserName,
|
||||
this.handleTime,
|
||||
this.handleRemark,
|
||||
this.rootCause,
|
||||
this.handleSuggestion,
|
||||
this.siteId,
|
||||
this.orgId,
|
||||
this.notifySms,
|
||||
this.notifyTelegram,
|
||||
this.notifyEmail,
|
||||
this.handleResult,
|
||||
});
|
||||
|
||||
/// 告警ID
|
||||
@@ -84,6 +102,60 @@ class AlarmDetailEntity extends Equatable {
|
||||
/// 历史指标数据
|
||||
final HistoryMetrics historyData;
|
||||
|
||||
/// 告警编号
|
||||
final String? alarmNo;
|
||||
|
||||
/// 告警类型
|
||||
final int? alarmType;
|
||||
|
||||
/// 设备ID
|
||||
final String? deviceId;
|
||||
|
||||
/// 设备类型
|
||||
final String? deviceType;
|
||||
|
||||
/// 创建时间
|
||||
final String? createTime;
|
||||
|
||||
/// 更新时间
|
||||
final String? updateTime;
|
||||
|
||||
/// 处理人ID
|
||||
final String? handleUserId;
|
||||
|
||||
/// 处理人名称
|
||||
final String? handleUserName;
|
||||
|
||||
/// 处理时间
|
||||
final String? handleTime;
|
||||
|
||||
/// 处理备注
|
||||
final String? handleRemark;
|
||||
|
||||
/// 根因
|
||||
final String? rootCause;
|
||||
|
||||
/// 处理建议(原始字符串)
|
||||
final String? handleSuggestion;
|
||||
|
||||
/// 站点ID
|
||||
final int? siteId;
|
||||
|
||||
/// 组织ID
|
||||
final int? orgId;
|
||||
|
||||
/// 是否短信通知
|
||||
final int? notifySms;
|
||||
|
||||
/// 是否电报通知
|
||||
final int? notifyTelegram;
|
||||
|
||||
/// 是否邮件通知
|
||||
final int? notifyEmail;
|
||||
|
||||
/// 处理结果
|
||||
final String? handleResult;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
@@ -98,6 +170,24 @@ class AlarmDetailEntity extends Equatable {
|
||||
description,
|
||||
suggestions,
|
||||
historyData,
|
||||
alarmNo,
|
||||
alarmType,
|
||||
deviceId,
|
||||
deviceType,
|
||||
createTime,
|
||||
updateTime,
|
||||
handleUserId,
|
||||
handleUserName,
|
||||
handleTime,
|
||||
handleRemark,
|
||||
rootCause,
|
||||
handleSuggestion,
|
||||
siteId,
|
||||
orgId,
|
||||
notifySms,
|
||||
notifyTelegram,
|
||||
notifyEmail,
|
||||
handleResult,
|
||||
];
|
||||
|
||||
AlarmDetailEntity copyWith({
|
||||
@@ -113,6 +203,24 @@ class AlarmDetailEntity extends Equatable {
|
||||
String? description,
|
||||
List<String>? suggestions,
|
||||
HistoryMetrics? historyData,
|
||||
String? alarmNo,
|
||||
int? alarmType,
|
||||
String? deviceId,
|
||||
String? deviceType,
|
||||
String? createTime,
|
||||
String? updateTime,
|
||||
String? handleUserId,
|
||||
String? handleUserName,
|
||||
String? handleTime,
|
||||
String? handleRemark,
|
||||
String? rootCause,
|
||||
String? handleSuggestion,
|
||||
int? siteId,
|
||||
int? orgId,
|
||||
int? notifySms,
|
||||
int? notifyTelegram,
|
||||
int? notifyEmail,
|
||||
String? handleResult,
|
||||
}) {
|
||||
return AlarmDetailEntity(
|
||||
id: id ?? this.id,
|
||||
@@ -127,6 +235,24 @@ class AlarmDetailEntity extends Equatable {
|
||||
description: description ?? this.description,
|
||||
suggestions: suggestions ?? this.suggestions,
|
||||
historyData: historyData ?? this.historyData,
|
||||
alarmNo: alarmNo ?? this.alarmNo,
|
||||
alarmType: alarmType ?? this.alarmType,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
deviceType: deviceType ?? this.deviceType,
|
||||
createTime: createTime ?? this.createTime,
|
||||
updateTime: updateTime ?? this.updateTime,
|
||||
handleUserId: handleUserId ?? this.handleUserId,
|
||||
handleUserName: handleUserName ?? this.handleUserName,
|
||||
handleTime: handleTime ?? this.handleTime,
|
||||
handleRemark: handleRemark ?? this.handleRemark,
|
||||
rootCause: rootCause ?? this.rootCause,
|
||||
handleSuggestion: handleSuggestion ?? this.handleSuggestion,
|
||||
siteId: siteId ?? this.siteId,
|
||||
orgId: orgId ?? this.orgId,
|
||||
notifySms: notifySms ?? this.notifySms,
|
||||
notifyTelegram: notifyTelegram ?? this.notifyTelegram,
|
||||
notifyEmail: notifyEmail ?? this.notifyEmail,
|
||||
handleResult: handleResult ?? this.handleResult,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/// 告警派发工单实体
|
||||
class AlarmDispatchEntity {
|
||||
/// 告警ID
|
||||
final String alarmId;
|
||||
|
||||
/// 告警编号
|
||||
final String? alarmNo;
|
||||
|
||||
/// 告警原始设备类型(如 UAV, MOWER),用于映射 orderType
|
||||
final String? deviceType;
|
||||
|
||||
/// 映射后的工单类型(如 UAV_ERROR, MOWER_ERROR)
|
||||
final String? orderType;
|
||||
|
||||
/// 场站ID
|
||||
final int? siteId;
|
||||
|
||||
/// 场站名称
|
||||
final String? siteName;
|
||||
|
||||
/// 设备ID
|
||||
final String? deviceId;
|
||||
|
||||
/// 设备名称
|
||||
final String? deviceName;
|
||||
|
||||
/// 任务描述
|
||||
final String? description;
|
||||
|
||||
/// 问题等级
|
||||
final String? problemLevel;
|
||||
|
||||
/// 媒体文件路径列表
|
||||
final List<String>? mediaUrls;
|
||||
|
||||
/// 计划开始时间
|
||||
final DateTime? planStartTime;
|
||||
|
||||
/// 计划结束时间
|
||||
final DateTime? planEndTime;
|
||||
|
||||
const AlarmDispatchEntity({
|
||||
required this.alarmId,
|
||||
this.alarmNo,
|
||||
this.deviceType,
|
||||
this.orderType,
|
||||
this.siteId,
|
||||
this.siteName,
|
||||
this.deviceId,
|
||||
this.deviceName,
|
||||
this.description,
|
||||
this.problemLevel,
|
||||
this.mediaUrls,
|
||||
this.planStartTime,
|
||||
this.planEndTime,
|
||||
});
|
||||
|
||||
AlarmDispatchEntity copyWith({
|
||||
String? alarmId,
|
||||
String? alarmNo,
|
||||
String? deviceType,
|
||||
String? orderType,
|
||||
int? siteId,
|
||||
String? siteName,
|
||||
String? deviceId,
|
||||
String? deviceName,
|
||||
String? description,
|
||||
String? problemLevel,
|
||||
List<String>? mediaUrls,
|
||||
DateTime? planStartTime,
|
||||
DateTime? planEndTime,
|
||||
}) {
|
||||
return AlarmDispatchEntity(
|
||||
alarmId: alarmId ?? this.alarmId,
|
||||
alarmNo: alarmNo ?? this.alarmNo,
|
||||
deviceType: deviceType ?? this.deviceType,
|
||||
orderType: orderType ?? this.orderType,
|
||||
siteId: siteId ?? this.siteId,
|
||||
siteName: siteName ?? this.siteName,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
deviceName: deviceName ?? this.deviceName,
|
||||
description: description ?? this.description,
|
||||
problemLevel: problemLevel ?? this.problemLevel,
|
||||
mediaUrls: mediaUrls ?? this.mediaUrls,
|
||||
planStartTime: planStartTime ?? this.planStartTime,
|
||||
planEndTime: planEndTime ?? this.planEndTime,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,13 @@ abstract class AlarmDetailRepository {
|
||||
/// 获取告警详情
|
||||
Future<Either<Failure, AlarmDetailEntity>> getAlarmDetail(String alarmId);
|
||||
|
||||
/// 确认告警
|
||||
Future<Either<Failure, bool>> confirmAlarm(String alarmId);
|
||||
/// 确认告警(处理中)
|
||||
Future<Either<Failure, Map<String, dynamic>>> confirmAlarm(String alarmId);
|
||||
|
||||
/// 处理告警(已关闭)
|
||||
Future<Either<Failure, Map<String, dynamic>>> handleAlarm(
|
||||
Map<String, dynamic> handleData,
|
||||
);
|
||||
|
||||
/// AI诊断
|
||||
Future<Either<Failure, String>> aiDiagnosis(String alarmId);
|
||||
|
||||
@@ -6,12 +6,21 @@ import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/constant
|
||||
|
||||
/// 告警仓储接口
|
||||
abstract class AlarmRepository {
|
||||
/// 获取告警列表
|
||||
/// 获取告警列表(支持分页)
|
||||
/// [filter] 筛选条件
|
||||
Future<Either<Failure, List<AlarmEntity>>> getAlarmList({
|
||||
AlarmFilterTab? filter,
|
||||
int? siteId,
|
||||
int? configId,
|
||||
int? page,
|
||||
int? pageSize,
|
||||
});
|
||||
|
||||
/// 获取告警统计
|
||||
Future<Either<Failure, AlarmCountEntity>> getAlarmCount();
|
||||
Future<Either<Failure, AlarmCountEntity>> getAlarmCount({int? siteId});
|
||||
|
||||
/// 获取告警工单配置列表
|
||||
Future<Either<Failure, List<AlarmOrderConfigEntity>>> getAlarmOrderConfigList(
|
||||
int siteId,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,24 @@ class ConfirmAlarmUseCase {
|
||||
|
||||
final AlarmDetailRepository _repository;
|
||||
|
||||
Future<Either<Failure, bool>> call(String alarmId) async {
|
||||
Future<Either<Failure, Map<String, dynamic>>> call(String alarmId) async {
|
||||
return await _repository.confirmAlarm(alarmId);
|
||||
}
|
||||
}
|
||||
|
||||
/// 处理告警用例
|
||||
class HandleAlarmUseCase {
|
||||
HandleAlarmUseCase(this._repository);
|
||||
|
||||
final AlarmDetailRepository _repository;
|
||||
|
||||
Future<Either<Failure, Map<String, dynamic>>> call(
|
||||
Map<String, dynamic> handleData,
|
||||
) async {
|
||||
return await _repository.handleAlarm(handleData);
|
||||
}
|
||||
}
|
||||
|
||||
/// AI诊断用例
|
||||
class AIDiagnosisUseCase {
|
||||
AIDiagnosisUseCase(this._repository);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
import '../entities/alarm_dispatch_entity.dart';
|
||||
|
||||
/// 派发工单用例
|
||||
abstract class AlarmDispatchRepository {
|
||||
Future<Either<Failure, bool>> dispatchWorkOrder(
|
||||
AlarmDispatchEntity entity,
|
||||
);
|
||||
}
|
||||
|
||||
class DispatchWorkOrderUseCase {
|
||||
final AlarmDispatchRepository repository;
|
||||
|
||||
DispatchWorkOrderUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, bool>> execute(AlarmDispatchEntity entity) async {
|
||||
if (entity.siteId == null) {
|
||||
return left(Failure('请选择场站'));
|
||||
}
|
||||
if (entity.orderType == null || entity.orderType!.isEmpty) {
|
||||
return left(Failure('请选择上报类型'));
|
||||
}
|
||||
if (entity.deviceId == null || entity.deviceId!.isEmpty) {
|
||||
return left(Failure('请选择设备'));
|
||||
}
|
||||
if (entity.description == null || entity.description!.isEmpty) {
|
||||
return left(Failure('请填写问题描述'));
|
||||
}
|
||||
if (entity.problemLevel == null || entity.problemLevel!.isEmpty) {
|
||||
return left(Failure('请选择问题等级'));
|
||||
}
|
||||
if (entity.planStartTime == null) {
|
||||
return left(Failure('请选择计划开始时间'));
|
||||
}
|
||||
|
||||
return await repository.dispatchWorkOrder(entity);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ class GetAlarmCountUseCase {
|
||||
final AlarmRepository _repository;
|
||||
|
||||
/// 执行用例
|
||||
Future<Either<Failure, AlarmCountEntity>> call() async {
|
||||
return await _repository.getAlarmCount();
|
||||
Future<Either<Failure, AlarmCountEntity>> call({int? siteId}) async {
|
||||
return await _repository.getAlarmCount(siteId: siteId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,21 @@ class GetAlarmListUseCase {
|
||||
|
||||
/// 执行用例
|
||||
/// [filter] 筛选条件
|
||||
/// [page] 页码
|
||||
/// [pageSize] 每页条数
|
||||
Future<Either<Failure, List<AlarmEntity>>> call({
|
||||
AlarmFilterTab? filter,
|
||||
int? siteId,
|
||||
int? configId,
|
||||
int? page,
|
||||
int? pageSize,
|
||||
}) async {
|
||||
return await _repository.getAlarmList(filter: filter);
|
||||
return await _repository.getAlarmList(
|
||||
filter: filter,
|
||||
siteId: siteId,
|
||||
configId: configId,
|
||||
page: page,
|
||||
pageSize: pageSize,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/entities/alarm_count_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/domain/repositories/alarm_repository.dart';
|
||||
|
||||
/// 获取告警工单配置列表用例
|
||||
class GetAlarmOrderConfigUseCase {
|
||||
GetAlarmOrderConfigUseCase(this._repository);
|
||||
|
||||
final AlarmRepository _repository;
|
||||
|
||||
/// 执行用例
|
||||
Future<Either<Failure, List<AlarmOrderConfigEntity>>> call(int siteId) async {
|
||||
return await _repository.getAlarmOrderConfigList(siteId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user