From c83101eb62f5d4906b9c01ceea6b21a37f9e84d8 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 18 十一月 2025 09:24:53 +0800
Subject: [PATCH] bug修复
---
ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java | 141 +++++++++++++++++++++++++++++-----------------
1 files changed, 88 insertions(+), 53 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 6258a85..9a8ed07 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java
@@ -1,20 +1,17 @@
package com.ycl.calculate;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ycl.platform.domain.entity.CheckIndexVideo;
-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.vo.TMonitorVO;
+import com.ycl.platform.domain.result.SYS.TMonitorResult;
+import com.ycl.platform.domain.result.UY.VideoOnlineResult;
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.CheckConstants;
+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;
import utils.DateUtils;
import java.math.BigDecimal;
@@ -22,19 +19,18 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.function.Function;
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<VideoOnlineResult, VideoOnlineCalculation.AreaStats> implements CalculationStrategy<VideoOnlineResult> {
@Autowired
private CheckIndexVideoMapper checkIndexVideoMapper;
@Autowired
@@ -43,71 +39,76 @@
private ICheckIndexVideoService checkIndexVideoService;
//鍖哄煙瑙嗛鍦ㄧ嚎鐜囩殑鍐呴儴绫�
- private static class AreaStats {
+ protected static class AreaStats {
int totalSites = 0;
int onlineSites = 0;
int importantSites = 0;
int importantOnlineSites = 0;
+ int commandSites = 0;
+ int commandOnlineSites =0;
+ int deptSites = 0;
+ int deptOnlineSites = 0;
}
@Override
- public void calculate(List<QueryVqdResult> list) {
- if (CollectionUtils.isEmpty(list)) {
- return;
- }
-
- //鑾峰緱鍥芥爣鐮佷负key鐨勮澶噈ap
- Map<String, TMonitorVO> monitorMap = monitorMapper.selectListByIds(list.stream().map(QueryVqdResult::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 (QueryVqdResult result : list) {
- TMonitorVO monitor = monitorMap.get(result.getDeviceId());
- if (monitor == null) continue;
-
- String deptId = monitor.getDeptId().toString();
- updateAreaStats(areaStatsMap, deptId, result, important);
-
- // 澶勭悊鐪佸巺鏁版嵁
- if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) {
- String provinceKey = ApiConstants.Province + deptId;
- updateAreaStats(areaStatsMap, provinceKey, result, important);
- }
- }
+ public void calculate(List<VideoOnlineResult> list) {
+ //鑾峰彇鍒嗗尯鍩熺殑鎸囨爣鏁伴噺
+ Map<String, VideoOnlineCalculation.AreaStats> areaStatsMap = getAreaStatsMap(list,Boolean.TRUE);
+ if (areaStatsMap == null) return;
// 鏌ヨ鏄惁index琛ㄥ凡缁忓瓨鍦ㄤ粖鏃ユ暟鎹�
List<CheckIndexVideo> checkIndexVideoList = checkIndexVideoMapper.selectToday(DateUtils.getDate());
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);
}
}
});
-
+ //閲嶇偣鎸囨尌鍥惧儚鐗规畩澶勭悊锛岀粺涓�閲囩敤鍖哄幙鏁版嵁
+ Map<Long, BigDecimal> keyCommandMap = checkIndexVideos.stream().filter(checkIndexVideo -> CheckConstants.Examine_Tag_County.equals(checkIndexVideo.getExamineTag()))
+ .collect(Collectors.toMap(checkIndexVideo -> checkIndexVideo.getDeptId(), checkIndexVideo -> checkIndexVideo.getKeyCommandImageOnline()));
+ for (CheckIndexVideo checkIndexVideo : checkIndexVideos) {
+ //鏇挎崲鐪佸巺鍜岄儴绾� 閲嶇偣鎸囨尌鍥惧儚
+ if(CheckConstants.Examine_Tag_Province.equals(checkIndexVideo.getExamineTag()) || CheckConstants.Examine_Tag_Dept.equals(checkIndexVideo.getExamineTag())){
+ BigDecimal keyCommand = keyCommandMap.get(checkIndexVideo.getDeptId());
+ checkIndexVideo.setKeyCommandImageOnline(keyCommand);
+ }
+ }
checkIndexVideoService.saveOrUpdateBatch(checkIndexVideos);
}
/**
- * 绱鎬荤偣浣嶆暟銆佸湪绾跨偣浣嶆暟銆侀噸鐐圭偣浣嶆暟銆侀噸鐐圭偣浣嶅湪绾挎暟
+ * 绱鎬荤偣浣嶆暟銆佸湪绾跨偣浣嶆暟銆侀噸鐐圭偣浣嶆暟銆侀噸鐐圭偣浣嶅湪绾挎暟銆佹寚鎸ュ浘鍍忔暟銆佹寚鎸ュ浘鍍忓湪绾挎暟
*/
- private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, QueryVqdResult result, List<String> important) {
+ @Override
+ public void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, VideoOnlineResult result) {
//杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value
AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats());
stats.totalSites++;
- if(important.contains(result.getDeviceId())){
+ //閲嶇偣鐐逛綅
+ if(result.getImportantTag()!=null && result.getImportantTag()){
stats.importantSites++;
}
- if (ApiConstants.UY_OnlineSite_Online.equals(result.getOnlineStatus())){
+ //鎸囨尌鍥惧儚鐐逛綅
+ if(result.getImportantCommandImageTag()!=null && result.getImportantCommandImageTag()){
+ stats.commandSites++;
+ }
+ if(result.getDeptTag()!=null && result.getDeptTag()){
+ stats.deptSites++;
+ }
+ if (ApiConstants.UY_OnlineSite_Online.equals(result.getStatus())){
stats.onlineSites++;
- if(important.contains(result.getDeviceId())){
+ if(result.getImportantTag()!=null && result.getImportantTag()){
stats.importantOnlineSites++;
+ }
+ if(result.getImportantCommandImageTag()!=null && result.getImportantCommandImageTag()){
+ stats.commandOnlineSites++;
+ }
+ if(result.getDeptTag()!=null && result.getDeptTag()){
+ stats.deptOnlineSites++;
}
}
}
@@ -115,7 +116,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,12 +127,46 @@
param.put("onlineSites", stats.onlineSites);
BigDecimal siteOnline = siteOnline(param);
checkIndexVideo.setSiteOnline(siteOnline);
+ //鍖哄幙涓嶅皯浜�100璺�
+ if(!key.startsWith(ApiConstants.Dept) && 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(!key.startsWith(ApiConstants.Dept) && 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");
+ }
+ //璋冪敤鐐逛綅鍦ㄧ嚎鐜囪绠楁柟娉� 璁$畻閮ㄧ骇鐐逛綅鍦ㄧ嚎鐜�
+ 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