From ed8c7a5effd0d423ce1118b680ecdca6fe732609 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 02 七月 2025 16:43:13 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.11.205:9000/r/P2022036_Service

---
 src/main/java/com/lf/server/service/all/ScheduleService.java |   62 +++++++++++++-----------------
 1 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/src/main/java/com/lf/server/service/all/ScheduleService.java b/src/main/java/com/lf/server/service/all/ScheduleService.java
index 03399cc..ec263b0 100644
--- a/src/main/java/com/lf/server/service/all/ScheduleService.java
+++ b/src/main/java/com/lf/server/service/all/ScheduleService.java
@@ -53,9 +53,6 @@
 
     /**
      * 鏌ヨ鏈嶅姟鍣ㄧ姸鎬�
-     *
-     * @return
-     * @throws InterruptedException
      */
     public JSONObject selectServerStatus() throws InterruptedException {
         JSONObject json = new JSONObject();
@@ -67,9 +64,6 @@
 
     /**
      * 鏌ヨCpu淇℃伅
-     *
-     * @return
-     * @throws InterruptedException
      */
     public JSONObject selectCpuInfo() throws InterruptedException {
         SystemInfo systemInfo = new SystemInfo();
@@ -101,8 +95,6 @@
 
     /**
      * 鏌ヨ鍐呭瓨淇℃伅
-     *
-     * @return
      */
     public JSONObject selectMemInfo() {
         JSONObject map = new JSONObject();
@@ -124,8 +116,6 @@
 
     /**
      * 鏌ヨ鍦ㄧ嚎鐢ㄦ埛
-     *
-     * @return
      */
     public List<JSONObject> selectOnlineUsers() {
         List<JSONObject> list = new ArrayList<JSONObject>();
@@ -133,7 +123,7 @@
         Set<String> keys = redisTemplate.keys(RedisCacheKey.signUserKey("*"));
         for (String key : keys) {
             Object obj = redisTemplate.opsForValue().get(key);
-            if (obj != null && obj instanceof UserEntity) {
+            if (obj instanceof UserEntity) {
                 UserEntity ue = (UserEntity) obj;
 
                 JSONObject map = new JSONObject();
@@ -149,9 +139,16 @@
     }
 
     /**
+     * 缁熻鍦ㄧ嚎鐢ㄦ埛鏁�
+     */
+    public int countOnlineUsers() {
+        Set<String> keys = redisTemplate.keys(RedisCacheKey.signUserKey("*"));
+
+        return null == keys ? 0 : keys.size();
+    }
+
+    /**
      * 鏌ヨ鏈嶅姟璧勬簮鐘舵��
-     *
-     * @return
      */
     public List<ResEntity> selectResStatus() {
         List<ResEntity> resList = resService.selectResAll();
@@ -159,6 +156,9 @@
         return testResStatus(resList);
     }
 
+    /**
+     * 娴嬭瘯璧勬簮鐘舵��
+     */
     private List<ResEntity> testResStatus(List<ResEntity> resList) {
         List<ResEntity> list = new ArrayList<ResEntity>();
         for (ResEntity re : resList) {
@@ -175,7 +175,7 @@
                 // Ping閫氬湴鍧�
                 socket.connect(add, 2000);
             } catch (Exception e) {
-                log.error(e.getMessage());
+                // log.error(e.getMessage())
                 list.add(re);
             } finally {
                 try {
@@ -191,8 +191,6 @@
 
     /**
      * 缁熻鏈嶅姟璧勬簮鐘舵��
-     *
-     * @return
      */
     public JSONObject countResStatus() {
         List<ResEntity> resList = resService.selectResAll();
@@ -210,10 +208,7 @@
 
     /**
      * 璧勬簮鎿嶄綔鐘舵��
-     *
-     * @return
      */
-
     public JSONObject operateCount() {
         List<OperateEntity> list = operateService.operateCount();
         JSONObject jsonObject = new JSONObject();
@@ -234,26 +229,23 @@
 
     /**
      * 鐢ㄦ埛鐧诲綍鐘舵��
-     *
-     * @return
      */
-
     public JSONObject userLoginCount() {
         List<LoginEntity> list = loginService.selectLoginCounts();
-        JSONObject jsonObject = new JSONObject();
-        if (list.isEmpty()) {
+        if (list == null || list.isEmpty()) {
             return null;
-        } else {
-            List<JSONObject> lister = new ArrayList<JSONObject>();
-            for (LoginEntity key : list) {
-                JSONObject map = new JSONObject();
-                map.put("count", key.getCount());
-                map.put("optime", key.getOptime());
-                lister.add(map);
-            }
-            jsonObject.put("userLoginCount", lister);
-            return jsonObject;
         }
-    }
 
+        JSONObject jsonObject = new JSONObject();
+        List<JSONObject> lister = new ArrayList<JSONObject>();
+        for (LoginEntity key : list) {
+            JSONObject map = new JSONObject();
+            map.put("count", key.getCount());
+            map.put("optime", key.getOptime());
+            lister.add(map);
+        }
+        jsonObject.put("userLoginCount", lister);
+
+        return jsonObject;
+    }
 }

--
Gitblit v1.9.3