Commit 0eaef2f5 by 朱淼

工作台

parent 21b4b6e1
......@@ -4,10 +4,7 @@ import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.service.platform.workstation.WorkStationService;
import com.makeit.vo.platform.workstation.WorkStationHomeRoomVO;
import com.makeit.vo.platform.workstation.WorkStationHomeStatisticsVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionRoomVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionStatisticsVO;
import com.makeit.vo.platform.workstation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -46,7 +43,7 @@ public class WorkStationController {
@ApiOperation("居家-列表")
@PostMapping("homeList")
public ApiResponseEntity<WorkStationHomeRoomVO> homeList(@RequestBody WorkStationQueryDTO dto) {
public ApiResponseEntity<List<WorkStationHomeBedVO>> homeList(@RequestBody WorkStationQueryDTO dto) {
return ApiResponseUtils.success(workStationService.homeList(dto));
}
}
......@@ -2,9 +2,11 @@ package com.makeit.mapper.platform.space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.workstation.WorkStationBedVO;
import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -21,5 +23,7 @@ public interface PlatBedMapper extends BaseMapper<PlatBed> {
long countByOrdIdsAndType(@Param("orgIds") List<String> orgIds, @Param("orgType")String orgType);
List<WorkStationBedVO> selectByRoomIds(@Param("roomIds")List<String> roomIds);
List<WorkStationInstitutionBedVO> selectByRoomIds(@Param("roomIds")List<String> roomIds);
List<WorkStationHomeBedVO> selectByCondition(WorkStationQueryDTO dto);
}
......@@ -4,12 +4,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.device.PlatDeviceDTO;
import com.makeit.dto.platform.space.*;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.workstation.WorkStationBedVO;
import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO;
import java.util.List;
......@@ -62,5 +63,7 @@ public interface PlatBedService extends IService<PlatBed> {
long countByOrdIds(List<String> orgIds);
List<WorkStationBedVO> selectByRoomIds(List<String> roomIds);
List<WorkStationInstitutionBedVO> selectByRoomIds(List<String> roomIds);
List<WorkStationHomeBedVO> selectByCondition(WorkStationQueryDTO dto);
}
......@@ -7,6 +7,7 @@ import com.makeit.common.dto.StatusDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.space.*;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
......@@ -15,13 +16,13 @@ import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.auth.PlatOrgEnum;
import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatBedMapper;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.service.platform.space.PlatRoomService;
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 com.makeit.vo.platform.workstation.WorkStationBedVO;
import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -187,7 +188,12 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
}
@Override
public List<WorkStationBedVO> selectByRoomIds(List<String> roomIds) {
public List<WorkStationInstitutionBedVO> selectByRoomIds(List<String> roomIds) {
return baseMapper.selectByRoomIds(roomIds);
}
@Override
public List<WorkStationHomeBedVO> selectByCondition(WorkStationQueryDTO dto) {
return baseMapper.selectByCondition(dto);
}
}
......@@ -2,10 +2,7 @@ package com.makeit.service.platform.workstation;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.vo.platform.workstation.WorkStationHomeRoomVO;
import com.makeit.vo.platform.workstation.WorkStationHomeStatisticsVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionRoomVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionStatisticsVO;
import com.makeit.vo.platform.workstation.*;
import java.util.List;
......@@ -23,5 +20,5 @@ public interface WorkStationService {
WorkStationHomeStatisticsVO homeStatistics(WorkStationQueryDTO dto);
WorkStationHomeRoomVO homeList(WorkStationQueryDTO dto);
List<WorkStationHomeBedVO> homeList(WorkStationQueryDTO dto);
}
package com.makeit.service.platform.workstation.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.common.entity.BaseEntity;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
......@@ -10,7 +8,6 @@ import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.platform.alarm.PlatAlarmRecordEnum;
import com.makeit.enums.platform.auth.PlatOrgEnum;
......@@ -23,18 +20,13 @@ import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.service.platform.workstation.WorkStationService;
import com.makeit.utils.user.plat.PlatUserUtil;
import com.makeit.utils.user.plat.PlatUserVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import com.makeit.vo.platform.workstation.*;
import jodd.util.StringUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -125,12 +117,13 @@ public class WorkStationServiceImpl implements WorkStationService {
@Override
public List<WorkStationInstitutionRoomVO> institutionList(WorkStationQueryDTO dto) {
List<PlatSpace> spaces = new ArrayList<>();
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
if (orgs.isEmpty()) {
return new ArrayList<>();
}
if (dto.getSpaceIds().isEmpty()) {
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
if (orgs.isEmpty()) {
return new ArrayList<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
......@@ -139,9 +132,7 @@ public class WorkStationServiceImpl implements WorkStationService {
return new ArrayList<>();
}
} else {
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getId, dto.getSpaceIds()));
//todo 获取父级的所有子级空间
//获取父级的所有子级空间
spaces = platSpaceService.listChild(dto.getSpaceIds());
}
Map<String, String> platSpaceMap = spaces.stream().collect(Collectors.toMap(PlatSpace::getId, PlatSpace::getName));
......@@ -161,16 +152,18 @@ public class WorkStationServiceImpl implements WorkStationService {
elderIds.forEach(e -> {
elderIdList.addAll(Arrays.asList(e.split(",")));
});
dto.setElderIds(elderIdList);
//长者对应的报警类型
Map<String, Map<String,List<String>>> elderAlarmTypeMap = mapElderAlarmType(alarmRecords);
List<WorkStationInstitutionRoomVO> roomVOList = platRoomService.workStationList(dto);
if (roomVOList.isEmpty()) {
return new ArrayList<>();
}
List<String> roomIds = roomVOList.stream().map(WorkStationInstitutionRoomVO::getRoomId).collect(Collectors.toList());
//获取床号及长者/设备
List<WorkStationBedVO> bedVos = platBedService.selectByRoomIds(roomIds);
Map<String, List<WorkStationBedVO>> bedMap = bedVos.stream().collect(Collectors.groupingBy(WorkStationBedVO::getRoomId));
List<WorkStationInstitutionBedVO> bedVos = platBedService.selectByRoomIds(roomIds);
Map<String, List<WorkStationInstitutionBedVO>> bedMap = bedVos.stream().collect(Collectors.groupingBy(WorkStationInstitutionBedVO::getRoomId));
for (WorkStationInstitutionRoomVO roomVo : roomVOList) {
WorkStationInstitutionRoomVO vo = new WorkStationInstitutionRoomVO();
......@@ -184,7 +177,7 @@ public class WorkStationServiceImpl implements WorkStationService {
vo.setRoomId(roomVo.getRoomId());
vo.setPathName(pathName);
if (bedMap.get(roomVo.getRoomId()) != null) {
List<WorkStationBedVO> roomBedVos = bedMap.get(roomVo.getRoomId());
List<WorkStationInstitutionBedVO> roomBedVos = bedMap.get(roomVo.getRoomId());
//获取告警类型及老人状态
roomBedVos.forEach(r -> {
if (StringUtil.isNotEmpty(r.getElderId()) ) {
......@@ -295,7 +288,76 @@ public class WorkStationServiceImpl implements WorkStationService {
}
@Override
public WorkStationHomeRoomVO homeList(WorkStationQueryDTO dto) {
return null;
public List<WorkStationHomeBedVO> homeList(WorkStationQueryDTO dto) {
List<PlatSpace> spaces = new ArrayList<>();
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
if (orgs.isEmpty()) {
return new ArrayList<>();
}
if (dto.getSpaceIds().isEmpty()) {
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, orgIds));
if (spaces.isEmpty()) {
return new ArrayList<>();
}
} else {
//获取父级的所有子级空间
spaces = platSpaceService.listChild(dto.getSpaceIds());
}
Map<String, String> platSpaceMap = spaces.stream().collect(Collectors.toMap(PlatSpace::getId, PlatSpace::getName));
List<String> elderIdList = new ArrayList<>();
List<PlatAlarmRecord> alarmRecords = platAlarmRecordService.list(
new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(StringUtil.isNotEmpty(dto.getAlarmType()), PlatAlarmRecord::getAlarmType, dto.getAlarmType())
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue())
.in(PlatAlarmRecord::getOrgId, dto.getOrgIds())
);
List<String> elderIds = alarmRecords.stream().filter(t -> StringUtil.isNotEmpty(t.getElderIds()))
.map(PlatAlarmRecord::getElderIds).collect(Collectors.toList());
if (elderIds.isEmpty()) {
return new ArrayList<>();
}
elderIds.forEach(e -> {
elderIdList.addAll(Arrays.asList(e.split(",")));
});
dto.setElderIds(elderIdList);
//长者对应的报警类型
Map<String, Map<String,List<String>>> elderAlarmTypeMap = mapElderAlarmType(alarmRecords);
List<WorkStationHomeBedVO> list = platBedService.selectByCondition(dto);
for(WorkStationHomeBedVO vo : list){
String pathName = "";
for (String spaceId : Arrays.asList(vo.getSpacePath().split(","))) {
if (platSpaceMap.get(spaceId) != null) {
pathName = "".equals(pathName) ? platSpaceMap.get(spaceId) : pathName + "-" + platSpaceMap.get(spaceId);
}
}
pathName = pathName + "-" + vo.getRoomName();
vo.setPathName(pathName);
if (StringUtil.isNotEmpty(vo.getElderId()) ) {
if(elderAlarmTypeMap.containsKey(vo.getElderId())){
vo.setAlarmTypeMap(elderAlarmTypeMap.get(vo.getElderId()));
}
if(StringUtil.isNotEmpty(vo.getDeviceId())){
PlatElderIdDTO platElderIdDTO = new PlatElderIdDTO();
platElderIdDTO.setElderId(vo.getElderId());
platElderIdDTO.setDeviceId(vo.getDeviceId());
PlatElderRealTimeNowVO nowStatus = platElderRealTimeService.nowStatus(platElderIdDTO);
vo.setElderStatus(nowStatus.getStatus());
vo.setHeartRate(nowStatus.getHeartRate());
vo.setRespiratoryRate(nowStatus.getRespiratoryRate());
}
}
}
return list;
}
}
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* Controller
......@@ -13,8 +14,8 @@ import java.util.List;
* @version 2023/9/13
*/
@Data
@ApiModel("WorkStationHomeRoomVO对象")
public class WorkStationHomeRoomVO {
@ApiModel("WorkStationHomeBedVO对象")
public class WorkStationHomeBedVO {
@ApiModelProperty(value = "房间路径id")
private String spacePath;
......@@ -28,5 +29,33 @@ public class WorkStationHomeRoomVO {
@ApiModelProperty(value = "房间路径")
private String pathName;
private WorkStationBedVO bedVo;
@ApiModelProperty(value = "床号")
private String bedName;
@ApiModelProperty(value = "床id")
private String bedId;
@ApiModelProperty(value = "状态")
private String stauts;
@ApiModelProperty(value = "长者id")
private String elderId;
@ApiModelProperty(value = "长者姓名")
private String elderName;
@ApiModelProperty(value = "设备id")
private String deviceId;
@ApiModelProperty(value = "长者状态")
private String elderStatus;
@ApiModelProperty("心率")
private Integer heartRate;
@ApiModelProperty("呼吸率")
private Integer respiratoryRate;
@ApiModelProperty(value = "告警类型")
private Map<String,List<String>> alarmTypeMap;
}
package com.makeit.vo.platform.workstation;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Controller
......@@ -16,8 +14,8 @@ import java.util.Set;
* @version 2023/9/13
*/
@Data
@ApiModel("WorkStationRoomVO对象")
public class WorkStationBedVO {
@ApiModel("WorkStationInstitutionBedVO对象")
public class WorkStationInstitutionBedVO {
@ApiModelProperty(value = "床号")
private String bedName;
......
......@@ -28,5 +28,5 @@ public class WorkStationInstitutionRoomVO {
@ApiModelProperty(value = "房间路径")
private String pathName;
private List<WorkStationBedVO> list;
private List<WorkStationInstitutionBedVO> list;
}
......@@ -49,7 +49,7 @@
</where>
</select>
<select id="selectByRoomIds" resultType="com.makeit.vo.platform.workstation.WorkStationBedVO">
<select id="selectByRoomIds" resultType="com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO">
SELECT pb.`name` as bedName, pb.id as bedId, pb.room_id , pe.id as elderId, pb.name as elderName, prbd.device_id
FROM plat_bed pb
LEFT JOIN plat_elder pe ON pe.bed_id = pb.id
......@@ -65,5 +65,33 @@
</where>
</select>
<select id="selectByCondition" resultType="com.makeit.vo.platform.workstation.WorkStationHomeBedVO">
SELECT pb.`name` as bedName, pb.id as bedId, pb.room_id , pe.id as elderId, pb.name as elderName, prbd.device_id,pm.id as roomId,pm.name as roomName ,pm.space_path
FROM plat_bed pb
LEFT JOIN plat_room pr ON pr.id = pb.room_id
LEFT JOIN plat_space ps ON ps.id = pr.space_id
LEFT JOIN plat_elder pe ON pe.bed_id = pb.id
LEFT JOIN plat_room_bed_device rpbd ON rpbd.bed_id = pb.id
<where>
pb.del_flag = 0 and pe.del_flag = 0 and rpbd.del_flag = 0 and pb.status = 0
<if test="dto.elderName != null and dto.elderName != ''">
AND pe.naem LIKE CONCAT('%',#{dto.elderName},'%')
</if>
<if test="dto.spaceIds != null and dto.spaceIds.size()>0 ">
AND pm.space_id IN
<foreach collection="dto.spaceIds" item="item" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
<if test="dto.elderIds != null and dto.elderIds.size()>0 ">
AND pe.id IN
<foreach collection="dto.elderIds" item="item" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
</where>
order by pr.room_id
</select>
</mapper>
......@@ -27,6 +27,13 @@
#{item}
</foreach>
</if>
<if test="dto.elderIds != null and dto.elderIds.size()>0 ">
AND pe.id IN
<foreach collection="dto.elderIds" item="item" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
group by pm.id
</where>
</select>
......
......@@ -15,7 +15,7 @@
del_flag = 0
<if test="spaceIds != null and spaceIds.size() > 0 ">
AND (
<foreach collection="roomIds" item="item" separator="," open="(" close=")" index="">
<foreach collection="spaceIds" item="item" separator="or" open="" close="" index="">
FIND_IN_SET(#{item},parent_path) OR id = #{item}
</foreach>
)
......
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