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

import com.fasterxml.jackson.annotation.JsonFormat;
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>
 * 对应前端"静态网架评估"仪表盘，按4大模块分组。
 * 部分字段不在静态网架算法返回中（属于运行态指标或外部台账），以 null 预留。
 *
 * @author lsl
 * @since 2026-07-19
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ApiModel(description = "静态网架评估仪表盘")
public class StaticGridDashboardVO implements Serializable {

    private static final long serialVersionUID = 1L;

    // ============================================================
    // 基础信息
    // ============================================================

    @ApiModelProperty(value = "主表ID")
    private Long resultId;

    @ApiModelProperty(value = "批次ID")
    private String batchId;

    @ApiModelProperty(value = "区县ID（即运维单位ID maintOrgId）")
    private String countyId;

    @ApiModelProperty(value = "区县短标识")
    private String countySid;

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

    @ApiModelProperty(value = "计算时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "数据质量状态")
    private String dataQualityStatus;

    @ApiModelProperty(value = "数据完整率(%)\")")
    private BigDecimal dataQualityCompletenessRate;

    // ============================================================
    // 一、标准化网架
    // ============================================================

    @ApiModelProperty(value = "10kV接线标准化率(%)")
    private BigDecimal wiringStandardizationRate;

    @ApiModelProperty(value = "10kV主干线截面标准化率(%)")
    private BigDecimal mainTrunkSectionStandardizationRate;

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

    @ApiModelProperty(value = "停电时户数")
    private BigDecimal outageDurationHoursHouseholds;

    @ApiModelProperty(value = "线路N-1通过率(%)")
    private BigDecimal lineNMinus1PassRate;

    @ApiModelProperty(value = "站间无联络线路数")
    private Integer interSubstationNoConnectionCount;

    @ApiModelProperty(value = "馈线同母线联络数")
    private Integer sameBusInterconnectionIssueCount;

    @ApiModelProperty(value = "联络点过多线路数")
    private Integer excessiveTiePointFeederCount;

    @ApiModelProperty(value = "无联络/单辐射线路数")
    private Integer singleRadialFeederCount;

    @ApiModelProperty(value = "存在大分支馈线数")
    private Integer largeBranchFeederCount;

    @ApiModelProperty(value = "分段数不合理线路数")
    private Integer unreasonableSegmentCount;

    @ApiModelProperty(value = "主干线分段配变密集数")
    private Integer mainTrunkSegmentDenseCount;

    // ============================================================
    // 三、电压质量
    // ============================================================

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

    @ApiModelProperty(value = "供电半径过长线路数")
    private Integer supplyRadiusExceedFeederCount;

    @ApiModelProperty(value = "超长馈线数")
    private Integer extraLongFeederCount;

    // ============================================================
    // 四、供电能力
    // ============================================================

    @ApiModelProperty(value = "区域最大负载率(%)（预留，来自运行态指标）")
    private BigDecimal regionalMaxLoadRate;

    @ApiModelProperty(value = "区域平均负载率(%)（预留，来自运行态指标）")
    private BigDecimal regionalAvgLoadRate;

    @ApiModelProperty(value = "线路过载条数（预留，来自运行态指标）")
    private Integer lineOverloadCount;

    @ApiModelProperty(value = "主干线截面不匹配线路数")
    private Integer mainTrunkSectionMismatchCount;

    @ApiModelProperty(value = "线路装接容量超标准线路数")
    private Integer connectedCapacityExceedFeederCount;

    @ApiModelProperty(value = "负荷组容量异常数")
    private Integer loadGroupCapacityAnomalyCount;

    @ApiModelProperty(value = "综合线损率(%)（预留，来自运行态指标）")
    private BigDecimal comprehensiveLossRate;

    @ApiModelProperty(value = "功率因数合格率(%)（预留，来自运行态指标）")
    private BigDecimal powerFactorPassRate;

    // ============================================================
    // 问题详情列表
    // ============================================================

    @ApiModelProperty(value = "问题详情列表")
    private List<ProblemDetailItem> problemDetails;

    /**
     * 问题详情条目
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    @ApiModel(description = "问题详情条目")
    public static class ProblemDetailItem implements Serializable {

        private static final long serialVersionUID = 1L;

        @ApiModelProperty(value = "问题ID")
        private String problemId;

        @ApiModelProperty(value = "馈线ID")
        private String feederId;

        @ApiModelProperty(value = "分类名称")
        private String categoryName;

        @ApiModelProperty(value = "指标名称")
        private String metricName;

        @ApiModelProperty(value = "严重程度")
        private String severity;

        @ApiModelProperty(value = "对象类型")
        private String objectType;

        @ApiModelProperty(value = "实际值")
        private String actualValue;

        @ApiModelProperty(value = "问题描述")
        private String description;

        @ApiModelProperty(value = "整改建议")
        private String suggestion;
    }
}