| | |
| | | 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 deviceName; |
| | | |
| | | /** 设备类型 **/ |
| | | private String type; |
| | | |
| | | /** 改设备当月在线情况 **/ |
| | | private List<TMonitorResult> onlineStateList; |
| | | /** 内部处理用 */ |
| | | private LocalDate mongoCreateTime; |
| | | |
| | | /** 标签 */ |
| | | @Excel(name = "标签") |
| | |
| | | @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; |
| | | } |
| | | |
| | | } |