package com.mortals.xhx.common.code;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author: finegirl
 * @date: 2021/7/16 11:50
 * @description: 组件枚举类
 **/
public enum ProcessInstanceEnum {
    请假("PROC-2E5C0DFF-3615-4409-A614-A2011FED5D38", "请假"),
    外出("PROC-56D3ADEE-45A4-47BC-931A-2A0DC067DE32", "外出"),
    出差("PROC-578CBDDF-B768-496D-9918-44A3F1D9CAE7", "出差");

    private String value;
    private String desc;

    ProcessInstanceEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String getValue() {
        return this.value;
    }

    public String getDesc() {
        return this.desc;
    }

    public static ProcessInstanceEnum getByValue(String value) {
        for (ProcessInstanceEnum componentEnum : ProcessInstanceEnum.values()) {
            if (componentEnum.getValue() == value) {
                return componentEnum;
            }
        }
        return null;
    }

    /**
     * 获取Map集合
     *
     * @param eItem 不包含项
     * @return
     */
    public static Map<String, String> getEnumMap(String... eItem) {
        Map<String, String> resultMap = new LinkedHashMap<>();
        for (ProcessInstanceEnum item : ProcessInstanceEnum.values()) {
            try {
                boolean hasE = false;
                for (String e : eItem) {
                    if (item.getValue() == e) {
                        hasE = true;
                        break;
                    }
                }
                if (!hasE) {
                    resultMap.put(item.getValue() + "", item.getDesc());
                }
            } catch (Exception ex) {
            }
        }
        return resultMap;
    }
}