From 615af82c9ea47993e78b00e9c64e887e063474f8 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 04 九月 2024 22:08:50 +0800
Subject: [PATCH] 点位修改增加部级标签设置
---
ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java | 70 ++++++++++++++++++++++++++++-------
1 files changed, 56 insertions(+), 14 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java
index 5c4f9ea..2135fba 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java
@@ -13,6 +13,8 @@
import com.ycl.platform.service.ICheckIndexVideoService;
import com.ycl.platform.service.ITMonitorService;
import constant.ApiConstants;
+import constant.CheckThreadConstants;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@@ -27,13 +29,14 @@
import java.util.stream.Collectors;
/**
- * 璁$畻瑙嗛璁惧鐐逛綅鍦ㄧ嚎鐜囥�侀噸鐐圭偣浣嶅湪绾跨巼銆侀噸鐐规寚鎸ュ浘鍍忓湪绾跨巼
+ * 璁$畻瑙嗛璁惧鐐逛綅鍦ㄧ嚎鐜囥�侀噸鐐圭偣浣嶅湪绾跨巼銆侀噸鐐规寚鎸ュ浘鍍忓湪绾跨巼銆侀儴绾х偣浣嶅湪绾跨巼
* 鍥惧儚鐩戞祴璇婃柇缁撴灉
* 鑾峰彇鍒嗙渷鍘呫�佸尯鍩熺殑map<k,v> k涓篸eptId鎴栬�匬rovince_deptId
* 寰幆map璁$畻鏁版嵁涓婁紶鍙婃椂鎬�
* 鏇存柊鎴栨柊澧�
*/
@Component
+@Slf4j
public class VideoOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<VideoOnlineResult> {
@Autowired
private CheckIndexVideoMapper checkIndexVideoMapper;
@@ -50,11 +53,14 @@
int importantOnlineSites = 0;
int commandSites = 0;
int commandOnlineSites =0;
+ int deptSites = 0;
+ int deptOnlineSites = 0;
}
@Override
public void calculate(List<VideoOnlineResult> list) {
if (CollectionUtils.isEmpty(list)) {
+ log.info("鏁版嵁涓虹┖");
return;
}
@@ -67,6 +73,8 @@
List<String> important = getImportant();
//閲嶇偣鎸囨尌鍥惧儚闆嗗悎
List<String> commandImage = getCommandImage();
+ //鑾峰彇閮ㄧ骇鐐逛綅闆嗗悎
+ List<String> deptTag = getDeptTag();
Map<String, AreaStats> areaStatsMap = new HashMap<>();
for (VideoOnlineResult result : list) {
@@ -74,12 +82,12 @@
if (monitor == null) continue;
String deptId = monitor.getDeptId().toString();
- updateAreaStats(areaStatsMap, deptId, result, important,commandImage);
+ updateAreaStats(areaStatsMap, deptId, result, important,commandImage,deptTag);
// 澶勭悊鐪佸巺鏁版嵁
if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) {
String provinceKey = ApiConstants.Province + deptId;
- updateAreaStats(areaStatsMap, provinceKey, result, important,commandImage);
+ updateAreaStats(areaStatsMap, provinceKey, result, important,commandImage,deptTag);
}
}
@@ -101,7 +109,7 @@
/**
* 绱鎬荤偣浣嶆暟銆佸湪绾跨偣浣嶆暟銆侀噸鐐圭偣浣嶆暟銆侀噸鐐圭偣浣嶅湪绾挎暟銆佹寚鎸ュ浘鍍忔暟銆佹寚鎸ュ浘鍍忓湪绾挎暟
*/
- private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, VideoOnlineResult result, List<String> important, List<String> commandImage) {
+ private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, VideoOnlineResult result, List<String> important, List<String> commandImage,List<String> deptTag) {
//杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value
AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats());
stats.totalSites++;
@@ -113,6 +121,9 @@
if(commandImage.contains(result.getDeviceId())){
stats.commandSites++;
}
+ if(deptTag.contains(result.getDeviceId())){
+ stats.deptSites++;
+ }
if (ApiConstants.UY_OnlineSite_Online.equals(result.getStatus())){
stats.onlineSites++;
if(important.contains(result.getDeviceId())){
@@ -120,6 +131,9 @@
}
if(commandImage.contains(result.getDeviceId())){
stats.commandOnlineSites++;
+ }
+ if(deptTag.contains(result.getDeviceId())){
+ stats.deptOnlineSites++;
}
}
}
@@ -138,18 +152,46 @@
param.put("onlineSites", stats.onlineSites);
BigDecimal siteOnline = siteOnline(param);
checkIndexVideo.setSiteOnline(siteOnline);
+ //鍖哄幙涓嶅皯浜�100璺�
+ if(stats.totalSites < CheckThreadConstants.Check_Video_SiteOnline){
+ checkIndexVideo.setSiteOnline(BigDecimal.ZERO);
+ }
//璋冪敤鐐逛綅鍦ㄧ嚎鐜囪绠楁柟娉� 璁$畻閲嶇偣鐐逛綅鍦ㄧ嚎鐜�
- Map<String, Object> importantParam = new HashMap<>();
- param.put("totalSites", stats.importantSites);
- param.put("onlineSites", stats.importantOnlineSites);
- BigDecimal importantSiteOnline = siteOnline(importantParam);
- checkIndexVideo.setKeySiteOnline(importantSiteOnline);
+ if(stats.importantSites!=0) {
+ Map<String, Object> importantParam = new HashMap<>();
+ importantParam.put("totalSites", stats.importantSites);
+ importantParam.put("onlineSites", stats.importantOnlineSites);
+ BigDecimal importantSiteOnline = siteOnline(importantParam);
+ checkIndexVideo.setKeySiteOnline(importantSiteOnline);
+ }else {
+ log.info("閲嶇偣鐐逛綅鏁颁负0");
+ }
+
+ //鍖哄幙瑙嗛閲嶇偣鐐逛綅鏁颁笉灏戜簬10璺�
+ if(stats.importantSites<CheckThreadConstants.Check_Video_ImportantSite){
+ checkIndexVideo.setKeySiteOnline(BigDecimal.ZERO);
+ }
+
//璋冪敤鐐逛綅鍦ㄧ嚎鐜囪绠楁柟娉� 璁$畻鎸囨尌鍥惧儚鍦ㄧ嚎鐜�
- Map<String, Object> commandParam = new HashMap<>();
- param.put("totalSites", stats.commandSites);
- param.put("onlineSites", stats.commandOnlineSites);
- BigDecimal commandSiteOnline = siteOnline(importantParam);
- checkIndexVideo.setKeyCommandImageOnline(commandSiteOnline);
+ if(stats.commandSites!=0) {
+ Map<String, Object> commandParam = new HashMap<>();
+ commandParam.put("totalSites", stats.commandSites);
+ commandParam.put("onlineSites", stats.commandOnlineSites);
+ BigDecimal commandSiteOnline = siteOnline(commandParam);
+ checkIndexVideo.setKeyCommandImageOnline(commandSiteOnline);
+ }else {
+ log.info("鎸囨尌鍥惧儚鐐逛綅鏁颁负0");
+ }
+ //璋冪敤鐐逛綅鍦ㄧ嚎鐜囪绠楁柟娉� 璁$畻閮ㄧ骇鐐逛綅鍦ㄧ嚎鐜�
+ if(stats.deptSites!=0) {
+ Map<String, Object> deptParam = new HashMap<>();
+ deptParam.put("totalSites", stats.deptSites);
+ deptParam.put("onlineSites", stats.deptOnlineSites);
+ BigDecimal deptOnline = siteOnline(deptParam);
+ checkIndexVideo.setMinistrySiteOnline(deptOnline);
+ }else {
+ log.info("閮ㄧ骇鐐逛綅鏁颁负0");
+ }
return checkIndexVideo;
}
}
--
Gitblit v1.8.0