| | |
| | | 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 java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 计算视频设备点位在线率、重点点位在线率、重点指挥图像在线率 |
| | | * 计算视频设备点位在线率、重点点位在线率、重点指挥图像在线率、部级点位在线率 |
| | | * 图像监测诊断结果 |
| | | * 获取分省厅、区域的map<k,v> k为deptId或者Province_deptId |
| | | * 循环map计算数据上传及时性 |
| | |
| | | int importantOnlineSites = 0; |
| | | int commandSites = 0; |
| | | int commandOnlineSites =0; |
| | | int deptSites = 0; |
| | | int deptOnlineSites = 0; |
| | | } |
| | | |
| | | @Override |
| | |
| | | List<String> important = getImportant(); |
| | | //重点指挥图像集合 |
| | | List<String> commandImage = getCommandImage(); |
| | | //获取部级点位集合 |
| | | List<String> deptTag = getDeptTag(); |
| | | |
| | | Map<String, AreaStats> areaStatsMap = new HashMap<>(); |
| | | for (VideoOnlineResult result : list) { |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * 累计总点位数、在线点位数、重点点位数、重点点位在线数、指挥图像数、指挥图像在线数 |
| | | */ |
| | | 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++; |
| | |
| | | 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())){ |
| | |
| | | } |
| | | if(commandImage.contains(result.getDeviceId())){ |
| | | stats.commandOnlineSites++; |
| | | } |
| | | if(deptTag.contains(result.getDeviceId())){ |
| | | stats.deptOnlineSites++; |
| | | } |
| | | } |
| | | } |
| | |
| | | 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<>(); |
| | | importantParam.put("totalSites", stats.importantSites); |
| | | importantParam.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<>(); |
| | | commandParam.put("totalSites", stats.commandSites); |
| | | commandParam.put("onlineSites", stats.commandOnlineSites); |
| | | BigDecimal commandSiteOnline = siteOnline(commandParam); |
| | | 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; |
| | | } |
| | | } |