From ac20dc99bf1f463365dba071973e08fffbd294b4 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 14 七月 2023 14:12:21 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/service/all/ScheduleService.java | 79 ++++++++++++++++++++++++++++++++------- 1 files changed, 64 insertions(+), 15 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 592514f..1382d29 100644 --- a/src/main/java/com/lf/server/service/all/ScheduleService.java +++ b/src/main/java/com/lf/server/service/all/ScheduleService.java @@ -1,10 +1,14 @@ package com.lf.server.service.all; import com.lf.server.entity.all.RedisCacheKey; +import com.lf.server.entity.sys.LoginEntity; +import com.lf.server.entity.sys.OperateEntity; import com.lf.server.entity.sys.ResEntity; import com.lf.server.entity.sys.UserEntity; import com.lf.server.helper.FileHelper; import com.lf.server.helper.StringHelper; +import com.lf.server.service.sys.LoginService; +import com.lf.server.service.sys.OperateService; import com.lf.server.service.sys.ResService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -37,15 +41,18 @@ private ResService resService; @Autowired + private LoginService loginService; + + @Autowired + private OperateService operateService; + + @Autowired private RedisTemplate<String, Object> redisTemplate; private static final Log log = LogFactory.getLog(ScheduleService.class); /** * 鏌ヨ鏈嶅姟鍣ㄧ姸鎬� - * - * @return - * @throws InterruptedException */ public JSONObject selectServerStatus() throws InterruptedException { JSONObject json = new JSONObject(); @@ -57,9 +64,6 @@ /** * 鏌ヨCpu淇℃伅 - * - * @return - * @throws InterruptedException */ public JSONObject selectCpuInfo() throws InterruptedException { SystemInfo systemInfo = new SystemInfo(); @@ -91,8 +95,6 @@ /** * 鏌ヨ鍐呭瓨淇℃伅 - * - * @return */ public JSONObject selectMemInfo() { JSONObject map = new JSONObject(); @@ -114,8 +116,6 @@ /** * 鏌ヨ鍦ㄧ嚎鐢ㄦ埛 - * - * @return */ public List<JSONObject> selectOnlineUsers() { List<JSONObject> list = new ArrayList<JSONObject>(); @@ -123,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(); @@ -139,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(); @@ -181,8 +189,6 @@ /** * 缁熻鏈嶅姟璧勬簮鐘舵�� - * - * @return */ public JSONObject countResStatus() { List<ResEntity> resList = resService.selectResAll(); @@ -197,4 +203,47 @@ return jsonObject; } + + /** + * 璧勬簮鎿嶄綔鐘舵�� + */ + public JSONObject operateCount() { + List<OperateEntity> list = operateService.operateCount(); + JSONObject jsonObject = new JSONObject(); + if (list.isEmpty()) { + return null; + } else { + List<JSONObject> lister = new ArrayList<JSONObject>(); + for (OperateEntity key : list) { + JSONObject map = new JSONObject(); + map.put("count", key.getCount()); + map.put("modular2", key.getModular2()); + lister.add(map); + } + jsonObject.put("operateCount", lister); + return jsonObject; + } + } + + /** + * 鐢ㄦ埛鐧诲綍鐘舵�� + */ + public JSONObject userLoginCount() { + List<LoginEntity> list = loginService.selectLoginCounts(); + if (list == null || list.isEmpty()) { + return null; + } + + 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