170 lines
4.1 KiB
Dart
170 lines
4.1 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
class HomeEntity extends Equatable {
|
|
final String plantName;
|
|
final double realTimePower;
|
|
final double todayGeneration;
|
|
final double equivalentHours;
|
|
final int pendingWorkOrders;
|
|
final WeatherInfo weather;
|
|
final int alarmCount;
|
|
final WorkOrderStats workOrderStats;
|
|
final List<PowerTrendPoint> powerTrendData;
|
|
final PlantOverview plantOverview;
|
|
|
|
const HomeEntity({
|
|
required this.plantName,
|
|
required this.realTimePower,
|
|
required this.todayGeneration,
|
|
required this.equivalentHours,
|
|
required this.pendingWorkOrders,
|
|
required this.weather,
|
|
required this.alarmCount,
|
|
required this.workOrderStats,
|
|
required this.powerTrendData,
|
|
required this.plantOverview,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
plantName,
|
|
realTimePower,
|
|
todayGeneration,
|
|
equivalentHours,
|
|
pendingWorkOrders,
|
|
weather,
|
|
alarmCount,
|
|
workOrderStats,
|
|
powerTrendData,
|
|
plantOverview,
|
|
];
|
|
}
|
|
|
|
class WeatherInfo extends Equatable {
|
|
final String condition;
|
|
final int tempMin;
|
|
final int tempMax;
|
|
final String windDirection;
|
|
final String windLevel;
|
|
|
|
const WeatherInfo({
|
|
required this.condition,
|
|
required this.tempMin,
|
|
required this.tempMax,
|
|
required this.windDirection,
|
|
required this.windLevel,
|
|
});
|
|
|
|
factory WeatherInfo.fromJson(Map<String, dynamic> json) {
|
|
return WeatherInfo(
|
|
condition: json['condition'] as String,
|
|
tempMin: json['tempMin'] as int,
|
|
tempMax: json['tempMax'] as int,
|
|
windDirection: json['windDirection'] as String,
|
|
windLevel: json['windLevel'] as String,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'condition': condition,
|
|
'tempMin': tempMin,
|
|
'tempMax': tempMax,
|
|
'windDirection': windDirection,
|
|
'windLevel': windLevel,
|
|
};
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [condition, tempMin, tempMax, windDirection, windLevel];
|
|
}
|
|
|
|
class WorkOrderStats extends Equatable {
|
|
final int pending;
|
|
final int processing;
|
|
final int pendingAcceptance;
|
|
|
|
const WorkOrderStats({
|
|
required this.pending,
|
|
required this.processing,
|
|
required this.pendingAcceptance,
|
|
});
|
|
|
|
factory WorkOrderStats.fromJson(Map<String, dynamic> json) {
|
|
return WorkOrderStats(
|
|
pending: json['pending'] as int,
|
|
processing: json['processing'] as int,
|
|
pendingAcceptance: json['pendingAcceptance'] as int,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'pending': pending,
|
|
'processing': processing,
|
|
'pendingAcceptance': pendingAcceptance,
|
|
};
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [pending, processing, pendingAcceptance];
|
|
}
|
|
|
|
class PowerTrendPoint extends Equatable {
|
|
final String time;
|
|
final double power;
|
|
|
|
const PowerTrendPoint({
|
|
required this.time,
|
|
required this.power,
|
|
});
|
|
|
|
factory PowerTrendPoint.fromJson(Map<String, dynamic> json) {
|
|
return PowerTrendPoint(
|
|
time: json['time'] as String,
|
|
power: (json['power'] as num).toDouble(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'time': time,
|
|
'power': power,
|
|
};
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [time, power];
|
|
}
|
|
|
|
class PlantOverview extends Equatable {
|
|
final double installedCapacity;
|
|
final String commissionDate;
|
|
final String backgroundImage;
|
|
|
|
const PlantOverview({
|
|
required this.installedCapacity,
|
|
required this.commissionDate,
|
|
this.backgroundImage = 'assets/images/carousel1.png',
|
|
});
|
|
|
|
factory PlantOverview.fromJson(Map<String, dynamic> json) {
|
|
return PlantOverview(
|
|
installedCapacity: (json['installedCapacity'] as num).toDouble(),
|
|
commissionDate: json['commissionDate'] as String,
|
|
backgroundImage: json['backgroundImage'] as String? ?? 'assets/images/carousel1.png',
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'installedCapacity': installedCapacity,
|
|
'commissionDate': commissionDate,
|
|
'backgroundImage': backgroundImage,
|
|
};
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [installedCapacity, commissionDate, backgroundImage];
|
|
}
|