Commit 6d364455 by huangjy

Merge remote-tracking branch 'origin/dev' into dev

parents 398f1437 54708acf
...@@ -99,15 +99,16 @@ public class FallAlarm implements IAlarm { ...@@ -99,15 +99,16 @@ public class FallAlarm implements IAlarm {
private void recordDuration(PlatAlarmCheckDTO platAlarmCheckDTO) { private void recordDuration(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice(); PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
PlatAlarmConfig config = alarmConfigCacheUtil.get(platDevice.getOrgId(), PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue()); PlatAlarmConfig config = alarmConfigCacheUtil.get(platDevice.getOrgId(), PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue());
if (config == null ||StringUtils.isBlank(config.getRuleConfig())) {
log.error("行为告警配置未配置,告警配置id:" + config.getId());
return;
}
String ruleConfigStr = config.getRuleConfig(); String ruleConfigStr = config.getRuleConfig();
JSONObject properties = platAlarmCheckDTO.getProperties(); JSONObject properties = platAlarmCheckDTO.getProperties();
String messageType = platAlarmCheckDTO.getMessageType(); String messageType = platAlarmCheckDTO.getMessageType();
String deviceId = platDevice.getId(); String deviceId = platDevice.getId();
if (StringUtils.isBlank(ruleConfigStr)) {
log.error("行为告警配置未配置,告警配置id:" + config.getId());
return;
}
String personState = Convert.toStr(properties.get("personState")); String personState = Convert.toStr(properties.get("personState"));
String person = Convert.toStr(properties.get("person")); String person = Convert.toStr(properties.get("person"));
PlatAlarmConfigBehaviorDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigBehaviorDTOVO.class); PlatAlarmConfigBehaviorDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigBehaviorDTOVO.class);
...@@ -155,7 +156,9 @@ public class FallAlarm implements IAlarm { ...@@ -155,7 +156,9 @@ public class FallAlarm implements IAlarm {
if(duration1 != 0) { if(duration1 != 0) {
alarmRedisDTO.setAlarm(CommonEnum.YES.getValue()); alarmRedisDTO.setAlarm(CommonEnum.YES.getValue());
RedisUtil.set(RedisConst.ALARM_DEVICE_BEHAVIOR_ID + deviceId, alarmRedisDTO); RedisUtil.set(RedisConst.ALARM_DEVICE_BEHAVIOR_ID + deviceId, alarmRedisDTO);
notice(platAlarmCheckDTO); PlatAlarmCheckDTO platAlarmCheckDTO_behavior = BeanDtoVoUtils.convert(platAlarmCheckDTO, PlatAlarmCheckDTO.class);
platAlarmCheckDTO_behavior.setPlatAlarmConfig(config);
notice(platAlarmCheckDTO_behavior);
}else { }else {
return; return;
} }
......
...@@ -686,6 +686,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -686,6 +686,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
} }
platRoomService.save(platRoom); platRoomService.save(platRoom);
//已有房间的空间不允许再创建下级
lastSpaceIds.add(platRoom.getSpaceId());
platBedService.add(platRoom); platBedService.add(platRoom);
} }
} }
......
...@@ -40,8 +40,8 @@ public class DayDurationUtil implements ApplicationRunner { ...@@ -40,8 +40,8 @@ public class DayDurationUtil implements ApplicationRunner {
return; return;
} }
Map<String, List<PlatDayDurationRecord>> deviceIdMap = platDayDurationRecords.stream().collect(Collectors.groupingBy(PlatDayDurationRecord::getDeviceId)); Map<String, List<PlatDayDurationRecord>> deviceIdMap = platDayDurationRecords.stream().collect(Collectors.groupingBy(PlatDayDurationRecord::getDeviceId));
//七天都得有数据 //七天内 至少有三条数据
deviceIdMap.entrySet().stream().filter(vo->vo.getValue().size()>=7).map(vo -> { deviceIdMap.entrySet().stream().filter(vo->vo.getValue().size()>=3).map(vo -> {
List<PlatDayDurationRecord> value = vo.getValue(); List<PlatDayDurationRecord> value = vo.getValue();
int size = value.size(); int size = value.size();
int mid = size / 2; int mid = size / 2;
......
...@@ -171,23 +171,28 @@ public class PushCallback implements MqttCallback { ...@@ -171,23 +171,28 @@ public class PushCallback implements MqttCallback {
} }
@Transactional @Transactional
@TenantIdIgnore
public void updateDeviceStatus(String messageType, String deviceId, String iot_tenantId) { public void updateDeviceStatus(String messageType, String deviceId, String iot_tenantId) {
if(StringUtils.equalsAnyIgnoreCase(messageType, DeviceState.offline.getValue(),DeviceState.online.getValue())){ try {
if (StringUtils.equalsAnyIgnoreCase(messageType, DeviceState.offline.getValue(), DeviceState.online.getValue())) {
platDeviceService.update(new UpdateWrapper<PlatDevice>().lambda() platDeviceService.update(new UpdateWrapper<PlatDevice>().lambda()
.set(PlatDevice::getStatus,messageType.toLowerCase()) .set(PlatDevice::getStatus, messageType.toLowerCase())
.eq(PlatDevice::getOriDeviceId,deviceId)); .eq(PlatDevice::getOriDeviceId, deviceId));
LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceLambdaQueryWrapper.eq(PlatDevice::getOriDeviceId,deviceId); deviceLambdaQueryWrapper.eq(PlatDevice::getOriDeviceId, deviceId);
List<PlatDevice> deviceList = platDeviceService.list(deviceLambdaQueryWrapper); List<PlatDevice> deviceList = platDeviceService.list(deviceLambdaQueryWrapper);
if(CollectionUtils.isEmpty(deviceList)){ if (CollectionUtils.isEmpty(deviceList)) {
return; return;
} }
for (PlatDevice platDevice : deviceList) { for (PlatDevice platDevice : deviceList) {
platDevice.setStatus(messageType.toLowerCase()); platDevice.setStatus(messageType.toLowerCase());
}
deviceCacheUtil.putAll(deviceList);
} }
deviceCacheUtil.putAll(deviceList); }catch (Exception e){
logger.error("更新设备状态:",e);
} }
} }
......
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