From c0a6471efcf392e54aeefe318a27d5da78220fd7 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期一, 19 八月 2024 16:32:51 +0800
Subject: [PATCH] 人脸指标计算测试+修改

---
 ycl-server/src/main/java/com/ycl/calculate/VideoUsabilityCalculation.java |   37 +++++++++++++++++++++----------------
 1 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/calculate/VideoUsabilityCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/VideoUsabilityCalculation.java
index 954343f..b169a11 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/VideoUsabilityCalculation.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/VideoUsabilityCalculation.java
@@ -5,10 +5,14 @@
 import com.ycl.platform.domain.entity.TMonitor;
 import com.ycl.platform.domain.param.UY.RecordMetaDSumParam;
 import com.ycl.platform.domain.result.UY.QueryVqdResult;
+import com.ycl.platform.domain.result.UY.RecordMetaDSumResult;
+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 com.ycl.platform.service.ITMonitorService;
 import constant.ApiConstants;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
@@ -30,11 +34,12 @@
  * 鏇存柊鎴栨柊澧�
  */
 @Component
-public class VideoUsabilityCalculation extends IndexCalculationServe implements CalculationStrategy<RecordMetaDSumParam> {
+@Slf4j
+public class VideoUsabilityCalculation extends IndexCalculationServe implements CalculationStrategy<RecordMetaDSumResult> {
     @Autowired
     private CheckIndexVideoMapper checkIndexVideoMapper;
     @Autowired
-    private ITMonitorService monitorService;
+    private TMonitorMapper monitorMapper;
     @Autowired
     private ICheckIndexVideoService checkIndexVideoService;
 
@@ -47,23 +52,23 @@
     }
 
     @Override
-    public void calculate(List<RecordMetaDSumParam> list) {
+    public void calculate(List<RecordMetaDSumResult> list) {
         if (CollectionUtils.isEmpty(list)) {
+            log.info("鏁版嵁涓虹┖");
             return;
         }
 
         //鑾峰緱鍥芥爣鐮佷负key鐨勮澶噈ap
-        Map<String, TMonitor> monitorMap = monitorService.list(new QueryWrapper<TMonitor>()
-                        .in("serial_number", list.stream().map(RecordMetaDSumParam::getDeviceId).collect(Collectors.toList())))
-                .stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity()));
+        Map<String, TMonitorVO> monitorMap = monitorMapper.selectListByIds(list.stream().map(RecordMetaDSumResult::getDeviceId).collect(Collectors.toList()))
+                .stream().collect(Collectors.toMap(TMonitorVO::getSerialNumber, Function.identity()));
         //鑾峰彇鐪佸巺鍥芥爣鐮侀泦鍚�
         List<String> provinceIds = getProvince();
         //閲嶇偣鐐逛綅闆嗗悎
         List<String> important = getImportant();
 
         Map<String, AreaStats> areaStatsMap = new HashMap<>();
-        for (RecordMetaDSumParam result : list) {
-            TMonitor monitor = monitorMap.get(result.getDeviceId());
+        for (RecordMetaDSumResult result : list) {
+            TMonitorVO monitor = monitorMap.get(result.getDeviceId());
             if (monitor == null) continue;
 
             String deptId = monitor.getDeptId().toString();
@@ -71,7 +76,7 @@
 
             // 澶勭悊鐪佸巺鏁版嵁
             if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) {
-                String provinceKey = "Province_" + deptId;
+                String provinceKey = ApiConstants.Province + deptId;
                 updateAreaStats(areaStatsMap, provinceKey, result, important);
             }
         }
@@ -81,9 +86,9 @@
         List<CheckIndexVideo> checkIndexVideos = new ArrayList<>();
         areaStatsMap.forEach((deptId, stats) -> {
             if (stats.totalSites > 0) {
-                CheckIndexVideo CheckIndexVideo = createOrUpdateCheckIndexFace(deptId, stats, checkIndexVideoList);
-                if (CheckIndexVideo != null) {
-                    checkIndexVideos.add(CheckIndexVideo);
+                CheckIndexVideo checkIndexVideo = createOrUpdateCheckIndexVideo(deptId, stats, checkIndexVideoList);
+                if (checkIndexVideo != null) {
+                    checkIndexVideos.add(checkIndexVideo);
                 }
             }
         });
@@ -94,7 +99,7 @@
     /**
      * 绱鎬荤偣浣嶆暟銆佸湪绾跨偣浣嶆暟銆侀噸鐐圭偣浣嶆暟銆侀噸鐐圭偣浣嶅湪绾挎暟
      */
-    private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, RecordMetaDSumParam result, List<String> important) {
+    private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, RecordMetaDSumResult result, List<String> important) {
         //杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value
         AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats());
         stats.totalSites++;
@@ -113,7 +118,7 @@
     /**
      * 瑙嗛鐐逛綅鍦ㄧ嚎鐜�
      */
-    private CheckIndexVideo createOrUpdateCheckIndexFace(String key, AreaStats stats, List<CheckIndexVideo> checkIndexVideoList) {
+    private CheckIndexVideo createOrUpdateCheckIndexVideo(String key, AreaStats stats, List<CheckIndexVideo> checkIndexVideoList) {
         CheckIndexVideo checkIndexVideo = getCheckIndex(key, checkIndexVideoList, CheckIndexVideo.class);
         if (checkIndexVideo == null) {
             return null;
@@ -126,8 +131,8 @@
         checkIndexVideo.setVideoAvailable(videoUsability);
         //璋冪敤褰曞儚鍙敤鐜囪绠楁柟娉� 璁$畻閲嶇偣鐐逛綅褰曞儚鍙敤鐜�
         Map<String, Object> importantParam = new HashMap<>();
-        param.put("totalSites", stats.importantSites);
-        param.put("usabilitySites", stats.importantUsabilitySites);
+        importantParam.put("totalSites", stats.importantSites);
+        importantParam.put("usabilitySites", stats.importantUsabilitySites);
         BigDecimal importantVideoUsability = videoUsability(importantParam);
         checkIndexVideo.setKeyVideoAvailable(importantVideoUsability);
         return checkIndexVideo;

--
Gitblit v1.8.0