Commit 7ace2a21 by 汪志阳

fix:bug fix

parent e289d4a1
......@@ -57,6 +57,9 @@ public class OffBedAlarm implements IAlarm {
log.error("离床告警心率设备未关联长者,设备plat_id:" + platAlarmCheckDTO.getPlatDevice().getId());
return;
}
if(!platDevice.getId().equals("1732609639364812805")){
return;
}
PlatAlarmConfig config = alarmConfigCacheUtil.get(platDevice.getOrgId(), PlatAlarmConfigEnum.AlarmTypeEnum.OFF_BED.getValue());
offBedCheckAlarm(config, platAlarmCheckDTO, platDevice);
......@@ -214,7 +217,7 @@ public class OffBedAlarm implements IAlarm {
log.info("deviceId:{},uncross_config:{},第一次离床时间:{}", deviceId, config.getRuleConfig(), longToTime(alarmRedisDTO.getStartLong()));
Integer duration = ruleConfig.getDuration();
LocalTime startTime = ruleConfig.getOffBedStart();
LocalDateTime startLocalDteTime = LocalDateTime.of(LocalDate.now(), startTime);
// LocalDateTime startLocalDteTime = LocalDateTime.of(LocalDate.now(), startTime);
LocalTime endTime = ruleConfig.getOffBedEnd();
// LocalDateTime endLocalDteTime = LocalDateTime.of(LocalDate.now(), endTime);
......@@ -239,13 +242,14 @@ public class OffBedAlarm implements IAlarm {
}
LocalDateTime now = currentTime();
LocalTime localTime = LocalTime.now().plusHours(9);
LocalTime localTime = LocalTime.now().plusHours(8);
if (!isInTime && localTime.isAfter(startTime) && localTime.isBefore(endTime)) {
long mills = Duration.between(startLocalDteTime, now).toMillis() / 1000;
LocalDateTime dateTime = LocalDateTime.of(LocalDate.now(), startTime);
long mills = Duration.between(dateTime, now).toMillis() / 1000;
boolean noInOverTime = mills >= duration * 60;
if (noInOverTime) {
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
log.info("deviceId:{},uncross离床告警第一次离床时间在范围前,配置:{}", deviceId, config.getRuleConfig());
log.info("deviceId:{},uncross离床告警第一次离床时间在范围前,配置:{},date:{},mills:{}", deviceId, config.getRuleConfig(),dateTime,mills);
platAlarmCheckDTO.setPlatAlarmConfig(config);
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
} else {
......@@ -326,7 +330,7 @@ public class OffBedAlarm implements IAlarm {
}
private static LocalDateTime currentTime() {
return LocalDateTime.now().plusHours(9);
return LocalDateTime.now().plusHours(8);
// return LocalDateTime.now();
}
......
......@@ -123,7 +123,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
Boolean isUnWechatRead = CollUtil.isNotEmpty(list) && list.stream()
.anyMatch(a -> CommonEnum.NO.getValue().equals(a.getWechatReadFlag()));
Boolean statusFlag = CollUtil.isNotEmpty(list) && list.stream()
.anyMatch(a -> CommonEnum.NO.getValue().equals(a.getStatus()));
.anyMatch(a -> CommonEnum.NO.getValue().equals(a.getReadFlag()));
Page<PlatAlarmRecord> page = page(mpPage, lambdaQueryWrapper);
List<PlatAlarmRecord> records = page.getRecords();
List<PlatAlarmRecordVO> dtos = BeanDtoVoUtils.listVo(records, PlatAlarmRecordVO.class);
......
......@@ -43,6 +43,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.multipart.MultipartFile;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.regex.Matcher;
......@@ -68,6 +69,11 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
private PlatElderService platElderService;
private void check(PlatSpaceAddDTO dto) {
if (StrUtil.isNotBlank(dto.getParentPath())
&& dto.getParentPath().split(",").length >= 4) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_OVER_LEVEL);
}
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatSpace::getName, dto.getName());
queryWrapper.ne(StringUtil.isNotEmpty(dto.getId()), PlatSpace::getId, dto.getId());
......@@ -149,7 +155,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT);
}
// todo 编辑后层级大于4,不允许编辑 脏数据太多,待校验
// checkAndUpdateSonSpace(space);
checkAndUpdateSonSpace(space);
this.updateById(space);
List<String> lastSpaceIds = recursionLastSpaceIds(space.getId(), new ArrayList<>());
if (CollUtil.isEmpty(lastSpaceIds)) {
......@@ -228,17 +234,19 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
.apply(StringUtils.isNotBlank(spaceId), "find_in_set('" + spaceId + "',parent_path)"));
int sonLevel = 0;
if (CollUtil.isNotEmpty(platSpaceList)) {
final int[] maxLength = {1};
AtomicInteger maxLength = new AtomicInteger(1);
platSpaceList.forEach(s -> {
if (StrUtil.isBlank(s.getParentPath())) {
return;
}
String[] parentSpaceIds = s.getParentPath().split(",");
if (parentSpaceIds.length > maxLength[0]) {
maxLength[0] = parentSpaceIds.length;
List<String> parentSpaceIds = Lists.newArrayList(s.getParentPath().split(","));
parentSpaceIds.remove(space.getId());
if (parentSpaceIds.size() > maxLength.get()) {
maxLength.set(parentSpaceIds.size());
}
maxLength.set(parentSpaceIds.size());
});
sonLevel = maxLength[0];
sonLevel = maxLength.get();
}
if (level + sonLevel > 3) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_OVER_LEVEL);
......@@ -843,7 +851,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
List<PlatSpace> list = this.list(queryWrapper);
list = list.stream()
.filter(s -> (StringUtil.isNotEmpty(s.getParentPath()) && s.getParentPath().split(",").length < 3)
.filter(s -> (StringUtil.isNotEmpty(s.getParentPath()) && s.getParentPath().split(",").length <= 3)
|| StringUtil.isEmpty(s.getParentPath()))
.collect(Collectors.toList());
//父级
......
package com.makeit.mqtt;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
import com.makeit.common.entity.BaseEntity;
import com.makeit.dto.platform.alarm.PlatAlarmCheckDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig;
......@@ -13,6 +15,7 @@ import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel;
import com.makeit.external.strategy.OpenApiBaseStrategy;
import com.makeit.external.strategy.OpenApiBaseStrategyFactory;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.redis.RedisConst;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.module.iot.enums.DeviceState;
import com.makeit.module.iot.vo.DeviceInfo;
......@@ -267,6 +270,7 @@ public class PushCallback implements MqttCallback {
List<PlatAlarmConfig> configList = alarmConfigService.listOfBed(orgIds);
Map<String, PlatAlarmConfig> configMap = StreamUtil.toMap(configList, PlatAlarmConfig::getOrgId);
String alarmType = PlatAlarmConfigEnum.AlarmTypeEnum.OFF_BED.getValue();
List<String> type = Lists.newArrayList("OFFLINE", "DISCONNECT");
platDeviceList.forEach(device -> {
for (IAlarm alarm : alarmList) {
if (alarm.support(alarmType)) {
......@@ -285,6 +289,9 @@ public class PushCallback implements MqttCallback {
platAlarmCheckDTO.setProperties(properties);
//设备状态
platAlarmCheckDTO.setMessageType(messageType);
if (StrUtil.isBlank(messageType) || type.contains(messageType)) {
RedisUtil.delete(RedisConst.ALARM_DEVICE_OFF_BED_ID + device.getId());
}
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