From 0217e80b8630f199c8a54c1fb6a8342cea9bb75f Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期二, 28 二月 2023 11:09:12 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/service/all/ScheduleService.java |   58 ++++++++++++++++++++++++----------------------------------
 1 files changed, 24 insertions(+), 34 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..1382d29 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,17 @@
     }
 
     /**
-     * 鏌ヨ鏈嶅姟璧勬簮鐘舵��
-     *
+     * 缁熻鍦ㄧ嚎鐢ㄦ埛鏁�
      * @return
+     */
+    public int countOnlineUsers() {
+        Set<String> keys = redisTemplate.keys(RedisCacheKey.signUserKey("*"));
+
+        return null == keys ? 0 : keys.size();
+    }
+
+    /**
+     * 鏌ヨ鏈嶅姟璧勬簮鐘舵��
      */
     public List<ResEntity> selectResStatus() {
         List<ResEntity> resList = resService.selectResAll();
@@ -191,8 +189,6 @@
 
     /**
      * 缁熻鏈嶅姟璧勬簮鐘舵��
-     *
-     * @return
      */
     public JSONObject countResStatus() {
         List<ResEntity> resList = resService.selectResAll();
@@ -210,10 +206,7 @@
 
     /**
      * 璧勬簮鎿嶄綔鐘舵��
-     *
-     * @return
      */
-
     public JSONObject operateCount() {
         List<OperateEntity> list = operateService.operateCount();
         JSONObject jsonObject = new JSONObject();
@@ -234,26 +227,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