From 1f11310ba04770a4efe4657d39872590575828f1 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期四, 10 四月 2025 17:17:24 +0800
Subject: [PATCH] 设备未知状态,新增,导出页新增统计一个月的离线数,与在线率

---
 ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoTypeOffOnlineExp.java |  153 +++++++++++++
 ycl-server/src/main/java/com/ycl/task/UYTask.java                               |    6 
 ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoDailyExp.java         |   64 +++++
 ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml                    |    4 
 ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoOnlineRateExp.java    |  141 ++++++++++++
 ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java |  276 ++++++++++++++++++++++++-
 6 files changed, 630 insertions(+), 14 deletions(-)

diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoDailyExp.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoDailyExp.java
index cc1bb92..9f73249 100644
--- a/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoDailyExp.java
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoDailyExp.java
@@ -1,7 +1,12 @@
 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 {
@@ -12,6 +17,14 @@
     /** 璁惧鍚嶇О */
     @Excel(name = "璁惧鍚嶇О",width = 20)
     private String deviceName;
+
+    /** 璁惧绫诲瀷 **/
+    private String type;
+
+    /** 鏀硅澶囧綋鏈堝湪绾挎儏鍐� **/
+    private List<TMonitorResult> onlineStateList;
+    /** 鍐呴儴澶勭悊鐢� */
+    private LocalDate mongoCreateTime;
 
     /** 鏍囩 */
     @Excel(name = "鏍囩")
@@ -145,5 +158,56 @@
     @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;
+    }
 
 }
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoOnlineRateExp.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoOnlineRateExp.java
new file mode 100644
index 0000000..020c63b
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoOnlineRateExp.java
@@ -0,0 +1,141 @@
+package com.ycl.platform.domain.excel;
+
+import annotation.Excel;
+import lombok.Data;
+
+//鍦ㄧ嚎鐜囩粺璁�
+@Data
+public class VideoOnlineRateExp {
+    //鍖哄煙
+    @Excel(name="鍖哄煙",width = 20)
+    private String area;
+
+    //1浜鸿劯 2杞﹁締 3瑙嗛
+    //璁惧绫诲瀷
+    @Excel(name="璁惧绫诲瀷",width = 20)
+    private String type;
+
+    /** 鏃ユ湡 */
+    @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;
+}
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoTypeOffOnlineExp.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoTypeOffOnlineExp.java
new file mode 100644
index 0000000..5d558fb
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/VideoTypeOffOnlineExp.java
@@ -0,0 +1,153 @@
+package com.ycl.platform.domain.excel;
+
+import annotation.Excel;
+import lombok.Data;
+
+//绂荤嚎鏁扮粺璁�
+@Data
+public class VideoTypeOffOnlineExp {
+
+
+    //鍖哄煙
+    @Excel(name="鍖哄煙",width = 20)
+    private String area;
+
+    //1浜鸿劯 2杞﹁締 3瑙嗛
+    //璁惧绫诲瀷
+    @Excel(name="璁惧绫诲瀷",width = 20)
+    private String type;
+
+    //绂荤嚎鏁伴噺
+    @Excel(name="绂荤嚎鏁伴噺",width = 20)
+    private String offlineCount;
+
+    /** 鏃ユ湡 */
+    @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;
+
+
+
+
+
+
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
index 3865624..3127208 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
@@ -3,14 +3,11 @@
 import annotation.DataScope;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.mongodb.ExplainVerbosity;
 import com.mongodb.client.AggregateIterable;
 import com.mongodb.client.MongoCollection;
 import com.mongodb.client.MongoDatabase;
 import com.ycl.platform.domain.entity.TMonitor;
-import com.ycl.platform.domain.excel.TMonitorExp;
-import com.ycl.platform.domain.excel.VideoDailyExp;
-import com.ycl.platform.domain.excel.VideoTotalExp;
+import com.ycl.platform.domain.excel.*;
 import com.ycl.platform.domain.form.VideoExportForm;
 import com.ycl.platform.domain.query.DashboardQuery;
 import com.ycl.platform.domain.query.DataCenterQuery;
@@ -37,7 +34,6 @@
 import com.ycl.platform.service.ITMonitorService;
 import com.ycl.system.Result;
 import com.ycl.system.entity.SysDictData;
-import com.ycl.system.mapper.SysConfigMapper;
 import com.ycl.system.mapper.SysDictDataMapper;
 import com.ycl.system.page.PageUtil;
 import com.ycl.system.service.ISysConfigService;
@@ -45,13 +41,12 @@
 import com.ycl.utils.StringUtils;
 import com.ycl.utils.poi.ExcelUtil;
 import constant.ApiConstants;
-import constant.CheckConstants;
 import enumeration.general.AreaDeptEnum;
 import jakarta.servlet.http.HttpServletResponse;
-import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.Validate;
 import org.bson.Document;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.query.Criteria;
@@ -68,17 +63,13 @@
 import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.YearMonth;
-import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
-import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.concurrent.*;
-import java.util.function.BinaryOperator;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -89,6 +80,7 @@
  * @date 2024-03-04
  */
 @Service
+@Slf4j
 public class TMonitorServiceImpl extends ServiceImpl<TMonitorMapper, TMonitor> implements ITMonitorService {
     @Autowired
     private TMonitorMapper tMonitorMapper;
@@ -570,6 +562,8 @@
      */
     @Override
     public void exportVideoOnline(HttpServletResponse response, VideoExportForm exportForm) throws IOException, NoSuchFieldException, IllegalAccessException {
+        log.error("寮�濮嬪鍑烘暟鎹�");
+        log.error("浼犲叆鐨勬湀浠�:{}",exportForm.getMonth());
         //榛樿鏌ユ墍鏈夐儴闂�
         if (CollectionUtils.isEmpty(exportForm.getDeptIds())) {
             List<Integer> deptIds = new ArrayList<>();
@@ -585,6 +579,7 @@
         Query query = getQuery(exportForm);
         //鏈堜唤姣忔棩鍦ㄧ嚎鏁版嵁
         List<TMonitorResult> onlineResult = mongoTemplate.find(query, TMonitorResult.class);
+        log.error("鏈堜唤鍦ㄧ嚎鏁版嵁:{}鏉℃暟",onlineResult.size());
         // 浣跨敤 Collectors.toMap 鍘婚噸锛屼繚鐣欐瘡涓� No 鐨勭涓�涓亣鍒扮殑鍏冪礌
         Map<String, TMonitorResult> uniqueResultsMap = onlineResult.stream()
                 .collect(Collectors.toMap(
@@ -594,6 +589,7 @@
                 ));
         // 灏� Map 杞崲涓� List
         List<TMonitorResult> tMonitorResults = new ArrayList<>(uniqueResultsMap.values());
+        log.error("鍘婚噸鍚庡ぇ灏�:{}",tMonitorResults.size());
         //鑾峰彇鍔ㄦ�佸垪鏁版嵁
         List<Integer> pointIds = tMonitorResults.stream().map(TMonitorResult::getPointId).collect(Collectors.toList());
         List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds);
@@ -605,6 +601,8 @@
                 tMonitorResult.setDynamicColumnList(map.get(pointId));
             }
         }
+        //瀛樻斁鍖哄煙 涓� 璁惧鍒楄〃 map key涓� 鍖哄煙
+        Map<Integer, List<VideoDailyExp>> map = new HashMap<>();
         List<CompletableFuture<List<VideoDailyExp>>> futures = new ArrayList<>();
         for (Integer deptId : exportForm.getDeptIds()) {
             CompletableFuture<List<VideoDailyExp>> future = CompletableFuture.supplyAsync(() -> {
@@ -628,6 +626,8 @@
                     VideoDailyExp videoDailyExp = new VideoDailyExp();
                     videoDailyExp.setSerialNumber(result.getNo());
                     videoDailyExp.setDeviceName(result.getName());
+                    videoDailyExp.setType(result.getMonitorType());
+
                     videoDailyExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName());
 
                     StringBuilder tag = new StringBuilder("" +
@@ -663,19 +663,267 @@
                 );
                 mysheet.add(excelExp);
 
+
                 return videoDailyExps;
             }, threadPoolTaskExecutor);
             futures.add(future);
+            map.put(deptId,future.join());
         }
         // 鑾峰彇鍏ㄩ噺鏁版嵁
         List<VideoDailyExp> totalExps = futures.stream()
                 .map(CompletableFuture::join)
                 .flatMap(List::stream)
                 .collect(Collectors.toList());
+        log.error("鎵撳嵃鍏ㄩ噺鏁版嵁:{}",totalExps);
         ExcelExp excelExp = new ExcelExp("鍏ㄩ噺", totalExps, VideoDailyExp.class);
         mysheet.add(excelExp);
+        //娣诲姞鏂扮殑sheet 绂荤嚎鏁扮粺璁¤〃
+        List<VideoTypeOffOnlineExp> videoTypeOffOnlineExps = new ArrayList<>();
+        //鎻掑叆excel鏃剁‘淇濇暟鎹嚭鐜板湪鏈�鍚�
+        List<VideoTypeOffOnlineExp> allVideoTypeOffOnlineExps = new ArrayList<>();
+
+        //鍦ㄧ嚎鐜囩粺璁¤〃
+        List<VideoOnlineRateExp> videoOnlineRateExps = new ArrayList<>();
+        //鎻掑叆excel鏃剁‘淇濇暟鎹嚭鐜板湪鏈�鍚�
+        List<VideoOnlineRateExp> allVideoOnlineRateExps = new ArrayList<>();
+
+        for (Integer deptId : map.keySet()){
+            List<VideoDailyExp>  list = map.get(deptId);
+            AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(deptId);
+            // 娣诲姞绂荤嚎琛ㄨ褰�
+            //璁惧绫诲瀷 1浜鸿劯 2杞﹁締 3瑙嗛
+            //浜鸿劯
+            log.error("浼犲叆閮ㄩ棬闆嗗悎澶у皬:{} + 閮ㄩ棬id:{}" ,list.size(),deptId);
+            VideoTypeOffOnlineExp faceVideoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"1",areaDeptEnum,false);
+            //鍗″彛
+            VideoTypeOffOnlineExp carVideoTypeOffOnlineExp =this.getListOfflineCountInfo(list,"2",areaDeptEnum,false);
+            //瑙嗛
+            VideoTypeOffOnlineExp videoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"3",areaDeptEnum,false);
+
+            VideoOnlineRateExp faceVideoOnlineRateExp = this.getListOnLineCountInfo(list,"1",areaDeptEnum,false);
+            //鍗″彛
+            VideoOnlineRateExp carVideoOnlineRateExp =this.getListOnLineCountInfo(list,"2",areaDeptEnum,false);
+            //瑙嗛
+            VideoOnlineRateExp VideoOnlineRateExp = this.getListOnLineCountInfo(list,"3",areaDeptEnum,false);
+
+
+            //灏嗚鍖哄煙绫讳笁绉嶈澶囩被鍨嬬殑 淇℃伅 鏀惧叆 excel瀵硅薄鍐�
+            //鏀惧叆褰撳墠鍖哄煙鐨勪汉鑴歌澶囩浉鍏宠缁�
+            videoTypeOffOnlineExps.add(faceVideoTypeOffOnlineExp);
+            //鏀惧叆褰撳墠鍖哄煙鐨勮溅杈嗚澶囩浉鍏宠缁�
+            videoTypeOffOnlineExps.add(carVideoTypeOffOnlineExp);
+            //鏀惧叆褰撳墠鍖哄煙鐨勮棰戣澶囩浉鍏宠缁�
+            videoTypeOffOnlineExps.add(videoTypeOffOnlineExp);
+
+            videoOnlineRateExps.add(faceVideoOnlineRateExp);
+            videoOnlineRateExps.add(carVideoOnlineRateExp);
+            videoOnlineRateExps.add(VideoOnlineRateExp);
+
+
+            VideoTypeOffOnlineExp ALLfaceVideoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"1",areaDeptEnum,true);
+            //鍗″彛
+            VideoTypeOffOnlineExp ALLcarVideoTypeOffOnlineExp =this.getListOfflineCountInfo(list,"2",areaDeptEnum,true);
+            //瑙嗛
+            VideoTypeOffOnlineExp ALLvideoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"3",areaDeptEnum,true);
+
+            VideoOnlineRateExp ALLfaceVideoOnlineRateExp = this.getListOnLineCountInfo(list,"1",areaDeptEnum,true);
+            //鍗″彛
+            VideoOnlineRateExp ALLcarVideoOnlineRateExp =this.getListOnLineCountInfo(list,"2",areaDeptEnum,true);
+            //瑙嗛
+            VideoOnlineRateExp ALLVideoOnlineRateExp = this.getListOnLineCountInfo(list,"3",areaDeptEnum,true);
+
+            //娣诲姞鍚堣鏁版嵁
+            allVideoTypeOffOnlineExps.add(ALLfaceVideoTypeOffOnlineExp);
+            //鏀惧叆褰撳墠鍖哄煙鐨勮溅杈嗚澶囩浉鍏宠缁�
+            allVideoTypeOffOnlineExps.add(ALLcarVideoTypeOffOnlineExp);
+            //鏀惧叆褰撳墠鍖哄煙鐨勮棰戣澶囩浉鍏宠缁�
+            allVideoTypeOffOnlineExps.add(ALLvideoTypeOffOnlineExp);
+
+            allVideoOnlineRateExps.add(ALLfaceVideoOnlineRateExp);
+            allVideoOnlineRateExps.add(ALLcarVideoOnlineRateExp);
+            allVideoOnlineRateExps.add(ALLVideoOnlineRateExp);
+
+        }
+        videoTypeOffOnlineExps.addAll(allVideoTypeOffOnlineExps);
+        videoOnlineRateExps.addAll(allVideoOnlineRateExps);
+        log.error("鎵撳嵃璁$畻绂荤嚎鐨勪俊鎭�:{}" ,videoTypeOffOnlineExps );
+        log.error("鎵撳嵃璁″湪绾跨殑淇℃伅:{}" ,videoOnlineRateExps );
+        //娣诲姞鍚堣鏁版嵁
+
+        ExcelExp excelTypeOffLineExp = new ExcelExp("绂荤嚎鏁扮粺璁�", videoTypeOffOnlineExps, VideoTypeOffOnlineExp.class);
+        mysheet.add(excelTypeOffLineExp);
+
+        //娣诲姞鍦ㄧ嚎鐜囪〃
+        ExcelExp excelOnlineRateExp = new ExcelExp("鍦ㄧ嚎鐜囩粺璁�",videoOnlineRateExps, VideoOnlineRateExp.class);
+        mysheet.add(excelOnlineRateExp);
+
         ExcelUtilManySheet<List<ExcelExp>> util = new ExcelUtilManySheet<>(mysheet);
         util.exportExcelManySheet(response, mysheet);
+        log.error("瀵煎嚭缁撴潫");
+    }
+
+    /**
+     * 璁$畻绂荤嚎璁惧excel瀵硅薄淇℃伅
+     * @param videoDailyExps 浼犲叆鐨勮澶囬泦鍚堜俊鎭�
+     * @param type 璁惧绫诲瀷 1浜鸿劯 2杞﹁締 3瑙嗛
+     * @param areaDeptEnum 鍖哄煙
+     * @return
+     */
+    public VideoTypeOffOnlineExp getListOfflineCountInfo(List<VideoDailyExp> videoDailyExps,
+                                                         String type,
+                                                         AreaDeptEnum areaDeptEnum,
+                                                         boolean isTotal){
+        VideoTypeOffOnlineExp videoTypeOffOnlineExp = new VideoTypeOffOnlineExp();
+
+        List<VideoDailyExp> list = videoDailyExps.stream()
+                .filter(device ->device.getType() != null && device.getType().contains(type)).collect(Collectors.toList());
+        log.error("绛涢�夊畬璁惧绫诲瀷 锛歿} 鍚庨泦鍚堢殑澶у皬锛歿}",type,list.size());
+        //绂荤嚎鏁伴噺
+        try {
+            //璁剧疆绂荤嚎鏁伴噺 浠ュ強姣忔棩绂荤嚎鏁伴噺
+            setVideoTypeOffOnlineExpCountAndDays(list,videoTypeOffOnlineExp,isTotal);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+        }
+        //璁惧绫诲瀷
+        if(isTotal){
+            if ("1".equals(type)){
+                videoTypeOffOnlineExp.setType("浜鸿劯鍚堣");
+            }else if ("2".equals(type)){
+                videoTypeOffOnlineExp.setType("鍗″彛鍚堣");
+            }else if ("3".equals(type)){
+                videoTypeOffOnlineExp.setType("瑙嗛鍚堣");
+            }
+        }else {
+            if ("1".equals(type)){
+                videoTypeOffOnlineExp.setType("浜鸿劯");
+            }else if ("2".equals(type)){
+                videoTypeOffOnlineExp.setType("鍗″彛");
+            }else if ("3".equals(type)){
+                videoTypeOffOnlineExp.setType("瑙嗛");
+            }
+        }
+        //淇敼鍖哄煙
+        videoTypeOffOnlineExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName());
+        return videoTypeOffOnlineExp;
+    }
+
+    private void setVideoTypeOffOnlineExpCountAndDays(List<VideoDailyExp> videoDailyExps,VideoTypeOffOnlineExp videoTypeOffOnlineExp,boolean isTotal)throws NoSuchFieldException, IllegalAccessException {
+        //寰幆涓�涓湀
+        //绂荤嚎鎬绘暟
+        long AllOffLineCount = 0;
+        log.error("浼犲叆闆嗗悎澶у皬:{}", videoDailyExps.size());
+        for (VideoDailyExp videoDailyExp : videoDailyExps) {
+            if (videoDailyExp.isAllOfflineByMonth()) {
+                AllOffLineCount++;
+            }
+        }
+        //鏄悎璁℃暟鎹笉闇�瑕佷笅鏂规暟鎹�
+//        if (!isTotal) {
+            for (int i = 1; i <= 31; i++) {
+                //姣忔棩绂荤嚎鏁�
+                long count = 0;
+                String fieldName = "day" + i;
+                for (VideoDailyExp videoDailyExp : videoDailyExps) {
+                    // 鏋勯�犲瓧娈靛悕
+                    Field field = videoDailyExp.getClass().getDeclaredField(fieldName);
+                    // 纭繚瀛楁鏄鏈夌殑鍙互璁块棶
+                    field.setAccessible(true);
+                    // 鑾峰彇瀛楁鍊�
+                    String value = (String) field.get(videoDailyExp);
+                    if ("绂荤嚎".equals(value)) {
+                        count++;
+                    }
+                }
+                //鍙嶅皠娣诲姞鍒板璞″睘鎬т腑
+                Field field = videoTypeOffOnlineExp.getClass().getDeclaredField(fieldName);
+                field.setAccessible(true);
+                String rateStr = count + "";
+                if (!"0".equals(rateStr)) {
+                    field.set(videoTypeOffOnlineExp, rateStr);
+                }
+
+            }
+//        }
+        videoTypeOffOnlineExp.setOfflineCount(String.valueOf(AllOffLineCount));
+    }
+
+    /**
+     * 璁$畻鍦ㄧ嚎璁惧excel瀵硅薄淇℃伅
+     * @param videoDailyExps 浼犲叆鐨勮澶囬泦鍚堜俊鎭�
+     * @param type 璁惧绫诲瀷 1浜鸿劯 2杞﹁締 3瑙嗛
+     * @param areaDeptEnum 鍖哄煙
+     * @return
+     */
+    public VideoOnlineRateExp getListOnLineCountInfo(List<VideoDailyExp> videoDailyExps,
+                                                         String type,
+                                                         AreaDeptEnum areaDeptEnum,
+                                                         boolean isTotal){
+        VideoOnlineRateExp videoOnlineRateExp = new VideoOnlineRateExp();
+
+        List<VideoDailyExp> list = videoDailyExps.stream()
+                .filter(device ->device.getType() != null && device.getType().contains(type)).collect(Collectors.toList());
+        log.error("绛涢�夊畬璁惧绫诲瀷 锛歿} 鍚庨泦鍚堢殑澶у皬锛歿}",type,list.size());
+        //绂荤嚎鏁伴噺
+        try {
+            //璁剧疆绂荤嚎鏁伴噺 浠ュ強姣忔棩绂荤嚎鏁伴噺
+            setVideoOnlineRateExpCountAndDays(list,videoOnlineRateExp,isTotal);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+        }
+        //璁惧绫诲瀷
+        if(isTotal) {
+            if ("1".equals(type)) {
+                videoOnlineRateExp.setType("浜鸿劯鍚堣");
+            } else if ("2".equals(type)) {
+                videoOnlineRateExp.setType("鍗″彛鍚堣");
+            } else if ("3".equals(type)) {
+                videoOnlineRateExp.setType("瑙嗛鍚堣");
+            }
+        }else {
+            if ("1".equals(type)) {
+                videoOnlineRateExp.setType("浜鸿劯");
+            } else if ("2".equals(type)) {
+                videoOnlineRateExp.setType("鍗″彛");
+            } else if ("3".equals(type)) {
+                videoOnlineRateExp.setType("瑙嗛");
+            }
+        }
+        //淇敼鍖哄煙
+        videoOnlineRateExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName());
+        return videoOnlineRateExp;
+    }
+
+
+    private void setVideoOnlineRateExpCountAndDays(List<VideoDailyExp> videoDailyExps,VideoOnlineRateExp videoOnlineRateExp,boolean isTotal)throws NoSuchFieldException, IllegalAccessException {
+
+        //寰幆涓�涓湀
+        for (int i = 1;i <= 31 ;i++){
+            //鍦ㄧ嚎鐜囪绠�
+            long count = 0;
+            String fieldName = "day" + i;
+            for(VideoDailyExp videoDailyExp: videoDailyExps){
+                // 鏋勯�犲瓧娈靛悕
+                Field field = videoDailyExp.getClass().getDeclaredField(fieldName);
+                // 纭繚瀛楁鏄鏈夌殑鍙互璁块棶
+                field.setAccessible(true);
+                // 鑾峰彇瀛楁鍊�
+                String value = (String) field.get(videoDailyExp);
+                if ("鍦ㄧ嚎".equals(value)) {
+                    count ++;
+                }
+            }
+            //姣忔棩鍦ㄧ嚎鐜�
+            double rate = (double) count / videoDailyExps.size();
+            //鍙嶅皠娣诲姞鍒板璞″睘鎬т腑
+            Field field = videoOnlineRateExp.getClass().getDeclaredField(fieldName);
+            field.setAccessible(true);
+            String rateStr = String.format("%.2f", rate * 100) +"%";
+            if (!"0.00%".equals(rateStr)){
+                field.set(videoOnlineRateExp, rateStr);
+            }
+
+        }
     }
 
 
@@ -826,6 +1074,7 @@
                         Function.identity(),  // valueMapper锛岀洿鎺ヤ娇鐢ㄥ璞℃湰韬�
                         (existing, replacement) -> existing // mergeFunction锛屽鏋滄湁閲嶅锛屼繚鐣欑涓�涓�
                 ));
+
         // 灏� Map 杞崲涓� List
         List<TMonitorResult> tMonitorResults = new ArrayList<>(uniqueResultsMap.values());
         //鑾峰彇鍔ㄦ�佸垪鏁版嵁
@@ -1387,6 +1636,7 @@
     private void setOnlineDaily(VideoDailyExp videoDailyExp, TMonitorResult result, List<TMonitorResult> onlines) throws NoSuchFieldException, IllegalAccessException {
         //涓�涓澶囧綋鏈堝湪绾挎儏鍐�
         List<TMonitorResult> onlineResult = onlines.stream().filter(online -> online.getNo().equals(result.getNo())).collect(Collectors.toList());
+        videoDailyExp.setOnlineStateList(onlineResult);
         for (TMonitorResult monitorResult : onlineResult) {
             int dayOfMonth = monitorResult.getMongoCreateTime().getDayOfMonth();
             String online = "";
@@ -1402,6 +1652,8 @@
             field.setAccessible(true);
             field.set(videoDailyExp, online);
         }
+
+
     }
 
     //璁剧疆姣忔棩褰曞儚鏁版嵁
diff --git a/ycl-server/src/main/java/com/ycl/task/UYTask.java b/ycl-server/src/main/java/com/ycl/task/UYTask.java
index c351a65..d320d67 100644
--- a/ycl-server/src/main/java/com/ycl/task/UYTask.java
+++ b/ycl-server/src/main/java/com/ycl/task/UYTask.java
@@ -194,6 +194,9 @@
         } else {
             log.error("璇烽厤缃绾挎鏁帮紝姝ゆ璁剧疆涓洪粯璁ゅ��2");
         }
+
+        // 鐜板湪闇�瑕佹煡鍑虹姸鎬佷负鏈煡鐨勮澶�
+
         // 鍏堟煡鍑鸿澶嘔P闆嗗悎,鍓旈櫎鎺夊湪绾挎儏鍐垫槸鏈煡鐨�,骞朵笖鍙娴嬫鍦ㄨ�冩牳鐨勮澶囬伩鍏嶅浣欏伐鍗�
         List<TMonitorResult> monitorList = monitorMapper.getDistinctIP();
         //琛ュ厖閿欒鏃堕棿鐐�
@@ -230,6 +233,7 @@
         CompletableFuture<Void> allOf = CompletableFuture.allOf(
                 futureList.toArray(new CompletableFuture[0])
         );
+
         try {
             allOf.get(60, TimeUnit.SECONDS); // 缁欎簣棰濆鐨�5绉掓潵鏀堕泦缁撴灉
         } catch (TimeoutException e) {
@@ -289,6 +293,8 @@
             Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
             DeleteResult result = mongoTemplate.remove(query, TMonitorResult.class);
             //瀛樻斁鍦╩ongo涓�
+
+            log.error("瀛樺叆鍚屾鍦ㄧ嚎mongo鏁版嵁{}" , monitorList );
             mongoTemplate.insertAll(mongoList);
         }
         //宸ュ崟锛堝悓涓�IP鍙敓鎴愪竴涓伐鍗曪級
diff --git a/ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml
index 045e962..244d095 100644
--- a/ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml
+++ b/ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml
@@ -694,9 +694,9 @@
         from t_monitor m
             left join t_yw_point p on m.serial_number = p.serial_number
             left join sys_dept d on p.dept_id = d.dept_id
-        where p.online != 0 and p.examine_status = 1
+        where  p.examine_status = 1
     </select>
-
+<!--涓婃柟淇敼浜�  p.online != 0 and-->
     <update id="updateOnlineFromUyOrHk">
         <foreach collection="onlineList" item="online" separator=";">
             UPDATE

--
Gitblit v1.8.0