package com.njcn.gather.system.dictionary.pojo.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author caozehui
 * @data 2024-12-12
 */
@Getter
public enum DictDataEnum {


    /**
     * 计划模式
     */
    DIGITAL("数字式", "Digital"),
    SIMULATE("模拟式", "Simulate"),
    CONTRAST("比对式", "Contrast"),


    /**
     * 数据处理原则
     */
    AT_WILL_VALUE("任意值", "At_Will_Value"),
    SECTION_VALUE("部分值", "Section_Value"),
    CP95_VALUE("cp95值", "Cp95_Value"),
    AVG_VALUE("平均值", "Avg_value"),
    Own_value("所有值", "Own_value"),

    /**
     * 字典树code
     */
    I2_50("谐波电流幅值", "I2-50"),
    SI_1_49("间谐波电流幅值", "SI_1-49"),
    P2_50("谐波有功功率", "P2-50")
    ;


    private final String name;
    private final String code;


    DictDataEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    public static String getMsgByValue(Integer name) {
        for (DictDataEnum state : DictDataEnum.values()) {
            if (state.getName().equals(name)) {
                return state.getCode();
            }
        }
        return null;
    }

    public static DictDataEnum getDictDataEnumByCode(String code) {
        for (DictDataEnum steadyIndicatorEnum : DictDataEnum.values()) {
            if (StringUtils.equals(code, steadyIndicatorEnum.getCode())) {
                return steadyIndicatorEnum;
            }
        }
        return null;
    }
}
