package com.njcn.influx.bo.param;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Description:
 * Date: 2024/1/4  13:54【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Getter
public enum TableEnum {
    DATAFLICKER("DataFlicker","电压闪变数据表", 1),
    DATAFLUC("DataFluc","电压波动数据表", 1),
    DATAHARMPHASICI("DataHarmphasicI","谐波电流角度数据表", 4),
    DATAHARMPHASICV("DataHarmphasicV","谐波电压角度数据表", 4),
    DATAHARMPOWERP("DataHarmpowerP","有功功率数据表", 4),
    DATAHARMPOWERQ("DataHarmpowerQ","无功功率数据表", 4),
    DATAHARMPOWERS("DataHarmpowerS","视在功率数据表", 4),
    DATAHARMRATEI("DataHarmrateI","谐波电流含有率数据表", 4),
    DATAHARMRATEV("DataHarmrateV","谐波电压含有率数据表", 4),
    DATAINHARMI("DataInharmI","电流简谐波幅值数据表", 4),
    DATAINHARMV("DataInharmV","电压间谐波幅值数据表", 4),
    DATAI("DataI","谐波电流幅值数据表", 4),
    DATAPLT("DataPlt","长时闪变数据表", 1),
    DATAV("DataV","谐波电压幅值数据表", 4),
    COMINFORMATION("ComInfoRmation","监测点状态监测数据", 4),
    ;


    private final String code;
    private final String value;

    private final Integer multiple;

    TableEnum(String code, String value, Integer multiple) {
        this.code = code;
        this.value = value;
        this.multiple = multiple;
    }

    /**
     * 获取所有可执行的组件类型，
     * 除了"目录"类型，其他都可以执行
     * @return
     */
    public static List<String> getExecutableTypes() {
        return Arrays.stream(TableEnum.values()).map(tmep->{
            return tmep.code;
        }).collect(Collectors.toList());
    }


    /**
     * 通过code获取枚举值
     * @param code
     * @return
     */
    public static String getValueByCode(String code) {
        for (TableEnum item : TableEnum.values()) {
            if (item.code.equals(code)) {
                return item.value;
            }
        }
        return null;
    }

    public static Integer getMultipleByCode(String code) {
        for (TableEnum item : TableEnum.values()) {
            if (item.code.equals(code)) {
                return item.multiple;
            }
        }
        return null;
    }

    }
