| | |
| | | |
| | | import com.ycl.platform.domain.entity.CheckIndexVideo; |
| | | import com.ycl.platform.domain.result.UY.MonitorQualifyResult; |
| | | import com.ycl.platform.domain.vo.TMonitorVO; |
| | | import com.ycl.platform.mapper.CheckIndexVideoMapper; |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.service.ICheckIndexVideoService; |
| | | import constant.ApiConstants; |
| | | import constant.CheckThreadConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | //区域视频在线率的内部类 |
| | | protected static class AreaStats { |
| | | //资产库登记在用数 |
| | | int totalSites = 0; |
| | | //当日档案数 |
| | | int todayFiles = 0; |
| | | //未注册的数量 |
| | | int newSites = 0; |
| | | //全年留存数 |
| | | int allFiles = 0; |
| | | //当日档案数(凌晨计算的,实际取得是昨日的一机一档数量) |
| | | int todayFiles = 0; |
| | | } |
| | | //TODO:改为MonitorQualifyResult,算法优化 |
| | | //TODO:改为MonitorQualifyResult |
| | | @Override |
| | | public void calculate(List<MonitorQualifyResult> list) { |
| | | //获取分区域的指标数量 |
| | | Map<String, MonitorRegistrationCalculation.AreaStats> areaStatsMap = getAreaStatsMap(list); |
| | | if (areaStatsMap == null) return; |
| | | |
| | | //查数据库补充全年留存数 |
| | | List<TMonitorVO> monitorVOS = monitorMapper.selectMonitorVOList(); |
| | | areaStatsMap.forEach((key,areaStats)->{ |
| | | if(key.startsWith(ApiConstants.Province)){ |
| | | long count = monitorVOS.stream().filter(vo -> ApiConstants.TRUE.equals(vo.getProvinceTag())) |
| | | .filter(vo -> key.split("_")[1].equals(vo.getDeptId() + "")).count(); |
| | | areaStats.allFiles = Integer.parseInt(count+""); |
| | | }else { |
| | | long count = monitorVOS.stream().filter(vo -> key.equals(vo.getDeptId() + "")).count(); |
| | | areaStats.allFiles = Integer.parseInt(count+""); |
| | | } |
| | | }); |
| | | |
| | | // 查询是否index表已经存在今日数据 |
| | | List<CheckIndexVideo> checkIndexVideoList = checkIndexVideoMapper.selectToday(DateUtils.getDate()); |
| | | List<CheckIndexVideo> checkIndexVideos = new ArrayList<>(); |
| | | areaStatsMap.forEach((key, stats) -> { |
| | | if (stats.totalSites > 0) { |
| | | if (stats.todayFiles > 0) { |
| | | CheckIndexVideo checkIndexVideo = createOrUpdateCheckIndexVideo(key, stats, checkIndexVideoList); |
| | | if (checkIndexVideo != null) { |
| | | checkIndexVideos.add(checkIndexVideo); |
| | |
| | | public void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, MonitorQualifyResult result) { |
| | | //返回对象的引用,如果不存在会放入新的key,value |
| | | AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); |
| | | stats.totalSites++; |
| | | stats.allFiles++; |
| | | stats.todayFiles++; |
| | | if (result.getNewDevice()!=null && result.getNewDevice()) { |
| | | stats.newSites++; |
| | | } |
| | |
| | | } |
| | | //调用一机一档注册率 |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("totalSites", stats.totalSites); |
| | | param.put("totalSites", stats.todayFiles); |
| | | param.put("newSites", stats.newSites); |
| | | BigDecimal monitorRegistration = monitorRegistration(param); |
| | | checkIndexVideo.setMonitorRegistration(monitorRegistration); |