package com.mortals.xhx.common.code;

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

/**
 * @author 
 * @create 2018/01/12
 */
public enum TaskExcuteStatusEnum {

    WAIT_RUN(0, "待执行"),
    RUNNING(1, "执行中"),
    SUCCESS_RUN(2, "执行成功"),
    FAIL_RUN(3, "执行失败"),
    CANCEL(4, "取消");

    private int value;
    private String desc;

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

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

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

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


}
