package com.goafanti.order.enums;

import java.util.HashMap;
import java.util.Map;

public enum TaskState {
	/** 未分派**/
	 WFP(0,"未分派"),
	 /** 已分派 **/
	 YFP(1,"已分派"),
	 /** 材料已启动 **/
	 CLYQD(2,"材料已启动"),
	 /** 材料已完成 **/
	 CLYWC(3,"材料已完成"),
	/** 无效 **/
	INVALID(10, "无效");
	
	private TaskState(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	private static Map<Integer, TaskState> status = new HashMap<Integer, TaskState>();

	static {
		for (TaskState value : TaskState.values()) {
			status.put(value.getCode(), value);
		}
	}
	public static TaskState getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return INVALID;
	}
	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}
	public static String getValueByCode(Integer code){
        for(TaskState taskState:TaskState.values()){
            if(code.equals(taskState.getCode())){
                return taskState.getDesc();
            }
        }
        return  null;
    }
	private Integer	code;
	private String	desc;
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
}
