Newer
Older
huludao / src / main / java / com / newfiber / modules / inspection / enums / EWorkScheduleStatisStatus.java
package com.newfiber.modules.inspection.enums;

import com.newfiber.common.utils.DateUtils;
import java.util.Date;

public enum EWorkScheduleStatisStatus {
    /**
     * 状态(to_effect待生效/effecting生效中/expired已过期)
     */
    TO_EFFECT("to_effect","待生效"),
    EFFECTING("effecting","生效中"),
    EXPIRED("expired","已过期")
    ;
    private String key;
    private String value;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static String getStatus(String dateStr){
        Date date = DateUtils.stringToDate(dateStr, DateUtils.DATE_TIME_PATTERN4);
        Date todayDate = DateUtils.stringToDate(DateUtils.dateToStr(new Date(), DateUtils.DATE_TIME_PATTERN4), DateUtils.DATE_TIME_PATTERN4);
        if(date.before(todayDate)){
            return EXPIRED.getKey();
        }else if(date.equals(todayDate)){
            return EFFECTING.getKey();
        }else if(date.after(todayDate)){
            return TO_EFFECT.getKey();
        }
        return null;
    }

    public static void main(String[] args){
        System.out.println(getStatus("2020-12"));
    }

    EWorkScheduleStatisStatus(String key, String value) {
        this.key = key;
        this.value = value;
    }
}