From fdcdd41fba7874c045766e3dea54d56d70df73ef Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期一, 12 五月 2025 10:06:50 +0800
Subject: [PATCH] (部级录像可用率,重点录像可用率,录像可用率)计算可用率

---
 ycl-server/src/main/java/com/ycl/calculate/MonitorRegistrationCalculation.java |   36 ++++++++++++++++++++++++++----------
 1 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/calculate/MonitorRegistrationCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/MonitorRegistrationCalculation.java
index 77353f2..eb34546 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/MonitorRegistrationCalculation.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/MonitorRegistrationCalculation.java
@@ -2,9 +2,11 @@
 
 import com.ycl.platform.domain.entity.CheckIndexVideo;
 import com.ycl.platform.domain.result.UY.MonitorQualifyResult;
+import com.ycl.platform.domain.vo.TMonitorVO;
 import com.ycl.platform.mapper.CheckIndexVideoMapper;
 import com.ycl.platform.mapper.TMonitorMapper;
 import com.ycl.platform.service.ICheckIndexVideoService;
+import constant.ApiConstants;
 import constant.CheckThreadConstants;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,27 +36,42 @@
 
     //鍖哄煙瑙嗛鍦ㄧ嚎鐜囩殑鍐呴儴绫�
     protected static class AreaStats {
-        //璧勪骇搴撶櫥璁板湪鐢ㄦ暟
-        int totalSites = 0;
+        //褰撴棩妗f鏁�
+        int todayFiles = 0;
         //鏈敞鍐岀殑鏁伴噺
         int newSites = 0;
         //鍏ㄥ勾鐣欏瓨鏁�
         int allFiles = 0;
-        //褰撴棩妗f鏁帮紙鍑屾櫒璁$畻鐨勶紝瀹為檯鍙栧緱鏄槰鏃ョ殑涓�鏈轰竴妗f暟閲忥級
-        int todayFiles = 0;
     }
-    //TODO:鏀逛负MonitorQualifyResult锛岀畻娉曚紭鍖�
     @Override
     public void calculate(List<MonitorQualifyResult> list) {
         //鑾峰彇鍒嗗尯鍩熺殑鎸囨爣鏁伴噺
-        Map<String, MonitorRegistrationCalculation.AreaStats> areaStatsMap = getAreaStatsMap(list);
+        Map<String, MonitorRegistrationCalculation.AreaStats> areaStatsMap = getAreaStatsMap(list,Boolean.TRUE);
         if (areaStatsMap == null) return;
+
+        //鏌ユ暟鎹簱琛ュ厖鍏ㄥ勾鐣欏瓨鏁�
+        List<TMonitorVO> monitorVOS = monitorMapper.selectMonitorVOList();
+        areaStatsMap.forEach((key,areaStats)->{
+            if(key.startsWith(ApiConstants.Province)){
+                long count = monitorVOS.stream().filter(TMonitorVO::getProvinceTag)
+                        .filter(vo -> key.split("_")[1].equals(vo.getDeptId() + "")).count();
+                areaStats.allFiles = Integer.parseInt(count+"");
+            }else if(key.startsWith(ApiConstants.Dept)){
+                long count = monitorVOS.stream().filter(TMonitorVO::getDeptTag)
+                        .filter(vo -> key.split("_")[1].equals(vo.getDeptId() + "")).count();
+                areaStats.allFiles = Integer.parseInt(count+"");
+            }
+            else {
+                long count = monitorVOS.stream().filter(vo -> key.equals(vo.getDeptId() + "")).count();
+                areaStats.allFiles = Integer.parseInt(count+"");
+            }
+        });
 
         // 鏌ヨ鏄惁index琛ㄥ凡缁忓瓨鍦ㄤ粖鏃ユ暟鎹�
         List<CheckIndexVideo> checkIndexVideoList = checkIndexVideoMapper.selectToday(DateUtils.getDate());
         List<CheckIndexVideo> checkIndexVideos = new ArrayList<>();
         areaStatsMap.forEach((key, stats) -> {
-            if (stats.totalSites > 0) {
+            if (stats.todayFiles > 0) {
                 CheckIndexVideo checkIndexVideo = createOrUpdateCheckIndexVideo(key, stats, checkIndexVideoList);
                 if (checkIndexVideo != null) {
                     checkIndexVideos.add(checkIndexVideo);
@@ -72,8 +89,7 @@
     public void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, MonitorQualifyResult result) {
         //杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value
         AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats());
-        stats.totalSites++;
-        stats.allFiles++;
+        stats.todayFiles++;
         if (result.getNewDevice()!=null && result.getNewDevice()) {
             stats.newSites++;
         }
@@ -89,7 +105,7 @@
         }
         //璋冪敤涓�鏈轰竴妗f敞鍐岀巼
         Map<String, Object> param = new HashMap<>();
-        param.put("totalSites", stats.totalSites);
+        param.put("totalSites", stats.todayFiles);
         param.put("newSites", stats.newSites);
         BigDecimal monitorRegistration = monitorRegistration(param);
         checkIndexVideo.setMonitorRegistration(monitorRegistration);

--
Gitblit v1.8.0