一次大的提交
This commit is contained in:
@@ -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