Commit 835ab649 by 汪志阳

fix:模拟测试夜间时间

parent 3242daaf
...@@ -242,7 +242,9 @@ public class OffBedAlarm implements IAlarm { ...@@ -242,7 +242,9 @@ public class OffBedAlarm implements IAlarm {
} }
private void sendToRedis(AlarmRedisDTO alarmRedisDTO, String deviceId) { private void sendToRedis(AlarmRedisDTO alarmRedisDTO, String deviceId) {
Date now = new Date(); // todo 模拟时间
Date now = toDate();
// Date now = new Date();
long endLong = now.getTime(); long endLong = now.getTime();
// 第一次上报 // 第一次上报
if (alarmRedisDTO == null) { if (alarmRedisDTO == null) {
...@@ -256,6 +258,7 @@ public class OffBedAlarm implements IAlarm { ...@@ -256,6 +258,7 @@ public class OffBedAlarm implements IAlarm {
log.info("离床告警 离床设备存储redis,第一次上报时间:{},开始上报时间:{},是否上报:{}", log.info("离床告警 离床设备存储redis,第一次上报时间:{},开始上报时间:{},是否上报:{}",
alarmRedisDTO.getStartLong(), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm()); alarmRedisDTO.getStartLong(), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
} else { } else {
//
alarmRedisDTO.setStart(now); alarmRedisDTO.setStart(now);
log.info("离床告警离床更新redis,第一次上报时间:{},更新时间:{},是否上报:{}", log.info("离床告警离床更新redis,第一次上报时间:{},更新时间:{},是否上报:{}",
longToTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm()); longToTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
...@@ -319,11 +322,17 @@ public class OffBedAlarm implements IAlarm { ...@@ -319,11 +322,17 @@ public class OffBedAlarm implements IAlarm {
} }
private LocalDateTime currentTime() { private LocalDateTime currentTime() {
return LocalDateTime.now().plusHours(9).plusMinutes(10); return LocalDateTime.now().plusHours(8);
} }
private LocalDateTime longToTime(Long longTime) { private LocalDateTime longToTime(Long longTime) {
return LocalDateTime.ofInstant(Instant.ofEpochMilli(longTime), ZoneOffset.of("+8")); return LocalDateTime.ofInstant(Instant.ofEpochMilli(longTime), ZoneOffset.of("+8"));
} }
private Date toDate(){
ZoneId zoneId = ZoneId.systemDefault();
ZonedDateTime zdt = currentTime().atZone(zoneId);
return Date.from(zdt.toInstant());
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment