zxl
2025-04-10 1f11310ba04770a4efe4657d39872590575828f1
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
package com.ycl.platform.domain.excel;
 
import annotation.Excel;
import com.ycl.platform.domain.result.SYS.TMonitorResult;
import lombok.Data;
 
import java.lang.reflect.Field;
import java.time.LocalDate;
import java.util.List;
 
@Data
public class VideoDailyExp {
    /** 设备编号 */
    @Excel(name = "设备编号",width = 20)
    private String serialNumber;
 
    /** 设备名称 */
    @Excel(name = "设备名称",width = 20)
    private String deviceName;
 
    /** 设备类型 **/
    private String type;
 
    /** 改设备当月在线情况 **/
    private List<TMonitorResult> onlineStateList;
    /** 内部处理用 */
    private LocalDate mongoCreateTime;
 
    /** 标签 */
    @Excel(name = "标签")
    private String tag;
 
    /** 区域 */
    @Excel(name = "区域")
    private String area;
 
    /** 日期 */
    @Excel(name = "1",width = 10)
    private String day1;
 
    /** 日期 */
    @Excel(name = "2",width = 10)
    private String day2;
 
    /** 日期 */
    @Excel(name = "3",width = 10)
    private String day3;
 
    /** 日期 */
    @Excel(name = "4",width = 10)
    private String day4;
 
    /** 日期 */
    @Excel(name = "5",width = 10)
    private String day5;
 
    /** 日期 */
    @Excel(name = "6",width = 10)
    private String day6;
 
    /** 日期 */
    @Excel(name = "7",width = 10)
    private String day7;
 
    /** 日期 */
    @Excel(name = "8",width = 10)
    private String day8;
 
    /** 日期 */
    @Excel(name = "9",width = 10)
    private String day9;
 
    /** 日期 */
    @Excel(name = "10",width = 10)
    private String day10;
 
    /** 日期 */
    @Excel(name = "11",width = 10)
    private String day11;
 
    /** 日期 */
    @Excel(name = "12",width = 10)
    private String day12;
 
    /** 日期 */
    @Excel(name = "13",width = 10)
    private String day13;
 
    /** 日期 */
    @Excel(name = "14",width = 10)
    private String day14;
 
    /** 日期 */
    @Excel(name = "15",width = 10)
    private String day15;
 
    /** 日期 */
    @Excel(name = "16",width = 10)
    private String day16;
 
    /** 日期 */
    @Excel(name = "17",width = 10)
    private String day17;
 
    /** 日期 */
    @Excel(name = "18",width = 10)
    private String day18;
 
    /** 日期 */
    @Excel(name = "19",width = 10)
    private String day19;
 
    /** 日期 */
    @Excel(name = "20",width = 10)
    private String day20;
 
    /** 日期 */
    @Excel(name = "21",width = 10)
    private String day21;
 
    /** 日期 */
    @Excel(name = "22",width = 10)
    private String day22;
 
    /** 日期 */
    @Excel(name = "23",width = 10)
    private String day23;
 
    /** 日期 */
    @Excel(name = "24",width = 10)
    private String day24;
 
    /** 日期 */
    @Excel(name = "25",width = 10)
    private String day25;
 
    /** 日期 */
    @Excel(name = "26",width = 10)
    private String day26;
 
    /** 日期 */
    @Excel(name = "27",width = 10)
    private String day27;
 
    /** 日期 */
    @Excel(name = "28",width = 10)
    private String day28;
 
    /** 日期 */
    @Excel(name = "29",width = 10)
    private String day29;
 
    /** 日期 */
    @Excel(name = "30",width = 10)
    private String day30;
 
    /** 日期 */
    @Excel(name = "31",width = 10)
    private String day31;
 
    public boolean isAllOfflineByMonth() {
        boolean allOffline = true;
        try {
            // 遍历 day1 到 day31
            for (int i = 1; i <= 31; i++) {
                // 构造字段名
                String fieldName = "day" + i;
                // 获取字段
                Field field = this.getClass().getDeclaredField(fieldName);
                // 确保字段是私有的可以访问
                field.setAccessible(true);
                // 获取字段值
                String value = (String) field.get(this);
                // 检查值是否为 "离线"
                if (!"离线".equals(value)) {
                    allOffline = false;
                    break;
                }
            }
 
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return allOffline;
    }
 
    public long getAllOnlineDayCountByMonth() {
        long count = 0;
        try {
 
            // 遍历 day1 到 day31
            for (int i = 1; i <= 31; i++) {
                // 构造字段名
                String fieldName = "day" + i;
                // 获取字段
                Field field = this.getClass().getDeclaredField(fieldName);
                // 确保字段是私有的可以访问
                field.setAccessible(true);
                // 获取字段值
                String value = (String) field.get(this);
                // 检查值是否为 "在线"
                if ("在线".equals(value)) {
                    count++;
                }
            }
 
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return count;
    }
 
}