package com.rongwei.bsentity.enums;

import java.util.stream.Stream;

/**
 * @author shangmi
 * @title lubricationFrequencyEnum
 * @date 2024/1/31 16:37
 * @description 润滑频率周期
 */
public enum LubricationFrequencyEnum {
    WEEKLY("20","每周"),
    MONTHLY("40","每月"),
    PER_QUARTER("60","每季度"),
    SEMIANNUALLY("70","每半年"),
    ;

    private String code;

    private String massage;

    LubricationFrequencyEnum(String code, String massage) {
        this.code = code;
        this.massage = massage;
    }


    public static String massageOf(String code){
        return getTaskStatusByCode(code,null).massage;
    }

    public static LubricationFrequencyEnum getTaskStatusByCode(String code,LubricationFrequencyEnum lubricationFrequencyEnum){
        return Stream.of(values()).filter(info->code.equals(info.code)).findFirst().orElse(lubricationFrequencyEnum);
    }

    public static String codeOf(String massage){
        return getTaskStatusByMassage(massage,null).code;
    }

    public static LubricationFrequencyEnum getTaskStatusByMassage(String massage,LubricationFrequencyEnum lubricationFrequencyEnum){
        return Stream.of(values()).filter(info->massage.equals(info.massage)).findFirst().orElse(lubricationFrequencyEnum);
    }
}
