| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.MessageFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | /** |
| | | * @author Mr.huang |
| | |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | private static final String deviceExcLogFormat = "【设备预警提示】{0} 硬件设备离线。"; |
| | | |
| | | private static final DateTimeFormatter deviceExcLogFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss"); |
| | | |
| | | |
| | | @Scheduled(cron = "0/30 * * * * ?") |
| | | |
| | | @Scheduled(cron = "0 0/10 * * * ?") |
| | | @Async(value = "SocketTaskExecutor") |
| | | public void gasConcentrationStatus() { |
| | | GasConcentration gasConcentration = gasConcentrationService.getLastData(); |
| | | if (gasConcentration != null){ |
| | | LocalDateTime lastReceiveTime = gasConcentration.getDataReceivingTime().plusMinutes(2); |
| | | LocalDateTime lastReceiveTime = gasConcentration.getDataReceivingTime().plusMinutes(5); |
| | | if (LocalDateTime.now().compareTo(lastReceiveTime) > 0){ |
| | | try { |
| | | heartbeatExcWebsocketServer.sendInfo(HeartbeatExecEnum.GAS_CONCENTRATION.getStatus()+"",null); |
| | | logger.info(HeartbeatExecEnum.GAS_CONCENTRATION.getDesc()); |
| | | //logger.info(HeartbeatExecEnum.GAS_CONCENTRATION.getDesc()); |
| | | DeviceExceptionLog deviceExceptionLog = new DeviceExceptionLog(); |
| | | deviceExceptionLog.setTime(LocalDateTime.now()); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | String content = MessageFormat.format(deviceExcLogFormat,deviceExcLogFormatter.format(now)); |
| | | deviceExceptionLog.setTime(now); |
| | | deviceExceptionLog.setContent(content); |
| | | deviceExceptionLog.setExecDesc(HeartbeatExecEnum.GAS_CONCENTRATION.getDesc()); |
| | | DeviceExceptionLog save = deviceExceptionLogService.save(deviceExceptionLog); |
| | | if (save == null) |
| | |
| | | if (LocalDateTime.now().compareTo(lastReceiveTime) > 0){ |
| | | try { |
| | | heartbeatExcWebsocketServer.sendInfo(HeartbeatExecEnum.GAS_FLUX.getStatus()+"",null); |
| | | logger.info(HeartbeatExecEnum.GAS_FLUX.getDesc()); |
| | | //logger.info(HeartbeatExecEnum.GAS_FLUX.getDesc()); |
| | | DeviceExceptionLog deviceExceptionLog = new DeviceExceptionLog(); |
| | | deviceExceptionLog.setTime(LocalDateTime.now()); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | String content = MessageFormat.format(deviceExcLogFormat,deviceExcLogFormatter.format(now)); |
| | | deviceExceptionLog.setTime(now); |
| | | deviceExceptionLog.setContent(content); |
| | | deviceExceptionLog.setExecDesc(HeartbeatExecEnum.GAS_FLUX.getDesc()); |
| | | DeviceExceptionLog save = deviceExceptionLogService.save(deviceExceptionLog); |
| | | if (save == null) |