package com.njcn.oracle.bo.param;

import lombok.Data;
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 ServiceTypeEnum {
    DATAFLICKER("DataFlicker","电压闪变数据表"),
    DATAFLUC("DataFluc","电压波动数据表"),
    DATAHARMPHASICI("DataHarmphasicI","谐波电流角度数据表"),
    DATAHARMPHASICV("DataHarmphasicV","谐波电压角度数据表"),
    DATAHARMPOWERP("DataHarmpowerP","有功功率数据表"),
    DATAHARMPOWERQ("DataHarmpowerQ","无功功率数据表"),
    DATAHARMPOWERS("DataHarmpowerS","视在功率数据表"),
    DATAHARMRATEI("DataHarmrateI","谐波电流含有率数据表"),
    DATAHARMRATEV("DataHarmrateV","谐波电压含有率数据表"),
    DATAINHARMI("DataInharmI","电流简谐波幅值数据表"),
    DATAINHARMV("DataInharmV","电压间谐波幅值数据表"),
    DATAI("DataI","谐波电流幅值数据表"),
    DATAPLT("DataPlt","长时闪变数据表"),
    DATAV("DataV","谐波电压幅值数据表"),
    DAYFLICKER("DayFlicker","电压闪变日统计表"),
    DAYFLUC("DayFluc","电压波动日统计表"),
    DAYHARMPHASICI("DayHarmphasicI","谐波电流角度日统计表"),
    DAYHARMPHASICV("DayHarmphasicV","谐波电压角度日统计表"),
    DAYHARMPOWERP("DayHarmpowerP","有功功率日统计表"),
    DAYHARMPOWERQ("DayHarmpowerQ","无功功率日统计表"),
    DAYHARMPOWERS("DayHarmpowerS","视在功率日统计表"),
    DAYHARMRATEI("DayHarmrateI","谐波电流含有率日统计表"),
    DAYHARMRATEV("DayHarmrateV","谐波电压含有率日统计表"),
    DAYINHARMI("DayInharmI","电流简谐波幅值日统计表"),
    DAYINHARMV("DayInharmV","电压间谐波幅值日统计表"),
    DAYI("DayI","谐波电流幅值日统计表"),
    DAYPLT("DayPlt","长时闪变日统计表"),
    DAYV("DayV","谐波电压幅值日统计表"),
    LIMITRATE("LimitRate","合格率统计表"),
    LIMITTARGET("LimitTarget","合格率指标表");

    private final String code;
    private final String value;

    ServiceTypeEnum( String code,String value) {
        this.code = code;
        this.value = value;
    }

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


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

    }
