package com.sw.mes.enumvalue;


import com.sw.mes.utils.StringUtils;

/**
 * @Author: xushu
 * @Date: 2022/08/17/16:59
 * @Description:
 */
public enum StockStateEnum  {
        TOBEOUT(1, "待出库"),
        CANCEL(2, "取消"),
        TOBEDETERMINE(3, "待确定"),
        RECEIVED(4, "已接收"),
        REFUSE(5, "拒收");

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

        private Integer code;
        private String desc;

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }



    public static Integer getCodeByDesc(String desc) {
        if(StringUtils.isBlank(desc)){
            return null;
        }
        for (StockStateEnum item : StockStateEnum.values()) {
            if (item.getDesc().equals(desc)) {
                return item.getCode();
            }
        }
        return null;
    }

    public static String getDescByCode(Integer code) {
        if(null == code) {
            return null;
        }
        for (StockStateEnum item : StockStateEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getDesc();
            }
        }
        return null;
    }

    }

