一次大的提交
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class WorkOrderEntity extends Equatable {
|
||||
final int? id;
|
||||
final String? orderNo;
|
||||
final String? orderTitle;
|
||||
final int? sourceType;
|
||||
final int? orderType;
|
||||
final int? priorityLevel;
|
||||
final int? deviceId;
|
||||
final String? deviceName;
|
||||
final int? deviceType;
|
||||
final int? siteId;
|
||||
final String? siteName;
|
||||
final int? orgId;
|
||||
final int? assigneeId;
|
||||
final String? assigneeName;
|
||||
final String? collaboratorIds;
|
||||
final String? collaboratorNames;
|
||||
final String? planStartTime;
|
||||
final String? planEndTime;
|
||||
final String? deadlineTime;
|
||||
final String? actualStartTime;
|
||||
final String? actualEndTime;
|
||||
final int? orderStatus;
|
||||
final int? alarmId;
|
||||
final String? alarmNo;
|
||||
final String? taskDescription;
|
||||
final String? aiSuggestion;
|
||||
final String? requiredEquipment;
|
||||
final double? estimatedImpact;
|
||||
final String? handleResult;
|
||||
final String? handleRemark;
|
||||
|
||||
const WorkOrderEntity({
|
||||
this.id,
|
||||
this.orderNo,
|
||||
this.orderTitle,
|
||||
this.sourceType,
|
||||
this.orderType,
|
||||
this.priorityLevel,
|
||||
this.deviceId,
|
||||
this.deviceName,
|
||||
this.deviceType,
|
||||
this.siteId,
|
||||
this.siteName,
|
||||
this.orgId,
|
||||
this.assigneeId,
|
||||
this.assigneeName,
|
||||
this.collaboratorIds,
|
||||
this.collaboratorNames,
|
||||
this.planStartTime,
|
||||
this.planEndTime,
|
||||
this.deadlineTime,
|
||||
this.actualStartTime,
|
||||
this.actualEndTime,
|
||||
this.orderStatus,
|
||||
this.alarmId,
|
||||
this.alarmNo,
|
||||
this.taskDescription,
|
||||
this.aiSuggestion,
|
||||
this.requiredEquipment,
|
||||
this.estimatedImpact,
|
||||
this.handleResult,
|
||||
this.handleRemark,
|
||||
});
|
||||
|
||||
WorkOrderEntity copyWith({
|
||||
int? id,
|
||||
String? orderNo,
|
||||
String? orderTitle,
|
||||
int? sourceType,
|
||||
int? orderType,
|
||||
int? priorityLevel,
|
||||
int? deviceId,
|
||||
String? deviceName,
|
||||
int? deviceType,
|
||||
int? siteId,
|
||||
String? siteName,
|
||||
int? orgId,
|
||||
int? assigneeId,
|
||||
String? assigneeName,
|
||||
String? collaboratorIds,
|
||||
String? collaboratorNames,
|
||||
String? planStartTime,
|
||||
String? planEndTime,
|
||||
String? deadlineTime,
|
||||
String? actualStartTime,
|
||||
String? actualEndTime,
|
||||
int? orderStatus,
|
||||
int? alarmId,
|
||||
String? alarmNo,
|
||||
String? taskDescription,
|
||||
String? aiSuggestion,
|
||||
String? requiredEquipment,
|
||||
double? estimatedImpact,
|
||||
String? handleResult,
|
||||
String? handleRemark,
|
||||
}) {
|
||||
return WorkOrderEntity(
|
||||
id: id ?? this.id,
|
||||
orderNo: orderNo ?? this.orderNo,
|
||||
orderTitle: orderTitle ?? this.orderTitle,
|
||||
sourceType: sourceType ?? this.sourceType,
|
||||
orderType: orderType ?? this.orderType,
|
||||
priorityLevel: priorityLevel ?? this.priorityLevel,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
deviceName: deviceName ?? this.deviceName,
|
||||
deviceType: deviceType ?? this.deviceType,
|
||||
siteId: siteId ?? this.siteId,
|
||||
siteName: siteName ?? this.siteName,
|
||||
orgId: orgId ?? this.orgId,
|
||||
assigneeId: assigneeId ?? this.assigneeId,
|
||||
assigneeName: assigneeName ?? this.assigneeName,
|
||||
collaboratorIds: collaboratorIds ?? this.collaboratorIds,
|
||||
collaboratorNames: collaboratorNames ?? this.collaboratorNames,
|
||||
planStartTime: planStartTime ?? this.planStartTime,
|
||||
planEndTime: planEndTime ?? this.planEndTime,
|
||||
deadlineTime: deadlineTime ?? this.deadlineTime,
|
||||
actualStartTime: actualStartTime ?? this.actualStartTime,
|
||||
actualEndTime: actualEndTime ?? this.actualEndTime,
|
||||
orderStatus: orderStatus ?? this.orderStatus,
|
||||
alarmId: alarmId ?? this.alarmId,
|
||||
alarmNo: alarmNo ?? this.alarmNo,
|
||||
taskDescription: taskDescription ?? this.taskDescription,
|
||||
aiSuggestion: aiSuggestion ?? this.aiSuggestion,
|
||||
requiredEquipment: requiredEquipment ?? this.requiredEquipment,
|
||||
estimatedImpact: estimatedImpact ?? this.estimatedImpact,
|
||||
handleResult: handleResult ?? this.handleResult,
|
||||
handleRemark: handleRemark ?? this.handleRemark,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
orderNo,
|
||||
orderTitle,
|
||||
sourceType,
|
||||
orderType,
|
||||
priorityLevel,
|
||||
deviceId,
|
||||
deviceName,
|
||||
deviceType,
|
||||
siteId,
|
||||
siteName,
|
||||
orgId,
|
||||
assigneeId,
|
||||
assigneeName,
|
||||
collaboratorIds,
|
||||
collaboratorNames,
|
||||
planStartTime,
|
||||
planEndTime,
|
||||
deadlineTime,
|
||||
actualStartTime,
|
||||
actualEndTime,
|
||||
orderStatus,
|
||||
alarmId,
|
||||
alarmNo,
|
||||
taskDescription,
|
||||
aiSuggestion,
|
||||
requiredEquipment,
|
||||
estimatedImpact,
|
||||
handleResult,
|
||||
handleRemark,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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';
|
||||
|
||||
abstract class WorkOrderRepository {
|
||||
Future<Either<Failure, List<WorkOrderEntity>>> getWorkOrderList(
|
||||
Map<String, dynamic> params,
|
||||
);
|
||||
|
||||
Future<Either<Failure, WorkOrderEntity>> getWorkOrderDetail(int id);
|
||||
|
||||
Future<Either<Failure, bool>> dispatchWorkOrder(Map<String, dynamic> params);
|
||||
|
||||
Future<Either<Failure, bool>> suspendWorkOrder(int id);
|
||||
|
||||
Future<Either<Failure, bool>> completeWorkOrder(Map<String, dynamic> params);
|
||||
|
||||
Future<Either<Failure, bool>> startWorkOrder(Map<String, dynamic> params);
|
||||
}
|
||||
@@ -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