package org.wcs.constant.enums.database;

import lombok.Getter;
import org.wcs.business.stock.impl.StockTaskDataCheck.*;
import org.wcs.business.stock.intf.IStockTaskDataCheck;

import java.util.List;

@Getter
public enum StockComposeTaskTypeEnum {

    UNKNOWN(-1, "未知", new UnknownStockTaskDataCheck()),
    AUTO(0, "自动任务", new AutoStockTaskDataCheck()),
    IN(1, "入库", new InStockTaskDataCheck()),
    OUT(2, "出库", new OutStockTaskDataCheck()),
    MOVE(9, "移库", new MoveStockTaskDataCheck()),
    CONVEY(3, "输送搬运", new ConveyStockTaskDataCheck());

    private final Integer code;
    private final String msg;
    private final IStockTaskDataCheck stockTaskDataCheck;

    StockComposeTaskTypeEnum(Integer code, String msg, IStockTaskDataCheck stockTaskDataCheck) {
        this.code = code;
        this.msg = msg;
        this.stockTaskDataCheck = stockTaskDataCheck;
    }

    public static StockComposeTaskTypeEnum getByCode(Integer code) {
        for (StockComposeTaskTypeEnum value : StockComposeTaskTypeEnum.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return StockComposeTaskTypeEnum.UNKNOWN;
    }

    /**
     * 是否自动计算路径
     *
     * @param code 组合任务类型
     * @return true:是
     */
    public static boolean autoCalculateCourseType(Integer code) {
        if (code == null) {
            return false;
        }
        return List.of(IN, OUT, MOVE).contains(StockComposeTaskTypeEnum.getByCode(code));
    }


}
