Commit 30457045 by huangjy

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

parents 6955f0e4 dbac1e6d
......@@ -106,6 +106,7 @@ public enum CodeMessageEnum {
PLATFORM_ERROR_SPACE_NAME_DUPLICATE(500, "PLATFORM.ERROR.SPACE.NAME.DUPLICATE"),
PLATFORM_ERROR_SPACE_NOT_DEL(500, "PLATFORM.ERROR.SPACE.NOT.DEL"),
PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT(500, "PLATFORM.ERROR.SPACE.NOT.AUTH.PARENT"),
PLATFORM_ERROR_SPACE_OVER_LEVEL(500, "PLATFORM.ERROR.SPACE.OVER.LEVEL"),
PLATFORM_ERROR_SPACE_USER_NOT_ADD(500, "PLATFORM.ERROR.SPACE.USER.NOT.ADD"),
PLATFORM_ERROR_SPACE_ROOM_NOT_ADD(500, "PLATFORM.ERROR.SPACE.ROOM.NOT.ADD"),
PLATFORM_ERROR_ROOM_EXIT_BAD(500, "PLATFORM.ERROR.ROOM.EXIT.BED"),
......
package com.makeit.module.controller.wechat.alarm;
import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Maps;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO;
......@@ -8,7 +9,6 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.report.PlatformTypeEnum;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
......@@ -16,7 +16,6 @@ import com.makeit.utils.user.common.CommonUserUtil;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -44,7 +43,8 @@ public class PlatAlarmRecordWechatController {
Map<String,Object> resMap = Maps.newHashMap();
PageVO<PlatAlarmRecordVO> page = platAlarmRecordService.page(dto);
boolean b = page.getList().stream().anyMatch(platAlarmRecord -> StringUtils.equals(CommonEnum.NO.getValue(), platAlarmRecord.getStatus()));
// boolean b = page.getList().stream().anyMatch(platAlarmRecord -> StringUtils.equals(CommonEnum.NO.getValue(), platAlarmRecord.getStatus()));
boolean b = CollUtil.isNotEmpty(page.getList()) && page.getList().get(0).getStatusFlag();
resMap.put("todoFlag",b);
resMap.put("page",page);
return ApiResponseUtils.success(resMap);
......
......@@ -63,6 +63,10 @@ public class PlatOrg extends BaseBusEntity {
@TableField(exist = false)
private PlatOrg parent;
@ApiModelProperty(value = "级别")
@TableField(exist = false)
private Integer grade;
private String remark;
}
\ No newline at end of file
......@@ -150,7 +150,11 @@ public class OffBedAlarm implements IAlarm {
LocalTime endTime = ruleConfig.getOffBedEnd();
Long firstOffBedLong = alarmRedisDTO.getStartLong();
boolean isOverTime = (System.currentTimeMillis() - firstOffBedLong) / 1000 >= duration * 60;
long currentTimeMillis = System.currentTimeMillis();
LocalDateTime nowTest = LocalDateTime.now().plusHours(7).plusMinutes(20);
currentTimeMillis = nowTest.toInstant(ZoneOffset.of("+8")).toEpochMilli();
log.info("handleCrossDay,测试当前的时间:{},时间戳:{}", nowTest, currentTimeMillis);
boolean isOverTime = (currentTimeMillis - firstOffBedLong) / 1000 >= duration * 60;
LocalDateTime firstOffBedTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(firstOffBedLong), ZoneOffset.of("+8"));
LocalTime firstTime = firstOffBedTime.toLocalTime();
......@@ -163,19 +167,20 @@ public class OffBedAlarm implements IAlarm {
log.info("handleCrossDay 第一次离床时间,{}+持续时间:{}将超过范围,{}", firstTime, duration, endTime);
return;
}
platAlarmCheckDTO.setAbnormalValue(String.valueOf(System.currentTimeMillis() - firstOffBedLong));
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
platAlarmCheckDTO.setPlatAlarmConfig(config);
log.info("cross离床告警离床时间在范围时间内,配置:{}", config.getRuleConfig());
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
return;
}
LocalDateTime now = LocalDateTime.now();
// LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now().plusHours(7).plusMinutes(20);;
LocalDateTime startLocalDteTime = LocalDateTime.of(LocalDate.now(), startTime);
if (!isInTime) {
long mills = Duration.between(startLocalDteTime, now).toMillis() / 1000;
boolean noInOverTime = mills >= duration * 60;
if (noInOverTime) {
platAlarmCheckDTO.setAbnormalValue(String.valueOf(System.currentTimeMillis() - firstOffBedLong));
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
platAlarmCheckDTO.setPlatAlarmConfig(config);
log.info("cross离床告警第一次离床时间在范围前,配置:{}", config.getRuleConfig());
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
......@@ -189,6 +194,11 @@ public class OffBedAlarm implements IAlarm {
}
public static void main(String[] args) {
LocalDateTime now = LocalDateTime.now().plusHours(7).plusMinutes(20);
System.out.println(now);
}
private void handleUnCrossDay(AlarmRedisDTO alarmRedisDTO, PlatAlarmConfigOffBedDTOVO ruleConfig,
PlatAlarmCheckDTO platAlarmCheckDTO,
PlatAlarmConfig config,
......@@ -201,7 +211,10 @@ public class OffBedAlarm implements IAlarm {
LocalDateTime endLocalDteTime = LocalDateTime.of(LocalDate.now(), endTime);
Long firstOffBedLong = alarmRedisDTO.getStartLong();
boolean isOverTime = (System.currentTimeMillis() - firstOffBedLong) / 1000 >= duration * 60;
long currentTimeMillis = System.currentTimeMillis();
LocalDateTime nowTest = LocalDateTime.now().plusHours(7).plusMinutes(20);
currentTimeMillis = nowTest.toInstant(ZoneOffset.of("+8")).toEpochMilli();
boolean isOverTime = (currentTimeMillis - firstOffBedLong) / 1000 >= duration * 60;
LocalDateTime firstOffBedTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(firstOffBedLong), ZoneOffset.of("+8"));
LocalTime firstTime = firstOffBedTime.toLocalTime();
......@@ -219,19 +232,19 @@ public class OffBedAlarm implements IAlarm {
log.info("handleUnCrossDay第一次离床时间,{}+持续时间:{}将超过范围,{}", firstTime, duration, endTime);
return;
}
platAlarmCheckDTO.setAbnormalValue(String.valueOf(System.currentTimeMillis() - firstOffBedLong));
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
platAlarmCheckDTO.setPlatAlarmConfig(config);
log.info("uncross离床告警离床时间在范围时间内,配置:{}", config.getRuleConfig());
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
return;
}
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = LocalDateTime.now().plusHours(7).plusMinutes(20);
if (!isInTime && now.isAfter(startLocalDteTime) && now.isBefore(endLocalDteTime)) {
long mills = Duration.between(startLocalDteTime, now).toMillis() / 1000;
boolean noInOverTime = mills >= duration * 60;
if (noInOverTime) {
platAlarmCheckDTO.setAbnormalValue(String.valueOf(System.currentTimeMillis() - firstOffBedLong));
platAlarmCheckDTO.setAbnormalValue(String.valueOf(currentTimeMillis - firstOffBedLong));
platAlarmCheckDTO.setPlatAlarmConfig(config);
log.info("uncross离床告警第一次离床时间在范围前,配置:{}", config.getRuleConfig());
noticeAlarm(alarmRedisDTO, platAlarmCheckDTO, deviceId);
......
......@@ -121,7 +121,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
LambdaQueryWrapper<PlatAlarmRecord> lambdaQueryWrapper = getLambdaQueryWrapper(param);
List<PlatAlarmRecord> list = list(lambdaQueryWrapper);
Boolean isUnWechatRead = CollUtil.isNotEmpty(list) && list.stream()
.anyMatch(a -> CommonEnum.YES.getValue().equals(a.getWechatReadFlag()));
.anyMatch(a -> CommonEnum.NO.getValue().equals(a.getWechatReadFlag()));
Boolean statusFlag = CollUtil.isNotEmpty(list) && list.stream()
.anyMatch(a -> CommonEnum.NO.getValue().equals(a.getStatus()));
Page<PlatAlarmRecord> page = page(mpPage, lambdaQueryWrapper);
List<PlatAlarmRecord> records = page.getRecords();
List<PlatAlarmRecordVO> dtos = BeanDtoVoUtils.listVo(records, PlatAlarmRecordVO.class);
......@@ -136,6 +138,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
platAlarmRecordVO.setDevice(platDevice);
}
platAlarmRecordVO.setIsUnWechatRead(isUnWechatRead);
platAlarmRecordVO.setStatusFlag(statusFlag);
}
return PageUtil.toPageVO(dtos, page);
}
......
......@@ -607,6 +607,10 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
if(CollectionUtils.isEmpty(list)){
return new ArrayList<>();
}
list = list.stream().map(org -> {
org.setGrade(org.getPath().split(",").length);
return org;
}).collect(Collectors.toList());
return createOrgTree(list);
}
......
......@@ -35,6 +35,7 @@ import com.makeit.utils.user.plat.PlatUserVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -147,6 +148,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if (parentSpace!=null && parentSpace.getParentPath()!=null && parentSpace.getParentPath().contains(dto.getId())) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_NOT_AUTH_PARENT);
}
// 编辑后层级大于4,不允许编辑
checkMaxLevel(space);
this.updateById(space);
List<String> lastSpaceIds = recursionLastSpaceIds(space.getId(), new ArrayList<>());
......@@ -169,11 +172,6 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
log.info("房间id:{},对应的空间id:{},parentId:{}", platRoom.getId(), join, dto.getParentPath());
String roomSpacePath = dto.getParentPath() + "," + join;
log.info("roomSpacePath" + roomSpacePath);
// if (lastSpaceIds.get(0).equals(space.getId())) {
// roomSpacePath = dto.getParentPath() + "," + String.join(",", lastSpaceIds);
// } else {
// roomSpacePath = dto.getParentPath() + "," + space.getId() + "," + String.join(",", lastSpaceIds);
// }
platRoom.setSpacePath(roomSpacePath);
platRoomService.updateById(platRoom);
}
......@@ -220,6 +218,44 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return result;
}
private void checkMaxLevel(PlatSpace space) {
int level = StrUtil.isBlank(space.getParentPath()) ? 0 : space.getParentPath().split(",").length;
if (level > 3) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_OVER_LEVEL);
}
String spaceId = space.getId();
List<PlatSpace> platSpaceList = list(Wrappers.<PlatSpace>lambdaQuery()
.apply(StringUtils.isNotBlank(spaceId), "find_in_set('" + spaceId + "',parent_path)"));
int sonLevel = 0;
if (CollUtil.isNotEmpty(platSpaceList)) {
final int[] maxLength = {1};
platSpaceList.forEach(s -> {
if (StrUtil.isBlank(s.getParentPath())) {
return;
}
String[] parentSpaceIds = s.getParentPath().split(",");
if (parentSpaceIds.length > maxLength[0]) {
maxLength[0] = parentSpaceIds.length;
}
});
sonLevel = maxLength[0];
}
if (level + sonLevel > 3) {
throw new BusinessException(CodeMessageEnum.PLATFORM_ERROR_SPACE_OVER_LEVEL);
}
}
private List<String> recursionSpaceId(List<String> result, String spaceId) {
List<PlatSpace> platSpaces = this.list(Wrappers.<PlatSpace>lambdaQuery().eq(PlatSpace::getParentId, spaceId));
if (CollUtil.isNotEmpty(platSpaces)) {
platSpaces.forEach(p -> recursionLastSpaceIds(p.getId(), result));
} else {
result.add(spaceId);
return result;
}
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void del(String id) {
......
......@@ -74,4 +74,6 @@ public class PlatAlarmRecordVO extends BaseTenantDTO {
@ApiModelProperty(value = "是否存在未读")
private Boolean isUnWechatRead;
@ApiModelProperty(value = "是否存在未处理")
private Boolean statusFlag;
}
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