Commit 6d364455 by huangjy

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

parents 398f1437 54708acf
......@@ -99,15 +99,16 @@ public class FallAlarm implements IAlarm {
private void recordDuration(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
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();
JSONObject properties = platAlarmCheckDTO.getProperties();
String messageType = platAlarmCheckDTO.getMessageType();
String deviceId = platDevice.getId();
if (StringUtils.isBlank(ruleConfigStr)) {
log.error("行为告警配置未配置,告警配置id:" + config.getId());
return;
}
String personState = Convert.toStr(properties.get("personState"));
String person = Convert.toStr(properties.get("person"));
PlatAlarmConfigBehaviorDTOVO ruleConfig = JsonUtil.toObj(ruleConfigStr, PlatAlarmConfigBehaviorDTOVO.class);
......@@ -155,7 +156,9 @@ public class FallAlarm implements IAlarm {
if(duration1 != 0) {
alarmRedisDTO.setAlarm(CommonEnum.YES.getValue());
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 {
return;
}
......
......@@ -686,6 +686,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
platRoomService.save(platRoom);
//已有房间的空间不允许再创建下级
lastSpaceIds.add(platRoom.getSpaceId());
platBedService.add(platRoom);
}
}
......
......@@ -40,8 +40,8 @@ public class DayDurationUtil implements ApplicationRunner {
return;
}
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();
int size = value.size();
int mid = size / 2;
......
......@@ -171,23 +171,28 @@ public class PushCallback implements MqttCallback {
}
@Transactional
@TenantIdIgnore
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()
.set(PlatDevice::getStatus,messageType.toLowerCase())
.eq(PlatDevice::getOriDeviceId,deviceId));
platDeviceService.update(new UpdateWrapper<PlatDevice>().lambda()
.set(PlatDevice::getStatus, messageType.toLowerCase())
.eq(PlatDevice::getOriDeviceId, deviceId));
LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceLambdaQueryWrapper.eq(PlatDevice::getOriDeviceId,deviceId);
List<PlatDevice> deviceList = platDeviceService.list(deviceLambdaQueryWrapper);
if(CollectionUtils.isEmpty(deviceList)){
return;
}
for (PlatDevice platDevice : deviceList) {
platDevice.setStatus(messageType.toLowerCase());
LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceLambdaQueryWrapper.eq(PlatDevice::getOriDeviceId, deviceId);
List<PlatDevice> deviceList = platDeviceService.list(deviceLambdaQueryWrapper);
if (CollectionUtils.isEmpty(deviceList)) {
return;
}
for (PlatDevice platDevice : deviceList) {
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