| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.integration.api.model.*; |
| | | import com.ruoyi.jianguan.mongodb.service.*; |
| | | import com.ruoyi.jianguan.mqtt.config.TopicConstants; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.*; |
| | | |
| | | /** |
| | |
| | | private UploadRealTimeMonitoringDataService uploadRealTimeMonitoringDataService; |
| | | @Autowired |
| | | private MqttPushUtil mqttPushUtil; |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | /** |
| | | * 每天的9点执行的任务 |
| | | */ |
| | | @Scheduled(cron = "0 0 12 * * ?") |
| | | @Scheduled(fixedRate = 86400000) |
| | | public void taskDay(){ |
| | | try { |
| | | // 传输mongodb的硬件数据 |
| | | createCustomThreadPool(); |
| | | // 判断是否存在标识 |
| | | Thread.sleep(1000); |
| | | String flag = redisService.getCacheObject("cloud_integration"); |
| | | System.out.println("市政云硬件数据传输标识:" + flag); |
| | | if (Objects.isNull(flag)) { |
| | | log.info("市政云硬件数据传输无标识,开始传输硬件数据"); |
| | | redisService.setCacheObject("cloud_integration", "1",24L,TimeUnit.HOURS); |
| | | // 传输mongodb的硬件数据 |
| | | createCustomThreadPool(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |