From 3b0516a2959e25576e4f3fda697a3b025d06c8c9 Mon Sep 17 00:00:00 2001 From: zxl <763096477@qq.com> Date: 星期二, 24 六月 2025 14:09:07 +0800 Subject: [PATCH] 每日录像可用指标添加日志,修改大屏为查看当前月平均 --- ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java | 79 +++++++++++++-------------------------- 1 files changed, 27 insertions(+), 52 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 2135fba..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,23 +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.result.SYS.TMonitorResult; 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.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; @@ -25,7 +19,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -37,7 +30,7 @@ */ @Component @Slf4j -public class VideoOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<VideoOnlineResult> { +public class VideoOnlineCalculation extends IndexCalculationServe<VideoOnlineResult, VideoOnlineCalculation.AreaStats> implements CalculationStrategy<VideoOnlineResult> { @Autowired private CheckIndexVideoMapper checkIndexVideoMapper; @Autowired @@ -46,7 +39,7 @@ private ICheckIndexVideoService checkIndexVideoService; //鍖哄煙瑙嗛鍦ㄧ嚎鐜囩殑鍐呴儴绫� - private static class AreaStats { + protected static class AreaStats { int totalSites = 0; int onlineSites = 0; int importantSites = 0; @@ -59,37 +52,9 @@ @Override public void calculate(List<VideoOnlineResult> list) { - if (CollectionUtils.isEmpty(list)) { - log.info("鏁版嵁涓虹┖"); - return; - } - - //鑾峰緱鍥芥爣鐮佷负key鐨勮澶噈ap - 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(); - //鑾峰彇閮ㄧ骇鐐逛綅闆嗗悎 - List<String> deptTag = getDeptTag(); - - Map<String, AreaStats> areaStatsMap = new HashMap<>(); - for (VideoOnlineResult result : list) { - TMonitorVO monitor = monitorMap.get(result.getDeviceId()); - if (monitor == null) continue; - - String deptId = monitor.getDeptId().toString(); - 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,deptTag); - } - } + //鑾峰彇鍒嗗尯鍩熺殑鎸囨爣鏁伴噺 + Map<String, VideoOnlineCalculation.AreaStats> areaStatsMap = getAreaStatsMap(list,Boolean.TRUE); + if (areaStatsMap == null) return; // 鏌ヨ鏄惁index琛ㄥ凡缁忓瓨鍦ㄤ粖鏃ユ暟鎹� List<CheckIndexVideo> checkIndexVideoList = checkIndexVideoMapper.selectToday(DateUtils.getDate()); @@ -102,37 +67,47 @@ } } }); - + //閲嶇偣鎸囨尌鍥惧儚鐗规畩澶勭悊锛岀粺涓�閲囩敤鍖哄幙鏁版嵁 + 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, VideoOnlineResult result, List<String> important, List<String> commandImage,List<String> deptTag) { + @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(commandImage.contains(result.getDeviceId())){ + if(result.getImportantCommandImageTag()!=null && result.getImportantCommandImageTag()){ stats.commandSites++; } - if(deptTag.contains(result.getDeviceId())){ + 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(commandImage.contains(result.getDeviceId())){ + if(result.getImportantCommandImageTag()!=null && result.getImportantCommandImageTag()){ stats.commandOnlineSites++; } - if(deptTag.contains(result.getDeviceId())){ + if(result.getDeptTag()!=null && result.getDeptTag()){ stats.deptOnlineSites++; } } @@ -153,7 +128,7 @@ BigDecimal siteOnline = siteOnline(param); checkIndexVideo.setSiteOnline(siteOnline); //鍖哄幙涓嶅皯浜�100璺� - if(stats.totalSites < CheckThreadConstants.Check_Video_SiteOnline){ + if(!key.startsWith(ApiConstants.Dept) && stats.totalSites < CheckThreadConstants.Check_Video_SiteOnline){ checkIndexVideo.setSiteOnline(BigDecimal.ZERO); } //璋冪敤鐐逛綅鍦ㄧ嚎鐜囪绠楁柟娉� 璁$畻閲嶇偣鐐逛綅鍦ㄧ嚎鐜� @@ -168,7 +143,7 @@ } //鍖哄幙瑙嗛閲嶇偣鐐逛綅鏁颁笉灏戜簬10璺� - if(stats.importantSites<CheckThreadConstants.Check_Video_ImportantSite){ + if(!key.startsWith(ApiConstants.Dept) && stats.importantSites < CheckThreadConstants.Check_Video_ImportantSite){ checkIndexVideo.setKeySiteOnline(BigDecimal.ZERO); } -- Gitblit v1.8.0