Commit ab4479ac by lzy

Merge branch 'dev' of git.xmmakeit.com:huangjiay/iot-platform-server into dev

parents 79b4ed18 c8987595
Showing with 825 additions and 41 deletions
...@@ -19,7 +19,7 @@ public class PlatUserUtil { ...@@ -19,7 +19,7 @@ public class PlatUserUtil {
public static boolean isSuper() { public static boolean isSuper() {
PlatUserVO userVO = PlatUserUtil.getUserVO(); PlatUserVO userVO = PlatUserUtil.getUserVO();
return IsFactoryAccountEnum.YES.getValue().equals(userVO.getTenantId()) return IsFactoryAccountEnum.YES.getValue().equals(userVO.getIsTenant())
|| IdConst.SUPER_ADMIN_ID.equals(userVO.getId()); || IdConst.SUPER_ADMIN_ID.equals(userVO.getId());
} }
......
package com.makeit.module.controller.space;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.service.platform.space.PlatRoomDynamicService;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomPanoramaVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Api(tags = "房态管理")
@RestController
@RequestMapping("/plat/room/dynamic")
public class PlatRoomDynamicController {
@Autowired
private PlatRoomDynamicService platRoomDynamicService;
@ApiOperation("房间全景")
@PostMapping("roomPanorama")
public ApiResponseEntity<List<PlatRoomPanoramaVO>> roomPanorama(@RequestBody PlatRoomPanoramaDTO dto) {
List<PlatRoomPanoramaVO> data = platRoomDynamicService.roomPanorama(dto);
return ApiResponseUtils.success(data);
}
@ApiOperation("床位全景")
@PostMapping("bedPanorama")
public ApiResponseEntity<List<PlatBedPanoramaVO>> bedPanorama(@RequestBody PlatBedPanoramaDTO dto) {
List<PlatBedPanoramaVO> data = platRoomDynamicService.bedPanorama(dto);
return ApiResponseUtils.success(data);
}
@ApiOperation("房间全景-下拉空间树")
@PostMapping("roomPanoramaTree")
public ApiResponseEntity<List<PlatSpaceAndRoomVO>> roomPanoramaTree() {
List<PlatSpaceAndRoomVO> data = platRoomDynamicService.roomPanoramaTree();
return ApiResponseUtils.success(data);
}
@ApiOperation("床位全景-下拉空间树")
@PostMapping("bedPanoramaTree")
public ApiResponseEntity<List<PlatSpaceAndRoomVO>> bedPanoramaTree() {
List<PlatSpaceAndRoomVO> data = platRoomDynamicService.bedPanoramaTree();
return ApiResponseUtils.success(data);
}
}
package com.makeit.dto.platform.space;
import com.makeit.enums.platform.space.PlatBedStatusEnum;
import com.makeit.enums.platform.space.PlatSpaceEnum;
import com.makeit.global.validator.DictEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Data
@ApiModel("PlatBedPanoramaDTO参数")
public class PlatBedPanoramaDTO {
@ApiModelProperty("空间/房间id")
private String id;
@ApiModelProperty("类型 1-空间 2-房间")
private String type;
@DictEnum(em = PlatBedStatusEnum.BedStatusEnum.class, message = "状态可选值为{m}")
@ApiModelProperty("状态 1-空闲 2-已入住")
private String status;
}
package com.makeit.dto.platform.space;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Data
@ApiModel("PlatRoomPanoramaDTO参数")
public class PlatRoomPanoramaDTO {
@ApiModelProperty("空间id")
private String id;
}
package com.makeit.enums.platform.space;
import com.makeit.enums.BaseEnum;
import com.makeit.utils.sys.SysDictUtil;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
public class PlatBedPanoramaSpaceType {
public enum BedPanoramaSpaceType implements BaseEnum {
SPACE("bedPanorama.space.type.space"),
ROOM("bedPanorama.space.type.room");
private String code;
BedPanoramaSpaceType(String code) {
this.code = code;
}
@Override
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
package com.makeit.enums.platform.space;
import com.makeit.enums.BaseEnum;
import com.makeit.utils.sys.SysDictUtil;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
public class PlatBedStatusEnum {
public enum BedStatusEnum implements BaseEnum {
//SPARE 空闲
//NOT_FULL 未住满
//FULL 已住满
SPARE("room.status.spare"),
CHECKED_IN("bed.status.CheckedIn");
private String code;
BedStatusEnum(String code) {
this.code = code;
}
@Override
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
package com.makeit.enums.platform.space;
import com.makeit.enums.BaseEnum;
import com.makeit.utils.sys.SysDictUtil;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
public class PlatRoomStatusEnum {
public enum RoomStatusEnum implements BaseEnum {
//SPARE 空闲
//NOT_FULL 未住满
//FULL 已住满
SPARE("room.status.spare"),
NOT_FULL("room.status.notFull"),
FULL("room.status.full");
private String code;
RoomStatusEnum(String code) {
this.code = code;
}
@Override
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
package com.makeit.mapper.platform.space; package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.entity.platform.space.PlatBed; import com.makeit.entity.platform.space.PlatBed;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @Author:lzy * @Author:lzy
...@@ -9,4 +14,7 @@ import com.makeit.entity.platform.space.PlatBed; ...@@ -9,4 +14,7 @@ import com.makeit.entity.platform.space.PlatBed;
* @Describe: * @Describe:
*/ */
public interface PlatBedMapper extends BaseMapper<PlatBed> { public interface PlatBedMapper extends BaseMapper<PlatBed> {
List<PlatBedPanoramaVO> selectBySpaceIdAndStatus(@Param("dto") PlatBedPanoramaDTO dto);
List<PlatBedPanoramaVO> selectByRoomIdAndStatus(@Param("dto")PlatBedPanoramaDTO dto);
} }
package com.makeit.mapper.platform.space; package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.entity.platform.space.PlatRoom; import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.vo.platform.space.PlatRoomVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @Author:lzy * @Author:lzy
...@@ -9,4 +15,5 @@ import com.makeit.entity.platform.space.PlatRoom; ...@@ -9,4 +15,5 @@ import com.makeit.entity.platform.space.PlatRoom;
* @Describe: * @Describe:
*/ */
public interface PlatRoomMapper extends BaseMapper<PlatRoom> { public interface PlatRoomMapper extends BaseMapper<PlatRoom> {
List<PlatSpaceAndRoomVO> spaceAndRoomList();
} }
package com.makeit.mapper.platform.space; package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.entity.platform.space.PlatSpace; import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import java.util.List;
/** /**
* @Author:lzy * @Author:lzy
...@@ -9,4 +13,6 @@ import com.makeit.entity.platform.space.PlatSpace; ...@@ -9,4 +13,6 @@ import com.makeit.entity.platform.space.PlatSpace;
* @Describe: * @Describe:
*/ */
public interface PlatSpaceMapper extends BaseMapper<PlatSpace> { public interface PlatSpaceMapper extends BaseMapper<PlatSpace> {
List<PlatSpaceAndRoomVO> spaceListExcludeLast();
} }
...@@ -5,6 +5,7 @@ import com.makeit.common.dto.StatusDTO; ...@@ -5,6 +5,7 @@ import com.makeit.common.dto.StatusDTO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigDTOVO; import com.makeit.dto.platform.alarm.PlatAlarmConfigDTOVO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigQueryDTO; import com.makeit.dto.platform.alarm.PlatAlarmConfigQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig; import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.vo.platform.alarm.PlatAlarmConfigListVO; import com.makeit.vo.platform.alarm.PlatAlarmConfigListVO;
import java.util.List; import java.util.List;
...@@ -35,4 +36,6 @@ public interface PlatAlarmConfigService extends IService<PlatAlarmConfig> { ...@@ -35,4 +36,6 @@ public interface PlatAlarmConfigService extends IService<PlatAlarmConfig> {
void audit(StatusDTO dto); void audit(StatusDTO dto);
void copyForOrg(PlatOrg org);
} }
...@@ -9,18 +9,16 @@ import com.makeit.entity.platform.alarm.PlatAlarmRecord; ...@@ -9,18 +9,16 @@ import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO; import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
/** /**
* @author lixl * @author lixl
* @description 针对表【plat_alarm_record(告警记录)】的数据库操作Service * @description 针对表【plat_alarm_record(告警记录)】的数据库操作Service
* @createDate 2023-09-06 14:26:05 * @createDate 2023-09-06 14:26:05
*/ */
public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> { public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
PageVO<PlatAlarmRecordVO> page(PageReqDTO<PlatAlarmRecordQueryDTO> dto); PageVO<PlatAlarmRecordVO> page(PageReqDTO<PlatAlarmRecordQueryDTO> dto);
/** /**
* 子女端告警列表 * 子女端告警列表
* @param dto
* @return
*/ */
PageVO<PlatAlarmRecordVO> childrenPage(PageReqDTO<PlatAlarmRecordQueryDTO> dto); PageVO<PlatAlarmRecordVO> childrenPage(PageReqDTO<PlatAlarmRecordQueryDTO> dto);
...@@ -28,11 +26,30 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> { ...@@ -28,11 +26,30 @@ public interface PlatAlarmRecordService extends IService<PlatAlarmRecord> {
void deal(String recordId); void deal(String recordId);
/**
* 通知家属
* @param recordId
*/
void noticeRelation(String recordId); void noticeRelation(String recordId);
/**
* 通知家属
* 子女端小程序
* 短信
* 语音短信
*/
void noticeChildren(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord); void noticeChildren(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord);
void noticeUser(PlatAlarmConfig alarmConfig,PlatAlarmRecord alarmRecord); /**
* 通知工作人员
* 短信
* 语音短信
* 邮件
*/
void noticeUser(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord);
void noticeDeviceAlarm(PlatAlarmConfig alarmConfig,PlatAlarmRecord alarmRecord); /**
* 设备告警调用 发送消息
*/
void noticeDeviceAlarm(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord);
} }
...@@ -6,17 +6,25 @@ import com.makeit.common.dto.StatusDTO; ...@@ -6,17 +6,25 @@ import com.makeit.common.dto.StatusDTO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigDTOVO; import com.makeit.dto.platform.alarm.PlatAlarmConfigDTOVO;
import com.makeit.dto.platform.alarm.PlatAlarmConfigQueryDTO; import com.makeit.dto.platform.alarm.PlatAlarmConfigQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig; import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatUser; import com.makeit.entity.platform.auth.PlatUser;
import com.makeit.enums.CodeMessageEnum; import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.enums.id.IdConst;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.mapper.platform.alarm.PlatAlarmConfigMapper; import com.makeit.mapper.platform.alarm.PlatAlarmConfigMapper;
import com.makeit.module.admin.dto.plat.PlatTenantDTOVO;
import com.makeit.module.system.entity.SysConfig;
import com.makeit.module.system.entity.SysConfigCategory;
import com.makeit.service.platform.alarm.PlatAlarmConfigService; import com.makeit.service.platform.alarm.PlatAlarmConfigService;
import com.makeit.service.platform.auth.PlatUserService; import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.StreamUtil; import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.data.validate.MapUtil;
import com.makeit.utils.old.StringUtils; import com.makeit.utils.old.StringUtils;
import com.makeit.utils.sql.join.JoinUtil; import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.utils.user.plat.PlatUserVO;
import com.makeit.vo.platform.alarm.PlatAlarmConfigListVO; import com.makeit.vo.platform.alarm.PlatAlarmConfigListVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -24,6 +32,8 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -24,6 +32,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
/** /**
* <p> * <p>
...@@ -86,7 +96,7 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe ...@@ -86,7 +96,7 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe
@Override @Override
@Transactional @Transactional
public void edit(PlatAlarmConfigDTOVO dto) { public void edit(PlatAlarmConfigDTOVO dto) {
updateById(BeanDtoVoUtils.convert(dto,PlatAlarmConfig.class)); updateById(BeanDtoVoUtils.convert(dto, PlatAlarmConfig.class));
} }
@Override @Override
...@@ -154,5 +164,35 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe ...@@ -154,5 +164,35 @@ public class PlatAlarmConfigServiceImpl extends ServiceImpl<PlatAlarmConfigMappe
updateById(alarmConfig); updateById(alarmConfig);
} }
@Transactional
@Override
public void copyForOrg(PlatOrg org) {
List<PlatAlarmConfig> configList = TenantIdUtil.execute(IdConst.DEFAULT_TENANT_ID, () -> list());
List<BiConsumer<PlatAlarmConfig, String>> list = Arrays.asList(
PlatAlarmConfig::setCityOrgId,
PlatAlarmConfig::setDistrictOrgId,
PlatAlarmConfig::setStreetOrgId
);
String orgPath = org.getPath() + "," + org.getId();
String[] split = orgPath.split(",");
configList.forEach(e -> {
e.setId(null);
for (int i = 1; i < split.length; i++) {
BiConsumer<PlatAlarmConfig, String> consumer = list.get(i - 1);
consumer.accept(e, split[i]);
}
e.setOrgId(org.getId());
e.setOrgPath(orgPath);
});
saveBatch(configList);
}
} }
...@@ -3,6 +3,7 @@ package com.makeit.service.platform.alarm.impl; ...@@ -3,6 +3,7 @@ package com.makeit.service.platform.alarm.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity; import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO; import com.makeit.common.page.PageVO;
...@@ -17,6 +18,7 @@ import com.makeit.global.aspect.tenant.TenantIdIgnore; ...@@ -17,6 +18,7 @@ import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper; import com.makeit.mapper.platform.alarm.PlatAlarmRecordMapper;
import com.makeit.service.platform.alarm.PlatAlarmConfigService; import com.makeit.service.platform.alarm.PlatAlarmConfigService;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.auth.PlatUserService;
import com.makeit.service.platform.elder.PlatElderChildrenInfoService; import com.makeit.service.platform.elder.PlatElderChildrenInfoService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil; import com.makeit.utils.data.convert.PageUtil;
...@@ -58,6 +60,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -58,6 +60,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
private PlatElderChildrenInfoService platElderChildrenInfoService; private PlatElderChildrenInfoService platElderChildrenInfoService;
@Autowired @Autowired
private PlatUserService platUserService;
@Autowired
private MsgSendUtil msgUtil; private MsgSendUtil msgUtil;
@Override @Override
...@@ -69,9 +74,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -69,9 +74,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
List<PlatAlarmRecord> records = page.getRecords(); List<PlatAlarmRecord> records = page.getRecords();
List<PlatAlarmRecordVO> dtos = BeanDtoVoUtils.listVo(records, PlatAlarmRecordVO.class); List<PlatAlarmRecordVO> dtos = BeanDtoVoUtils.listVo(records, PlatAlarmRecordVO.class);
JoinUtil.join(dtos, platAlarmConfigService, PlatAlarmRecordVO::getAlarmId, BaseEntity::getId, (t, m) -> { JoinUtil.join(dtos, platAlarmConfigService, PlatAlarmRecordVO::getAlarmId, BaseEntity::getId, (t, m) -> t.setNotifyRelation(m.getNotifyRelation()));
t.setNotifyRelation(m.getNotifyRelation());
});
return PageUtil.toPageVO(dtos, page); return PageUtil.toPageVO(dtos, page);
} }
...@@ -119,9 +122,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -119,9 +122,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
public PlatAlarmRecordVO view(String recordId) { public PlatAlarmRecordVO view(String recordId) {
PlatAlarmRecord platAlarmRecord = getById(recordId); PlatAlarmRecord platAlarmRecord = getById(recordId);
PlatAlarmRecordVO vo = BeanDtoVoUtils.convert(platAlarmRecord, PlatAlarmRecordVO.class); PlatAlarmRecordVO vo = BeanDtoVoUtils.convert(platAlarmRecord, PlatAlarmRecordVO.class);
JoinUtil.join(Arrays.asList(vo), platAlarmConfigService, PlatAlarmRecordVO::getAlarmId, BaseEntity::getId, (t, m) -> { JoinUtil.join(Arrays.asList(vo), platAlarmConfigService, PlatAlarmRecordVO::getAlarmId, BaseEntity::getId, (t, m) -> t.setNotifyRelation(m.getNotifyRelation()));
t.setNotifyRelation(m.getNotifyRelation());
});
return vo; return vo;
} }
...@@ -136,6 +137,10 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -136,6 +137,10 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
updateById(platAlarmRecord); updateById(platAlarmRecord);
} }
/**
* 通知家属
* @param recordId
*/
@Override @Override
@Transactional @Transactional
public void noticeRelation(String recordId) { public void noticeRelation(String recordId) {
...@@ -145,15 +150,22 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -145,15 +150,22 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
if (StringUtils.isBlank(elderIds)) { if (StringUtils.isBlank(elderIds)) {
throw new BusinessException("设备没绑定长者"); throw new BusinessException("设备没绑定长者");
} }
noticeChildren(platAlarmConfig,platAlarmRecord); noticeChildren(platAlarmConfig, platAlarmRecord);
} }
/** /**
* 发送消息 * 设备告警调用 发送消息
*/ */
@Transactional @Transactional
@Override @Override
public void noticeDeviceAlarm(PlatAlarmConfig alarmConfig,PlatAlarmRecord alarmRecord){ @TenantIdIgnore
public void noticeDeviceAlarm(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord) {
//判断是否需要同时通知家属
if (StringUtils.equals(alarmConfig.getNotifyRelation(), "1")) {
noticeChildren(alarmConfig, alarmRecord);
}
//通知内部人员
noticeUser(alarmConfig, alarmRecord);
} }
...@@ -162,12 +174,13 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -162,12 +174,13 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
* 子女端小程序 * 子女端小程序
* 短信 * 短信
* 语音短信 * 语音短信
*
* @param alarmConfig * @param alarmConfig
* @param alarmRecord * @param alarmRecord
*/ */
@Transactional @Transactional
@TenantIdIgnore @TenantIdIgnore
public void noticeChildren(PlatAlarmConfig alarmConfig,PlatAlarmRecord alarmRecord){ public void noticeChildren(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord) {
String elderIds = alarmRecord.getElderIds(); String elderIds = alarmRecord.getElderIds();
List<PlatElderChildrenInfo> allChildInfoList = new ArrayList<>(); List<PlatElderChildrenInfo> allChildInfoList = new ArrayList<>();
...@@ -175,9 +188,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -175,9 +188,8 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
//通知每个长者的子女 //通知每个长者的子女
for (String elderId : elderIdSplit) { for (String elderId : elderIdSplit) {
LambdaQueryWrapper<PlatElderChildrenInfo> childrenInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatElderChildrenInfo> childrenInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
childrenInfoLambdaQueryWrapper.and(qw -> { childrenInfoLambdaQueryWrapper.eq(BaseBusEntity::getTenantId, alarmConfig.getTenantId());
qw.apply("find_in_set('" + elderId + "',elder_id)"); childrenInfoLambdaQueryWrapper.and(qw -> qw.apply("find_in_set('" + elderId + "',elder_id)"));
});
List<PlatElderChildrenInfo> childrenInfoList = platElderChildrenInfoService.list(childrenInfoLambdaQueryWrapper); List<PlatElderChildrenInfo> childrenInfoList = platElderChildrenInfoService.list(childrenInfoLambdaQueryWrapper);
if (CollectionUtils.isEmpty(childrenInfoList)) { if (CollectionUtils.isEmpty(childrenInfoList)) {
log.debug("子女端账号未绑定长者"); log.debug("子女端账号未绑定长者");
...@@ -185,23 +197,11 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -185,23 +197,11 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
} }
allChildInfoList.addAll(childrenInfoList); allChildInfoList.addAll(childrenInfoList);
Set<String> phoneSet = childrenInfoList.stream().map(PlatElderChildrenInfo::getPhone).collect(Collectors.toSet()); Set<String> phoneSet = childrenInfoList.stream().map(PlatElderChildrenInfo::getPhone).collect(Collectors.toSet());
String notifyChannel = alarmConfig.getNotifyChannel();
String[] split = notifyChannel.split(",");
//告警配置和租户告警 字典一致 //告警配置和租户告警 字典一致
List<SendTypeEnum> notifyChannelList = Arrays.asList(SendTypeEnum.SMS, SendTypeEnum.VOICE_SMS, SendTypeEnum.CHILD_WECHAT); List<SendTypeEnum> notifyChannelList = Arrays.asList(SendTypeEnum.SMS, SendTypeEnum.VOICE_SMS, SendTypeEnum.CHILD_WECHAT);
for (String sendType : split) {
SendTypeEnum sendTypeEnum = SendTypeEnum.getByValue(sendType); //发送消息
boolean contains = notifyChannelList.contains(sendTypeEnum); noticeByChannel(alarmConfig, alarmRecord, phoneSet, notifyChannelList);
if (contains) {
MsgSendDTO msgSendDTO = new MsgSendDTO();
msgSendDTO.setSendTypeEnum(sendTypeEnum);
msgSendDTO.setReceiverList(phoneSet);
msgSendDTO.setOriContent(alarmRecord.getContent());
//todo 小程序消息
msgUtil.send(msgSendDTO);
}
}
} }
String childIdJoin = allChildInfoList.stream().map(BaseEntity::getId).collect(Collectors.joining(",")); String childIdJoin = allChildInfoList.stream().map(BaseEntity::getId).collect(Collectors.joining(","));
//通知的子女 //通知的子女
...@@ -216,18 +216,63 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe ...@@ -216,18 +216,63 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
* 短信 * 短信
* 语音短信 * 语音短信
* 邮件 * 邮件
*
* @param alarmConfig * @param alarmConfig
* @param alarmRecord * @param alarmRecord
*/ */
@Transactional @Transactional
@Override @Override
@TenantIdIgnore @TenantIdIgnore
public void noticeUser(PlatAlarmConfig alarmConfig,PlatAlarmRecord alarmRecord){ public void noticeUser(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord) {
String notifyWay = alarmConfig.getNotifyWay(); String notifyWay = alarmConfig.getNotifyWay();
List<PlatUser> platUserList = new ArrayList<>(); List<PlatUser> platUserList = new ArrayList<>();
if(StringUtils.equals(notifyWay,"1")){ if (StringUtils.equals(notifyWay, "1")) {
}else { LambdaQueryWrapper<PlatUser> platUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
platUserLambdaQueryWrapper.eq(PlatUser::getTenantId, alarmConfig.getTenantId())
.eq(PlatUser::getOrgId, alarmConfig.getOrgId());
List<PlatUser> platUsers = platUserService.list(platUserLambdaQueryWrapper);
platUserList.addAll(platUsers);
} else {
String notifyUser = alarmConfig.getNotifyUser();
String[] userArray = notifyUser.split(",");
List<PlatUser> platUsers = platUserService.listByIds(Arrays.asList(userArray));
platUserList.addAll(platUsers);
}
platUserList.removeIf(Objects::isNull);
if (CollectionUtils.isEmpty(platUserList)) {
log.debug("通知工作人员时,找不到人员数据;" + "orgId:" + alarmConfig.getOrgId() + ",tenantId:" + alarmConfig.getTenantId() + "alarmConfigId:" + alarmConfig.getId());
return;
}
List<SendTypeEnum> notifyChannelList = Arrays.asList(SendTypeEnum.SMS, SendTypeEnum.VOICE_SMS, SendTypeEnum.MAIL);
Set<String> phoneSet = platUserList.stream().map(PlatUser::getMobile).collect(Collectors.toSet());
//发送消息
noticeByChannel(alarmConfig, alarmRecord, phoneSet, notifyChannelList);
}
/**
* 根据配置渠道发送消息
*
* @param alarmConfig
* @param alarmRecord
* @param phoneSet 工作人员手机号
* @param notifyChannelList 通知渠道
*/
private void noticeByChannel(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord, Set<String> phoneSet, List<SendTypeEnum> notifyChannelList) {
String notifyChannel = alarmConfig.getNotifyChannel();
String[] split = notifyChannel.split(",");
for (String sendType : split) {
SendTypeEnum sendTypeEnum = SendTypeEnum.getByValue(sendType);
boolean contains = notifyChannelList.contains(sendTypeEnum);
if (contains) {
MsgSendDTO msgSendDTO = new MsgSendDTO();
msgSendDTO.setSendTypeEnum(sendTypeEnum);
msgSendDTO.setReceiverList(phoneSet);
msgSendDTO.setOriContent(alarmRecord.getContent());
//todo 小程序消息
msgUtil.send(msgSendDTO);
}
} }
} }
} }
...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.entity.BaseEntity; import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO; import com.makeit.common.page.PageVO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole; import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleOrg; import com.makeit.entity.platform.auth.PlatRoleOrg;
...@@ -17,6 +18,7 @@ import com.makeit.enums.CommonEnum; ...@@ -17,6 +18,7 @@ import com.makeit.enums.CommonEnum;
import com.makeit.enums.id.TreeConst; import com.makeit.enums.id.TreeConst;
import com.makeit.global.aspect.tenant.TenantIdUtil; import com.makeit.global.aspect.tenant.TenantIdUtil;
import com.makeit.mapper.platform.auth.PlatOrgMapper; import com.makeit.mapper.platform.auth.PlatOrgMapper;
import com.makeit.service.platform.alarm.PlatAlarmConfigService;
import com.makeit.service.platform.auth.PlatOrgService; import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.auth.PlatRoleOrgService; import com.makeit.service.platform.auth.PlatRoleOrgService;
import com.makeit.service.platform.auth.PlatRoleService; import com.makeit.service.platform.auth.PlatRoleService;
...@@ -65,6 +67,9 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -65,6 +67,9 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
@Autowired @Autowired
private PlatRoleService platRoleService; private PlatRoleService platRoleService;
@Autowired
private PlatAlarmConfigService platAlarmConfigService;
@Override @Override
public List<PlatOrg> filter(List<PlatOrg> deptList, PlatOrgQueryDTO dto) { public List<PlatOrg> filter(List<PlatOrg> deptList, PlatOrgQueryDTO dto) {
return new HashSet<>(deptList).stream() return new HashSet<>(deptList).stream()
...@@ -521,5 +526,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -521,5 +526,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public void saveOrg(PlatOrg platOrg) { public void saveOrg(PlatOrg platOrg) {
save(platOrg); save(platOrg);
platAlarmConfigService.copyForOrg(platOrg);
} }
} }
...@@ -8,6 +8,7 @@ import com.makeit.dto.platform.device.PlatDeviceDTO; ...@@ -8,6 +8,7 @@ import com.makeit.dto.platform.device.PlatDeviceDTO;
import com.makeit.dto.platform.space.*; import com.makeit.dto.platform.space.*;
import com.makeit.entity.platform.space.PlatBed; import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom; import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import java.util.List; import java.util.List;
...@@ -53,4 +54,7 @@ public interface PlatBedService extends IService<PlatBed> { ...@@ -53,4 +54,7 @@ public interface PlatBedService extends IService<PlatBed> {
void changeStatus(StatusDTO dto); void changeStatus(StatusDTO dto);
List<PlatBedPanoramaVO> selectBySpaceIdAndStatus(PlatBedPanoramaDTO dto);
List<PlatBedPanoramaVO> selectByRoomIdAndStatus(PlatBedPanoramaDTO dto);
} }
package com.makeit.service.platform.space;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomPanoramaVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
public interface PlatRoomDynamicService {
List<PlatRoomPanoramaVO> roomPanorama(PlatRoomPanoramaDTO dto);
List<PlatBedPanoramaVO> bedPanorama(PlatBedPanoramaDTO dto);
List<PlatSpaceAndRoomVO> roomPanoramaTree();
List<PlatSpaceAndRoomVO> bedPanoramaTree();
}
...@@ -6,7 +6,9 @@ import com.makeit.common.page.PageVO; ...@@ -6,7 +6,9 @@ import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.elder.PlatElderQueryDTO; import com.makeit.dto.platform.elder.PlatElderQueryDTO;
import com.makeit.dto.platform.space.PlatRoomDTO; import com.makeit.dto.platform.space.PlatRoomDTO;
import com.makeit.dto.platform.space.PlatRoomQueryDTO; import com.makeit.dto.platform.space.PlatRoomQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.entity.platform.space.PlatRoom; import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import java.util.List; import java.util.List;
...@@ -57,4 +59,6 @@ public interface PlatRoomService extends IService<PlatRoom> { ...@@ -57,4 +59,6 @@ public interface PlatRoomService extends IService<PlatRoom> {
* @return * @return
*/ */
PageVO<PlatRoom> page(PageReqDTO<PlatRoomQueryDTO> page); PageVO<PlatRoom> page(PageReqDTO<PlatRoomQueryDTO> page);
List<PlatSpaceAndRoomVO> spaceAndRoomList();
} }
...@@ -5,6 +5,7 @@ import com.makeit.dto.platform.space.PlatSpaceAddDTO; ...@@ -5,6 +5,7 @@ import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO; import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
import com.makeit.dto.platform.space.PlatSpaceVO; import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.entity.platform.space.PlatSpace; import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import java.util.List; import java.util.List;
...@@ -46,4 +47,6 @@ public interface PlatSpaceService extends IService<PlatSpace> { ...@@ -46,4 +47,6 @@ public interface PlatSpaceService extends IService<PlatSpace> {
* @return * @return
*/ */
PlatSpaceAddDTO view(String id); PlatSpaceAddDTO view(String id);
List<PlatSpaceAndRoomVO> spaceListExcludeLast();
} }
...@@ -22,6 +22,7 @@ import com.makeit.service.platform.space.PlatBedService; ...@@ -22,6 +22,7 @@ import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService; import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil; import com.makeit.utils.data.convert.PageUtil;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import jodd.util.StringUtil; import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -146,5 +147,15 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl ...@@ -146,5 +147,15 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
updateById(bed); updateById(bed);
} }
@Override
public List<PlatBedPanoramaVO> selectBySpaceIdAndStatus(PlatBedPanoramaDTO dto) {
return baseMapper.selectBySpaceIdAndStatus(dto);
}
@Override
public List<PlatBedPanoramaVO> selectByRoomIdAndStatus(PlatBedPanoramaDTO dto) {
return baseMapper.selectByRoomIdAndStatus(dto);
}
} }
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.platform.space.PlatBedPanoramaSpaceType;
import com.makeit.enums.platform.space.PlatRoomStatusEnum;
import com.makeit.mapper.platform.space.PlatBedMapper;
import com.makeit.mapper.platform.space.PlatRoomMapper;
import com.makeit.mapper.platform.space.PlatSpaceMapper;
import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomDynamicService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Service
public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
@Autowired
private PlatSpaceService platSpaceService;
@Autowired
private PlatRoomService platRoomService;
@Autowired
private PlatBedService platBedService;
@Override
public List<PlatRoomPanoramaVO> roomPanorama(PlatRoomPanoramaDTO dto) {
List<PlatRoomPanoramaVO> list = new ArrayList<>();
//获取下级空间
List<PlatSpace> spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.eq(PlatSpace::getParentId,dto.getId()));
if(!spaces.isEmpty()){
List<String> spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList());
//空间下的房间
List<PlatRoom> rooms = platRoomService.list(new QueryWrapper<PlatRoom>().lambda()
.in(PlatRoom::getSpaceId,spaceIds));
List<String> roomIds = rooms.stream().map(PlatRoom::getId).collect(Collectors.toList());
List<PlatBed> beds = platBedService.list(new QueryWrapper<PlatBed>().lambda()
.in(PlatBed::getRoomId,roomIds));
Map<String,List<PlatBed>> bedMap = beds.stream().collect(Collectors.groupingBy(PlatBed::getRoomId));
for(PlatSpace space : spaces){
PlatRoomPanoramaVO platRoomPanoramaVO = new PlatRoomPanoramaVO();
platRoomPanoramaVO.setSpaceName(space.getName());
platRoomPanoramaVO.setSpaceId(dto.getId());
List<PlatRoomVO> roomVOList = new ArrayList<>();
for(PlatRoom room : rooms){
PlatRoomVO vo = convertToVO(room,bedMap);
roomVOList.add(vo);
}
platRoomPanoramaVO.setList(roomVOList);
list.add(platRoomPanoramaVO);
}
}
return list;
}
private PlatRoomVO convertToVO(PlatRoom room, Map<String, List<PlatBed>> bedMap) {
PlatRoomVO vo = new PlatRoomVO();
vo.setBedNumber(room.getBedNumber());
vo.setRoomName(room.getName());
vo.setRoomId(room.getId());
if(bedMap.get(room.getId())!=null){
vo.setUsedTotal(bedMap.get(room.getId()).size());
}else {
vo.setUsedTotal(0);
}
if(vo.getUsedTotal()==0){
vo.setRoomStatus(PlatRoomStatusEnum.RoomStatusEnum.SPARE.getValue());
}else if(vo.getUsedTotal() < vo.getBedNumber()){
vo.setRoomStatus(PlatRoomStatusEnum.RoomStatusEnum.NOT_FULL.getValue());
}else {
vo.setRoomStatus(PlatRoomStatusEnum.RoomStatusEnum.FULL.getValue());
}
return vo;
}
@Override
public List<PlatBedPanoramaVO> bedPanorama(PlatBedPanoramaDTO dto) {
List<PlatBedPanoramaVO> list = new ArrayList<>();
if(PlatBedPanoramaSpaceType.BedPanoramaSpaceType.SPACE.getValue().equals(dto.getType())){
list = platBedService.selectBySpaceIdAndStatus(dto);
}else if(PlatBedPanoramaSpaceType.BedPanoramaSpaceType.ROOM.getValue().equals(dto.getType())){
list = platBedService.selectByRoomIdAndStatus(dto);
}
List<PlatSpace> spaces = platSpaceService.list();
Map<String,String> spaceNameMap = spaces.stream().collect(Collectors.toMap(PlatSpace::getId,PlatSpace::getName));
list.forEach(vo->{
String spacePathName = "";
if(StringUtil.isNotEmpty(vo.getSpacePath())){
List<String> spaceIds = Arrays.asList(vo.getSpacePath().split(","));
for(String spaceId : spaceIds){
if(spaceNameMap.get(spaceId)!=null && StringUtil.isNotEmpty(spaceNameMap.get(spaceId))){
spacePathName = "".equals(spacePathName) ? spaceNameMap.get(spaceId) : spacePathName + "-" + spaceNameMap.get(spaceId);
}
}
}
if(StringUtil.isNotEmpty(vo.getRoomName())){
spacePathName = "".equals(spacePathName) ? vo.getRoomName() : spacePathName + "-" + vo.getRoomName();
}
if(StringUtil.isNotEmpty(vo.getBedName())){
spacePathName = "".equals(spacePathName) ? vo.getBedName() : spacePathName + "-" + vo.getBedName();
}
vo.setSpacePathName(spacePathName);
});
return list;
}
@Override
public List<PlatSpaceAndRoomVO> roomPanoramaTree() {
//获取房间前两级空间
List<PlatSpaceAndRoomVO> list = platSpaceService.spaceListExcludeLast();
//父级
List<PlatSpaceAndRoomVO> listParent = list.stream().filter(item-> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集
List<PlatSpaceAndRoomVO> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpaceAndRoomVO>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpaceAndRoomVO::getParentId));
List<PlatSpaceAndRoomVO> data = new ArrayList<>();
for(PlatSpaceAndRoomVO space:listParent){
space = child(space,map);
data.add(space);
}
return data;
}
@Override
public List<PlatSpaceAndRoomVO> bedPanoramaTree() {
//获取空间及房间
List<PlatSpaceAndRoomVO> list = platRoomService.spaceAndRoomList();
//父级
List<PlatSpaceAndRoomVO> listParent = list.stream().filter(item-> StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集
List<PlatSpaceAndRoomVO> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpaceAndRoomVO>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpaceAndRoomVO::getParentId));
List<PlatSpaceAndRoomVO> data = new ArrayList<>();
for(PlatSpaceAndRoomVO space:listParent){
space = child(space,map);
data.add(space);
}
return data;
}
private PlatSpaceAndRoomVO child(PlatSpaceAndRoomVO vo,Map<String,List<PlatSpaceAndRoomVO>> map){
if(!map.containsKey(vo.getId())){
return vo;
}
List<PlatSpaceAndRoomVO> list = map.get(vo.getId());
List<PlatSpaceAndRoomVO> listChild = new ArrayList<>();
for(PlatSpaceAndRoomVO item:list){
this.child(item,map);
listChild.add(item);
}
vo.setChild(listChild);
return vo;
}
}
...@@ -17,6 +17,7 @@ import com.makeit.service.platform.space.PlatBedService; ...@@ -17,6 +17,7 @@ import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomService; import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil; import com.makeit.utils.data.convert.PageUtil;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import jodd.util.StringUtil; import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -123,5 +124,10 @@ public class PlatRoomServiceImpl extends ServiceImpl<PlatRoomMapper, PlatRoom> i ...@@ -123,5 +124,10 @@ public class PlatRoomServiceImpl extends ServiceImpl<PlatRoomMapper, PlatRoom> i
return PageUtil.toPageVO(pages.getRecords(), pages); return PageUtil.toPageVO(pages.getRecords(), pages);
} }
@Override
public List<PlatSpaceAndRoomVO> spaceAndRoomList() {
return baseMapper.spaceAndRoomList();
}
} }
...@@ -13,6 +13,7 @@ import com.makeit.mapper.platform.space.PlatSpaceMapper; ...@@ -13,6 +13,7 @@ import com.makeit.mapper.platform.space.PlatSpaceMapper;
import com.makeit.service.platform.space.PlatRoomService; import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService; import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import jodd.util.StringUtil; import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -124,6 +125,11 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -124,6 +125,11 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return data; return data;
} }
@Override
public List<PlatSpaceAndRoomVO> spaceListExcludeLast() {
return baseMapper.spaceListExcludeLast();
}
private PlatSpaceVO child(PlatSpaceVO vo,Map<String,List<PlatSpace>> map){ private PlatSpaceVO child(PlatSpaceVO vo,Map<String,List<PlatSpace>> map){
if(!map.containsKey(vo.getId())){ if(!map.containsKey(vo.getId())){
......
package com.makeit.vo.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Data
@ApiModel("PlatBedPanoramaVO参数")
public class PlatBedPanoramaVO extends BaseIdDTO {
@ApiModelProperty("空间全路径id")
private String spacePath;
@ApiModelProperty("全路径名称")
private String spacePathName;
@ApiModelProperty("房间名称")
private String roomName;
@ApiModelProperty("床位名称")
private String bedName;
@ApiModelProperty("是否空闲 1 是 0 否")
private String status;
@ApiModelProperty("长者id")
private String elderId;
@ApiModelProperty("长者姓名")
private String elderName;
}
package com.makeit.vo.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/6
*/
@Data
@ApiModel("PlatRoomPanoramaVO参数")
public class PlatRoomPanoramaVO{
@ApiModelProperty("空间名称")
private String spaceName;
@ApiModelProperty("空间id")
private String spaceId;
private List<PlatRoomVO> list;
}
package com.makeit.vo.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Data
@ApiModel("PlatRoomVO参数")
public class PlatRoomVO {
@ApiModelProperty("房间名称")
private String roomName;
@ApiModelProperty("房间床位总数")
private Integer bedNumber;
@ApiModelProperty("房间id")
private String roomId;
@ApiModelProperty("房间床位使用数")
private Integer usedTotal;
@ApiModelProperty("状态")
private String roomStatus;
}
package com.makeit.vo.platform.space;
import com.makeit.common.dto.BaseIdDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/6
*/
@Data
@ApiModel("PlatSpaceVO参数")
public class PlatSpaceAndRoomVO extends BaseIdDTO {
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("父级Id")
private String parentId;
@ApiModelProperty("类型 0-空间 1-房间")
private String type;
@ApiModelProperty("子集")
private List<PlatSpaceAndRoomVO> child;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.platform.space.PlatBedMapper">
<select id="selectBySpaceIdAndStatus" resultType="com.makeit.vo.platform.space.PlatBedPanoramaVO">
SELECT pb.id,pb.`status`,pb.name bedName ,pm.`name` roomName,pm.space_path,pe.name as elderName,pe.id as elderId
FROM `plat_bed` pb
LEFT JOIN plat_room pm on pb.room_id = pm.id
LEFT JOIN plat_elder pe on pe.bed_id = pb.id
<where>
pb.del_flag = 0
<if test="dto.id != null and dto.id != ''">
AND FIND_IN_SET(#{dto.id},pm.space_path)
</if>
<if test="dto.status != null and dto.status != ''">
AND pb.statue = #{dto.status}
</if>
</where>
</select>
<select id="selectByRoomIdAndStatus" resultType="com.makeit.vo.platform.space.PlatBedPanoramaVO">
SELECT pb.id,pb.`status`,pb.name bedName ,pm.`name` roomName,pm.space_path,pe.name as elderName,pe.id as elderId
FROM `plat_bed` pb
LEFT JOIN plat_room pm on pb.room_id = pm.id
LEFT JOIN plat_elder pe on pe.bed_id = pb.id
<where>
pb.del_flag = 0
AND pm.id = #{dto.id}
<if test="dto.status != null and dto.status != ''">
AND pb.statue = #{dto.status}
</if>
</where>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.platform.space.PlatRoomMapper">
<select id="spaceAndRoomList" resultType="com.makeit.vo.platform.space.PlatSpaceAndRoomVO">
SELECT ps.id,ps.`name`,ps.parent_id as parentId,'0' as type FROM plat_space ps
WHERE ps.del_flag = 0
UNION
SELECT pr.id,pr.`name`,pr.space_id as parentId,'1' as type FROM plat_room pr
WHERE pr.del_flag = 0
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.platform.space.PlatSpaceMapper">
<select id="spaceListExcludeLast" resultType="com.makeit.vo.platform.space.PlatSpaceAndRoomVO">
SELECT ps.id,ps.`name`,ps.parent_id as parentId FROM plat_space ps
WHERE ps.id in (SELECT parent_id FROM `plat_space` WHERE del_flag =0) and ps.del_flag = 0
</select>
</mapper>
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