package org.wcs.constant.enums.database;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 组合式任务表任务状态枚举
 */
@Getter
public enum StockComposeTaskStatusEnum {

    UNKNOWN(-1, "未知"),
    CREATE(0, "新建待执行"),
    QUEUE(1, "排队中"),
    EXECUTING(2, "执行中"),
    COMPLETE(3, "已完成"),
    CANCEL(4, "已取消"),
    ERROR(5, "任务异常"),
    TIMEOUT(6, "任务超时");

    private final Integer code;
    private final String msg;

    StockComposeTaskStatusEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static StockComposeTaskStatusEnum getByCode(Integer code) {
        for (StockComposeTaskStatusEnum stockComposeTaskStatusEnum : StockComposeTaskStatusEnum.values()) {
            if (stockComposeTaskStatusEnum.getCode().equals(code)) {
                return stockComposeTaskStatusEnum;
            }
        }
        return StockComposeTaskStatusEnum.UNKNOWN;
    }

    /**
     * 获取所有非执行状态
     *
     * @return 未执行状态
     */
    public static List<Integer> getAllNotExecuteStatus() {
        return List.of(StockComposeTaskStatusEnum.CREATE.getCode(), StockComposeTaskStatusEnum.QUEUE.getCode());
    }




}
