Commit b4067fd8 by 汪志阳

fix:离床日志输出

parent 9c792fbc
...@@ -171,11 +171,11 @@ public class OffBedAlarm implements IAlarm { ...@@ -171,11 +171,11 @@ public class OffBedAlarm implements IAlarm {
if (isInTime && isOverTime) { if (isInTime && isOverTime) {
// 离床时间为23:00-1:00 持续时间5分钟 ,第一次离床为0:55,满足条件的时间>1:00,不预警 // 离床时间为23:00-1:00 持续时间5分钟 ,第一次离床为0:55,满足条件的时间>1:00,不预警
if (firstTime.isAfter(endTimeLimit) && firstTime.isBefore(endTime)) { if (firstTime.isAfter(endTimeLimit) && firstTime.isBefore(endTime)) {
log.info("deviceId:{},UnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}", deviceId, firstTime, duration, endTime); // log.info("deviceId:{},UnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}", deviceId, firstTime, duration, endTime);
return; return;
} }
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong)); platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
log.info("deviceId:{},cross离床告警离床时间在范围时间内,配置:{}", deviceId, config.getRuleConfig()); // log.info("deviceId:{},cross离床告警离床时间在范围时间内,配置:{}", deviceId, config.getRuleConfig());
platAlarmCheckDTO.setPlatAlarmConfig(config); platAlarmCheckDTO.setPlatAlarmConfig(config);
// platAlarmCheckDTO.setAlarmRecordId(IdWorker.getIdStr(PlatAlarmRecord.class)); // platAlarmCheckDTO.setAlarmRecordId(IdWorker.getIdStr(PlatAlarmRecord.class));
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId); noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
...@@ -188,15 +188,15 @@ public class OffBedAlarm implements IAlarm { ...@@ -188,15 +188,15 @@ public class OffBedAlarm implements IAlarm {
boolean noInOverTime = mills >= duration * 60; boolean noInOverTime = mills >= duration * 60;
if (noInOverTime) { if (noInOverTime) {
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong)); platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
log.info("deviceId:{}, cross离床告警第一次离床时间在范围前,配置:{}", deviceId, config.getRuleConfig()); // log.info("deviceId:{}, cross离床告警第一次离床时间在范围前,配置:{}", deviceId, config.getRuleConfig());
platAlarmCheckDTO.setPlatAlarmConfig(config); platAlarmCheckDTO.setPlatAlarmConfig(config);
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId); noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
} else { } else {
log.info("deviceId:{},cross离床告警,第一次离床时间在范围前,未预警,配置:{},", deviceId, config.getRuleConfig()); // log.info("deviceId:{},cross离床告警,第一次离床时间在范围前,未预警,配置:{},", deviceId, config.getRuleConfig());
} }
} else { } else {
log.info("deviceId:{},Cross 未满足预警条件!first:{},config:{}", deviceId, firstTime, config.getRuleConfig()); // log.info("deviceId:{},Cross 未满足预警条件!first:{},config:{}", deviceId, firstTime, config.getRuleConfig());
} }
} }
...@@ -229,12 +229,12 @@ public class OffBedAlarm implements IAlarm { ...@@ -229,12 +229,12 @@ public class OffBedAlarm implements IAlarm {
// 离床时间在范围内 // 离床时间在范围内
if (isInTime && isOverTime) { if (isInTime && isOverTime) {
if (firstTime.isAfter(endTimeLimit)) { if (firstTime.isAfter(endTimeLimit)) {
log.info("deviceId:{},UnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}", deviceId, firstTime, duration, endTime); // log.info("deviceId:{},UnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}", deviceId, firstTime, duration, endTime);
return; return;
} }
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong)); platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
platAlarmCheckDTO.setPlatAlarmConfig(config); platAlarmCheckDTO.setPlatAlarmConfig(config);
log.info("deviceId:{},uncross离床告警离床时间在范围时间内,配置:{}", deviceId, config.getRuleConfig()); // log.info("deviceId:{},uncross离床告警离床时间在范围时间内,配置:{}", deviceId, config.getRuleConfig());
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId); noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
return; return;
} }
...@@ -244,26 +244,26 @@ public class OffBedAlarm implements IAlarm { ...@@ -244,26 +244,26 @@ public class OffBedAlarm implements IAlarm {
LocalDateTime dateTime = LocalDateTime.of(LocalDate.now(), startTime); LocalDateTime dateTime = LocalDateTime.of(LocalDate.now(), startTime);
long mills = Duration.between(dateTime, currentTime()).toMillis() / 1000; long mills = Duration.between(dateTime, currentTime()).toMillis() / 1000;
if (mills >= 86400) { if (mills >= 86400) {
log.info("uncross离床告警第一次离床时间在范围前,跨天了:mills:{}", mills); // log.info("uncross离床告警第一次离床时间在范围前,跨天了:mills:{}", mills);
mills = mills - 86400; mills = mills - 86400;
} }
if (mills <= -86400) { if (mills <= -86400) {
log.info("uncross离床告警第一次离床时间在范围前,跨天了:mills:{}", mills); // log.info("uncross离床告警第一次离床时间在范围前,跨天了:mills:{}", mills);
mills = mills + 86400; mills = mills + 86400;
} }
boolean noInOverTime = mills >= duration * 60; boolean noInOverTime = mills >= duration * 60;
if (noInOverTime) { if (noInOverTime) {
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong)); platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
log.info("deviceId:{},uncross离床告警第一次离床时间在范围前,配置:{},date:{},mills:{},first:{}", // log.info("deviceId:{},uncross离床告警第一次离床时间在范围前,配置:{},date:{},mills:{},first:{}",
deviceId, config.getRuleConfig(),dateTime,mills,firstTime); // deviceId, config.getRuleConfig(),dateTime,mills,firstTime);
platAlarmCheckDTO.setPlatAlarmConfig(config); platAlarmCheckDTO.setPlatAlarmConfig(config);
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId); noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
} else { } else {
log.info("deviceId:{},uncross离床告警第一次离床时间在范围前,未预警,配置:{},间隔:{},first:{}", // log.info("deviceId:{},uncross离床告警第一次离床时间在范围前,未预警,配置:{},间隔:{},first:{}",
deviceId, config.getRuleConfig(), mills, firstTime); // deviceId, config.getRuleConfig(), mills, firstTime);
} }
} else { } else {
log.info("deviceId:{},UnCrossDay 未满足预警条件!fis:{},config:{}", deviceId, firstTime, config.getRuleConfig()); // log.info("deviceId:{},UnCrossDay 未满足预警条件!fis:{},config:{}", deviceId, firstTime, config.getRuleConfig());
} }
} }
...@@ -289,13 +289,13 @@ public class OffBedAlarm implements IAlarm { ...@@ -289,13 +289,13 @@ public class OffBedAlarm implements IAlarm {
LocalDateTime firstOffBedTime = longToTime(alarmRedisDTO.getStartLong()); LocalDateTime firstOffBedTime = longToTime(alarmRedisDTO.getStartLong());
String remark = "第一次离床时间:" + firstOffBedTime + ",config:" + platAlarmConfig.getRuleConfig() + ",当前时间:" + currentTime(); String remark = "第一次离床时间:" + firstOffBedTime + ",config:" + platAlarmConfig.getRuleConfig() + ",当前时间:" + currentTime();
platAlarmCheckDTO.setRemark(remark); platAlarmCheckDTO.setRemark(remark);
notice(platAlarmCheckDTO);
alarmRedisDTO.setStart(new Date()); alarmRedisDTO.setStart(new Date());
alarmRedisDTO.setAlarm(CommonEnum.YES.getValue()); alarmRedisDTO.setAlarm(CommonEnum.YES.getValue());
RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO); RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
log.info("deviceId:{},离床告警推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{},上报的config:{}", deviceId, notice(platAlarmCheckDTO);
longToTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm() // log.info("deviceId:{},离床告警推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{},上报的config:{}", deviceId,
, platAlarmConfig.getRuleConfig()); // longToTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm()
// , platAlarmConfig.getRuleConfig());
} }
@Override @Override
...@@ -317,8 +317,7 @@ public class OffBedAlarm implements IAlarm { ...@@ -317,8 +317,7 @@ public class OffBedAlarm implements IAlarm {
return; return;
} }
// PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom(); // PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
log.info("离床告警配置,发出告警,设备id:{},长者名称:{},config_id:{},configL{}", platDevice.getId(), JSONUtil.toJsonStr(platElderList), log.info("离床告警配置,发出告警,设备id:{},长者名称:{},,config{}", platDevice.getId(), JSONUtil.toJsonStr(platElderList), config.getRuleConfig());
config.getId(), config.getRuleConfig());
platElderList = platElderList.stream().distinct().collect(Collectors.toList()); platElderList = platElderList.stream().distinct().collect(Collectors.toList());
for (PlatElder platElder : platElderList) { for (PlatElder platElder : platElderList) {
List<String> param = new ArrayList<>(); List<String> param = new ArrayList<>();
...@@ -329,9 +328,11 @@ public class OffBedAlarm implements IAlarm { ...@@ -329,9 +328,11 @@ public class OffBedAlarm implements IAlarm {
platAlarmRecord.setElderName(platElder.getName()); platAlarmRecord.setElderName(platElder.getName());
platAlarmRecord.setElderIds(platElder.getId()); platAlarmRecord.setElderIds(platElder.getId());
platAlarmRecord.setRemark(platAlarmCheckDTO.getRemark()); platAlarmRecord.setRemark(platAlarmCheckDTO.getRemark());
try {
platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(), platAlarmRecord); platAlarmRecordService.noticeDeviceAlarm(platAlarmCheckDTO.getPlatAlarmConfig(), platAlarmRecord);
log.info("离床告警配置,发出告警,设备id:" + platDevice.getId() + ", 长者名称:" + platElder.getName() } catch (Exception e) {
+ "config_id:" + config.getId() + "--" + config.getRuleConfig()); log.error("离床通知异常:{}", e.getMessage());
}
} }
} }
......
package com.makeit.iotapi; package com.makeit.iotapi;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.module.admin.vo.plat.PlatTenantVO; import com.makeit.module.admin.vo.plat.PlatTenantVO;
import com.makeit.module.iot.service.IotOrgService; import com.makeit.module.iot.service.IotOrgService;
import com.makeit.module.iot.service.IotProductDeviceService; import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.service.IotTokenService; import com.makeit.module.iot.service.IotTokenService;
import com.makeit.service.platform.alarm.alarmStrategy.OffBedAlarm;
import com.makeit.service.platform.elder.PlatElderSleepService;
import com.makeit.utils.redis.RedisUtil; import com.makeit.utils.redis.RedisUtil;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
...@@ -28,13 +21,6 @@ public class IotDeviceInfoContentFall { ...@@ -28,13 +21,6 @@ public class IotDeviceInfoContentFall {
private IotOrgService iotOrgService; private IotOrgService iotOrgService;
@Autowired @Autowired
private IotProductDeviceService iotProductDeviceService; private IotProductDeviceService iotProductDeviceService;
@Autowired
private OffBedAlarm offBedAlarm;
@Autowired
private PlatElderSleepService platElderSleepService;
private static final Logger logger = LoggerFactory.getLogger(IotDeviceInfoContentFall.class);
@Test @Test
...@@ -95,24 +81,6 @@ public class IotDeviceInfoContentFall { ...@@ -95,24 +81,6 @@ public class IotDeviceInfoContentFall {
iotOrgService.updateIotOrgInfo("1698964909267415040", "lxl2234"); iotOrgService.updateIotOrgInfo("1698964909267415040", "lxl2234");
} }
@Test
void offBedAlarm() {
PlatAlarmCheckDTO platAlarmCheckDTO = new PlatAlarmCheckDTO();
PlatDevice platDevice = new PlatDevice();
platDevice.setOrgId("1712384736845950978");
platDevice.setId("1732609639364812811");
platAlarmCheckDTO.setPlatDevice(platDevice);
JSONObject properties = JSON.parseObject("{\n" +
" \"person\": 0,\n" +
" \"personState\": 0,\n" +
" \"distance\": 50,\n" +
" \"hr\": 80,\n" +
" \"br\": 20,\n" +
" \"bodymove\": 50,\n}");
platAlarmCheckDTO.setProperties(properties);
offBedAlarm.checkConfig(platAlarmCheckDTO);
}
@Test @Test
void getRedis() { void getRedis() {
......
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