package llc.arma.fleet.monitor.presentation.model

import llc.arma.fleet.monitor.data.entity.MachineEntity
import llc.arma.fleet.monitor.data.entity.MachineStateCode
import llc.arma.fleet.monitor.data.entity.MachineStateDefinitionEntity
import llc.arma.fleet.monitor.data.entity.ReportFormat
import java.time.LocalDate
import java.time.OffsetDateTime

data class GenerateFleetDailyReportPayload(
    val date: LocalDate,
    val format: ReportFormat,
)

data class ReportFile(
    val fileName: String,
    val mimeType: String,
    val downloadUrl: String,
    val expiresAt: OffsetDateTime?,
)

data class FleetDailyReport(
    val date: LocalDate,
    val generatedAt: OffsetDateTime,
    val summary: FleetDailyReportSummary,
    val machines: List<FleetDailyReportMachineRow>,
    val history: List<FleetDailyReportHistoryRow>,
)

data class FleetDailyReportSummary(
    val totalMachines: Int,
    val boundMachines: Int,
    val unboundMachines: Int,
    val machinesWithMovement: Int,
    val machinesWithoutData: Int,
    val movingSeconds: Int,
    val engineOnSeconds: Int,
    val idleSeconds: Int,
    val noDataSeconds: Int,
    val stateChangesCount: Int,
)

data class FleetDailyReportMachineRow(
    val machine: MachineEntity,
    val movingSeconds: Int,
    val engineOnSeconds: Int,
    val idleSeconds: Int,
    val noDataSeconds: Int,
    val stateChangesCount: Int,
    val utilizationPercent: Int,
)

data class FleetDailyReportHistoryRow(
    val machine: MachineEntity,
    val startedAt: OffsetDateTime,
    val endedAt: OffsetDateTime?,
    val stateDefinition: MachineStateDefinitionEntity?,
    val stateCode: MachineStateCode?,
    val durationSeconds: Int,
)
