“djh”
2025-11-11 63486c527b01c459110a88930d9cda1ded633aee
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
package com.gkhy.fourierSpecialGasMonitor.enums;
 
public enum StatsTypeEnum {
    TEMP("temp", "temp", "tempMin", "tempMax", "tempAvg"),
    HUMIDITY("humidity", "humidity", "humidityMin", "humidityMax", "humidityAvg"),
    WIND_SPEED("windSpeed", "windSpeed", "windSpeedMin", "windSpeedMax", "windSpeedAvg"),
    WIND_DIRECTION("windDirection", "windDirection", "windDirectionMin", "windDirectionMax", "windDirectionAvg"),
    PRESSURE("pressure", "pressure", "pressureMin", "pressureMax", "pressureAvg");
 
    private  String type; // 与传入的 type 字符串对应
    private  String valueField; // 对应 value 的字段名
    private  String minField;   // 最小值字段名
    private  String maxField;   // 最大值字段名
    private  String avgField;   // 平均值字段名
 
    StatsTypeEnum(String type, String valueField, String minField, String maxField, String avgField) {
        this.type = type;
        this.valueField = valueField;
        this.minField = minField;
        this.maxField = maxField;
        this.avgField = avgField;
    }
 
    // 根据 type 字符串获取枚举
    public static StatsTypeEnum getByType(String type) {
        if (type == null) {
            return null;
        }
        for (StatsTypeEnum mapper : values()) {
            if (mapper.type.equalsIgnoreCase(type)) { // 忽略大小写(可选,根据需求调整)
                return mapper;
            }
        }
        return null;
    }
 
    // getter 方法
    public String getType() { return type; }
    public String getValueField() { return valueField; }
    public String getMinField() { return minField; }
    public String getMaxField() { return maxField; }
    public String getAvgField() { return avgField; }
}