月球大数据地理空间分析展示平台-【后端】-月球后台服务
1
13693261870
2024-11-11 fee67ca8a0760315047a52fc4101a8f4f80b7a7f
src/main/java/com/moon/server/config/ScheduleConfig.java
@@ -15,12 +15,9 @@
import java.util.List;
/**
 * 日程配置类
 * @author WWW
 */
@Component
@EnableScheduling
@SuppressWarnings("ALL")
public class ScheduleConfig {
    @Autowired
    AttachService attachService;
@@ -37,11 +34,8 @@
        try {
            JSONObject jsonObject = new JSONObject();
            // 查询Cpu信息
            jsonObject.put("cpuInfo", scheduleService.selectCpuInfo());
            // 查询内存信息
            jsonObject.put("memInfo", scheduleService.selectMemInfo());
            // 查询在线用户
            jsonObject.put("userInfo", scheduleService.selectOnlineUsers());
            String json = JSONObject.toJSONStringWithDateFormat(jsonObject, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
@@ -57,7 +51,6 @@
        try {
            JSONObject jsonObject = new JSONObject();
            // 查询服务资源状态
            jsonObject.put("resInfo", scheduleService.selectResStatus());
            String json = JSONObject.toJSONStringWithDateFormat(jsonObject, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
@@ -74,43 +67,16 @@
        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);
        }
    }