package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum OrgCognizanceStatus {
	
	CREATE(0, "创建"),
	SIGN(1,"签单"),
	DELIVERD(2, "派单"),
	CIRCULATION(3,"流转"),
	PREPARE(4, "准备材料"),
	SUBMIT(5, "提交国家系统"),
	ACCEPT(6, "受理"),
	APPRVOVED(7, "审批通过"),
	REJECT(8, "审批不通过"),
	ISSUING(9, "已发证"),
	EXPIRED(10, "已到期"),
	FOSTER(11, "培育中"),
	SETTLEMENT(12, "已结款"),
	CALLBACK(13, "退单"),
	OTHER(14, "其他");
	
	private Integer	code;
	private String	desc;

	private OrgCognizanceStatus(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

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

	static {
		for (OrgCognizanceStatus value : OrgCognizanceStatus.values()) {
			status.put(value.getCode(), value);
		}
	}

	public static OrgCognizanceStatus getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return OTHER;
	}

	public static OrgCognizanceStatus getStatus(String code) {
		if (StringUtils.isNumeric(code)) {
			return getStatus(Integer.parseInt(code));
		}
		return OTHER;
	}

	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}

	

	public Integer getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}

}
