|
|
|
|
@ -17,6 +17,7 @@ class ServiceReport {
|
|
|
|
|
DateTime startDate;
|
|
|
|
|
Lookup assetType;
|
|
|
|
|
Lookup callLastSituation;
|
|
|
|
|
Lookup currentSituation;
|
|
|
|
|
Lookup repairLocation;
|
|
|
|
|
Engineer engineer;
|
|
|
|
|
Lookup equipmentStatus;
|
|
|
|
|
@ -25,7 +26,7 @@ class ServiceReport {
|
|
|
|
|
int faultDescriptionId;
|
|
|
|
|
String workPreformed;
|
|
|
|
|
|
|
|
|
|
//String workHours;
|
|
|
|
|
num workingHours;
|
|
|
|
|
double travelingHours;
|
|
|
|
|
String invoiceNumber;
|
|
|
|
|
String invoiceCode;
|
|
|
|
|
@ -40,7 +41,7 @@ class ServiceReport {
|
|
|
|
|
String comment;
|
|
|
|
|
Uint8List localNurseSignature;
|
|
|
|
|
Uint8List localEngineerSignature;
|
|
|
|
|
int travelingExpense;
|
|
|
|
|
num travelingExpense;
|
|
|
|
|
String reviewComment;
|
|
|
|
|
FaultDescription faultDescription;
|
|
|
|
|
|
|
|
|
|
@ -52,7 +53,7 @@ class ServiceReport {
|
|
|
|
|
this.equipmentStatus,
|
|
|
|
|
this.type,
|
|
|
|
|
this.faultDescriptionId,
|
|
|
|
|
//this.workHours,
|
|
|
|
|
this.workingHours,
|
|
|
|
|
this.travelingHours,
|
|
|
|
|
this.parts,
|
|
|
|
|
this.engineer,
|
|
|
|
|
@ -60,6 +61,7 @@ class ServiceReport {
|
|
|
|
|
this.reason,
|
|
|
|
|
this.operatingHours,
|
|
|
|
|
this.callLastSituation,
|
|
|
|
|
this.currentSituation,
|
|
|
|
|
this.jobSheetNumber,
|
|
|
|
|
this.image,
|
|
|
|
|
this.device,
|
|
|
|
|
@ -83,7 +85,7 @@ class ServiceReport {
|
|
|
|
|
if (id != null) _map["id"] = id;
|
|
|
|
|
if (visitDate != null) _map["visitDate"] = visitDate.toIso8601String();
|
|
|
|
|
//if(serviceType != null) _map["service_type"] = serviceType.id.toString();
|
|
|
|
|
if (equipmentStatus != null) _map["status"] = equipmentStatus?.toMap();
|
|
|
|
|
if (equipmentStatus != null) _map["equipmentStatus"] = equipmentStatus?.toMap();
|
|
|
|
|
if (type != null) _map["typeOfWO"] = type?.toMap();
|
|
|
|
|
if (assetType != null) _map["TypeOfWO"] = assetType?.toMap();
|
|
|
|
|
//if(faultDescriptionId != null && faultDescriptionId.isNotEmpty) _map["fault_description"] = faultDescriptionId;
|
|
|
|
|
@ -93,17 +95,19 @@ class ServiceReport {
|
|
|
|
|
_map["endofWorkTime"] = (timer.endAt ?? DateTime.now()).toIso8601String();
|
|
|
|
|
_map["workingHours"] = (timer.durationInSecond / 60 / 60).toStringAsFixed(5);
|
|
|
|
|
}
|
|
|
|
|
if (travelingHours != null && travelingHours.toString().isNotEmpty) _map["traveling_hours"] = travelingHours;
|
|
|
|
|
if (travelingHours != null && travelingHours.toString().isNotEmpty) _map["travelingHours"] = travelingHours;
|
|
|
|
|
// if(workPreformed != null && workPreformed.isNotEmpty){
|
|
|
|
|
// _map["faultDescription"] = {
|
|
|
|
|
// //"id":faultDescriptionId ?? 0,
|
|
|
|
|
// "id":faultDescriptionId ?? 0,
|
|
|
|
|
// "workPerformed":workPreformed
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
if (travelingHours != null) _map["traveling_hours"] = travelingHours;
|
|
|
|
|
if (workPreformed != null && workPreformed.isNotEmpty) {
|
|
|
|
|
_map["faultDescription"] = faultDescription.toJson();
|
|
|
|
|
}
|
|
|
|
|
_map["faultDescription"] = {"id": faultDescription?.id ?? 0, "workPerformed": faultDescription?.workPerformed};
|
|
|
|
|
if (travelingHours != null) _map["travelingHours"] = travelingHours;
|
|
|
|
|
// if (workingHours != null) _map["workingHours"] = workingHours;
|
|
|
|
|
// if (workPreformed != null && workPreformed.isNotEmpty) {
|
|
|
|
|
// _map["faultDescription"] = faultDescription.toJson();
|
|
|
|
|
// }
|
|
|
|
|
if (jobSheetNumber != null && jobSheetNumber.isNotEmpty) _map["job_sheet_no"] = jobSheetNumber;
|
|
|
|
|
if (parts != null && parts.isNotEmpty) {
|
|
|
|
|
_map["sparePartsWorkOrders"] = parts.map((e) => e.toJson()).toList();
|
|
|
|
|
@ -122,6 +126,7 @@ class ServiceReport {
|
|
|
|
|
if (reason != null) _map["reason"] = reason.toMap();
|
|
|
|
|
//if(operatingHours != null && operatingHours.isNotEmpty) _map["operation_hours"] = operatingHours;
|
|
|
|
|
if (callLastSituation != null) _map["calllastSituation"] = callLastSituation.toMap();
|
|
|
|
|
if (currentSituation != null) _map["currentSituation"] = currentSituation.toMap();
|
|
|
|
|
//if(image != null) _map["image"] = image;
|
|
|
|
|
//if(invoiceCode != null) _map["invoice_no"] = invoiceCode;
|
|
|
|
|
//if(invoiceNumber != null) _map["invoice_code"] = invoiceNumber;
|
|
|
|
|
@ -133,15 +138,20 @@ class ServiceReport {
|
|
|
|
|
_map["nurseSignature"] = signatureNurse;
|
|
|
|
|
_map["engSignature"] = signatureEngineer;
|
|
|
|
|
_map["comment"] = comment;
|
|
|
|
|
_map["travelingExpense"] = travelingExpense;
|
|
|
|
|
_map["startofWorkTime"] = startDate;
|
|
|
|
|
_map["endofWorkTime"] = endDate;
|
|
|
|
|
_map["travelingExpenses"] = travelingExpense;
|
|
|
|
|
_map["startofWorkTime"] = startDate.toIso8601String();
|
|
|
|
|
_map["endofWorkTime"] = endDate.toIso8601String();
|
|
|
|
|
_map["workingHours"] = endDate?.difference(startDate)?.inHours ?? 0;
|
|
|
|
|
_map["reviewComment"] = reviewComment;
|
|
|
|
|
return _map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool validate() {
|
|
|
|
|
print("visitDate:$visitDate");
|
|
|
|
|
print("equipmentStatus:$equipmentStatus");
|
|
|
|
|
print("callLastSituation:${callLastSituation.toMap()}");
|
|
|
|
|
print("parts:$parts");
|
|
|
|
|
print("reason:${reason.toMap()}");
|
|
|
|
|
if (visitDate == null) return false;
|
|
|
|
|
//if(serviceType == null) return false;
|
|
|
|
|
if (equipmentStatus == null) return false;
|
|
|
|
|
@ -174,27 +184,34 @@ class ServiceReport {
|
|
|
|
|
id: id,
|
|
|
|
|
assetType: Lookup.fromJson(parsedJson["assetType"]),
|
|
|
|
|
callLastSituation: Lookup.fromJson(parsedJson["calllastSituation"]),
|
|
|
|
|
currentSituation: Lookup.fromJson(parsedJson["currentSituation"]),
|
|
|
|
|
repairLocation: Lookup.fromJson(parsedJson["repairLocation"]),
|
|
|
|
|
reason: Lookup.fromJson(parsedJson["reason"]),
|
|
|
|
|
equipmentStatus: Lookup.fromJson(parsedJson["status"]),
|
|
|
|
|
equipmentStatus: Lookup.fromJson(parsedJson["equipmentStatus"]),
|
|
|
|
|
type: Lookup.fromJson(parsedJson["typeOfWO"]),
|
|
|
|
|
faultDescriptionId: parsedJson["fault_description"],
|
|
|
|
|
endDate: DateTime.tryParse(parsedJson["endofWorkTime"]),
|
|
|
|
|
faultDescription: parsedJson['faultDescription'] != null ? FaultDescription.fromJson(parsedJson['faultDescription']) : null,
|
|
|
|
|
|
|
|
|
|
// faultDescription: parsedJson["faultDescription"],
|
|
|
|
|
startDate: DateTime.tryParse(parsedJson["startofWorkTime"]?? ""),
|
|
|
|
|
endDate: DateTime.tryParse(parsedJson["endofWorkTime"]??""),
|
|
|
|
|
//invoiceCode: parsedJson["invoice_code"],
|
|
|
|
|
//invoiceNumber: parsedJson["invoice_no"],
|
|
|
|
|
//jobSheetNumber: parsedJson["job_sheet_no"],
|
|
|
|
|
operatingHours: parsedJson["workingHours"],
|
|
|
|
|
// workingHours: parsedJson["workingHours"],
|
|
|
|
|
engineer: Engineer.fromJson(parsedJson["assignedEmployee"]),
|
|
|
|
|
parts: _parts,
|
|
|
|
|
//quantity: parsedJson["nid"],
|
|
|
|
|
travelingHours: parsedJson["traveling_hours"],
|
|
|
|
|
travelingHours: parsedJson["travelingHours"],
|
|
|
|
|
travelingExpense: parsedJson["travelingExpenses"],
|
|
|
|
|
visitDate: DateTime.tryParse(parsedJson["visitDate"]),
|
|
|
|
|
//workHours: parsedJson["working_hours"],
|
|
|
|
|
workingHours: parsedJson["workingHours"],
|
|
|
|
|
timer: TimerModel(
|
|
|
|
|
startAt: DateTime.tryParse(parsedJson["startofWorkTime"]), endAt: DateTime.tryParse(parsedJson["endofWorkTime"]), durationInSecond: ((parsedJson["workingHours"] ?? 0) * 60 * 60).toInt()),
|
|
|
|
|
startAt: DateTime.tryParse(parsedJson["startofWorkTime"]??""), endAt: DateTime.tryParse(parsedJson["endofWorkTime"]??""), durationInSecond: ((parsedJson["workingHours"] ?? 0) * 60 * 60).toInt()),
|
|
|
|
|
//workPreformed: parsedJson["work_performed"],
|
|
|
|
|
device: Device.fromJson(parsedJson["callRequest"]["asset"]),
|
|
|
|
|
signatureNurse: URLs.getFileUrl(parsedJson["nurseSignature"]),
|
|
|
|
|
signatureEngineer: URLs.getFileUrl(parsedJson["engSignature"]),
|
|
|
|
|
comment: parsedJson['comment'],
|
|
|
|
|
reviewComment: parsedJson['reviewComment'],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|