package com.njcn.gather.report.pojo.enums;

import lombok.Getter;

/**
 * 电能质量测试大项枚举
 *
 * @author hongawen
 * @version 1.0
 * @data 2025/3/27 18:29
 */
@Getter
public enum PowerIndexEnum {


    UNKNOWN("UNKNOWN", "未知指标"),
    LINE_TITLE("LINE_TITLE", "测量回路"),
    FREQ("FREQ", "频率"),
    V("V", "电压"),
    HV("HV", "谐波电压"),
    HI("HI", "谐波电流"),
    HP("HP", "谐波有功功率"),
    HSV("HSV", "间谐波电压"),
    HSI("HSI", "间谐波电流"),
    VOLTAGE("VOLTAGE", "电压暂降、暂升及短时中断"),
    I("I", "电流"),
    IMBV("IMBV", "负序电压不平衡度"),
    IMBA("IMBA", "负序电流不平衡度"),
    F("F", "短时电压闪变"),
    LF("LF", "长时电压闪变"),
    P("P", "功率"),
    ANGLE("Angle", "基波相位");

    private String key;

    private String desc;

    PowerIndexEnum(String key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    /**
     * 根据key找到适配的枚举
     *
     * @param key 枚举的key
     * @return 匹配的枚举实例，如果没有找到则返回null
     */
    public static PowerIndexEnum getByKey(String key) {
        for (PowerIndexEnum powerIndexEnum : PowerIndexEnum.values()) {
            if (powerIndexEnum.getKey().equalsIgnoreCase(key)) {
                return powerIndexEnum;
            }
        }
        return null;
    }
}
