122 lines
4.1 KiB
Dart
122 lines
4.1 KiB
Dart
// lib/models/air_collection_data.dart
|
|
|
|
class AirCollectionData {
|
|
// Link to the original installation
|
|
String? installationRefID;
|
|
int? airManId; // The ID from the server database
|
|
|
|
// Collection Info
|
|
String? collectionDate;
|
|
String? collectionTime;
|
|
String? weather;
|
|
double? temperature;
|
|
String? powerFailure;
|
|
|
|
// PM10 Readings
|
|
double? pm10Flowrate;
|
|
String? pm10FlowrateResult;
|
|
String? pm10TotalTime;
|
|
String? pm10TotalTimeResult;
|
|
double? pm10Pressure;
|
|
String? pm10PressureResult;
|
|
double? pm10Vstd;
|
|
|
|
// PM2.5 Readings
|
|
double? pm25Flowrate;
|
|
String? pm25FlowrateResult;
|
|
String? pm25TotalTime;
|
|
String? pm25TotalTimeResult;
|
|
double? pm25Pressure;
|
|
String? pm25PressureResult;
|
|
double? pm25Vstd;
|
|
|
|
// General
|
|
String? remarks;
|
|
int? collectionUserId;
|
|
String? status;
|
|
|
|
AirCollectionData({
|
|
this.installationRefID,
|
|
this.airManId,
|
|
this.collectionDate,
|
|
this.collectionTime,
|
|
this.weather,
|
|
this.temperature,
|
|
this.powerFailure,
|
|
this.pm10Flowrate,
|
|
this.pm10FlowrateResult,
|
|
this.pm10TotalTime,
|
|
this.pm10TotalTimeResult,
|
|
this.pm10Pressure,
|
|
this.pm10PressureResult,
|
|
this.pm10Vstd,
|
|
this.pm25Flowrate,
|
|
this.pm25FlowrateResult,
|
|
this.pm25TotalTime,
|
|
this.pm25TotalTimeResult,
|
|
this.pm25Pressure,
|
|
this.pm25PressureResult,
|
|
this.pm25Vstd,
|
|
this.remarks,
|
|
this.collectionUserId,
|
|
this.status,
|
|
});
|
|
|
|
/// Creates a map for saving all data to local storage.
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'installationRefID': installationRefID,
|
|
'air_man_id': airManId,
|
|
'air_man_collection_date': collectionDate,
|
|
'air_man_collection_time': collectionTime,
|
|
'air_man_collection_weather': weather,
|
|
'air_man_collection_temperature': temperature,
|
|
'air_man_collection_power_failure': powerFailure,
|
|
'air_man_collection_pm10_flowrate': pm10Flowrate,
|
|
'air_man_collection_pm10_flowrate_result': pm10FlowrateResult,
|
|
'air_man_collection_pm10_total_time': pm10TotalTime,
|
|
'air_man_collection_total_time_result': pm10TotalTimeResult,
|
|
'air_man_collection_pm10_pressure': pm10Pressure,
|
|
'air_man_collection_pm10_pressure_result': pm10PressureResult,
|
|
'air_man_collection_pm10_vstd': pm10Vstd,
|
|
'air_man_collection_pm25_flowrate': pm25Flowrate,
|
|
'air_man_collection_pm25_flowrate_result': pm25FlowrateResult,
|
|
'air_man_collection_pm25_total_time': pm25TotalTime,
|
|
'air_man_collection_pm25_total_time_result': pm25TotalTimeResult,
|
|
'air_man_collection_pm25_pressure': pm25Pressure,
|
|
'air_man_collection_pm25_pressure_result': pm25PressureResult,
|
|
'air_man_collection_pm25_vstd': pm25Vstd,
|
|
'air_man_collection_remarks': remarks,
|
|
'status': status,
|
|
};
|
|
}
|
|
|
|
/// Creates a JSON map with keys that match the backend API.
|
|
Map<String, dynamic> toJson() {
|
|
// This method is now designed to match the API structure perfectly.
|
|
return {
|
|
'air_man_id': airManId,
|
|
'air_man_collection_date': collectionDate,
|
|
'air_man_collection_time': collectionTime,
|
|
'air_man_collection_weather': weather,
|
|
'air_man_collection_temperature': temperature,
|
|
'air_man_collection_power_failure': powerFailure,
|
|
'air_man_collection_pm10_flowrate': pm10Flowrate,
|
|
'air_man_collection_pm10_flowrate_result': pm10FlowrateResult,
|
|
'air_man_collection_pm10_total_time': pm10TotalTime,
|
|
'air_man_collection_total_time_result': pm10TotalTimeResult,
|
|
'air_man_collection_pm10_pressure': pm10Pressure,
|
|
'air_man_collection_pm10_pressure_result': pm10PressureResult,
|
|
'air_man_collection_pm10_vstd': pm10Vstd,
|
|
'air_man_collection_pm25_flowrate': pm25Flowrate,
|
|
'air_man_collection_pm25_flowrate_result': pm25FlowrateResult,
|
|
'air_man_collection_pm25_total_time': pm25TotalTime,
|
|
'air_man_collection_pm25_total_time_result': pm25TotalTimeResult,
|
|
'air_man_collection_pm25_pressure': pm25Pressure,
|
|
'air_man_collection_pm25_pressure_result': pm25PressureResult,
|
|
'air_man_collection_pm25_vstd': pm25Vstd,
|
|
'air_man_collection_remarks': remarks,
|
|
};
|
|
}
|
|
}
|