一次大的提交
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/work_order/domain/entities/work_order_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/work_order/domain/repositories/work_order_repository.dart';
|
||||
|
||||
class GetWorkOrderListUseCase {
|
||||
final WorkOrderRepository repository;
|
||||
|
||||
GetWorkOrderListUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, List<WorkOrderEntity>>> execute({
|
||||
String? orderNo,
|
||||
String? orderTitle,
|
||||
int? sourceType,
|
||||
int? orderType,
|
||||
int? priorityLevel,
|
||||
int? assigneeId,
|
||||
int? deviceId,
|
||||
int? siteId,
|
||||
int? orgId,
|
||||
int? orderStatus,
|
||||
String? startTime,
|
||||
String? endTime,
|
||||
String? keyword,
|
||||
int pageNum = 1,
|
||||
int pageSize = 10000,
|
||||
}) async {
|
||||
final params = <String, dynamic>{
|
||||
if (orderNo != null) 'orderNo': orderNo,
|
||||
if (orderTitle != null) 'orderTitle': orderTitle,
|
||||
if (sourceType != null) 'sourceType': sourceType,
|
||||
if (orderType != null) 'orderType': orderType,
|
||||
if (priorityLevel != null) 'priorityLevel': priorityLevel,
|
||||
if (assigneeId != null) 'assigneeId': assigneeId,
|
||||
if (deviceId != null) 'deviceId': deviceId,
|
||||
if (siteId != null) 'siteId': siteId,
|
||||
if (orgId != null) 'orgId': orgId,
|
||||
if (orderStatus != null) 'orderStatus': orderStatus,
|
||||
if (startTime != null) 'startTime': startTime,
|
||||
if (endTime != null) 'endTime': endTime,
|
||||
if (keyword != null) 'keyword': keyword,
|
||||
'pageNum': pageNum,
|
||||
'pageSize': pageSize,
|
||||
};
|
||||
return await repository.getWorkOrderList(params);
|
||||
}
|
||||
}
|
||||
|
||||
class GetWorkOrderDetailUseCase {
|
||||
final WorkOrderRepository repository;
|
||||
|
||||
GetWorkOrderDetailUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, WorkOrderEntity>> execute(int id) async {
|
||||
return await repository.getWorkOrderDetail(id);
|
||||
}
|
||||
}
|
||||
|
||||
class DispatchWorkOrderUseCase {
|
||||
final WorkOrderRepository repository;
|
||||
|
||||
DispatchWorkOrderUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, bool>> execute({
|
||||
required int orderId,
|
||||
required int assigneeId,
|
||||
required String assigneeName,
|
||||
String? collaboratorIds,
|
||||
String? collaboratorNames,
|
||||
String? planStartTime,
|
||||
String? planEndTime,
|
||||
String? deadlineTime,
|
||||
}) async {
|
||||
final params = <String, dynamic>{
|
||||
'orderId': orderId,
|
||||
'assigneeId': assigneeId,
|
||||
'assigneeName': assigneeName,
|
||||
if (collaboratorIds != null) 'collaboratorIds': collaboratorIds,
|
||||
if (collaboratorNames != null) 'collaboratorNames': collaboratorNames,
|
||||
if (planStartTime != null) 'planStartTime': planStartTime,
|
||||
if (planEndTime != null) 'planEndTime': planEndTime,
|
||||
if (deadlineTime != null) 'deadlineTime': deadlineTime,
|
||||
};
|
||||
return await repository.dispatchWorkOrder(params);
|
||||
}
|
||||
}
|
||||
|
||||
class SuspendWorkOrderUseCase {
|
||||
final WorkOrderRepository repository;
|
||||
|
||||
SuspendWorkOrderUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, bool>> execute(int id) async {
|
||||
return await repository.suspendWorkOrder(id);
|
||||
}
|
||||
}
|
||||
|
||||
class CompleteWorkOrderUseCase {
|
||||
final WorkOrderRepository repository;
|
||||
|
||||
CompleteWorkOrderUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, bool>> execute({
|
||||
required int id,
|
||||
String? handleResult,
|
||||
String? failureCause,
|
||||
String? handleMeasures,
|
||||
String? completeRemark,
|
||||
String? completeTime,
|
||||
List<String>? images,
|
||||
}) async {
|
||||
final params = <String, dynamic>{
|
||||
'id': id,
|
||||
if (handleResult != null) 'handleResult': handleResult,
|
||||
if (failureCause != null) 'failureCause': failureCause,
|
||||
if (handleMeasures != null) 'handleMeasures': handleMeasures,
|
||||
if (completeRemark != null) 'completeRemark': completeRemark,
|
||||
if (completeTime != null) 'completeTime': completeTime,
|
||||
if (images != null && images.isNotEmpty) 'images': images,
|
||||
};
|
||||
return await repository.completeWorkOrder(params);
|
||||
}
|
||||
}
|
||||
|
||||
class StartWorkOrderUseCase {
|
||||
final WorkOrderRepository repository;
|
||||
|
||||
StartWorkOrderUseCase(this.repository);
|
||||
|
||||
Future<Either<Failure, bool>> execute({
|
||||
required List<int> ids,
|
||||
String? startTime,
|
||||
String? deviceId,
|
||||
}) async {
|
||||
final params = <String, dynamic>{
|
||||
'ids': ids,
|
||||
if (startTime != null) 'startTime': startTime,
|
||||
if (deviceId != null) 'deviceId': deviceId,
|
||||
};
|
||||
return await repository.startWorkOrder(params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user