package com.zzsmart.qomo.kn.cost.manage.enums;

/**
 * @Classname StandardStageEnum
 * @Description 阶段枚举
 * @Version 1.0.0
 * @Date 2024/6/18 9:51
 * @Created wangqiong
 */
public enum CostCountStatusEnum {

    NotExecute("NotExecute", "未执行", 0), Executing("Executing", "计算中", 1), ExecutedFinished("ExecutedFinished", "计算完成", 2), ExecutedError("ExecutedError", "出错中止", 3);
    private final String code;
    private final String name;
    private final Integer value;

    CostCountStatusEnum(String code, String name, Integer value) {
        this.code = code;
        this.name = name;
        this.value = value;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public Integer getValue() {
        return value;
    }

    /**
     * 根据code获取text
     *
     * @param codeNo
     * @return
     */
    public static String getTextByCode(String codeNo) {
        for (CostCountStatusEnum value : CostCountStatusEnum.values()) {
            if (value.getCode().equals(codeNo)) {
                return value.name();
            }
        }
        return codeNo.toString();
    }

    public static String getTextByValue(Integer indexNo) {
        for (CostCountStatusEnum value : CostCountStatusEnum.values()) {
            if (value.getValue().equals(indexNo)) {
                return value.name();
            }
        }
        return indexNo.toString();
    }

    /**
     * 根据text获取code
     *
     * @param name
     * @return
     */
    public static String getCodeByName(String name) {
        for (CostCountStatusEnum value : CostCountStatusEnum.values()) {
            if (value.name().equals(name)) {
                return value.name();
            }
        }
        return name;
    }
}
