You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/models/new_models/task_request/task_request_model.dart

564 lines
18 KiB
Dart

import 'package:test_sa/models/base.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/building.dart';
import 'package:test_sa/models/new_models/floor.dart';
import 'package:test_sa/models/new_models/site.dart';
import 'package:test_sa/models/new_models/department.dart';
import 'package:test_sa/models/new_models/room_model.dart';
class TaskRequestModel {
final Data? data;
final String? message;
final String? title;
final String? innerMessage;
final int? responseCode;
final bool? isSuccess;
TaskRequestModel({
this.data,
this.message,
this.title,
this.innerMessage,
this.responseCode,
this.isSuccess,
});
factory TaskRequestModel.fromJson(Map<String, dynamic> json) => TaskRequestModel(
data: json['data'] != null ? Data.fromJson(json['data']) : null,
message: json['message'],
title: json['title'],
innerMessage: json['innerMessage'],
responseCode: json['responseCode'],
isSuccess: json['isSuccess'],
);
Map<String, dynamic> toJson() => {
'data': data?.toJson(),
'message': message,
'title': title,
'innerMessage': innerMessage,
'responseCode': responseCode,
'isSuccess': isSuccess,
};
}
class Data {
final int? id;
final String? taskJobNo;
final User? userCreated;
final List<TaskJobContactPerson>? taskJobContactPersons;
final TaskTypeModel? taskType;
final TaskJobStatus? taskJobStatus;
final dynamic asset;
final dynamic site;
final dynamic building;
final dynamic floor;
final dynamic department;
final dynamic room;
final String? callComment;
final List<TaskJobAttachment>? taskJobAttachments;
final User? assignedEngineer;
final List<dynamic>? taskJobAssistantEmployees;
final List<dynamic>? taskJobActivityEngineerTimers;
final List<TaskJobHistory>? taskJobHistories;
final BuildingData? installationBuilding;
final dynamic installationFloor;
final dynamic installationDepartment;
final String? serialNo;
final String? installationDate;
final dynamic completedAction;
final dynamic impactStatus;
final bool? isUserAcknowledge;
final dynamic typeOfAlert;
final dynamic riskLevel;
final dynamic resource;
final dynamic actionNeeded;
final dynamic alertNo;
final String? estimationDeliveryDate;
final dynamic reasonOfFSCA;
final dynamic correctiveActionDescription;
final User? evaluatorUser;
Data({
this.id,
this.taskJobNo,
this.userCreated,
this.taskJobContactPersons,
this.taskType,
this.taskJobStatus,
this.asset,
this.site,
this.building,
this.floor,
this.department,
this.room,
this.callComment,
this.taskJobAttachments,
this.assignedEngineer,
this.taskJobAssistantEmployees,
this.taskJobActivityEngineerTimers,
this.taskJobHistories,
this.installationBuilding,
this.installationFloor,
this.installationDepartment,
this.serialNo,
this.installationDate,
this.completedAction,
this.impactStatus,
this.isUserAcknowledge,
this.typeOfAlert,
this.riskLevel,
this.resource,
this.actionNeeded,
this.alertNo,
this.estimationDeliveryDate,
this.reasonOfFSCA,
this.correctiveActionDescription,
this.evaluatorUser,
});
factory Data.fromJson(Map<String, dynamic> json) => Data(
id: json['id'],
taskJobNo: json['taskJobNo'],
userCreated: json['userCreated'] != null ? User.fromJson(json['userCreated']) : null,
taskJobContactPersons: (json['taskJobContactPersons'] as List?)?.map((e) => TaskJobContactPerson.fromJson(e)).toList(),
taskType: json['taskType'] != null ? TaskTypeModel.fromJson(json['taskType']) : null,
taskJobStatus: json['taskJobStatus'] != null ? TaskJobStatus.fromJson(json['taskJobStatus']) : null,
asset: json['asset'],
site: json['site'],
building: json['building'],
floor: json['floor'],
department: json['department'],
room: json['room'],
callComment: json['callComment'],
taskJobAttachments: (json['taskJobAttachments'] as List?)?.map((e) => TaskJobAttachment.fromJson(e)).toList(),
assignedEngineer: json['assignedEngineer'] != null ? User.fromJson(json['assignedEngineer']) : null,
taskJobAssistantEmployees: json['taskJobAssistantEmployees'],
taskJobActivityEngineerTimers: json['taskJobActivityEngineerTimers'],
taskJobHistories: (json['taskJobHistories'] as List?)?.map((e) => TaskJobHistory.fromJson(e)).toList(),
installationBuilding: json['installationBuilding'] != null ? BuildingData.fromJson(json['installationBuilding']) : null,
installationFloor: json['installationFloor'],
installationDepartment: json['installationDepartment'],
serialNo: json['serialNo'],
installationDate: json['installationDate'],
completedAction: json['completedAction'],
impactStatus: json['impactStatus'],
isUserAcknowledge: json['isUserAcknowledge'],
typeOfAlert: json['typeOfAlert'],
riskLevel: json['riskLevel'],
resource: json['resource'],
actionNeeded: json['actionNeeded'],
alertNo: json['alertNo'],
estimationDeliveryDate: json['estimationDeliveryDate'],
reasonOfFSCA: json['reasonOfFSCA'],
correctiveActionDescription: json['correctiveActionDescription'],
evaluatorUser: json['evaluatorUser'] != null ? User.fromJson(json['evaluatorUser']) : null,
);
Map<String, dynamic> toJson() => {
'id': id,
'taskJobNo': taskJobNo,
'userCreated': userCreated?.toJson(),
'taskJobContactPersons': taskJobContactPersons?.map((e) => e.toJson()).toList(),
'taskType': taskType?.toJson(),
'taskJobStatus': taskJobStatus?.toJson(),
'asset': asset,
'site': site,
'building': building,
'floor': floor,
'department': department,
'room': room,
'callComment': callComment,
'taskJobAttachments': taskJobAttachments?.map((e) => e.toJson()).toList(),
'assignedEngineer': assignedEngineer?.toJson(),
'taskJobAssistantEmployees': taskJobAssistantEmployees,
'taskJobActivityEngineerTimers': taskJobActivityEngineerTimers,
'taskJobHistories': taskJobHistories?.map((e) => e.toJson()).toList(),
'installationBuilding': installationBuilding?.toJson(),
'installationFloor': installationFloor,
'installationDepartment': installationDepartment,
'serialNo': serialNo,
'installationDate': installationDate,
'completedAction': completedAction,
'impactStatus': impactStatus,
'isUserAcknowledge': isUserAcknowledge,
'typeOfAlert': typeOfAlert,
'riskLevel': riskLevel,
'resource': resource,
'actionNeeded': actionNeeded,
'alertNo': alertNo,
'estimationDeliveryDate': estimationDeliveryDate,
'reasonOfFSCA': reasonOfFSCA,
'correctiveActionDescription': correctiveActionDescription,
'evaluatorUser': evaluatorUser?.toJson(),
};
Map<String, dynamic> createTaskJson() => {
'id': id,
'taskJobNo': taskJobNo,
'userCreated': userCreated?.toJson(),
'taskJobContactPersons': taskJobContactPersons?.map((e) => e.toJson()).toList(),
'taskType': taskType?.toJson(),
'taskJobStatus': taskJobStatus?.toJson(),
'asset': asset,
'site': site,
'building': building,
'floor': floor,
'department': department,
'room': room,
'callComment': callComment,
'taskJobAttachments': taskJobAttachments?.map((e) => e.toJson()).toList(),
'assignedEngineer': assignedEngineer?.toJson(),
'taskJobAssistantEmployees': taskJobAssistantEmployees,
'taskJobActivityEngineerTimers': taskJobActivityEngineerTimers,
'taskJobHistories': taskJobHistories?.map((e) => e.toJson()).toList(),
'installationBuilding': installationBuilding?.toJson(),
'installationFloor': installationFloor,
'installationDepartment': installationDepartment,
'serialNo': serialNo,
'installationDate': installationDate,
'completedAction': completedAction,
'impactStatus': impactStatus,
'isUserAcknowledge': isUserAcknowledge,
'typeOfAlert': typeOfAlert,
'riskLevel': riskLevel,
'resource': resource,
'actionNeeded': actionNeeded,
'alertNo': alertNo,
'estimationDeliveryDate': estimationDeliveryDate,
'reasonOfFSCA': reasonOfFSCA,
'correctiveActionDescription': correctiveActionDescription,
'evaluatorUser': evaluatorUser?.toJson(),
};
}
class User {
final String? userId;
final String? userName;
final String? email;
final String? employeeId;
final int? languageId;
User({this.userId, this.userName, this.email, this.employeeId, this.languageId});
factory User.fromJson(Map<String, dynamic> json) => User(
userId: json['userId'],
userName: json['userName'],
email: json['email'],
employeeId: json['employeeId'],
languageId: json['languageId'],
);
Map<String, dynamic> toJson() => {
'userId': userId,
'userName': userName,
'email': email,
'employeeId': employeeId,
'languageId': languageId,
};
}
class TaskJobContactPerson {
final int? id;
final User? user;
TaskJobContactPerson({this.id, this.user});
factory TaskJobContactPerson.fromJson(Map<String, dynamic> json) => TaskJobContactPerson(
id: json['id'],
user: json['user'] != null ? User.fromJson(json['user']) : null,
);
Map<String, dynamic> toJson() => {
'id': id,
'user': user?.toJson(),
};
}
class TaskTypeModel {
final int? id;
final String? typeName;
final RelatedTo? relatedTo;
final bool? linkWithMultiAssets;
final List<dynamic>? taskTypeRoles;
final bool? isInstallation;
final bool? isRecallAndAlert;
TaskTypeModel({
this.id,
this.typeName,
this.relatedTo,
this.linkWithMultiAssets,
this.taskTypeRoles,
this.isInstallation,
this.isRecallAndAlert,
});
factory TaskTypeModel.fromJson(Map<String, dynamic> json) => TaskTypeModel(
id: json['id'],
typeName: json['typeName'],
relatedTo: json['relatedTo'] != null ? RelatedTo.fromJson(json['relatedTo']) : null,
linkWithMultiAssets: json['linkWithMultiAssets'],
taskTypeRoles: json['taskTypeRoles'],
isInstallation: json['isInstallation'],
isRecallAndAlert: json['isRecallAndAlert'],
);
Map<String, dynamic> toJson() => {
'id': id,
'typeName': typeName,
'relatedTo': relatedTo?.toJson(),
'linkWithMultiAssets': linkWithMultiAssets,
'taskTypeRoles': taskTypeRoles,
'isInstallation': isInstallation,
'isRecallAndAlert': isRecallAndAlert,
};
}
class RelatedTo {
final int? id;
final String? name;
final int? value;
RelatedTo({this.id, this.name, this.value});
factory RelatedTo.fromJson(Map<String, dynamic> json) => RelatedTo(
id: json['id'],
name: json['name'],
value: json['value'],
);
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'value': value,
};
}
class TaskJobStatus {
final int? id;
final String? name;
final int? value;
TaskJobStatus({this.id, this.name, this.value});
factory TaskJobStatus.fromJson(Map<String, dynamic> json) => TaskJobStatus(
id: json['id'],
name: json['name'],
value: json['value'],
);
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'value': value,
};
}
class TaskJobAttachment {
final int? id;
final String? name;
TaskJobAttachment({this.id, this.name});
factory TaskJobAttachment.fromJson(Map<String, dynamic> json) => TaskJobAttachment(
id: json['id'],
name: json['name'],
);
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
};
}
class TaskJobHistory {
final int? id;
final RelatedTo? action;
final TaskJobStatus? taskJobStatus;
final User? user;
final dynamic typeOfAlert;
final dynamic riskLevel;
final dynamic resource;
final dynamic actionNeeded;
final User? assignedEmployee;
final dynamic alertNo;
final String? estimationDeliveryDate;
final String? createdDate;
final BuildingData? installationBuilding;
final dynamic installationFloor;
final dynamic installationDepartment;
final String? installationDate;
final String? serialNo;
TaskJobHistory({
this.id,
this.action,
this.taskJobStatus,
this.user,
this.typeOfAlert,
this.riskLevel,
this.resource,
this.actionNeeded,
this.assignedEmployee,
this.alertNo,
this.estimationDeliveryDate,
this.createdDate,
this.installationBuilding,
this.installationFloor,
this.installationDepartment,
this.installationDate,
this.serialNo,
});
factory TaskJobHistory.fromJson(Map<String, dynamic> json) => TaskJobHistory(
id: json['id'],
action: json['action'] != null ? RelatedTo.fromJson(json['action']) : null,
taskJobStatus: json['taskJobStatus'] != null ? TaskJobStatus.fromJson(json['taskJobStatus']) : null,
user: json['user'] != null ? User.fromJson(json['user']) : null,
typeOfAlert: json['typeOfAlert'],
riskLevel: json['riskLevel'],
resource: json['resource'],
actionNeeded: json['actionNeeded'],
assignedEmployee: json['assignedEmployee'] != null ? User.fromJson(json['assignedEmployee']) : null,
alertNo: json['alertNo'],
estimationDeliveryDate: json['estimationDeliveryDate'],
createdDate: json['createdDate'],
installationBuilding: json['installationBuilding'] != null ? BuildingData.fromJson(json['installationBuilding']) : null,
installationFloor: json['installationFloor'],
installationDepartment: json['installationDepartment'],
installationDate: json['installationDate'],
serialNo: json['serialNo'],
);
Map<String, dynamic> toJson() => {
'id': id,
'action': action?.toJson(),
'taskJobStatus': taskJobStatus?.toJson(),
'user': user?.toJson(),
'typeOfAlert': typeOfAlert,
'riskLevel': riskLevel,
'resource': resource,
'actionNeeded': actionNeeded,
'assignedEmployee': assignedEmployee?.toJson(),
'alertNo': alertNo,
'estimationDeliveryDate': estimationDeliveryDate,
'createdDate': createdDate,
'installationBuilding': installationBuilding?.toJson(),
'installationFloor': installationFloor,
'installationDepartment': installationDepartment,
'installationDate': installationDate,
'serialNo': serialNo,
};
}
class BuildingData {
final int? id;
final String? name;
final int? value;
BuildingData({this.id, this.name, this.value});
factory BuildingData.fromJson(Map<String, dynamic> json) => BuildingData(
id: json['id'],
name: json['name'],
value: json['value'],
);
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'value': value,
};
}
class AddTaskModel {
int? id;
int? taskTypeId;
List<int>? assetIds = [];
Site? site;
Building? building;
Floor? floor;
Department? department;
Rooms? room;
String? callComment;
Lookup? typeOfAlert;
Lookup? riskLevel;
Lookup? resource;
Lookup? actionNeeded;
TaskEvaluatorUser? taskEvaluatorUser;
String? alertNo;
String? estimationDeliveryDate;
List<TaskJobAttachment>? attachments;
String? reasonOfFSCA;
String? correctiveActionDescription;
AddTaskModel({
this.id,
this.taskTypeId,
this.assetIds,
this.site,
this.building,
this.floor,
this.department,
this.room,
this.callComment,
this.typeOfAlert,
this.riskLevel,
this.resource,
this.actionNeeded,
this.alertNo,
this.estimationDeliveryDate,
this.attachments,
this.reasonOfFSCA,
this.taskEvaluatorUser,
this.correctiveActionDescription,
});
Map<String, dynamic> toJson() => {
'id': id,
'taskTypeId': taskTypeId,
'assetIds': assetIds ?? [],
'siteId': site?.id,
'buildingId': building?.id,
'floorId': floor?.id,
'departmentId': department?.id,
'roomId': room?.id,
'callComment': callComment,
'typeOfAlertId': typeOfAlert?.id,
'riskLevelId': riskLevel?.id,
'resourceId': resource?.id,
'actionNeededId': actionNeeded?.id,
'alertNo': alertNo,
'estimationDeliveryDate': estimationDeliveryDate,
'reasonOfFSCA': reasonOfFSCA,
'correctiveActionDescription': correctiveActionDescription,
'evaluatorUserId': taskEvaluatorUser?.userId,
'attachments': attachments?.map((x) => x.toJson()).toList(),
};
}
class TaskEvaluatorUser extends Base {
String? userId;
String? userName;
String? email;
String? employeeId;
int? languageId;
TaskEvaluatorUser({this.userId, this.userName, this.email, this.employeeId, this.languageId}) : super(name: userName, identifier: userId?.toString());
factory TaskEvaluatorUser.fromJson(Map<String, dynamic> json) {
return TaskEvaluatorUser(userId: json['userId'], userName: json['userName'], email: json['email'], employeeId: json['employeeId'], languageId: json['languageId']);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['userId'] = userId;
data['userName'] = userName;
data['email'] = email;
data['employeeId'] = employeeId;
data['languageId'] = languageId;
return data;
}
}