| | |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.service.ICheckIndexVideoService; |
| | | import constant.ApiConstants; |
| | | import constant.CheckThreadConstants; |
| | | import constant.RedisConstant; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | } |
| | | //获得国标码为key的设备map |
| | | Map<String, TMonitorVO> monitorMap = new HashMap<>(); |
| | | if(!CollectionUtils.isEmpty(list)){ |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | monitorMap = list.stream().collect(Collectors.toMap(TMonitorVO::getSerialNumber, Function.identity())); |
| | | } |
| | | //获取省厅国标码集合 |
| | | List<String> provinceIds = getProvince(); |
| | | //未注册设备 |
| | | Map<String,TMonitor> newMonitorMap = new HashMap<>(); |
| | | Map<String, TMonitor> newMonitorMap = new HashMap<>(); |
| | | //Mongo一机一档同步Mysql时放入Redis |
| | | String json = (String) redisTemplate.opsForValue().get(RedisConstant.New_Monitor_Set); |
| | | if (!StringUtils.isEmpty(json)) { |
| | | List<TMonitor> newMonitors = JSONArray.parseArray(json, TMonitor.class); |
| | | if(!CollectionUtils.isEmpty(newMonitors)){ |
| | | if (!CollectionUtils.isEmpty(newMonitors)) { |
| | | newMonitorMap = newMonitors.stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity())); |
| | | } |
| | | } |
| | |
| | | if (monitor == null) continue; |
| | | |
| | | String deptId = monitor.getDeptId().toString(); |
| | | updateAreaStats(areaStatsMap, deptId, result,newMonitorMap,todayMonitor); |
| | | updateAreaStats(areaStatsMap, deptId, result, newMonitorMap, todayMonitor); |
| | | // 处理省厅数据 |
| | | if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) { |
| | | String provinceKey = ApiConstants.Province + deptId; |
| | | updateAreaStats(areaStatsMap, provinceKey, result,newMonitorMap,todayMonitor); |
| | | updateAreaStats(areaStatsMap, provinceKey, result, newMonitorMap, todayMonitor); |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * 累计总点位数、在线点位数、重点点位数、重点点位在线数、指挥图像数、指挥图像在线数 |
| | | */ |
| | | private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, TMonitorVO result,Map<String,TMonitor> newMonitors,List<String> todayMonitor) { |
| | | private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, TMonitorVO result, Map<String, TMonitor> newMonitors, List<String> todayMonitor) { |
| | | //返回对象的引用,如果不存在会放入新的key,value |
| | | AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); |
| | | stats.totalSites++; |
| | | stats.allFiles++; |
| | | if(newMonitors.containsKey(result.getSerialNumber())){ |
| | | if (newMonitors.containsKey(result.getSerialNumber())) { |
| | | stats.newSites++; |
| | | } |
| | | if(todayMonitor.contains(result.getSerialNumber())){ |
| | | if (todayMonitor.contains(result.getSerialNumber())) { |
| | | stats.todayFiles++; |
| | | } |
| | | } |
| | |
| | | archiveParam.put("allFiles", stats.allFiles); |
| | | archiveParam.put("todayFiles", stats.todayFiles); |
| | | BigDecimal archivesRate = archivesRate(archiveParam); |
| | | checkIndexVideo.setArchivesRate(archivesRate); |
| | | //如果档案考核比低于0.9不得分 |
| | | if (new BigDecimal(CheckThreadConstants.Check_Video_Archive).compareTo(archivesRate) <= 0) { |
| | | checkIndexVideo.setArchivesRate(archivesRate); |
| | | } else { |
| | | checkIndexVideo.setArchivesRate(BigDecimal.ZERO); |
| | | } |
| | | |
| | | return checkIndexVideo; |
| | | } |