package com.njcn.relational.pojo.commEnum;

import lombok.Getter;

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

@Getter
public enum TableEnum {
    DATAFLICKER("r_stat_data_flicker_d","电压闪变数据表", "time"),
    DATAFLUC("r_stat_data_fluc_d","电压波动数据表", "time"),
    DATAHARMPHASICI("r_stat_data_harmphasic_i_d","谐波电流角度数据表", "time"),
    DATAHARMPHASICV("r_stat_data_harmphasic_v_d","谐波电压角度数据表", "time"),
    DATAHARMPOWERP("r_stat_data_harmpower_p_d","有功功率数据表", "time"),
    DATAHARMPOWERQ("r_stat_data_harmpower_q_d","无功功率数据表", "time"),
    DATAHARMPOWERS("r_stat_data_harmpower_s_d","视在功率数据表", "time"),
    DATAHARMRATEI("r_stat_data_harmrate_i_d","谐波电流含有率数据表", "time"),
    DATAHARMRATEV("r_stat_data_harmrate_v_d","谐波电压含有率数据表", "time"),
    DATAINHARMI("r_stat_data_inharm_i_d","电流简谐波幅值数据表", "time"),
    DATAINHARMV("r_stat_data_inharm_v_d","电压间谐波幅值数据表", "time"),
    DATAI("r_stat_data_i_d","谐波电流幅值数据表", "time"),
    DATAPLT("r_stat_data_plt_d","长时闪变数据表", "time"),
    DATAV("r_stat_data_v_d","电压幅值数据表", "time"),
    r_stat_integrity_d("r_stat_integrity_d","数据性完整表","time_id"),
    r_stat_limit_qualified_d("r_stat_limit_qualified_d","数据性完整表","time_id"),
    r_stat_limit_rate_d("r_stat_limit_rate_d","稳态越限日表","time_id"),
    r_stat_limit_rate_detail_d("r_stat_limit_rate_detail_d","稳态越限详细日表","time_id"),
    r_stat_limit_target_d("r_stat_limit_target_d","稳态越限日表","time_id"),
    r_stat_onlinerate_d("r_stat_onlinerate_d","终端在线时长日表","time_id"),

    r_mp_event_detail("r_mp_event_detail","暂态事件详细表","start_time"),
    r_mp_event_detail_d("r_mp_event_detail_d","暂态事件日表","data_date"),
    r_mp_event_detail_m("r_mp_event_detail_m","暂态事件月表","data_date"),
    r_mp_event_detail_q("r_mp_event_detail_q","暂态事件季表","data_date"),
    r_mp_event_detail_y("r_mp_event_detail_y","暂态事件年表","data_date")
    ;


    private final String code;
    private final String value;

    private final String tableField;

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

    /**
     * 获取所有可执行的组件类型，
     * 除了"目录"类型，其他都可以执行
     * @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 String getFieldByCode(String code) {
        for (TableEnum item : TableEnum.values()) {
            if (item.code.equals(code)) {
                return item.tableField;
            }
        }
        return null;
    }

    }