From 4fc68eb0cafb74ff56796062e60a3e720898c378 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 13 三月 2024 17:13:47 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/config/ScheduleConfig.java | 67 +++++++++++++++++++++++++++++---- 1 files changed, 59 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/lf/server/config/ScheduleConfig.java b/src/main/java/com/lf/server/config/ScheduleConfig.java index 27cc2ff..0221adb 100644 --- a/src/main/java/com/lf/server/config/ScheduleConfig.java +++ b/src/main/java/com/lf/server/config/ScheduleConfig.java @@ -2,14 +2,21 @@ 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.show.AutoQueryService; +import com.lf.server.service.show.OneMapService; +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.apache.ibatis.annotations.Result; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; /** * 鏃ョ▼閰嶇疆绫� @@ -18,12 +25,34 @@ @Component @EnableScheduling public class ScheduleConfig { - @Autowired - private ScheduleService scheduleService; + @Resource + AttachService attachService; + + @Resource + ScheduleService scheduleService; + + @Resource + AutoQueryService autoQueryService; + + @Resource + OneMapService oneMapService; + + private static boolean isBusy = false; private static final Log log = LogFactory.getLog(ScheduleConfig.class); - @Scheduled(fixedRate = 10 * 1000) + @Scheduled(cron = "0 0 1 * * ?") + public void autoQuery() { + autoQueryService.autoQuery(); + } + + @Scheduled(cron = "0 0 2 * * ?") + public void calcData() { + String str = oneMapService.calcData(); + log.info("璁$畻鏁版嵁锛�" + str); + } + + @Scheduled(fixedRate = 15 * 1000) public void pushMonitorInfo() { try { JSONObject jsonObject = new JSONObject(); @@ -59,7 +88,7 @@ } } - @Scheduled(fixedRate = 60 * 1000) + @Scheduled(fixedRate = 30 * 1000) public void countSystemStatus() { // noinspection AlibabaRemoveCommentedCode try { @@ -69,13 +98,12 @@ jsonObject.put("resUseCount", scheduleService.countResStatus()); // 鐢ㄦ埛鐧诲綍鐘舵�� sys_login - // jsonObject.put("userLoginCount", scheduleService.userLoginCount()); + jsonObject.put("userLoginCount", scheduleService.userLoginCount()); // 璧勬簮鎿嶄綔鐘舵�� sys_operate - // jsonObject.put("operateCount", scheduleService.operateCount()); + jsonObject.put("operateCount", scheduleService.operateCount()); // 璧勬簮璋冪敤鐘舵�� - String json = JSONObject.toJSONStringWithDateFormat(jsonObject, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue); WebSocketService.broadCastInfo(json); @@ -83,4 +111,27 @@ 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