From 7a33c5b558e7e4ab5760261accbd32c7f2056c4a Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期一, 23 九月 2024 19:16:13 +0800
Subject: [PATCH] 大屏分离平台在线和考核成绩接口

---
 ycl-server/src/main/java/com/ycl/platform/controller/DashboardController.java     |    5 ++
 ycl-common/src/main/java/enumeration/general/AreaDeptEnum.java                    |    9 ++++
 ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java   |   43 +++++++++++++++++++--
 ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java |   23 ++++++-----
 ycl-server/src/main/java/com/ycl/platform/service/ITPlatformService.java          |    4 ++
 ycl-server/src/main/java/com/ycl/platform/service/PlatformService.java            |    4 ++
 6 files changed, 72 insertions(+), 16 deletions(-)

diff --git a/ycl-common/src/main/java/enumeration/general/AreaDeptEnum.java b/ycl-common/src/main/java/enumeration/general/AreaDeptEnum.java
index 08c3d54..5d23b48 100644
--- a/ycl-common/src/main/java/enumeration/general/AreaDeptEnum.java
+++ b/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;
+    }
 
 }
diff --git a/ycl-server/src/main/java/com/ycl/platform/controller/DashboardController.java b/ycl-server/src/main/java/com/ycl/platform/controller/DashboardController.java
index 5516a2b..2321d3a 100644
--- a/ycl-server/src/main/java/com/ycl/platform/controller/DashboardController.java
+++ b/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));
+    }
 }
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/ITPlatformService.java b/ycl-server/src/main/java/com/ycl/platform/service/ITPlatformService.java
index 8b13b28..5a8087e 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/ITPlatformService.java
+++ b/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);
+
+
 }
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/PlatformService.java b/ycl-server/src/main/java/com/ycl/platform/service/PlatformService.java
index 219389a..8e4bbd3 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/PlatformService.java
+++ b/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);
 }
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
index 6df38ab..c48bde7 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
+++ b/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));
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java
index 5bb2aaf..50a8d45 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/PlatformServiceImpl.java
+++ b/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) {
+        //鍏堥粯璁ゆ墍鏈夊尯鍘垮钩鍙板湪绾匡紝鍒濆鍖杕ap鏁版嵁
+        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;
+    }
 }

--
Gitblit v1.8.0