| | |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.service.ICheckIndexVideoService; |
| | | import constant.ApiConstants; |
| | | import constant.CheckConstants; |
| | | import constant.CheckThreadConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 计算视频设备点位在线率、重点点位在线率、重点指挥图像在线率、部级点位在线率 |
| | |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class VideoOnlineCalculation extends IndexCalculationServe<TMonitorResult, VideoOnlineCalculation.AreaStats> implements CalculationStrategy<TMonitorResult> { |
| | | public class VideoOnlineCalculation extends IndexCalculationServe<VideoOnlineResult, VideoOnlineCalculation.AreaStats> implements CalculationStrategy<VideoOnlineResult> { |
| | | @Autowired |
| | | private CheckIndexVideoMapper checkIndexVideoMapper; |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void calculate(List<TMonitorResult> list) { |
| | | public void calculate(List<VideoOnlineResult> list) { |
| | | //获取分区域的指标数量 |
| | | Map<String, VideoOnlineCalculation.AreaStats> areaStatsMap = getAreaStatsMap(list); |
| | | Map<String, VideoOnlineCalculation.AreaStats> areaStatsMap = getAreaStatsMap(list,Boolean.TRUE); |
| | | if (areaStatsMap == null) return; |
| | | |
| | | // 查询是否index表已经存在今日数据 |
| | |
| | | } |
| | | } |
| | | }); |
| | | |
| | | //重点指挥图像特殊处理,统一采用区县数据 |
| | | 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); |
| | | } |
| | | |
| | |
| | | * 累计总点位数、在线点位数、重点点位数、重点点位在线数、指挥图像数、指挥图像在线数 |
| | | */ |
| | | @Override |
| | | public void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, TMonitorResult result) { |
| | | public void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, VideoOnlineResult result) { |
| | | //返回对象的引用,如果不存在会放入新的key,value |
| | | AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); |
| | | stats.totalSites++; |
| | |
| | | if(result.getDeptTag()!=null && result.getDeptTag()){ |
| | | stats.deptSites++; |
| | | } |
| | | if (result.getOnline()!=null && result.getOnline()){ |
| | | if (ApiConstants.UY_OnlineSite_Online.equals(result.getStatus())){ |
| | | stats.onlineSites++; |
| | | if(result.getImportantTag()!=null && result.getImportantTag()){ |
| | | stats.importantOnlineSites++; |
| | |
| | | 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); |
| | | } |
| | | //调用点位在线率计算方法 计算重点点位在线率 |
| | |
| | | } |
| | | |
| | | //区县视频重点点位数不少于10路 |
| | | if(stats.importantSites<CheckThreadConstants.Check_Video_ImportantSite){ |
| | | if(!key.startsWith(ApiConstants.Dept) && stats.importantSites < CheckThreadConstants.Check_Video_ImportantSite){ |
| | | checkIndexVideo.setKeySiteOnline(BigDecimal.ZERO); |
| | | } |
| | | |