Commit 3730169d by 李小龙

fixbug

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