package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;


public enum OrderLogProcess {
//	流程 0发起退单 1提交 2审核 3驳回  4特批 5财务派单 6财务首付 7项目订单派单 8项目派单 9项目完成 10 退单完成 11财务全款 12发起外包 13外包通过 14外包拒绝
	TJ(1, "营销员提交"),
	SH(2, "管理员审核"),
	BH(3, "驳回"),
	TP(4, "特批通过"),
	CWPD(5, "财务派单"),
	CWSF(6, "财务首付"),
	XMDDPD(7, "项目订单派单"),
	XMPD(8, "项目派单"),
	XMWC(9, "项目完成"),
	FQTD(0,"发起退单"),
	WCTD(10,"退单完成"),
	CWQK(11,"财务全款"),
	FQWB(12,"发起外包"),
	WBTG(13,"订单外包通过"),
	WBBH(14,"订单外包驳回"),
	XMWBTG(15,"项目外包通过"),
	XMWBBH(16,"项目外包驳回"),
	NOT(99,"未知"),
	;
	
	private OrderLogProcess(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

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

	static {
		for (OrderLogProcess value : OrderLogProcess.values()) {
			status.put(value.getCode(), value);
		}
	}
	public static String getValueByCode(Integer code){
        for(OrderLogProcess orderLogProcess:OrderLogProcess.values()){
            if(code.equals(orderLogProcess.getCode())){
                return orderLogProcess.getDesc();
            }
        }
        return  NOT.getDesc();
    }
	
	
	public static OrderLogProcess getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return null;
	}

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

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

	private Integer	code;
	private String	desc;

	public Integer getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}
}
