package com.evobms.project.vehicledata.dto;

import java.math.BigDecimal;
import java.util.List;

import com.evobms.project.battery.domain.SubsystemTemperature;
import com.evobms.project.battery.domain.SubsystemVoltage;
import com.evobms.project.bms.domain.BmsChargeTemperature;
import com.evobms.project.bms.domain.BmsVoltageChannelData;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * One flattened history row aligned to vehicle_data time; other tables use latest snapshot at or before that time.
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "DeviceHistoryFlatRowDTO", description = "Device history flat row (same sources as realtime aggregate)")
public class DeviceHistoryFlatRowDTO {

    @ApiModelProperty("Device id")
    private String deviceId;

    @ApiModelProperty("vehicle_data primary key")
    private Long vehicleDataId;

    @ApiModelProperty("Point-in-time: business timestamp if present else create_time")
    private String pointTime;

    @ApiModelProperty("vehicle_data create_time")
    private String vehicleCreateTime;

    @ApiModelProperty("SOC percent")
    private Integer soc;
    @ApiModelProperty("Total voltage V")
    private BigDecimal totalVoltage;
    @ApiModelProperty("Total current A")
    private BigDecimal totalCurrent;
    @ApiModelProperty("Vehicle speed km/h")
    private BigDecimal vehicleSpeed;
    @ApiModelProperty("Total mileage km")
    private BigDecimal totalMileage;
    @ApiModelProperty("Charging status")
    private Integer chargingStatus;
    @ApiModelProperty("Vehicle status")
    private Integer vehicleStatus;
    @ApiModelProperty("Operation mode")
    private Integer operationMode;
    @ApiModelProperty("DC-DC status")
    private Integer dcdcStatus;
    @ApiModelProperty("Gear")
    private Integer gearPosition;
    @ApiModelProperty("Insulation resistance kOhm")
    private Integer insulationResistance;

    @ApiModelProperty("Max cell voltage V")
    private BigDecimal maxCellVoltage;
    @ApiModelProperty("Min cell voltage V")
    private BigDecimal minCellVoltage;
    @ApiModelProperty("Max temperature")
    private BigDecimal maxTempValue;
    @ApiModelProperty("Min temperature")
    private BigDecimal minTempValue;
    @ApiModelProperty("Max cell position subsystem-cell")
    private String maxCellPos;
    @ApiModelProperty("Min cell position")
    private String minCellPos;
    @ApiModelProperty("Max temp position subsystem-probe")
    private String maxTempPos;
    @ApiModelProperty("Min temp position")
    private String minTempPos;

    private Long relayStatus;
    private Long onaaccStatus;
    private Long resetCount;
    private Long cycleCount;
    private Long cellCount;
    private BigDecimal sample25v;
    private BigDecimal sample5v;
    private Integer tempSensorCount;

    private BigDecimal acChargeCurrent;
    private BigDecimal acChargeVoltage;
    private BigDecimal dcChargeCurrent;
    private BigDecimal dcChargeVoltage;
    private Long chargeTime;
    private Integer acStopCode;
    private Integer dcStopCode;
    private Integer acCpValue;
    private Integer acGunResistance;
    private Integer chargingStage;
    private Integer acStage;
    private Integer dcStage;

    private BigDecimal runtimeVehicleSpeed;
    private Long runtimeMileage;
    private BigDecimal systemVoltage;
    private BigDecimal systemCurrent;
    private Long runtimeInsulationResistance;
    private BigDecimal socMax;
    private BigDecimal socMin;
    private BigDecimal gpvVoltage;
    private Integer runStatus;
    private Integer powerStatus;

    private Long dischargeSop10s;
    private Long dischargeSop30s;
    private Long dischargeSop60s;
    private Long dischargeSopContinuous;
    private Long dischargeSopTotal;
    private Long regenSop10s;
    private Long regenSop30s;
    private Long regenSop60s;
    private Long regenSopContinuous;
    private Long regenSopTotal;
    private Long chargeSop;
    private Long acChargeSop;

    private BigDecimal longitude;
    private BigDecimal latitude;
    private Integer positioningStatus;

    @ApiModelProperty("Charge seat temperatures, latest per probe index 1-8 at point time")
    private List<BmsChargeTemperature> chargeTemperaturesAtPoint;

    @ApiModelProperty("Voltage channels, latest per type+index at point time")
    private List<BmsVoltageChannelData> voltageChannelsAtPoint;

    @ApiModelProperty("Per-subsystem voltage frame, latest per subsystem no at point time")
    private List<SubsystemVoltage> subsystemVoltagesAtPoint;

    @ApiModelProperty("Per-subsystem temperature frame, latest per subsystem no at point time")
    private List<SubsystemTemperature> subsystemTemperaturesAtPoint;

    @ApiModelProperty("Convenience: probe T1 deg C")
    private BigDecimal chargeSeatTemp1;

    @ApiModelProperty("Convenience: RTP channel 1 voltage")
    private BigDecimal rtp1Voltage;
}
