管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2024-03-13 4fc68eb0cafb74ff56796062e60a3e720898c378
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,13 +25,32 @@
@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() {
        String str = oneMapService.calcData();
        log.info("计算数据:" + str);
    }
    @Scheduled(fixedRate = 15 * 1000)
    public void pushMonitorInfo() {
@@ -82,7 +104,6 @@
            jsonObject.put("operateCount", scheduleService.operateCount());
            // 资源调用状态
            String json = JSONObject.toJSONStringWithDateFormat(jsonObject, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
            WebSocketService.broadCastInfo(json);
@@ -98,15 +119,18 @@
    public void syncAttaches() {
        try {
            List<FmeLogEntity> list = attachService.selectFmeLogs();
            if (null == list || list.isEmpty()) {
            if (isBusy || null == list || list.isEmpty()) {
                return;
            }
            isBusy = true;
            for (FmeLogEntity entity : list) {
                attachService.updateFmeLog(entity.getId());
                attachService.syncAttaches(entity);
                attachService.updateFmeLog(entity.getId());
            }
            isBusy = false;
        } catch (Exception ex) {
            isBusy = false;
            log.error(ex.getMessage(), ex);
        }
    }