package com.gkhy.huataiFourierSpecialGasMonitor.enums;
|
|
import com.gkhy.huataiFourierSpecialGasMonitor.entity.query.GasWarnTimesCountTimeSlotQuery;
|
import lombok.Getter;
|
|
import java.time.LocalDateTime;
|
import java.time.LocalTime;
|
import java.time.temporal.TemporalAdjusters;
|
|
/**
|
* @author Mr.huang
|
* @decription
|
* @date 2023/9/2 23:31
|
*/
|
@Getter
|
public enum GasWarnTimesCountEnum {
|
|
TODAY(1,"今天"){
|
@Override
|
public GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy() {
|
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime startTime = now.with(LocalTime.MIN);
|
return new GasWarnTimesCountTimeSlotQuery(startTime,now);
|
}
|
},
|
IN_7_DAYS(2,"7天内"){
|
@Override
|
public GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy() {
|
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime startTime = now.minusDays(6).with(LocalTime.MIN);
|
return new GasWarnTimesCountTimeSlotQuery(startTime,now);
|
}
|
},
|
IN_30_DAYS(3,"30天内"){
|
@Override
|
public GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy() {
|
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime startTime = now.minusDays(29).with(LocalTime.MIN);
|
return new GasWarnTimesCountTimeSlotQuery(startTime,now);
|
}
|
},
|
THISYEAR(4,"今年"){
|
@Override
|
public GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy() {
|
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime startTime = now.with(TemporalAdjusters.firstDayOfYear()).with(LocalTime.MIN);
|
return new GasWarnTimesCountTimeSlotQuery(startTime,now);
|
}
|
};
|
|
private Integer state;
|
private String description;
|
|
GasWarnTimesCountEnum(int state, String description) {
|
this.state = state;
|
this.description = description;
|
}
|
|
|
public static GasWarnTimesCountEnum getQueryObject(Integer key){
|
for (GasWarnTimesCountEnum value : GasWarnTimesCountEnum.values()) {
|
if (value.state.equals(key)){
|
return value;
|
}
|
}
|
return TODAY;
|
}
|
|
public abstract GasWarnTimesCountTimeSlotQuery getTimeSlotByStrategy();
|
|
}
|