package com.zt.plat.module.contractorder.enums.purchaseorder;

import lombok.Getter;

@Getter
public enum OrderStatusEnum {
    // 草稿状态
    DRAFT("DRAFT", "草稿"),
    // 审批中状态
    APPROVING("APPR", "审批中"),
    // 待提交ERP状态
    TO_SUBMIT_ERP("SUB", "待提交ERP"),
    // 执行中状态
    IN_PROGRESS("IN_PROGRESS", "执行中"),
    // 关闭状态
    CLOSED("CLOSE", "关闭"),
    REJECTED("REJECT", "驳回"),
    FIND("FIND", "ERP提交成功"),
    RLBK("RLBK", "ERP提交失败"),
    RCVG("RCVG", "ERP执行中"),
    WAIT("WAIT", "ERP待上传");

    /** 状态编码 */
    private final String code;
    /** 状态描述 */
    private final String description;

    OrderStatusEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据编码获取枚举实例
     * @param code 状态编码
     * @return 匹配的枚举，无匹配时返回 null
     */
    public static OrderStatusEnum getByCode(String code) {
        for (OrderStatusEnum status : OrderStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
}
