fuliqi
2024-08-19 fbe06367836796f584984e021729002b3707c26b
ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java
@@ -13,6 +13,8 @@
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 org.springframework.util.CollectionUtils;
@@ -34,6 +36,7 @@
 * 更新或新增
 */
@Component
@Slf4j
public class VideoOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<VideoOnlineResult> {
    @Autowired
    private CheckIndexVideoMapper checkIndexVideoMapper;
@@ -55,6 +58,7 @@
    @Override
    public void calculate(List<VideoOnlineResult> list) {
        if (CollectionUtils.isEmpty(list)) {
            log.info("数据为空");
            return;
        }
@@ -88,7 +92,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);
                }
@@ -127,7 +131,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;
@@ -138,18 +142,36 @@
        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<>();
        param.put("totalSites", stats.importantSites);
        param.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<>();
        param.put("totalSites", stats.commandSites);
        param.put("onlineSites", stats.commandOnlineSites);
        BigDecimal commandSiteOnline = siteOnline(importantParam);
        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");
        }
        return checkIndexVideo;
    }
}