Commit c88ffadf by 李小龙

fix:

parent 571a7f76
......@@ -12,3 +12,70 @@ server-api 提供外部接口
server-service 存放业务service、mapper、entity
server-common 通用模块 包含通用entity、service、mapper类等
DeviceInfo(
deviceId=407A00233900002,
timestamp=1698908455958,
messageType=REPORT_PROPERTY,
headers=HeaderInfo(deviceName=空间人感雷达测试-3,
productName=空间人感雷达,
productId=1701238458321530880,
_uid=GouO1cQWTrqGfyI6VW8MET9OgePzAj6T,
creatorId=1199596756811550720,
traceparent=00-dd6cff5f8d3944eb111d4cb0e9d68643-2525d125317f2158-01,
bindings=[HeaderInfo.Bind(id=1700040815264198656,
type=org),
HeaderInfo.Bind(id=1703950733042053120,
type=org),
HeaderInfo.Bind(id=1701223487902642176,
type=org)]),
properties={"mode":1,
"distance":471,
"personState":1,
"radarHitch":"normal",
"angle":0,
"mount":0})
{
"headers": {
"bindings": [
{
"id": "1712384736656117760",
"type": "org"
}
],
"serverId": "jetlinks-platform:8844",
"deviceName": "测试跌倒设备clt",
"productName": "跌倒监测雷达",
"connectTime": 1698909870220,
"from": "session",
"productId": "1701240238501588992",
"_uid": "GouPFld7CTch9ushBlCUlXVZ-eRIKI99",
"creatorId": "1199596756811550720"
},
"messageType": "OFFLINE",
"deviceId": "1712376995246002176",
"timestamp": 1698912687995
}
{
"headers": {
"bindings": [
{
"id": "1712384736656117760",
"type": "org"
}
],
"deviceName": "测试跌倒设备clt",
"productName": "跌倒监测雷达",
"productId": "1701240238501588992",
"_uid": "GouPO1KjVin2L3QiLnP0Y_woBBef55ZE",
"creatorId": "1199596756811550720",
"traceparent": "00-3d6664e9f3772492d9460bfc6bda7e75-d9817e2f1126ab11-01"
},
"messageType": "DISCONNECT",
"messageId": "1720000758644310016",
"deviceId": "1712376995246002176",
"timestamp": 1698915111586
}
\ No newline at end of file
......@@ -30,6 +30,8 @@ public class PlatAlarmCheckDTO {
private String remark;
//异常值
private String abnormalValue;
//设备状态
private String messageType;
}
......@@ -59,11 +59,17 @@ public class BehaviorAlarm implements IAlarm {
*/
@Override
public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) {
String messageType = platAlarmCheckDTO.getMessageType();
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
String ruleConfigStr = config.getRuleConfig();
JSONObject properties = platAlarmCheckDTO.getProperties();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getId();
if(properties == null ){
properties = new JSONObject();
}
String personState = Convert.toStr(properties.get("personState"));
PlatAlarmConfigBehaviorDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigBehaviorDTOVO.class);
Integer duration = ruleConfig.getAverageDuration();//分钟
......@@ -93,7 +99,7 @@ public class BehaviorAlarm implements IAlarm {
alarmRedisDTO = new AlarmRedisDTO();
}
//有人
if (!personStateList.contains(personState)) {
if (!personStateList.contains(personState) && StringUtils.equalsAnyIgnoreCase(messageType, "REPORT_PROPERTY")) {
//第一次进入空间
Long startLong = alarmRedisDTO.getStartLong();
if (startLong == null) {
......@@ -115,7 +121,7 @@ public class BehaviorAlarm implements IAlarm {
}
}
} else {//没人
} else if(StringUtils.equalsAnyIgnoreCase(messageType, "REPORT_PROPERTY","OFFLINE","DISCONNECT")) {//没人
// 是否有第一次进入记录,有则保存db
Long startLong = alarmRedisDTO.getStartLong();
if (startLong == null) {
......
......@@ -54,6 +54,7 @@ public class BreathAlarm implements IAlarm {
*/
@Override
public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) {
String messageType = platAlarmCheckDTO.getMessageType();
//todo 获取老人健康的阈值
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
......@@ -84,6 +85,9 @@ public class BreathAlarm implements IAlarm {
Integer end = ruleConfig.getRespiratoryRateEnd();
Integer duration = ruleConfig.getDuration();
JSONObject properties = platAlarmCheckDTO.getProperties();
if(properties == null ){
properties = new JSONObject();
}
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getId();
String personState = Convert.toStr(properties.get("personState"));
......@@ -135,7 +139,7 @@ public class BreathAlarm implements IAlarm {
notice(platAlarmCheckDTO);
}
} else {
} else if(StringUtils.equalsAnyIgnoreCase(messageType, "REPORT_PROPERTY","OFFLINE","DISCONNECT")){
RedisUtil.delete(RedisConst.ALARM_DEVICE_BR_ID + deviceId);
}
}
......
......@@ -64,6 +64,9 @@ public class FallAlarm implements IAlarm {
JSONObject properties = platAlarmCheckDTO.getProperties();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getId();
if(properties == null ){
properties = new JSONObject();
}
String personState = Convert.toStr(properties.get("personState"));
//记录停留时长
......@@ -98,6 +101,7 @@ public class FallAlarm implements IAlarm {
PlatAlarmConfig config = alarmConfigCacheUtil.get(platDevice.getOrgId(), PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue());
String ruleConfigStr = config.getRuleConfig();
JSONObject properties = platAlarmCheckDTO.getProperties();
String messageType = platAlarmCheckDTO.getMessageType();
String deviceId = platDevice.getId();
if (StringUtils.isBlank(ruleConfigStr)) {
......@@ -134,7 +138,7 @@ public class FallAlarm implements IAlarm {
alarmRedisDTO = new AlarmRedisDTO();
}
//有人
if (!personStateList.contains(person)) {
if (!personStateList.contains(person) && StringUtils.equalsAnyIgnoreCase(messageType, "REPORT_PROPERTY")) {
//第一次进入空间
Long startLong = alarmRedisDTO.getStartLong();
if (startLong == null) {
......@@ -156,7 +160,7 @@ public class FallAlarm implements IAlarm {
return;
}
}
} else {//没人
} else if(StringUtils.equalsAnyIgnoreCase(messageType, "REPORT_PROPERTY","OFFLINE","DISCONNECT")){//没人
// 是否有第一次进入记录,有则保存db
Long startLong = alarmRedisDTO.getStartLong();
if (startLong == null) {
......
......@@ -54,6 +54,7 @@ public class HeartAlarm implements IAlarm {
return;
}
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
String messageType = platAlarmCheckDTO.getMessageType();
if (CommonEnum.NO.getValue().equals(config.getStatus())) {
log.error("呼吸告警配置为禁用,告警配置id:" + config.getId());
return;
......@@ -74,6 +75,9 @@ public class HeartAlarm implements IAlarm {
}
JSONObject properties = platAlarmCheckDTO.getProperties();
if(properties == null ){
properties = new JSONObject();
}
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String deviceId = platDevice.getId();
Integer start = ruleConfig.getHeartRateStart();
......@@ -126,7 +130,7 @@ public class HeartAlarm implements IAlarm {
RedisUtil.set(RedisConst.ALARM_DEVICE_HR_ID + deviceId, alarmRedisDTO);
notice(platAlarmCheckDTO);
}
} else {
} else if(StringUtils.equalsAnyIgnoreCase(messageType, "REPORT_PROPERTY","OFFLINE","DISCONNECT")){
RedisUtil.delete(RedisConst.ALARM_DEVICE_HR_ID + deviceId);
}
......
......@@ -40,7 +40,8 @@ public class DayDurationUtil implements ApplicationRunner {
return;
}
Map<String, List<PlatDayDurationRecord>> deviceIdMap = platDayDurationRecords.stream().collect(Collectors.groupingBy(PlatDayDurationRecord::getDeviceId));
deviceIdMap.entrySet().stream().map(vo -> {
//七天都得有数据
deviceIdMap.entrySet().stream().filter(vo->vo.getValue().size()>=7).map(vo -> {
List<PlatDayDurationRecord> value = vo.getValue();
int size = value.size();
int mid = size / 2;
......
......@@ -4,13 +4,9 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.saas.PlatTenant;
import com.makeit.enums.CommonEnum;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.enums.DeviceState;
import com.makeit.module.iot.vo.DeviceInfo;
......@@ -38,7 +34,6 @@ import org.springframework.util.StopWatch;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Component
......@@ -157,6 +152,8 @@ public class PushCallback implements MqttCallback {
platAlarmCheckDTO.setPlatDevice(platDevice);
//iot上报数据
platAlarmCheckDTO.setProperties(properties);
//设备状态
platAlarmCheckDTO.setMessageType(messageType);
alarm.checkConfig(platAlarmCheckDTO);
}
}
......
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