package com.evobms.project.vehicledata.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;

@Data
@ApiModel(value = "DeviceRealtimeDTO", description = "设备实时详情聚合")
public class DeviceRealtimeDTO {
    @ApiModelProperty(value = "设备ID", example = "EVO0001")
    private String deviceId;

    @ApiModelProperty(value = "系统状态（总电压/电流、SOC、单体/温度极值等）")
    private SystemStatusSection systemStatus;

    @ApiModelProperty(value = "故障信息(名称+时间)，暂无则为空数组")
    private List<NameValueDTO> faults;

    @ApiModelProperty(value = "运行状态（充放电状态、继电器、复位次数、采样电压等）")
    private RunStatusSection runStatus;

    @ApiModelProperty(value = "充电信息（AC/DC电压电流、停止码、阶段等）")
    private ChargeSection charge;

    @ApiModelProperty(value = "统计信息（循环次数、累计时长等）")
    private StatisticsSection statistics;

    @ApiModelProperty(value = "单体电压列表，name=通道名，value=电压值")
    private List<NameValueDTO> voltages;

    @ApiModelProperty(value = "单体温度列表，name=T序号，value=温度值")
    private List<NameValueDTO> temperatures;

    @ApiModelProperty(value = "单体电压折线图（默认RTP-1，最近24小时）")
    private List<LineSeriesDTO> voltageTrend;

    @ApiModelProperty(value = "单体温度折线图（默认T1，最近24小时）")
    private List<LineSeriesDTO> temperatureTrend;

    @ApiModelProperty(value = "整车总电压折线图（vehicle_data，最近24小时）")
    private List<LineSeriesDTO> totalVoltageTrend;
    @ApiModelProperty(value = "整车总电流折线图（vehicle_data，最近24小时）")
    private List<LineSeriesDTO> totalCurrentTrend;
    @ApiModelProperty(value = "整车 SOC 折线图（vehicle_data，最近24小时）")
    private List<LineSeriesDTO> socTrend;

    @Data
    public static class SystemStatusSection {
        @ApiModelProperty(value = "总电压(V)", example = "372.5")
        private BigDecimal totalVoltage;
        @ApiModelProperty(value = "总电流(A)", example = "-52.3")
        private BigDecimal totalCurrent;
        @ApiModelProperty(value = "SOC(%)", example = "95")
        private Integer soc;
        @ApiModelProperty(value = "SOH(%)，暂无数据时为空", example = "86")
        private Integer soh;
        @ApiModelProperty(value = "最高单体电压(V)", example = "5.0")
        private BigDecimal maxCellVoltage;
        @ApiModelProperty(value = "最高单体位置（子系统-单体序号）", example = "10-5")
        private String maxCellPos;
        @ApiModelProperty(value = "最低单体电压(V)", example = "2.0")
        private BigDecimal minCellVoltage;
        @ApiModelProperty(value = "最低单体位置（子系统-单体序号）", example = "15-3")
        private String minCellPos;
        @ApiModelProperty(value = "平均单体电压(V)", example = "3.7")
        private BigDecimal avgCellVoltage;
        @ApiModelProperty(value = "压差单体(V) = 最高-最低", example = "0.005")
        private BigDecimal voltageDiff;
        @ApiModelProperty(value = "最高温度(℃)", example = "25")
        private BigDecimal maxTemp;
        @ApiModelProperty(value = "最高温度位置（子系统-探针序号）", example = "4-2")
        private String maxTempPos;
        @ApiModelProperty(value = "最低温度(℃)", example = "20")
        private BigDecimal minTemp;
        @ApiModelProperty(value = "最低温度位置（子系统-探针序号）", example = "5-1")
        private String minTempPos;
        @ApiModelProperty(value = "平均温度(℃)", example = "22")
        private BigDecimal avgTemp;
        @ApiModelProperty(value = "温差单体(℃) = 最高-最低", example = "2")
        private BigDecimal tempDiff;
    }

    @Data
    public static class RunStatusSection {
        @ApiModelProperty(value = "充放电状态：1停车充电/2行驶充电/3未充电/4充电完成/254异常/255无效", example = "1")
        private Integer chargingStatus;
        @ApiModelProperty(value = "继电器状态（按位标识）", example = "5")
        private Long relayStatus;
        @ApiModelProperty(value = "ON/A+/CC 状态（按位标识）", example = "4")
        private Long onaaccStatus;
        @ApiModelProperty(value = "系统复位次数", example = "12")
        private Long resetCount;
        @ApiModelProperty(value = "电池循环次数", example = "345")
        private Long cycleCount;
        @ApiModelProperty(value = "2.5V采样电压(V)", example = "2.5")
        private BigDecimal sample25v;
        @ApiModelProperty(value = "5V采样电压(V)", example = "5.0")
        private BigDecimal sample5v;
    }

    @Data
    public static class ChargeSection {
        @ApiModelProperty(value = "慢充电流(A)", example = "7")
        private BigDecimal acChargeCurrent;
        @ApiModelProperty(value = "慢充电压(V)", example = "12")
        private BigDecimal acChargeVoltage;
        @ApiModelProperty(value = "快充电流(A)", example = "0")
        private BigDecimal dcChargeCurrent;
        @ApiModelProperty(value = "快充电压(V)", example = "52")
        private BigDecimal dcChargeVoltage;
        @ApiModelProperty(value = "本次充电时长(min)", example = "6")
        private Long chargeTime;
        @ApiModelProperty(value = "慢充停止码", example = "5")
        private Integer acStopCode;
        @ApiModelProperty(value = "快充停止码", example = "12")
        private Integer dcStopCode;
        @ApiModelProperty(value = "慢充CP值", example = "20")
        private Integer acCpValue;
        @ApiModelProperty(value = "慢充枪阻值", example = "5")
        private Integer acGunResistance;
        @ApiModelProperty(value = "充电阶段", example = "3")
        private Integer chargingStage;
        @ApiModelProperty(value = "慢充阶段", example = "2")
        private Integer acStage;
        @ApiModelProperty(value = "快充阶段", example = "1")
        private Integer dcStage;
    }

    @Data
    public static class StatisticsSection {
        @ApiModelProperty(value = "循环次数", example = "345")
        private Long cycleCount;
        @ApiModelProperty(value = "累计运行时间(小时)", example = "1233")
        private Long totalRunHours;
        @ApiModelProperty(value = "累计充电时间(小时)", example = "456")
        private Long totalChargeHours;
        @ApiModelProperty(value = "累计放电时间(小时)", example = "321")
        private Long totalDischargeHours;
    }
}
