From 9d30f3aba92b1fe90eaecd486113f544f0f18b7c Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期五, 16 八月 2024 16:41:11 +0800 Subject: [PATCH] 资产管理动态字段 --- ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java | 44 +++++++++++++++++++++++++++++++------------- 1 files changed, 31 insertions(+), 13 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..5c4f9ea 100644 --- a/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java +++ b/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java @@ -5,6 +5,7 @@ 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; @@ -26,15 +27,14 @@ import java.util.stream.Collectors; /** - * 璁$畻瑙嗛璁惧鐐逛綅鍦ㄧ嚎鐜囥�侀噸鐐圭偣浣嶅湪绾跨巼 + * 璁$畻瑙嗛璁惧鐐逛綅鍦ㄧ嚎鐜囥�侀噸鐐圭偣浣嶅湪绾跨巼銆侀噸鐐规寚鎸ュ浘鍍忓湪绾跨巼 * 鍥惧儚鐩戞祴璇婃柇缁撴灉 * 鑾峰彇鍒嗙渷鍘呫�佸尯鍩熺殑map<k,v> k涓篸eptId鎴栬�匬rovince_deptId * 寰幆map璁$畻鏁版嵁涓婁紶鍙婃椂鎬� * 鏇存柊鎴栨柊澧� */ @Component -//TODO锛氶噸鐐规寚鎸ュ浘鍍忓湪绾跨巼 -public class VideoOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<QueryVqdResult> { +public class VideoOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<VideoOnlineResult> { @Autowired private CheckIndexVideoMapper checkIndexVideoMapper; @Autowired @@ -48,34 +48,38 @@ 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)) { return; } //鑾峰緱鍥芥爣鐮佷负key鐨勮澶噈ap - Map<String, TMonitorVO> monitorMap = monitorMapper.selectListByIds(list.stream().map(QueryVqdResult::getDeviceId).collect(Collectors.toList())) + 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) { + 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 = ApiConstants.Province + deptId; - updateAreaStats(areaStatsMap, provinceKey, result, important); + updateAreaStats(areaStatsMap, provinceKey, result, important,commandImage); } } @@ -84,7 +88,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); } @@ -95,19 +99,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++; } } } @@ -115,7 +127,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; @@ -132,6 +144,12 @@ param.put("onlineSites", stats.importantOnlineSites); BigDecimal importantSiteOnline = siteOnline(importantParam); checkIndexVideo.setKeySiteOnline(importantSiteOnline); + //璋冪敤鐐逛綅鍦ㄧ嚎鐜囪绠楁柟娉� 璁$畻鎸囨尌鍥惧儚鍦ㄧ嚎鐜� + Map<String, Object> commandParam = new HashMap<>(); + param.put("totalSites", stats.commandSites); + param.put("onlineSites", stats.commandOnlineSites); + BigDecimal commandSiteOnline = siteOnline(importantParam); + checkIndexVideo.setKeyCommandImageOnline(commandSiteOnline); return checkIndexVideo; } } -- Gitblit v1.8.0