From 7d536d24aa867e9dd4304db39f267373679a6480 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 13 三月 2024 10:54:18 +0800 Subject: [PATCH] 解决定时器启动计算数据时报错 --- src/main/java/com/lf/server/config/ScheduleConfig.java | 26 ++++++++++++++++++++++---- 1 files changed, 22 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 d818805..e1e615a 100644 --- a/src/main/java/com/lf/server/config/ScheduleConfig.java +++ b/src/main/java/com/lf/server/config/ScheduleConfig.java @@ -5,14 +5,17 @@ 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; /** @@ -22,15 +25,31 @@ @Component @EnableScheduling public class ScheduleConfig { - @Autowired + @Resource AttachService attachService; - @Autowired + @Resource ScheduleService scheduleService; + + @Resource + AutoQueryService autoQueryService; + + @Resource + OneMapService oneMapService; private static boolean isBusy = false; private static final Log log = LogFactory.getLog(ScheduleConfig.class); + + @Scheduled(cron = "0 0 1 * * ?") + public void autoQuery() { + autoQueryService.autoQuery(); + } + + @Scheduled(cron = "0 0 2 * * ?") + public void calcData() { + oneMapService.calcData(); + } @Scheduled(fixedRate = 15 * 1000) public void pushMonitorInfo() { @@ -84,7 +103,6 @@ jsonObject.put("operateCount", scheduleService.operateCount()); // 璧勬簮璋冪敤鐘舵�� - String json = JSONObject.toJSONStringWithDateFormat(jsonObject, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue); WebSocketService.broadCastInfo(json); -- Gitblit v1.9.3