package com.goafanti.common.enums;

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


public enum NoticeTypes {
	// 0其他 1专利提醒 2订单审核 3客户释放 4限时跟进 5催款\付款 6订单开票
	/** 专利提醒 */
	ZLTX(1,"专利提醒"),
	/** 订单审核 */
	DDSH(2,"订单审核"),
	/** 客户释放 */
	KHSF(3,"客户释放"),
	/** 限时跟进 */
	XSGJ(4,"限时跟进"),
	/** 催款\付款 */
	CKFK(5,"催款\\付款"),
	/** 订单开票 */
	DDKP(6,"订单开票"),

	HYCS(7,"会员催收"),

	GCXX(8,"公出"),
	ELSE(0,"其他");

	/**
	 * 跟进通知类型获取大分类
	 * @param i
	 * @return
	 */
	public static Integer getType(Integer i) {
		if (i == NoticeStatus.TASK_PATENT_ERROR.getCode() || i == NoticeStatus.TASK_PATENT_REMIND.getCode()) {
			return ZLTX.code;
		} else if (i == NoticeStatus.ORDER_CHANGE_ADD.getCode() || i == NoticeStatus.ORDER_CHANGE_UDPATE.getCode()
				|| i == NoticeStatus.ORDER_BACK.getCode() || i == NoticeStatus.ORDER_REFUND.getCode()
				|| i == NoticeStatus.ORDER_REFUND_REFUSE.getCode() || i == NoticeStatus.ORDER_CHANGE_YES.getCode()
				|| i == NoticeStatus.ORDER_CHANGE_NO.getCode() || i == NoticeStatus.ORDER_CHANGE_END.getCode()
				|| i == NoticeStatus.ORDER_CHANGE_START.getCode() || i == NoticeStatus.ORDER_START.getCode()
				|| i == NoticeStatus.ORDER_APPROVA_YES.getCode() || i == NoticeStatus.ORDER_APPROVA_NO.getCode()
				|| i == NoticeStatus.ORDER_OUTSOURCE_NO.getCode() || i == NoticeStatus.ORDER_OUTSOURCE_YES.getCode()
				|| i == NoticeStatus.ORDER_YES.getCode() || i == NoticeStatus.ORDER_NO.getCode()
				|| i == NoticeStatus.ORDER_TASK_TO.getCode() || i == NoticeStatus.PROJECT_OUTSOURCE_START.getCode()
				|| i == NoticeStatus.PROJECT_OUTSOURCE_YES.getCode() || i == NoticeStatus.PROJECT_OUTSOURCE_NO.getCode()
				|| i == NoticeStatus.ITEM_CHECK_START.getCode() || i == NoticeStatus.ITEM_CHECK_END.getCode()
				|| i == NoticeStatus.MENBER_START.getCode() || i == NoticeStatus.MENBER_YES.getCode()
				|| i == NoticeStatus.MENBER_NO.getCode() ||
				i == NoticeStatus.PROJECT_SOPT_START.getCode() || i == NoticeStatus.PROJECT_SOPT_YES.getCode()
				|| i == NoticeStatus.PROJECT_SOPT_NO.getCode()
				|| i == NoticeStatus.PROJECT_RENEW_START.getCode() || i == NoticeStatus.PROJECT_RENEW_YES.getCode()
				|| i == NoticeStatus.PROJECT_RENEW_NO.getCode() ) {
			return DDSH.code;
		} else if (i == NoticeStatus.CUSTOMER_LOSE30.getCode() || i == NoticeStatus.CUSTOMER_LOSE270.getCode()
				|| i == NoticeStatus.CUSTOMER_CHENNEL_LOSE.getCode() || i == NoticeStatus.CUSTOMER_CHENNEL_RECOVERY.getCode()
				|| i == NoticeStatus.RESTRICT_PROJECT_LOSE30.getCode() || i == NoticeStatus.RESTRICT_PROJECT_LOSE270.getCode()
				||i == NoticeStatus.CLUE_USER_RELEASE.getCode()
		) {
			return KHSF.code;
		} else if (i == NoticeStatus.CUSTOMER_PRIVATE_REMINDER.getCode()|| i == NoticeStatus.CUSTOMER_LOSE_REMINDER.getCode()
				|| i == NoticeStatus.RESTRICT_PROJECT_LOSE30_REMIND.getCode() || i == NoticeStatus.RESTRICT_PROJECT_LOSE270_REMIND.getCode()
		) {
			return XSGJ.code;
		} else if (i == NoticeStatus.ORDER_DUN.getCode() || i == NoticeStatus.ORDER_ARREARS_DUN.getCode()
				|| i == NoticeStatus.PAYMENT_DUN.getCode() || i == NoticeStatus.PAYMENT_NODE.getCode()
				|| i == NoticeStatus.PAYMENT_NO.getCode() || i == NoticeStatus.PAYMENT_YES.getCode()
				|| i == NoticeStatus.PAYMENT_COMPLETE.getCode()) {
			return CKFK.code;
		} else if (i == NoticeStatus.ORDER_INVPICE_START.getCode() || i == NoticeStatus.ORDER_INVPICE_YES.getCode()
				|| i == NoticeStatus.ORDER_INVPICE_NO.getCode() || i == NoticeStatus.ORDER_INVPICE_APPROVA_YES.getCode()
				|| i == NoticeStatus.ORDER_INVPICE_APPROVA_NO.getCode()
				|| i == NoticeStatus.ORDER_INVPICE_END.getCode()) {
			return DDKP.code;
		}else if (i == NoticeStatus.MENBER_DUN.getCode()) {
			return HYCS.code;
		}else if ( i== NoticeStatus.PUBLIC_OTHERS_USER.getCode() || i== NoticeStatus.PUBLIC_RELEASE_START.getCode()
				|| i== NoticeStatus.PUBLIC_RELEASE_YES.getCode()|| i== NoticeStatus.PUBLIC_RELEASE_NO.getCode()
				|| i== NoticeStatus.PUBLIC_CARBON_COPY.getCode()) {
			return GCXX.code;
		}
		return ELSE.code;
	}

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

	static {
		for (NoticeTypes value : NoticeTypes.values()) {
			status.put(value.getCode(), value);
		}
	}
	public static NoticeTypes getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return ELSE;
	}

	public static String getValueByCode(Integer code){
        for(NoticeTypes NoticeTypes:NoticeTypes.values()){
            if(code.equals(NoticeTypes.getCode())){
                return NoticeTypes.getDesc();
            }
        }
        return  ELSE.getDesc();
    }

	public static Integer getCount(){
		int count=0;
        for(NoticeTypes x:NoticeTypes.values()){
         if(x!=null)count++;
        }
        return  --count;
    }


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

	private String desc;
	private Integer code;

	private NoticeTypes(Integer code, String desc) {
		this.setCode(code);
		this.setDesc(desc);
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}
}
