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;
import java.util.List;

/**
 * 供电能力指标 VO
 * <p>
 * 从 fhzg_se_snapshot_detail 聚合（馈线保留1年），和中台T-2电压越限表完全独立
 * 今日馈线返回96点时序（折线图），变电站/区县只返回聚合值
 *
 * @author lsl
 * @since 2026-07-23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel(description = "供电能力指标")
public class SeCapacityDashboardVO implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

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

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

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

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

    @ApiModelProperty(value = "总事件次数")
    private Integer totalEventCount;

    // ============================================================
    // 今日馈线96点时序（仅馈线type=4+today时返回）
    // ============================================================

    @ApiModelProperty(value = "馈线负载率96点时序(仅馈线+今日)")
    private List<TimeSeriesPoint> loadRateSeries;

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class TimeSeriesPoint implements Serializable {
        private static final long serialVersionUID = 1L;
        @ApiModelProperty(value = "时间点 HH:mm")
        private String time;
        @ApiModelProperty(value = "负载率(%)")
        @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
        private BigDecimal loadRate;
        @ApiModelProperty(value = "电流(A)")
        @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
        private BigDecimal currentValue;
        @ApiModelProperty(value = "电压(kV)")
        @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
        private BigDecimal voltageValue;
        @ApiModelProperty(value = "有功功率(MW)")
        @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
        private BigDecimal activePower;
        @ApiModelProperty(value = "无功功率(MVar)")
        @JsonSerialize(using = BigDecimalSerializer.StripTrailingZerosSerializer.class)
        private BigDecimal reactivePower;
    }
}