package org.ta.pddserver.model.enums;

public enum StatusEnum {
    ORDERCREATE(1, "创建订单"),
    SIGNED(10, "签收"),
    REJECTED(11, "拒签"),
    DESTROY(12, "销毁"),
    UNINBOUND(19, "未入库"),
    INBOUND(20, "入库"),
    PARTINBOUND(21, "部分入库"),
    FULLINBOUND(22, "全部入库"),
    BOUNDERROR(23, "入库异常"),
    UNPACK(30, "通知拆包"),
    UNPACKBEGINPICK(31, "开始拣货"),
    UNPACKFINISHPICK(32, "拣货完成"),
    FINISHUNPACK(39, "拆包完成"),
    OUTBOUND(40, "通知出库"),
    BEGINPICK(50, "开始拣货"),
    PICKERROR(51, "开始拣货异常"),
    FINISHPICK(59, "拣货完成"),
    FINISHOUTBOUND(60, "出库"),
    UNKNOWN(-1, "未知");

    private final int code;
    private final String desc;

    // 枚举构造方法默认私有，无需 Spring 注入
    StatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // 仅保留 Getter，无 Setter
    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    // 根据状态码查询枚举（核心业务方法）
    public static StatusEnum getByCode(int code) {
        for (StatusEnum status : StatusEnum.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        return UNKNOWN;
    }

}
