From df9b5941f4e4f59f56b3234942f810f83c99b501 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 25 五月 2023 16:33:54 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/config/ScheduleConfig.java | 64 ++++++++++++++++++++++++++++++-- 1 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/lf/server/config/ScheduleConfig.java b/src/main/java/com/lf/server/config/ScheduleConfig.java index 7332c59..1fbe663 100644 --- a/src/main/java/com/lf/server/config/ScheduleConfig.java +++ b/src/main/java/com/lf/server/config/ScheduleConfig.java @@ -2,14 +2,18 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.serializer.SerializerFeature; +import com.lf.server.entity.data.FmeLogEntity; import com.lf.server.service.all.ScheduleService; import com.lf.server.service.all.WebSocketService; +import com.lf.server.service.sys.AttachService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; + +import java.util.List; /** * 鏃ョ▼閰嶇疆绫� @@ -19,7 +23,12 @@ @EnableScheduling public class ScheduleConfig { @Autowired - private ScheduleService scheduleService; + AttachService attachService; + + @Autowired + ScheduleService scheduleService; + + private static boolean isBusy = false; private static final Log log = LogFactory.getLog(ScheduleConfig.class); @@ -39,11 +48,11 @@ WebSocketService.broadCastInfo(json); } catch (Exception ex) { - log.error(ex.getStackTrace()); + log.error(ex.getMessage(), ex); } } - @Scheduled(fixedRate = 60 * 1000) + @Scheduled(fixedRate = 30 * 1000) public void checkSystemStatus() { try { JSONObject jsonObject = new JSONObject(); @@ -55,7 +64,54 @@ WebSocketService.broadCastInfo(json); } catch (Exception ex) { - log.error(ex.getStackTrace()); + log.error(ex.getMessage(), ex); + } + } + + @Scheduled(fixedRate = 30 * 1000) + public void countSystemStatus() { + // noinspection AlibabaRemoveCommentedCode + try { + JSONObject jsonObject = new JSONObject(); + + // 鏈嶅姟璧勬簮鐘舵�� sys_res + jsonObject.put("resUseCount", scheduleService.countResStatus()); + + // 鐢ㄦ埛鐧诲綍鐘舵�� sys_login + jsonObject.put("userLoginCount", scheduleService.userLoginCount()); + + // 璧勬簮鎿嶄綔鐘舵�� sys_operate + jsonObject.put("operateCount", scheduleService.operateCount()); + + // 璧勬簮璋冪敤鐘舵�� + String json = JSONObject.toJSONStringWithDateFormat(jsonObject, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue); + + WebSocketService.broadCastInfo(json); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + } + } + + /** + * 鍚屾闄勪欢 + */ + @Scheduled(fixedRate = 30 * 1000) + public void syncAttaches() { + try { + List<FmeLogEntity> list = attachService.selectFmeLogs(); + if (isBusy || null == list || list.isEmpty()) { + return; + } + + isBusy = true; + for (FmeLogEntity entity : list) { + attachService.syncAttaches(entity); + attachService.updateFmeLog(entity.getId()); + } + isBusy = false; + } catch (Exception ex) { + isBusy = false; + log.error(ex.getMessage(), ex); } } } -- Gitblit v1.9.3