Commit 204b709d by 汪志阳

fix:bug处理

parent 687c91fb
......@@ -96,17 +96,17 @@ public class OffBedAlarm implements IAlarm {
String personState = Convert.toStr(properties.get("person"));
boolean isOffBed = "0".equals(personState);
// 1-有人 0-无人
log.info("离床config:{}", JSONUtil.toJsonStr(properties));
log.info("离床告警config:{}", JSONUtil.toJsonStr(properties));
AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
if (!isOffBed && alarmRedisDTO != null) {
log.info("离床有人状态下,删除redis!");
log.info("离床告警有人状态下,删除redis!");
RedisUtil.delete(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
return;
}
// 设备无人,在范围内上报存储redis,超过离床持续时间,则预警
String messageType = platAlarmCheckDTO.getMessageType();
if (StringUtils.equalsAnyIgnoreCase(messageType, "OFFLINE", "DISCONNECT")) {
log.info("设备下线,删除redis off_bed 预警");
log.info("离床告警设备下线,删除redis off_bed 预警");
RedisUtil.delete(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
}
if (isOffBed) {
......@@ -118,17 +118,17 @@ public class OffBedAlarm implements IAlarm {
Long firstOffBedLong = alarmRedisDTO.getStartLong();
boolean isOverTime = (localDateLong - firstOffBedLong) / 1000 >= duration * 60;
LocalDateTime firstOffBedTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(firstOffBedLong), ZoneOffset.of("+8"));
log.info("第一次离床时间为:" + firstOffBedTime);
log.info("离床告警第一次离床时间为:" + firstOffBedTime);
if ("1".equals(alarmRedisDTO.getAlarm())) {
log.info("离床警已发送预警过!");
log.info("离床警已发送预警过!");
return;
}
// 第一次离床时间在范围前,则已范围开始时间起始算
if (firstOffBedTime.isBefore(startTime)) {
boolean over = (Duration.between(LocalDateTime.now(), startTime).toMillis()) / 1000 >= duration * 60;
boolean over = (Math.abs(Duration.between(LocalDateTime.now(), startTime).toMillis())) / 1000 >= duration * 60;
if (over) {
platAlarmCheckDTO.setAbnormalValue(String.valueOf(localDateLong - firstOffBedLong));
log.info("离床时间在范围前,发送预警");
log.info("离床告警离床时间在范围前,发送预警");
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
return;
}
......@@ -140,13 +140,13 @@ public class OffBedAlarm implements IAlarm {
boolean isInRange = LocalDateTime.now().isAfter(startTime) && LocalDateTime.now().isBefore(endTime);
if (isOffBedValid && isInRange && isOverTime) {
platAlarmCheckDTO.setAbnormalValue(String.valueOf(localDateLong - firstOffBedLong));
log.info("离床时间在范围时间内(小于范围结束时间-持续分钟)");
log.info("离床告警离床时间在范围时间内(小于范围结束时间-持续分钟)");
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
return;
}
if (firstOffBedTime.isAfter(endTime)) {
log.info("离床时间超出时间范围!");
log.info("离床告警离床时间超出时间范围!");
}
}
......@@ -185,6 +185,13 @@ public class OffBedAlarm implements IAlarm {
// }
}
public static void main(String[] args) {
LocalDateTime startTime = LocalDateTime.of(2023,12,12,15,43);
boolean over = (Math.abs(Duration.between(LocalDateTime.now(), startTime).toMillis())) / 1000 >= 2 * 60;
System.out.println(over);
System.out.println(Duration.between(LocalDateTime.now(), startTime).toMillis());
}
private void sendToRedis(AlarmRedisDTO alarmRedisDTO, String deviceId) {
Date now = new Date();
long endLong = now.getTime();
......@@ -195,11 +202,11 @@ public class OffBedAlarm implements IAlarm {
alarmRedisDTO.setStart(now);
alarmRedisDTO.setStartLong(endLong);
RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
log.info("离床设备存储redis,第一次上报时间:{},开始上报时间:{},是否上报:{}",
log.info("离床告警 离床设备存储redis,第一次上报时间:{},开始上报时间:{},是否上报:{}",
getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
} else {
alarmRedisDTO.setStart(now);
log.info("离床更新redis,第一次上报时间:{},更新时间:{},是否上报:{}",
log.info("离床告警离床更新redis,第一次上报时间:{},更新时间:{},是否上报:{}",
getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
}
......@@ -210,7 +217,7 @@ public class OffBedAlarm implements IAlarm {
alarmRedisDTO.setStart(new Date());
alarmRedisDTO.setAlarm(CommonEnum.YES.getValue());
RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
log.info("推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{}",
log.info("离床告警推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{}",
getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
}
......@@ -241,7 +248,6 @@ public class OffBedAlarm implements IAlarm {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
log.info("离床预警长者信息:{}", JSONUtil.toJsonStr(platElderList));
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("离床告警配置为禁用,告警配置id:" + config.getId());
......
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