From d6f915ecc8ee7efd5fcd3a205b57ef490b918fa5 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期三, 21 八月 2024 14:27:59 +0800
Subject: [PATCH] feat:数据中心数字增加中文字段
---
ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java | 87 ++++++++++++++++++++++++++++++++-----------
1 files changed, 64 insertions(+), 23 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 7b82051..1fbc17b 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java
@@ -5,11 +5,16 @@
import com.ycl.platform.domain.entity.TMonitor;
import com.ycl.platform.domain.result.HK.SnapshotDelayMonitorResult;
import com.ycl.platform.domain.result.UY.QueryVqdResult;
+import com.ycl.platform.domain.result.UY.VideoOnlineResult;
+import com.ycl.platform.domain.vo.TMonitorVO;
import com.ycl.platform.mapper.CheckIndexVideoMapper;
+import com.ycl.platform.mapper.TMonitorMapper;
import com.ycl.platform.service.ICheckIndexFaceService;
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;
@@ -24,19 +29,19 @@
import java.util.stream.Collectors;
/**
- * 璁$畻瑙嗛璁惧鐐逛綅鍦ㄧ嚎鐜囥�侀噸鐐圭偣浣嶅湪绾跨巼
+ * 璁$畻瑙嗛璁惧鐐逛綅鍦ㄧ嚎鐜囥�侀噸鐐圭偣浣嶅湪绾跨巼銆侀噸鐐规寚鎸ュ浘鍍忓湪绾跨巼
* 鍥惧儚鐩戞祴璇婃柇缁撴灉
* 鑾峰彇鍒嗙渷鍘呫�佸尯鍩熺殑map<k,v> k涓篸eptId鎴栬�匬rovince_deptId
* 寰幆map璁$畻鏁版嵁涓婁紶鍙婃椂鎬�
* 鏇存柊鎴栨柊澧�
*/
@Component
-//TODO锛氶噸鐐规寚鎸ュ浘鍍忓湪绾跨巼
-public class VideoOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<QueryVqdResult> {
+@Slf4j
+public class VideoOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<VideoOnlineResult> {
@Autowired
private CheckIndexVideoMapper checkIndexVideoMapper;
@Autowired
- private ITMonitorService monitorService;
+ private TMonitorMapper monitorMapper;
@Autowired
private ICheckIndexVideoService checkIndexVideoService;
@@ -46,35 +51,39 @@
int onlineSites = 0;
int importantSites = 0;
int importantOnlineSites = 0;
+ int commandSites = 0;
+ int commandOnlineSites =0;
}
@Override
- public void calculate(List<QueryVqdResult> list) {
+ public void calculate(List<VideoOnlineResult> 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(QueryVqdResult::getDeviceId).collect(Collectors.toList())))
- .stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity()));
+ Map<String, TMonitorVO> monitorMap = monitorMapper.selectListByIds(list.stream().map(VideoOnlineResult::getDeviceId).collect(Collectors.toList()))
+ .stream().collect(Collectors.toMap(TMonitorVO::getSerialNumber, Function.identity()));
//鑾峰彇鐪佸巺鍥芥爣鐮侀泦鍚�
List<String> provinceIds = getProvince();
//閲嶇偣鐐逛綅闆嗗悎
List<String> important = getImportant();
+ //閲嶇偣鎸囨尌鍥惧儚闆嗗悎
+ List<String> commandImage = getCommandImage();
Map<String, AreaStats> areaStatsMap = new HashMap<>();
- for (QueryVqdResult result : list) {
- TMonitor monitor = monitorMap.get(result.getDeviceId());
+ for (VideoOnlineResult result : list) {
+ TMonitorVO monitor = monitorMap.get(result.getDeviceId());
if (monitor == null) continue;
String deptId = monitor.getDeptId().toString();
- updateAreaStats(areaStatsMap, deptId, result, important);
+ updateAreaStats(areaStatsMap, deptId, result, important,commandImage);
// 澶勭悊鐪佸巺鏁版嵁
if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) {
- String provinceKey = "Province_" + deptId;
- updateAreaStats(areaStatsMap, provinceKey, result, important);
+ String provinceKey = ApiConstants.Province + deptId;
+ updateAreaStats(areaStatsMap, provinceKey, result, important,commandImage);
}
}
@@ -83,7 +92,7 @@
List<CheckIndexVideo> checkIndexVideos = new ArrayList<>();
areaStatsMap.forEach((deptId, stats) -> {
if (stats.totalSites > 0) {
- CheckIndexVideo CheckIndexVideo = createOrUpdateCheckIndexFace(deptId, stats, checkIndexVideoList);
+ CheckIndexVideo CheckIndexVideo = createOrUpdateCheckIndexVideo(deptId, stats, checkIndexVideoList);
if (CheckIndexVideo != null) {
checkIndexVideos.add(CheckIndexVideo);
}
@@ -94,19 +103,27 @@
}
/**
- * 绱鎬荤偣浣嶆暟銆佸湪绾跨偣浣嶆暟銆侀噸鐐圭偣浣嶆暟銆侀噸鐐圭偣浣嶅湪绾挎暟
+ * 绱鎬荤偣浣嶆暟銆佸湪绾跨偣浣嶆暟銆侀噸鐐圭偣浣嶆暟銆侀噸鐐圭偣浣嶅湪绾挎暟銆佹寚鎸ュ浘鍍忔暟銆佹寚鎸ュ浘鍍忓湪绾挎暟
*/
- private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, QueryVqdResult result, List<String> important) {
+ private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, VideoOnlineResult result, List<String> important, List<String> commandImage) {
//杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value
AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats());
stats.totalSites++;
+ //閲嶇偣鐐逛綅
if(important.contains(result.getDeviceId())){
stats.importantSites++;
}
- if (ApiConstants.UY_OnlineSite_Online.equals(result.getOnlineStatus())){
+ //鎸囨尌鍥惧儚鐐逛綅
+ if(commandImage.contains(result.getDeviceId())){
+ stats.commandSites++;
+ }
+ if (ApiConstants.UY_OnlineSite_Online.equals(result.getStatus())){
stats.onlineSites++;
if(important.contains(result.getDeviceId())){
stats.importantOnlineSites++;
+ }
+ if(commandImage.contains(result.getDeviceId())){
+ stats.commandOnlineSites++;
}
}
}
@@ -114,7 +131,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;
@@ -125,12 +142,36 @@
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);
+ }
+
+ //璋冪敤鐐逛綅鍦ㄧ嚎鐜囪绠楁柟娉� 璁$畻鎸囨尌鍥惧儚鍦ㄧ嚎鐜�
+ 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");
+ }
return checkIndexVideo;
}
}
--
Gitblit v1.8.0