From 36a00aa8bee92f62470fc1031c8c07f3de35910d Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 15 一月 2025 17:53:25 +0800
Subject: [PATCH] osd不做筛选,检测全量

---
 ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java |   70 ++++++++++++++++++++++++++++++++++-
 1 files changed, 68 insertions(+), 2 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 2ae0bfb..549028c 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java
@@ -1,13 +1,79 @@
 package com.ycl.calculate;
 
+import com.fasterxml.jackson.databind.ser.Serializers;
+import com.ycl.platform.domain.entity.CheckIndexVideo;
+import com.ycl.platform.domain.result.BaseResult;
 import com.ycl.platform.domain.result.UY.QueryVqdResult;
+import com.ycl.platform.domain.result.UY.VideoOnlineResult;
+import com.ycl.platform.domain.vo.PlatformOnlineVO;
+import com.ycl.platform.mapper.CheckIndexVideoMapper;
+import com.ycl.platform.service.ICheckIndexVideoService;
+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;
+import org.springframework.util.CollectionUtils;
+import utils.DateUtils;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
-public class PlatformOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<QueryVqdResult> {
+/**
+ * 骞冲彴鍦ㄧ嚎鐜囪绠�
+ * 绂荤嚎鏃堕暱姣忚秴杩�30鍒嗛挓鎵g櫨鍒嗕箣鍗�
+ * 涓嶅尯鍒嗗尯鍩�
+ */
+@Component
+@Slf4j
+public class PlatformOnlineCalculation extends IndexCalculationUtils implements CalculationStrategy<PlatformOnlineVO> {
+    @Autowired
+    private SysDeptMapper deptMapper;
+    @Autowired
+    private CheckIndexVideoMapper videoMapper;
+    @Autowired
+    private ICheckIndexVideoService checkIndexVideoService;
 
     @Override
-    public void calculate(List<QueryVqdResult> list) {
+    public void calculate(List<PlatformOnlineVO> list) {
+        Map<String,Double> map = new HashMap<>();
+        if (!CollectionUtils.isEmpty(list)) {
+            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);
+                    map.put(ApiConstants.Dept + deptId,score);
+                }
+            }
 
+            //鏄惁宸茬粡瀛樺湪褰撴棩鏁版嵁
+            List<CheckIndexVideo> checkIndexVideos = videoMapper.selectToday(DateUtils.getDate());
+
+            List<CheckIndexVideo> videos = new ArrayList<>();
+            map.forEach((key,score) -> {
+                //濡傛灉涓嶅瓨鍦ㄥ氨鏂板濡傛灉瀛樺湪鍒欏鐢�
+                CheckIndexVideo checkIndex = getCheckIndex(key, checkIndexVideos, CheckIndexVideo.class);
+                if (checkIndex != null) {
+                    checkIndex.setPlatformOnline(new BigDecimal(score));
+                    videos.add(checkIndex);
+                }
+            });
+            checkIndexVideoService.saveOrUpdateBatch(videos);
+        }else {
+            log.info("鏁版嵁涓虹┖");
+        }
     }
+
 }

--
Gitblit v1.8.0