| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.swing.text.DateFormatter; |
| | | import java.io.IOException; |
| | | import java.net.InetAddress; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | } |
| | | if (!reachable) { |
| | | // 如果ping不通,离线时长加5秒 |
| | | redisTemplate.opsForValue().increment(REDIS_KEY_PREFIX + platform.getPlatformIP(), 5); |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | String todayTime = localDateTime.format(dateTimeFormatter); |
| | | //每次redis累增5s |
| | | redisTemplate.opsForValue().increment(REDIS_KEY_PREFIX + todayTime + platform.getPlatformIP(), 5); |
| | | log.warn(platform.getPlatformName() + "平台未ping通"); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | .list(); |
| | | // 将java.util.Date转换为java.sql.Date |
| | | java.sql.Date sqlDate = new java.sql.Date(new Date().getTime()); |
| | | |
| | | LocalDateTime localDateTime = LocalDateTime.now(); |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | String todayTime = localDateTime.format(dateTimeFormatter); |
| | | for (Platform platform : platformList) { |
| | | Object outLineTime = redisTemplate.opsForValue().get(REDIS_KEY_PREFIX + platform.getPlatformIP()); |
| | | Object outLineTime = redisTemplate.opsForValue().get(REDIS_KEY_PREFIX + todayTime + platform.getPlatformIP()); |
| | | Integer outlineTimeSed = Objects.isNull(outLineTime) ? 0 : (Integer) outLineTime; |
| | | PlatformOnline one = new LambdaQueryChainWrapper<>(platformOnlineService.getBaseMapper()) |
| | | .eq(PlatformOnline::getPlatformId, platform.getId()) |