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

import lombok.Getter;

/**
 * 检测项模版枚举
 * @author hongawen
 * @version 1.0
 * @data 2025/3/27 10:24
 */
@Getter
public enum ItemReportKeyEnum {

    NAME("name", "检测项，比如：频率"),
    NAME_DETAIL("nameDetail", "检测项详细，比如：频率测量准确度"),
    INFLUENCE("influence", "影响量的描述，比如额定工作条件、谐波对电压的影响等等"),
    ERROR_SCOPE("errorScope", "误差范围，注：在段落中时需加上（），表格中无需添加"),
    A_ERROR_SCOPE("a_errorScope", "A级误差，比如：±0.1%Un\n(±0.05774)，需要换行，电压需要转为幅值"),
    NUM_OF_DATA("numOfData", "有效数据组数"),
    PHASE("phase", "相别"),
    ERROR_SCOPE_MAG("errorScopeMag", "特征幅值：误差范围"),
    ERROR_SCOPE_DUR("errorScopeDur", "持续时间：误差范围"),
    SCRIPT_DETAIL("scriptDetail", "脚本输出明细。比如：基波电压UN=57.74V，f=50Hz，谐波含有率Uh=10%UN=5.774V"),
    TIME("time", "次数"),
    STANDARD("standard", "标准值"),
    STANDARD_A("standardA", "A相标准值"),
    STANDARD_B("standardB", "B相标准值"),
    STANDARD_C("standardC", "C相标准值"),
    STANDARD_MAG("standardMag", "特征幅值的标准值"),
    STANDARD_DUR("standardDur_ms", "持续时间的标准值"),
    TEST("test", "测试值"),
    TEST_MAG("testMag", "特征幅值测试值"),
    TEST_DUR("testDur_ms", "持续时间测试值"),
    TEST_A("testA", "A相测试值"),
    TEST_B("testB", "B相测试值"),
    TEST_C("testC", "C相测试值"),
    ERROR("error", "误差"),
    ERROR_MAG("errorMag", "特征幅值误差"),
    ERROR_DUR("errorDur_ms", "持续时间误差"),
    ERROR_A("errorA", "A相误差"),
    ERROR_B("errorB", "B相误差"),
    ERROR_C("errorC", "C相误差"),
    RESULT("result", "结论 比如：合格/不合格"),
    RESULT_A("resultA", "结论 比如：合格/不合格"),
    RESULT_B("resultB", "结论 比如：合格/不合格"),
    RESULT_C("resultC", "结论 比如：合格/不合格"),
    RESULT_MAG("resultMag", "特征幅值结论 比如：合格/不合格"),
    RESULT_DUR("resultDur", "持续时间结论 比如：合格/不合格");

    private String key;

    private String desc;

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

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

}
