package thyyxxk.webserver.entity.highreport;

import lombok.Getter;
import org.jetbrains.annotations.Nullable;
import thyyxxk.webserver.utils.StringUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 报表所需字典类型集合
 * @author: hsh
 * @date: 2022/11/2 10:56
 **/
@Getter
public enum ReportType {
    ONE("1", "单个菜单"),

    TWO("2", "功能集合页面"),

    THREE("3", "其他"),

    ZY("zy_jc", "在院运营监测"),

    CY("cy_jc", "出院运营监测"),

    MZ("mz_jc", "门诊运营监测"),

    QT("qt_jc", "其他运营监测"),

    ZB("zb_jc", "指标运营监测"),

    MX("mx_show", "明细"),

    QST("qst_show", "趋势图"),

    FBT("fbt_show", "分布图"),

    GROUP_ZB("group_zb", "指标"),

    GROUP_KS("group_ks", "科室"),

    DISPLAY_ZB("comm_report", "公共指标");

    private final String code;
    private final String name;

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

    public static @Nullable String find(String code) {
        if (StringUtil.isBlank(code)) {
            return null;
        }
        for (ReportType type : ReportType.values()) {
            if(type.getCode().startsWith(code)){
                return type.getName();
            }
        }
        return null;
    }

    /**
     * @description: 获取对应的枚举（以”_“加code或者code结尾）
     * @author: hsh
     * @date: 2022/11/2 11:22
     * @param: [code]
     * @return: List<ReportType>
     **/
    public static @Nullable List<ReportType> get(String code) {
        if (StringUtil.isBlank(code)) {
            return null;
        }
        List<ReportType> list = new ArrayList<>();
        for (ReportType type : ReportType.values()) {
            if(type.getCode().endsWith(code)){
                list.add(type);
            }
        }
        return list;
    }

}
