From 1aa2a59a237dbc4c58a5e3d09be2bfeaf1535c8b Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期六, 31 八月 2024 21:26:30 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java
index 6f0c037..099bc3b 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java
@@ -8,6 +8,7 @@
 import com.ycl.system.mapper.SysDeptMapper;
 import constant.ApiConstants;
 import constant.CheckConstants;
+import enumeration.general.AreaDeptEnum;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -37,24 +38,27 @@
 
     @Override
     public void calculate(List<PlatformOnlineVO> list) {
+        Map<String,Double> map = new HashMap<>();
         if (!CollectionUtils.isEmpty(list)) {
-            //鎬荤绾挎椂闀�
-            int time = list.stream().map(PlatformOnlineVO::getTodayOutlineSed).reduce(0, Integer::sum);
-            //绂荤嚎鏃堕暱杞崲浣嶅垎閽熺劧鍚庡彇妯�
-            int num = (time / 60) % 30;
-            double score = Math.max(1 - num * 0.1, 0);
+            for (PlatformOnlineVO platformOnlineVO : list) {
+                String[] areas = platformOnlineVO.getArea().split(",");
+                for (String area : areas) {
+                    Integer deptId = AreaDeptEnum.fromCode(area).getDeptId();
+                    //绂荤嚎鏃堕暱
+                    Integer time = platformOnlineVO.getTodayOutlineSed();
+                    //绂荤嚎鏃堕暱杞崲浣嶅垎閽�
+                    int num = (time / 60) / 30;
+                    double score = Math.max(1 - num * 0.1, 0);
+                    map.put(deptId+"",score);
+                    map.put(ApiConstants.Province + deptId,score);
+                }
+            }
+
             //鏄惁宸茬粡瀛樺湪褰撴棩鏁版嵁
             List<CheckIndexVideo> checkIndexVideos = videoMapper.selectToday(DateUtils.getDate());
-            //鎵�鏈夊尯鍩熼儴闂�
-            List<Long> deptIds = deptMapper.selectByParentId(207L);
-            List<String> keys = new ArrayList<>();
-            //鍑嗗鍖哄垎鐪佸巺銆佸尯鍩熺殑deptId list
-            for (Long deptId : deptIds) {
-                keys.add(deptId + "");
-                keys.add(ApiConstants.Province + deptId);
-            }
+
             List<CheckIndexVideo> videos = new ArrayList<>();
-            keys.forEach(key -> {
+            map.forEach((key,score) -> {
                 //濡傛灉涓嶅瓨鍦ㄥ氨鏂板濡傛灉瀛樺湪鍒欏鐢�
                 CheckIndexVideo checkIndex = getCheckIndex(key, checkIndexVideos, CheckIndexVideo.class);
                 if (checkIndex != null) {

--
Gitblit v1.8.0