fuliqi
2024-09-23 7a33c5b558e7e4ab5760261accbd32c7f2056c4a
大屏分离平台在线和考核成绩接口
6个文件已修改
88 ■■■■ 已修改文件
ycl-common/src/main/java/enumeration/general/AreaDeptEnum.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/controller/DashboardController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/ITPlatformService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/PlatformService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-common/src/main/java/enumeration/general/AreaDeptEnum.java
@@ -47,6 +47,13 @@
        }
        return null;
    }
    public static AreaDeptEnum fromName(String name) {
        for (AreaDeptEnum type : AreaDeptEnum.values()) {
            if (type.getName().equals(name) ) {
                return type;
            }
        }
        return null;
    }
}
ycl-server/src/main/java/com/ycl/platform/controller/DashboardController.java
@@ -28,6 +28,7 @@
    private final ICheckIndexCarService checkIndexCarService;
    private final ICheckIndexVideoService checkIndexVideoService;
    private final ICheckScoreService checkScoreService;
    private final PlatformService platformService;
    @GetMapping("/department")
    public AjaxResult department() {
@@ -73,4 +74,8 @@
    public AjaxResult checkScore(DashboardQuery dashboardQuery) {
        return AjaxResult.success(checkScoreService.dashboard(dashboardQuery));
    }
    @GetMapping("/platform")
    public AjaxResult platform(DashboardQuery dashboardQuery) {
        return AjaxResult.success(platformService.dashboard(dashboardQuery));
    }
}
ycl-server/src/main/java/com/ycl/platform/service/ITPlatformService.java
@@ -1,8 +1,10 @@
package com.ycl.platform.service;
import com.ycl.platform.domain.entity.TPlatform;
import com.ycl.platform.domain.query.DashboardQuery;
import java.util.List;
import java.util.Map;
/**
 * 平台运行监控Service接口
@@ -58,4 +60,6 @@
     * @return 结果
     */
    public int deleteTPlatformById(Long id);
}
ycl-server/src/main/java/com/ycl/platform/service/PlatformService.java
@@ -3,10 +3,12 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ycl.platform.domain.entity.Platform;
import com.ycl.platform.domain.form.PlatformForm;
import com.ycl.platform.domain.query.DashboardQuery;
import com.ycl.platform.domain.query.PlatformQuery;
import com.ycl.system.Result;
import java.util.List;
import java.util.Map;
/**
 * 平台运行监控 服务类
@@ -63,4 +65,6 @@
     * @return
     */
    Result all();
    Map<String, Map<String, Object>> dashboard(DashboardQuery dashboardQuery);
}
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
@@ -3,6 +3,7 @@
import annotation.DataScope;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.platform.base.CheckIndex;
import com.ycl.platform.domain.dto.CheckResultExportDTO;
@@ -12,10 +13,7 @@
import com.ycl.platform.domain.entity.*;
import com.ycl.platform.domain.query.DashboardQuery;
import com.ycl.platform.domain.vo.*;
import com.ycl.platform.mapper.CheckRuleMapper;
import com.ycl.platform.mapper.CheckScoreMapper;
import com.ycl.platform.mapper.CheckTemplateMapper;
import com.ycl.platform.mapper.CheckTemplateRuleMapper;
import com.ycl.platform.mapper.*;
import com.ycl.platform.service.ICheckIndexCarService;
import com.ycl.platform.service.ICheckIndexFaceService;
import com.ycl.platform.service.ICheckIndexVideoService;
@@ -28,6 +26,7 @@
import com.ycl.utils.SecurityUtils;
import com.ycl.utils.StringUtils;
import constant.CheckConstants;
import enumeration.general.AreaDeptEnum;
import enumeration.general.PublishType;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
@@ -41,6 +40,7 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
@@ -72,7 +72,8 @@
    private ICheckIndexVideoService indexVideoService;
    @Autowired
    private ISysDeptService deptService;
    @Autowired
    private PlatformMapper platformMapper;
    /**
     * 查询考核积分指标
@@ -323,8 +324,8 @@
        roleControl(checkIndexCar);
        List<CheckIndexCar> checkIndexCars = new ArrayList<>();
        for (Integer examineTag : exportDTO.getExamineTags()) {
            checkIndexCar.setExamineTag(Short.valueOf(examineTag+""));
            if(examineTag ==0){
            checkIndexCar.setExamineTag(Short.valueOf(examineTag + ""));
            if (examineTag == 0) {
                checkIndexCar.setExamineTagQuery(1);
            }
            checkIndexCars.addAll(indexCarService.selectCheckIndexCarList(checkIndexCar));
@@ -371,8 +372,8 @@
        roleControl(checkIndexFace);
        List<CheckIndexFace> checkIndexFaces = new ArrayList<>();
        for (Integer examineTag : exportDTO.getExamineTags()) {
            checkIndexFace.setExamineTag(Short.valueOf(examineTag+""));
            if(examineTag ==0){
            checkIndexFace.setExamineTag(Short.valueOf(examineTag + ""));
            if (examineTag == 0) {
                checkIndexFace.setExamineTagQuery(1);
            }
            checkIndexFaces.addAll(indexFaceService.selectCheckIndexFaceList(checkIndexFace));
@@ -419,8 +420,8 @@
        roleControl(checkIndexVideo);
        List<CheckIndexVideo> checkIndexVideos = new ArrayList<>();
        for (Integer examineTag : exportDTO.getExamineTags()) {
            checkIndexVideo.setExamineTag(Short.valueOf(examineTag+""));
            if(examineTag ==0){
            checkIndexVideo.setExamineTag(Short.valueOf(examineTag + ""));
            if (examineTag == 0) {
                checkIndexVideo.setExamineTagQuery(1);
            }
            checkIndexVideos.addAll(indexVideoService.selectCheckIndexVideoList(checkIndexVideo));
ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.platform.domain.entity.Platform;
import com.ycl.platform.domain.form.PlatformForm;
import com.ycl.platform.domain.query.DashboardQuery;
import com.ycl.platform.domain.query.PlatformQuery;
import com.ycl.platform.domain.vo.PlatformVO;
import com.ycl.platform.mapper.PlatformMapper;
@@ -15,6 +16,7 @@
import com.ycl.system.service.ISysDictTypeService;
import com.ycl.system.service.impl.SysDictDataServiceImpl;
import com.ycl.system.service.impl.SysDictTypeServiceImpl;
import enumeration.general.AreaDeptEnum;
import org.ehcache.core.util.CollectionUtil;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
@@ -24,10 +26,9 @@
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.net.InetAddress;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -171,4 +172,38 @@
                .collect(Collectors.toList());
        return Result.ok().data(vos);
    }
    @Override
    public Map<String, Map<String, Object>> dashboard(DashboardQuery dashboardQuery) {
        //先默认所有区县平台在线,初始化map数据
        Map<String, Map<String, Object>> resultMap = new HashMap<>();
        for (AreaDeptEnum value : AreaDeptEnum.values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("platformOnline",Boolean.TRUE);
            resultMap.put(value.getName(),map);
        }
        //平台在线状态 默认在线,如果一个不在线改为false。
        List<Platform> platformList = new LambdaQueryChainWrapper<>(platformMapper)
                .isNotNull(Platform::getPlatformIP)
                .list();
        Boolean reachable = Boolean.FALSE;
        try {
            for (Platform platform : platformList) {
                reachable = InetAddress.getByName(platform.getPlatformIP()).isReachable(3000);
                //不在线
                if(!reachable) {
                    //获取平台管理的区域编码集合
                    List<String> areaCodes = Arrays.asList(com.ycl.utils.StringUtils.split(platform.getArea(), ","));
                    resultMap.forEach((deptName, map) -> {
                        if(areaCodes.contains(AreaDeptEnum.fromName(deptName).getCode())){
                            map.put("platformOnline",Boolean.FALSE);
                        }
                    });
                }
            }
        } catch (Exception e) {
            log.error("检查平台连通性时发生错误", e);
        }
        return resultMap;
    }
}