package com.brilliance.isc.automatic.engine.constant.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

/**
 * @description 自动化运行状态
 **/
@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum AutoStaEnum {
    WAITING("0", "待执行"),
    RUNNING("1", "处理中"),
    PAUSE("2", "待客户确认"),
    FINISH("3", "已完成"),
    ERROR("4", "已转人工（失败/手工）"),
    RESUME("5", "待执行");

    private String code;
    private String desc;

    public String getDesc() {
        return desc;
    }

    public String getCode() {
        return code;
    }

    public static String getDescForCode(String code) {
        for (AutoStaEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value.getDesc();
            }
        }
        return String.format("未定义的自动化状态:%s", code);
    }

    AutoStaEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public String toString() {
        return code;
    }
}
