Commit 3730169d by 李小龙

fixbug

parent 10b9e607
......@@ -19,6 +19,7 @@ public class DeviceInfo {
private HeaderInfo headers;
private JSONObject properties;
// private String properties;
/**
......
......@@ -52,7 +52,9 @@ public class PlatDevice extends BaseBusEntity {
/**
* @see DeviceState
*/
@ApiModelProperty(value = "状态 数据字典 1 在线 0离线 ")
@ApiModelProperty(value = "状态 notActive(\"notActive\",\"禁用\"),\n" +
" offline(\"offline\",\"离线\"),\n" +
" online(\"online\",\"在线\"); ")
private String status;
@ApiModelProperty(value = "组织id")
......
......@@ -84,7 +84,7 @@ public class BehaviorAlarm implements IAlarm {
Long duration1 = platDayDurationRecord.getDuration();
duration = duration * 60 + (int) (duration1 / 1000);
//duration+平均停留时长
List<String> personStateList = Arrays.asList("1", "2", "3");
List<String> personStateList = Arrays.asList("0");
//有人
//计数
Date now = new Date();
......@@ -94,7 +94,7 @@ public class BehaviorAlarm implements IAlarm {
alarmRedisDTO = new AlarmRedisDTO();
}
//有人
if (personStateList.contains(personState)) {
if (!personStateList.contains(personState)) {
//第一次进入空间
Long startLong = alarmRedisDTO.getStartLong();
if (startLong == null) {
......@@ -137,7 +137,7 @@ public class BehaviorAlarm implements IAlarm {
private void saveDayDurationRecord(PlatAlarmCheckDTO platAlarmCheckDTO, AlarmRedisDTO alarmRedisDTO) {
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
PlatRegionSetting platRegionSetting = platAlarmCheckDTO.getPlatRegionSetting();
Date now = new Date();
long endLong = now.getTime();
......@@ -149,6 +149,8 @@ public class BehaviorAlarm implements IAlarm {
log.info("未关联长者,设备id:"+platDevice.getId());
return;
}
PlatRoom platRoom = platAlarmCheckDTO.getPlatRoom();
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
PlatDayDurationRecord durationRecord = new PlatDayDurationRecord();
durationRecord.setElderIds(platElderList.stream().map(BaseEntity::getId).collect(Collectors.joining(",")));
......
......@@ -49,6 +49,7 @@ public class BreathAlarm implements IAlarm {
*/
@Override
public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) {
//todo 获取老人健康的阈值
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
String ruleConfigStr = config.getRuleConfig();
JSONObject properties = platAlarmCheckDTO.getProperties();
......
......@@ -40,6 +40,7 @@ public class HeartAlarm implements IAlarm {
@Override
public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) {
//todo 获取老人健康的阈值
PlatAlarmConfig config = platAlarmCheckDTO.getPlatAlarmConfig();
String ruleConfigStr = config.getRuleConfig();
JSONObject properties = platAlarmCheckDTO.getProperties();
......
......@@ -343,10 +343,14 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
@Override
@TenantIdIgnore
public void getElderListByDeviceId(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
String tenantId = platDevice.getTenantId();
LambdaQueryWrapper<PlatRoomBedDevice> roomBedDeviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
roomBedDeviceLambdaQueryWrapper.eq(PlatRoomBedDevice::getDeviceId, platDevice.getId());
roomBedDeviceLambdaQueryWrapper.eq(PlatRoomBedDevice::getDeviceId, platDevice.getId())
.eq(BaseBusEntity::getTenantId,tenantId)
;
PlatRoomBedDevice platRoomBedDevice = platRoomBedDeviceService.getOne(roomBedDeviceLambdaQueryWrapper, false);
if(platRoomBedDevice==null){
throw new BusinessException("设备没绑定房间:"+platDevice.getId());
......@@ -358,7 +362,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
LambdaQueryWrapper<PlatRegionSetting> platRegionSettingLambdaQueryWrapper = new LambdaQueryWrapper<>();
platRegionSettingLambdaQueryWrapper.eq(PlatRegionSetting::getRoomId, platRoom.getId())
.eq(PlatRegionSetting::getDeviceId, platDevice.getId());
.eq(PlatRegionSetting::getDeviceId, platDevice.getId())
.eq(BaseBusEntity::getTenantId,tenantId)
;
//区域设置
PlatRegionSetting platRegionSetting = platRegionSettingService.getOne(platRegionSettingLambdaQueryWrapper, false);
platAlarmCheckDTO.setPlatRegionSetting(platRegionSetting);
......@@ -366,7 +372,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
String bedId = platRoomBedDevice.getBedId();
if (StringUtils.isNotBlank(bedId)) {
LambdaQueryWrapper<PlatElder> elderLambdaQueryWrapper = new LambdaQueryWrapper<>();
elderLambdaQueryWrapper.eq(PlatElder::getBedId, bedId);
elderLambdaQueryWrapper.eq(PlatElder::getBedId, bedId)
.eq(BaseBusEntity::getTenantId,tenantId)
;
List<PlatElder> list = platElderService.list(elderLambdaQueryWrapper);
platAlarmCheckDTO.setPlatElderList(list);
}
......@@ -374,7 +382,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
String roomId = platRoomBedDevice.getRoomId();
if (StringUtils.isNotBlank(roomId)) {
LambdaQueryWrapper<PlatElder> elderLambdaQueryWrapper = new LambdaQueryWrapper<>();
elderLambdaQueryWrapper.eq(PlatElder::getRoomId, roomId);
elderLambdaQueryWrapper.eq(PlatElder::getRoomId, roomId)
.eq(BaseBusEntity::getTenantId,tenantId)
;
List<PlatElder> list = platElderService.list(elderLambdaQueryWrapper);
platAlarmCheckDTO.setPlatElderList(list);
}
......
......@@ -214,7 +214,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
BeanUtils.copyProperties(dto, db);
db.setId(id);
BeanUtils.copyProperties(dto, other);
BeanUtils.copyProperties(dto, other,BaseEntity.Fields.id);
other.setDeviceId(id);
updateById(db);
......
......@@ -19,6 +19,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;
import java.util.List;
import java.util.Objects;
......@@ -69,10 +70,17 @@ public class PushCallback implements MqttCallback {
logger.info("deliveryComplete--------------" + token.isComplete());
}
/**
* 触发告警耗时 3.07s
* 未触发告警耗时 0.08s
* @param device
*/
@TenantIdIgnore
public void checkAlarm(DeviceInfo device) {
StopWatch stopWatch = new StopWatch();
stopWatch.start("checkAlarm-1");
String deviceId = device.getDeviceId();
//String propertiesStr = device.getProperties();
// String propertiesStr = device.getProperties();
// if (StringUtils.isBlank(propertiesStr)) {
// return;
// }
......@@ -109,6 +117,8 @@ public class PushCallback implements MqttCallback {
}
}
}
stopWatch.stop();
logger.info(stopWatch.prettyPrint());
}
......
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