ppm model improvement.
parent
0a8b3314ce
commit
2cd5777f55
@ -0,0 +1,421 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
import 'package:test_sa/extensions/context_extension.dart';
|
||||||
|
import 'package:test_sa/models/lookup.dart';
|
||||||
|
import 'package:test_sa/models/timer_model.dart';
|
||||||
|
|
||||||
|
class PlanPreventiveVisit {
|
||||||
|
String? id;
|
||||||
|
String? visitNo;
|
||||||
|
Asset? asset;
|
||||||
|
String? planNo;
|
||||||
|
String? planName;
|
||||||
|
String? nextPMDate;
|
||||||
|
String? assetName;
|
||||||
|
String? model;
|
||||||
|
String? manufacturer;
|
||||||
|
String? supplierName;
|
||||||
|
String? siteName;
|
||||||
|
String? buildingName;
|
||||||
|
String? floorName;
|
||||||
|
String? departmentName;
|
||||||
|
String? roomName;
|
||||||
|
String? fromDate;
|
||||||
|
String? toDate;
|
||||||
|
AssignedEmployee? assignedEmployee;
|
||||||
|
String? acutalDateOfVisit;
|
||||||
|
TypeOfService? typeOfService;
|
||||||
|
VisitStatus? visitStatus;
|
||||||
|
String? travelingHours;
|
||||||
|
String? comments;
|
||||||
|
int? executionTimeFrame;
|
||||||
|
Lookup? taskStatus;
|
||||||
|
String? deviceStatus;
|
||||||
|
Lookup? assetAvailability;
|
||||||
|
Lookup? safety;
|
||||||
|
String? engSignature;
|
||||||
|
String? nurseSignature;
|
||||||
|
List<PreventiveVisitChecklists>? preventiveVisitAttachments;
|
||||||
|
List<PreventiveVisitChecklists>? preventiveVisitCalibrations;
|
||||||
|
List<PreventiveVisitChecklists>? preventiveVisitChecklists;
|
||||||
|
List<PreventiveVisitChecklists>? preventiveVisitKits;
|
||||||
|
List<PreventiveVisitTimers>? preventiveVisitTimers;
|
||||||
|
List<PreventiveVisitChecklists>? preventiveVisitSuppliers;
|
||||||
|
TimerModel? tbsTimer = TimerModel();
|
||||||
|
|
||||||
|
PlanPreventiveVisit(
|
||||||
|
{this.id,
|
||||||
|
this.visitNo,
|
||||||
|
this.asset,
|
||||||
|
this.planNo,
|
||||||
|
this.planName,
|
||||||
|
this.nextPMDate,
|
||||||
|
this.assetName,
|
||||||
|
this.model,
|
||||||
|
this.manufacturer,
|
||||||
|
this.supplierName,
|
||||||
|
this.siteName,
|
||||||
|
this.buildingName,
|
||||||
|
this.floorName,
|
||||||
|
this.departmentName,
|
||||||
|
this.roomName,
|
||||||
|
this.fromDate,
|
||||||
|
this.toDate,
|
||||||
|
this.assignedEmployee,
|
||||||
|
this.acutalDateOfVisit,
|
||||||
|
this.typeOfService,
|
||||||
|
this.visitStatus,
|
||||||
|
this.travelingHours,
|
||||||
|
this.comments,
|
||||||
|
this.executionTimeFrame,
|
||||||
|
this.taskStatus,
|
||||||
|
this.deviceStatus,
|
||||||
|
this.assetAvailability,
|
||||||
|
this.safety,
|
||||||
|
this.engSignature,
|
||||||
|
this.nurseSignature,
|
||||||
|
this.preventiveVisitAttachments,
|
||||||
|
this.preventiveVisitCalibrations,
|
||||||
|
this.preventiveVisitChecklists,
|
||||||
|
this.preventiveVisitKits,
|
||||||
|
this.preventiveVisitTimers,
|
||||||
|
this.preventiveVisitSuppliers});
|
||||||
|
|
||||||
|
PlanPreventiveVisit.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
visitNo = json['visitNo'];
|
||||||
|
asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : null;
|
||||||
|
planNo = json['planNo'];
|
||||||
|
planName = json['planName'];
|
||||||
|
nextPMDate = json['nextPMDate'];
|
||||||
|
assetName = json['assetName'];
|
||||||
|
model = json['model'];
|
||||||
|
manufacturer = json['manufacturer'];
|
||||||
|
supplierName = json['supplierName'];
|
||||||
|
siteName = json['siteName'];
|
||||||
|
buildingName = json['buildingName'];
|
||||||
|
floorName = json['floorName'];
|
||||||
|
departmentName = json['departmentName'];
|
||||||
|
roomName = json['roomName'];
|
||||||
|
fromDate = json['fromDate'];
|
||||||
|
toDate = json['toDate'];
|
||||||
|
assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : null;
|
||||||
|
acutalDateOfVisit = json['acutalDateOfVisit'];
|
||||||
|
typeOfService = json['typeOfService'] != null ? new TypeOfService.fromJson(json['typeOfService']) : null;
|
||||||
|
visitStatus = json['visitStatus'] != null ? new VisitStatus.fromJson(json['visitStatus']) : null;
|
||||||
|
travelingHours = json['travelingHours'];
|
||||||
|
comments = json['comments'];
|
||||||
|
executionTimeFrame = json['executionTimeFrame'];
|
||||||
|
taskStatus = json['taskStatus'];
|
||||||
|
deviceStatus = json['deviceStatus'];
|
||||||
|
assetAvailability = json['assetAvailability'];
|
||||||
|
safety = json['safety'];
|
||||||
|
engSignature = json['engSignature'];
|
||||||
|
nurseSignature = json['nurseSignature'];
|
||||||
|
if (json['preventiveVisitAttachments'] != null) {
|
||||||
|
preventiveVisitAttachments = <PreventiveVisitChecklists>[];
|
||||||
|
json['preventiveVisitAttachments'].forEach((v) {
|
||||||
|
preventiveVisitAttachments!.add(PreventiveVisitChecklists.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (json['preventiveVisitCalibrations'] != null) {
|
||||||
|
preventiveVisitCalibrations = <PreventiveVisitChecklists>[];
|
||||||
|
json['preventiveVisitCalibrations'].forEach((v) {
|
||||||
|
preventiveVisitCalibrations!.add(new PreventiveVisitChecklists.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (json['preventiveVisitChecklists'] != null) {
|
||||||
|
preventiveVisitChecklists = <PreventiveVisitChecklists>[];
|
||||||
|
json['preventiveVisitChecklists'].forEach((v) {
|
||||||
|
preventiveVisitChecklists!.add(new PreventiveVisitChecklists.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (json['preventiveVisitKits'] != null) {
|
||||||
|
preventiveVisitKits = <PreventiveVisitChecklists>[];
|
||||||
|
json['preventiveVisitKits'].forEach((v) {
|
||||||
|
preventiveVisitKits!.add(new PreventiveVisitChecklists.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (json['preventiveVisitTimers'] != null) {
|
||||||
|
preventiveVisitTimers = <PreventiveVisitTimers>[];
|
||||||
|
json['preventiveVisitTimers'].forEach((v) {
|
||||||
|
preventiveVisitTimers!.add(new PreventiveVisitTimers.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (json['preventiveVisitSuppliers'] != null) {
|
||||||
|
preventiveVisitSuppliers = <PreventiveVisitChecklists>[];
|
||||||
|
json['preventiveVisitSuppliers'].forEach((v) {
|
||||||
|
preventiveVisitSuppliers!.add(new PreventiveVisitChecklists.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['visitNo'] = this.visitNo;
|
||||||
|
if (this.asset != null) {
|
||||||
|
data['asset'] = this.asset!.toJson();
|
||||||
|
}
|
||||||
|
data['planNo'] = this.planNo;
|
||||||
|
data['planName'] = this.planName;
|
||||||
|
data['nextPMDate'] = this.nextPMDate;
|
||||||
|
data['assetName'] = this.assetName;
|
||||||
|
data['model'] = this.model;
|
||||||
|
data['manufacturer'] = this.manufacturer;
|
||||||
|
data['supplierName'] = this.supplierName;
|
||||||
|
data['siteName'] = this.siteName;
|
||||||
|
data['buildingName'] = this.buildingName;
|
||||||
|
data['floorName'] = this.floorName;
|
||||||
|
data['departmentName'] = this.departmentName;
|
||||||
|
data['roomName'] = this.roomName;
|
||||||
|
data['fromDate'] = this.fromDate;
|
||||||
|
data['toDate'] = this.toDate;
|
||||||
|
if (this.assignedEmployee != null) {
|
||||||
|
data['assignedEmployee'] = this.assignedEmployee!.toJson();
|
||||||
|
}
|
||||||
|
data['acutalDateOfVisit'] = this.acutalDateOfVisit;
|
||||||
|
if (this.typeOfService != null) {
|
||||||
|
data['typeOfService'] = this.typeOfService!.toJson();
|
||||||
|
}
|
||||||
|
if (this.visitStatus != null) {
|
||||||
|
data['visitStatus'] = this.visitStatus!.toJson();
|
||||||
|
}
|
||||||
|
data['travelingHours'] = this.travelingHours;
|
||||||
|
data['comments'] = this.comments;
|
||||||
|
data['executionTimeFrame'] = this.executionTimeFrame;
|
||||||
|
data['taskStatus'] = this.taskStatus;
|
||||||
|
data['deviceStatus'] = this.deviceStatus;
|
||||||
|
data['assetAvailability'] = this.assetAvailability;
|
||||||
|
data['safety'] = this.safety;
|
||||||
|
data['engSignature'] = this.engSignature;
|
||||||
|
data['nurseSignature'] = this.nurseSignature;
|
||||||
|
if (this.preventiveVisitAttachments != null) {
|
||||||
|
data['preventiveVisitAttachments'] = this.preventiveVisitAttachments!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.preventiveVisitCalibrations != null) {
|
||||||
|
data['preventiveVisitCalibrations'] = this.preventiveVisitCalibrations!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.preventiveVisitChecklists != null) {
|
||||||
|
data['preventiveVisitChecklists'] = this.preventiveVisitChecklists!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.preventiveVisitKits != null) {
|
||||||
|
data['preventiveVisitKits'] = this.preventiveVisitKits!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.preventiveVisitTimers != null) {
|
||||||
|
data['preventiveVisitTimers'] = this.preventiveVisitTimers!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.preventiveVisitSuppliers != null) {
|
||||||
|
data['preventiveVisitSuppliers'] = this.preventiveVisitSuppliers!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isLocalUrl(String url) {
|
||||||
|
if (url.isEmpty != false) return false;
|
||||||
|
return url.startsWith("/") || url.startsWith("file://") || url.substring(1).startsWith(':\\');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> validate(BuildContext context) async {
|
||||||
|
if (visitStatus?.id == null) {
|
||||||
|
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.status}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (acutalDateOfVisit == null) {
|
||||||
|
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.actualDate}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// if (expectedDate == null) {
|
||||||
|
// await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.visitDate}");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
if (tbsTimer?.startAt == null) {
|
||||||
|
await Fluttertoast.showToast(msg: "Working Hours Required");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (tbsTimer?.endAt == null) {
|
||||||
|
await Fluttertoast.showToast(msg: "Please Stop The Timer");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (externalEngineerTimer?.startAt != null && externalEngineerTimer?.endAt == null) {
|
||||||
|
// await Fluttertoast.showToast(msg: "Please Stop External Engineer Timer");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeEmptyObjects() {
|
||||||
|
// if (vCalibrationTools?.isNotEmpty ?? false) vCalibrationTools!.removeWhere((element) => element.assetId == null && element.calibrationDateOfTesters == null);
|
||||||
|
// if (vKits?.isNotEmpty ?? false) vKits!.removeWhere((element) => element.partName == null && element.partNumber == null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Asset {
|
||||||
|
int? id;
|
||||||
|
String? assetNumber;
|
||||||
|
String? assetSerialNo;
|
||||||
|
|
||||||
|
Asset({this.id, this.assetNumber, this.assetSerialNo});
|
||||||
|
|
||||||
|
Asset.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
assetNumber = json['assetNumber'];
|
||||||
|
assetSerialNo = json['assetSerialNo'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['assetNumber'] = this.assetNumber;
|
||||||
|
data['assetSerialNo'] = this.assetSerialNo;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AssignedEmployee {
|
||||||
|
String? userId;
|
||||||
|
String? userName;
|
||||||
|
String? email;
|
||||||
|
String? employeeId;
|
||||||
|
int? languageId;
|
||||||
|
|
||||||
|
AssignedEmployee({this.userId, this.userName, this.email, this.employeeId, this.languageId});
|
||||||
|
|
||||||
|
AssignedEmployee.fromJson(Map<String, dynamic> json) {
|
||||||
|
userId = json['userId'];
|
||||||
|
userName = json['userName'];
|
||||||
|
email = json['email'];
|
||||||
|
employeeId = json['employeeId'];
|
||||||
|
languageId = json['languageId'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['userId'] = this.userId;
|
||||||
|
data['userName'] = this.userName;
|
||||||
|
data['email'] = this.email;
|
||||||
|
data['employeeId'] = this.employeeId;
|
||||||
|
data['languageId'] = this.languageId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TypeOfService {
|
||||||
|
int? id;
|
||||||
|
String? name;
|
||||||
|
int? value;
|
||||||
|
|
||||||
|
TypeOfService({this.id, this.name, this.value});
|
||||||
|
|
||||||
|
TypeOfService.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
name = json['name'];
|
||||||
|
value = json['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['name'] = this.name;
|
||||||
|
data['value'] = this.value;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class VisitStatus {
|
||||||
|
int? id;
|
||||||
|
String? name;
|
||||||
|
int? value;
|
||||||
|
|
||||||
|
VisitStatus({this.id, this.name, this.value});
|
||||||
|
|
||||||
|
VisitStatus.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
name = json['name'];
|
||||||
|
value = json['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['name'] = this.name;
|
||||||
|
data['value'] = this.value;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PreventiveVisitChecklists {
|
||||||
|
int? id;
|
||||||
|
String? taskStatus;
|
||||||
|
String? taskComment;
|
||||||
|
String? measuredValue;
|
||||||
|
InstructionText? instructionText;
|
||||||
|
|
||||||
|
PreventiveVisitChecklists({this.id, this.taskStatus, this.taskComment, this.measuredValue, this.instructionText});
|
||||||
|
|
||||||
|
PreventiveVisitChecklists.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
taskStatus = json['taskStatus'];
|
||||||
|
taskComment = json['taskComment'];
|
||||||
|
measuredValue = json['measuredValue'];
|
||||||
|
instructionText = json['instructionText'] != null ? new InstructionText.fromJson(json['instructionText']) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['taskStatus'] = this.taskStatus;
|
||||||
|
data['taskComment'] = this.taskComment;
|
||||||
|
data['measuredValue'] = this.measuredValue;
|
||||||
|
if (this.instructionText != null) {
|
||||||
|
data['instructionText'] = this.instructionText!.toJson();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class InstructionText {
|
||||||
|
int? id;
|
||||||
|
String? text;
|
||||||
|
|
||||||
|
InstructionText({this.id, this.text});
|
||||||
|
|
||||||
|
InstructionText.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
text = json['text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['text'] = this.text;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PreventiveVisitTimers {
|
||||||
|
int? id;
|
||||||
|
String? startDateTime;
|
||||||
|
String? endDateTime;
|
||||||
|
double? workingHours;
|
||||||
|
|
||||||
|
PreventiveVisitTimers({this.id, this.startDateTime, this.endDateTime, this.workingHours});
|
||||||
|
|
||||||
|
PreventiveVisitTimers.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
startDateTime = json['startDateTime'];
|
||||||
|
endDateTime = json['endDateTime'];
|
||||||
|
workingHours = json['workingHours'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['id'] = id;
|
||||||
|
data['startDateTime'] = startDateTime;
|
||||||
|
data['endDateTime'] = endDateTime;
|
||||||
|
data['workingHours'] = workingHours;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue