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

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

/**
 * @Description: -- 对账结果:0-待对账;1-正常;2-异常; check_state check_time
 * -- 待对账:指该对账任务下所有第三方订单的对账结果全部为`待对账`的状态;
 * -- 正常:指该对账任务下所有第三方订单的对账结果全部为`正常`的状态;
 * -- 异常:指该对账任务下所有第三方订单的对账结果存在部分`异常`或`待对账`的状态;
 * @Author: linjinyu
 * @CreateDate: 2022/6/8 5:52 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/6/8 5:52 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum ScheduleTaskCheckStateEnum {

    待对账(0, "待对账"),
    正常(1, "正常"),
    异常(2, "异常"),

    ;

    private Integer key;
    private String  desc;

    ScheduleTaskCheckStateEnum(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 (ScheduleTaskCheckStateEnum c : ScheduleTaskCheckStateEnum.values()) {
            if (c.key.equals(key)) {
                return c.getDesc();
            }
        }
        return null;
    }

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

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

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