package com.hdkj.lt.bf.entity.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.hdkj.lt.base.serializer.BigDecimalSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 电压质量指标 VO
 * <p>
 * 今日：从 fhzg_se_voltage_event 查（馈线+台区+用户），分条/台/户数(去重) + 次数(事件总数)
 * 历史（当月/全年）：从 ads_mrt_voltage_over_limit_daily_result 查（8维度×4级别=16字段）
 *
 * @author lsl
 * @since 2026-07-23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel(description = "电压质量指标")
public class SeVoltageDashboardVO implements Serializable {

    private static final long serialVersionUID = 1L;

    // ============================================================
    // 今日统计（从 voltage_event 表实时查）
    // 条数/台数/户数 = 去重的 deviceId
    // 次数 = 事件总条数
    // ============================================================

    // --- 越上限：线路 ---
    @ApiModelProperty(value = "越上限线路条数(去重)")
    private Integer overUpperFeederCount;
    @ApiModelProperty(value = "越上限线路事件次数")
    private Integer overUpperFeederTimes;

    // --- 越上限：台区 ---
    @ApiModelProperty(value = "越上限台区台数(去重)")
    private Integer overUpperAreaCount;
    @ApiModelProperty(value = "越上限台区事件次数")
    private Integer overUpperAreaTimes;

    // --- 越上限：用户 ---
    @ApiModelProperty(value = "越上限用户户数(去重)")
    private Integer overUpperConsumerCount;
    @ApiModelProperty(value = "越上限用户事件次数")
    private Integer overUpperConsumerTimes;

    // --- 越下限：线路 ---
    @ApiModelProperty(value = "越下限线路条数(去重)")
    private Integer overLowerFeederCount;
    @ApiModelProperty(value = "越下限线路事件次数")
    private Integer overLowerFeederTimes;

    // --- 越下限：台区 ---
    @ApiModelProperty(value = "越下限台区台数(去重)")
    private Integer overLowerAreaCount;
    @ApiModelProperty(value = "越下限台区事件次数")
    private Integer overLowerAreaTimes;

    // --- 越下限：用户 ---
    @ApiModelProperty(value = "越下限用户户数(去重)")
    private Integer overLowerConsumerCount;
    @ApiModelProperty(value = "越下限用户事件次数")
    private Integer overLowerConsumerTimes;

    @ApiModelProperty(value = "IEC 用户电压合格率(%)，如 98.93 表示合格率 98.93%")
    private BigDecimal iecIndex;

    // ============================================================
    // 历史（当月/全年，查中台T-2 ads_mrt_voltage_over_limit_daily_result）
    // 8维度 × 4级别
    // ============================================================
    // 维度: 台区(tg) / 用户(cust) / 馈线(feeder) / 母线(generatrix)
    // 级别: 越上限严重(overUpperSevere) / 越上限一般(overUpperMild)
    //       越下限严重(overLowerSevere) / 越下限一般(overLowerMild)

    // --- 越上限-严重 ---
    @ApiModelProperty(value = "越上限台区数-严重")
    private Integer overUpperSevereTgCount;
    @ApiModelProperty(value = "越上限户数-严重")
    private Integer overUpperSevereCustCount;
    @ApiModelProperty(value = "越上限馈线数-严重")
    private Integer overUpperSevereFeederCount;
    @ApiModelProperty(value = "越上限母线数-严重")
    private Integer overUpperSevereGeneratrixCount;

    // --- 越上限-一般 ---
    @ApiModelProperty(value = "越上限台区数-一般")
    private Integer overUpperMildTgCount;
    @ApiModelProperty(value = "越上限户数-一般")
    private Integer overUpperMildCustCount;
    @ApiModelProperty(value = "越上限馈线数-一般")
    private Integer overUpperMildFeederCount;
    @ApiModelProperty(value = "越上限母线数-一般")
    private Integer overUpperMildGeneratrixCount;

    // --- 越下限-严重 ---
    @ApiModelProperty(value = "越下限台区数-严重")
    private Integer overLowerSevereTgCount;
    @ApiModelProperty(value = "越下限户数-严重")
    private Integer overLowerSevereCustCount;
    @ApiModelProperty(value = "越下限馈线数-严重")
    private Integer overLowerSevereFeederCount;
    @ApiModelProperty(value = "越下限母线数-严重")
    private Integer overLowerSevereGeneratrixCount;

    // --- 越下限-一般 ---
    @ApiModelProperty(value = "越下限台区数-一般")
    private Integer overLowerMildTgCount;
    @ApiModelProperty(value = "越下限户数-一般")
    private Integer overLowerMildCustCount;
    @ApiModelProperty(value = "越下限馈线数-一般")
    private Integer overLowerMildFeederCount;
    @ApiModelProperty(value = "越下限母线数-一般")
    private Integer overLowerMildGeneratrixCount;

    @ApiModelProperty(value = "越限总时长(小时)")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal totalOverLimitHours;
}
