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

import com.fasterxml.jackson.annotation.JsonFormat;
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;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 运行态指标仪表盘 VO（前端综合态势展示）
 * <p>
 * 对应前端“运行态指标”仪表盘，按 3 大模块分组：
 * 供电可靠性 / 电压质量 / 供电能力
 * <p>
 * 数据来源：
 * - t_indicator_result（算法 raw_response 解析）
 * - t_alarm_event（告警次数统计）
 * - SjztPwwyyqxtPrmPdrOutageMvDsService（停电时户数）
 * - 部分字段需新增数据源（标注 @pendingSource）
 *
 * @author lsl
 * @since 2026-07-21
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel(description = "运行态指标仪表盘")
public class IndicatorDashboardVO implements Serializable {

    private static final long serialVersionUID = 1L;

    // ============================================================
    // 基本信息
    // ============================================================

    @ApiModelProperty(value = "数据批次ID（t_indicator_result.id）")
    private Long indicatorResultId;

    @ApiModelProperty(value = "批次时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime batchTime;

    @ApiModelProperty(value = "区县名称")
    private String countyName;

    // ============================================================
    // 一、供电可靠性
    // ============================================================

    @ApiModelProperty(value = "停电时户数（今日）")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal outageHoursHouseholdsToday;

    @ApiModelProperty(value = "停电时户数（全年累计）")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal outageHoursHouseholdsYear;

    @ApiModelProperty(value = "平均停电时长（今日，单位：小时）")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal avgOutageDurationToday;

    @ApiModelProperty(value = "平均停电时长（全年，单位：小时）")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal avgOutageDurationYear;

    // ============================================================
    // 二、电压质量
    // ============================================================

    @ApiModelProperty(value = "IEC用户电压指数（预留，来源待定）")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal iecUserVoltageIndex;

    // --- 越上限 ---

    @ApiModelProperty(value = "越上限台区数-严重")
    private Integer overUpperLimitAreaSevere;

    @ApiModelProperty(value = "越上限台区数-一般")
    private Integer overUpperLimitAreaGeneral;

    @ApiModelProperty(value = "越上限户数-严重")
    private Integer overUpperLimitUserSevere;

    @ApiModelProperty(value = "越上限户数-一般")
    private Integer overUpperLimitUserGeneral;

    // --- 越下限 ---

    @ApiModelProperty(value = "越下限台区数-严重")
    private Integer belowLowerLimitAreaSevere;

    @ApiModelProperty(value = "越下限台区数-一般")
    private Integer belowLowerLimitAreaGeneral;

    @ApiModelProperty(value = "越下限户数-严重")
    private Integer belowLowerLimitUserSevere;

    @ApiModelProperty(value = "越下限户数-一般")
    private Integer belowLowerLimitUserGeneral;

    // ============================================================
    // 三、供电能力
    // ============================================================

    @ApiModelProperty(value = "区域最大负载率(%)")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal maxLoadRate;

    @ApiModelProperty(value = "区域平均负载率(%)")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal avgLoadRate;

    // --- 重过载事件 ---

    @ApiModelProperty(value = "重过载事件总次数")
    private Integer overloadEventTotal;

    @ApiModelProperty(value = "重载事件次数（黄色）")
    private Integer heavyLoadEventCount;

    @ApiModelProperty(value = "重载事件占比(%)")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal heavyLoadRate;

    @ApiModelProperty(value = "过载事件次数（红色）")
    private Integer overloadEventCount;

    @ApiModelProperty(value = "过载事件占比(%)")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal overloadRate;

    // --- 线损 ---

    @ApiModelProperty(value = "公线线损率(%)（预留，来源待定）")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal publicLineLossRate;

    @ApiModelProperty(value = "线损率(%)")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal lineLossRate;

    @ApiModelProperty(value = "台区线损达标率(%)（预留，来源待定）")
    @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
    private BigDecimal areaLineLossComplianceRate;
}
