“djh”
2024-12-04 d1549b8445c65a6775cf1ba093f5040ace0f87e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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();
 
}