package cn.superdesk.uniorder.common.enums.common;


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


/**
 * @Description: 处理结果:0-初始;1-正常;2-异常-数据本身问题;21-异常-数据处理问题;
 * @Author: linjinyu
 * @CreateDate: 2021/8/17 下午2:54
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/8/17 下午2:54
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum CommonProcessResultEnum {

	初始(0, "初始"),
	正常(1, "正常"),
	异常_数据本身缺失(2, "异常_数据本身缺东缺西,但业务上要求得过"),
	异常_数据处理过程中(21, "异常_程序处理过程中产生的"),
	异常_抛错(22, "异常_抛错_程序未能处理到的抛错"),
	异常_程序检查(23, "异常_程序检查得出记录的"),
	;

	private Integer key;
	private String  desc;

	CommonProcessResultEnum(Integer key, String desc) {
		this.key = key;
		this.desc = desc;
	}

	public Integer getKey() {
		return key;
	}

	public String getDesc() {
		return desc;
	}


	public static String getDesc(Integer key) {
		for (CommonProcessResultEnum c : CommonProcessResultEnum.values()) {
			if (c.key.equals(key)) {
				return c.getDesc();
			}
		}
		return null;
	}

	private static final Map<Integer, CommonProcessResultEnum> LOOKUP = new HashMap<>();

	static {
		for (CommonProcessResultEnum s : EnumSet.allOf(CommonProcessResultEnum.class)) {
			LOOKUP.put(s.getKey(), s);
		}
	}

	public static CommonProcessResultEnum get(Integer key) {
		return LOOKUP.get(key);
	}
}
