Commit ac8aec65 by 杨伟程
parents 8a85057d 7e7df2c5
Showing with 571 additions and 82 deletions
...@@ -73,4 +73,11 @@ public class PlatSpaceController { ...@@ -73,4 +73,11 @@ public class PlatSpaceController {
return ApiResponseUtils.success(data); return ApiResponseUtils.success(data);
} }
@ApiOperation("树-无权限-到床位")
@PostMapping("listTreeAuthIgnoreByBed")
public ApiResponseEntity<List<PlatSpaceVO>> listTreeAuthIgnoreByBed(@RequestBody PlatSpaceQueryDTO dto) {
List<PlatSpaceVO> data = spaceService.treeByBed(dto);
return ApiResponseUtils.success(data);
}
} }
...@@ -4,9 +4,7 @@ import com.makeit.common.response.ApiResponseEntity; ...@@ -4,9 +4,7 @@ import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO; import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.service.platform.workstation.WorkStationService; import com.makeit.service.platform.workstation.WorkStationService;
import com.makeit.vo.platform.workstation.WorkStationHomeStatisticsVO; import com.makeit.vo.platform.workstation.*;
import com.makeit.vo.platform.workstation.WorkStationInstitutionRoomVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionStatisticsVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -42,4 +40,10 @@ public class WorkStationController { ...@@ -42,4 +40,10 @@ public class WorkStationController {
public ApiResponseEntity<WorkStationHomeStatisticsVO> homeStatistics(@RequestBody WorkStationQueryDTO dto) { public ApiResponseEntity<WorkStationHomeStatisticsVO> homeStatistics(@RequestBody WorkStationQueryDTO dto) {
return ApiResponseUtils.success(workStationService.homeStatistics(dto)); return ApiResponseUtils.success(workStationService.homeStatistics(dto));
} }
@ApiOperation("居家-列表")
@PostMapping("homeList")
public ApiResponseEntity<List<WorkStationHomeBedVO>> homeList(@RequestBody WorkStationQueryDTO dto) {
return ApiResponseUtils.success(workStationService.homeList(dto));
}
} }
...@@ -2,8 +2,11 @@ package com.makeit.mapper.platform.space; ...@@ -2,8 +2,11 @@ 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.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.space.PlatBed; import com.makeit.entity.platform.space.PlatBed;
import com.makeit.vo.platform.space.PlatBedPanoramaVO; import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -19,4 +22,8 @@ public interface PlatBedMapper extends BaseMapper<PlatBed> { ...@@ -19,4 +22,8 @@ public interface PlatBedMapper extends BaseMapper<PlatBed> {
List<PlatBedPanoramaVO> selectByRoomIdAndStatus(@Param("dto")PlatBedPanoramaDTO dto); List<PlatBedPanoramaVO> selectByRoomIdAndStatus(@Param("dto")PlatBedPanoramaDTO dto);
long countByOrdIdsAndType(@Param("orgIds") List<String> orgIds, @Param("orgType")String orgType); long countByOrdIdsAndType(@Param("orgIds") List<String> orgIds, @Param("orgType")String orgType);
List<WorkStationInstitutionBedVO> selectByRoomIds(@Param("roomIds")List<String> roomIds);
List<WorkStationHomeBedVO> selectByCondition(WorkStationQueryDTO dto);
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO; 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 com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -15,4 +16,6 @@ import java.util.List; ...@@ -15,4 +16,6 @@ import java.util.List;
public interface PlatSpaceMapper extends BaseMapper<PlatSpace> { public interface PlatSpaceMapper extends BaseMapper<PlatSpace> {
List<PlatSpaceAndRoomVO> spaceListExcludeLast(); List<PlatSpaceAndRoomVO> spaceListExcludeLast();
List<PlatSpace> listChild(@Param("spaceIds") List<String> spaceIds);
} }
...@@ -22,6 +22,7 @@ import com.makeit.service.platform.device.PlatDeviceService; ...@@ -22,6 +22,7 @@ import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderService; import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.space.PlatBedService; import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatSpaceService; import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.area.AreaUtil;
import com.makeit.utils.area.ChinaAreaVO; import com.makeit.utils.area.ChinaAreaVO;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.vo.platform.dataScreen.*; import com.makeit.vo.platform.dataScreen.*;
...@@ -62,9 +63,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -62,9 +63,7 @@ public class DataScreenServiceImpl implements DataScreenService {
PlatAgeStatisticsVO vo = new PlatAgeStatisticsVO(); PlatAgeStatisticsVO vo = new PlatAgeStatisticsVO();
if(dto.getOrgIds().isEmpty()){ if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织 //获取该账号的权限组织
PlatOrg param = new PlatOrg(); List<PlatOrg> orgs = belongToScopeList(dto.getType());
param.setType(dto.getType());
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
if(orgs.isEmpty()){ if(orgs.isEmpty()){
return vo; return vo;
} }
...@@ -92,9 +91,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -92,9 +91,7 @@ public class DataScreenServiceImpl implements DataScreenService {
PlatSexStatisticsVO vo = new PlatSexStatisticsVO(); PlatSexStatisticsVO vo = new PlatSexStatisticsVO();
if(dto.getOrgIds().isEmpty()){ if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织 //获取该账号的权限组织
PlatOrg param = new PlatOrg(); List<PlatOrg> orgs = belongToScopeList(dto.getType());
param.setType(dto.getType());
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
if(orgs.isEmpty()){ if(orgs.isEmpty()){
return vo; return vo;
} }
...@@ -133,9 +130,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -133,9 +130,7 @@ public class DataScreenServiceImpl implements DataScreenService {
PlatDeviceStatisticsVO vo = new PlatDeviceStatisticsVO(); PlatDeviceStatisticsVO vo = new PlatDeviceStatisticsVO();
if(dto.getOrgIds().isEmpty()){ if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织 //获取该账号的权限组织
PlatOrg param = new PlatOrg(); List<PlatOrg> orgs = belongToScopeList(dto.getType());
param.setType(dto.getType());
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
if(orgs.isEmpty()){ if(orgs.isEmpty()){
return vo; return vo;
} }
...@@ -153,7 +148,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -153,7 +148,7 @@ public class DataScreenServiceImpl implements DataScreenService {
long fallNumber = devices.stream().filter(t-> PlatDeviceEnum.CategoryEnum.FALL.getValue().equals(t.getCategory())).count(); long fallNumber = devices.stream().filter(t-> PlatDeviceEnum.CategoryEnum.FALL.getValue().equals(t.getCategory())).count();
long spaceNumber = devices.stream().filter(t-> PlatDeviceEnum.CategoryEnum.SPACE.getValue().equals(t.getCategory())).count(); long spaceNumber = devices.stream().filter(t-> PlatDeviceEnum.CategoryEnum.SPACE.getValue().equals(t.getCategory())).count();
vo.setTotla(total); vo.setTotal(total);
vo.setOnlineNumber(onlineNumber); vo.setOnlineNumber(onlineNumber);
vo.setOfflineNumber(offlineNumber); vo.setOfflineNumber(offlineNumber);
vo.setDisableNumber(disableNumber); vo.setDisableNumber(disableNumber);
...@@ -168,9 +163,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -168,9 +163,7 @@ public class DataScreenServiceImpl implements DataScreenService {
PlatAlarmStatisticsVO vo = new PlatAlarmStatisticsVO(); PlatAlarmStatisticsVO vo = new PlatAlarmStatisticsVO();
if(dto.getOrgIds().isEmpty()){ if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织 //获取该账号的权限组织
PlatOrg param = new PlatOrg(); List<PlatOrg> orgs = belongToScopeList(dto.getType());
param.setType(dto.getType());
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
if(orgs.isEmpty()){ if(orgs.isEmpty()){
return vo; return vo;
} }
...@@ -184,7 +177,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -184,7 +177,7 @@ public class DataScreenServiceImpl implements DataScreenService {
List<PlatElder> platElders = platElderService.list(); List<PlatElder> platElders = platElderService.list();
Map<String,String> elderNameMap = platElders.stream().collect(Collectors.toMap(PlatElder::getId,PlatElder::getName)); Map<String,String> elderNameMap = platElders.stream().collect(Collectors.toMap(PlatElder::getId,PlatElder::getName));
List<PlatAlarmStatisticsListVo> list = new ArrayList<>(); List<PlatAlarmStatisticsListVo> list = new ArrayList<>();
long totla = 0; long total = 0;
long handledNumber = 0; long handledNumber = 0;
long unhandledNumber = 0; long unhandledNumber = 0;
for (PlatAlarmRecord record : alarmRecords){ for (PlatAlarmRecord record : alarmRecords){
...@@ -203,7 +196,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -203,7 +196,7 @@ public class DataScreenServiceImpl implements DataScreenService {
} }
listVo.setElderName(elderName); listVo.setElderName(elderName);
listVo.setType(record.getAlarmType()); listVo.setType(record.getAlarmType());
totla ++; total ++;
if(PlatAlarmRecordEnum.AlarmRecordStatusEnum.HANDLED.getValue().equals(record.getStatus())){ if(PlatAlarmRecordEnum.AlarmRecordStatusEnum.HANDLED.getValue().equals(record.getStatus())){
handledNumber ++; handledNumber ++;
}else { }else {
...@@ -213,7 +206,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -213,7 +206,7 @@ public class DataScreenServiceImpl implements DataScreenService {
} }
} }
vo.setTotla(totla); vo.setTotal(total);
vo.setHandledNumber(handledNumber); vo.setHandledNumber(handledNumber);
vo.setUnhandledNumber(unhandledNumber); vo.setUnhandledNumber(unhandledNumber);
vo.setList(list); vo.setList(list);
...@@ -225,9 +218,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -225,9 +218,7 @@ public class DataScreenServiceImpl implements DataScreenService {
PlatBaseInfoStatisticsVO vo = new PlatBaseInfoStatisticsVO(); PlatBaseInfoStatisticsVO vo = new PlatBaseInfoStatisticsVO();
if(dto.getOrgIds().isEmpty()){ if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织 //获取该账号的权限组织
PlatOrg param = new PlatOrg(); List<PlatOrg> orgs = belongToScopeList(dto.getType());
param.setType(dto.getType());
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
if(orgs.isEmpty()){ if(orgs.isEmpty()){
return vo; return vo;
} }
...@@ -257,9 +248,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -257,9 +248,7 @@ public class DataScreenServiceImpl implements DataScreenService {
List<PlatMapStatisticsVO> list = new ArrayList<>(); List<PlatMapStatisticsVO> list = new ArrayList<>();
if(dto.getOrgIds().isEmpty()){ if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织 //获取该账号的权限组织
PlatOrg param = new PlatOrg(); List<PlatOrg> orgs = belongToScopeList(dto.getType());
param.setType(dto.getType());
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
if(orgs.isEmpty()){ if(orgs.isEmpty()){
return new ArrayList<>(); return new ArrayList<>();
} }
...@@ -330,8 +319,41 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -330,8 +319,41 @@ public class DataScreenServiceImpl implements DataScreenService {
@Override @Override
public List<ChinaAreaVO> mapList(PlatDataScreenQueryDTO dto) { public List<ChinaAreaVO> mapList(PlatDataScreenQueryDTO dto) {
List<ChinaAreaVO> list = new ArrayList<>();
if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(dto.getType());
if(orgs.isEmpty()){
return new ArrayList<>();
}
List<String> codes = orgs.stream().map(PlatOrg::getRegion).collect(Collectors.toList());
list = AreaUtil.getByCodeList(codes);
}else {
List<PlatOrg> orgs = platOrgService.list(new QueryWrapper<PlatOrg>().lambda()
.in(PlatOrg::getId, dto.getOrgIds()));
Set<String> parentOrgIds = new HashSet<>();
orgs.forEach(t->{
parentOrgIds.addAll(Arrays.asList(t.getPath().split(",")));
});
List<PlatOrg> ancestorsOrgList = getAncestorsOrgList(orgs, parentOrgIds);
List<String> codes = ancestorsOrgList.stream().map(PlatOrg::getRegion).collect(Collectors.toList());
list = AreaUtil.getByCodeList(codes);
return null; }
return list;
}
private List<PlatOrg> getAncestorsOrgList(List<PlatOrg> orgs, Set<String> parentOrgIds) {
orgs = orgs.stream().filter(t->parentOrgIds.contains(t.getId())).collect(Collectors.toList());
Set<String> ancestorsOrgIdList = new HashSet<>();
orgs.forEach(t->{
ancestorsOrgIdList.addAll(Arrays.asList(t.getPath().split(",")));
});
if(ancestorsOrgIdList.size() != parentOrgIds.size()){
getAncestorsOrgList(orgs,ancestorsOrgIdList);
}
return orgs;
} }
private List<PlatAlarmRecordStatisticsVo> coverToVoList(List<PlatAlarmRecord> alarmRecords, Map<String,PlatElder> platElderMap) { private List<PlatAlarmRecordStatisticsVo> coverToVoList(List<PlatAlarmRecord> alarmRecords, Map<String,PlatElder> platElderMap) {
...@@ -350,5 +372,10 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -350,5 +372,10 @@ public class DataScreenServiceImpl implements DataScreenService {
return statisticsVos; return statisticsVos;
} }
private List<PlatOrg> belongToScopeList(String type) {
PlatOrg param = new PlatOrg();
param.setType(type);
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
return orgs;
}
} }
...@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.dto.StatusDTO; import com.makeit.common.dto.StatusDTO;
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.dto.platform.device.PlatDeviceDTO;
import com.makeit.dto.platform.space.*; 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.PlatBed;
import com.makeit.entity.platform.space.PlatRoom; import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.vo.platform.space.PlatBedPanoramaVO; import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO;
import java.util.List; import java.util.List;
...@@ -59,4 +61,9 @@ public interface PlatBedService extends IService<PlatBed> { ...@@ -59,4 +61,9 @@ public interface PlatBedService extends IService<PlatBed> {
List<PlatBedPanoramaVO> selectByRoomIdAndStatus(PlatBedPanoramaDTO dto); List<PlatBedPanoramaVO> selectByRoomIdAndStatus(PlatBedPanoramaDTO dto);
List<PlatBed> list(PlatBedQueryDTO dto); List<PlatBed> list(PlatBedQueryDTO dto);
long countByOrdIds(List<String> orgIds);} long countByOrdIds(List<String> orgIds);
List<WorkStationInstitutionBedVO> selectByRoomIds(List<String> roomIds);
List<WorkStationHomeBedVO> selectByCondition(WorkStationQueryDTO dto);
}
...@@ -49,4 +49,13 @@ public interface PlatSpaceService extends IService<PlatSpace> { ...@@ -49,4 +49,13 @@ public interface PlatSpaceService extends IService<PlatSpace> {
PlatSpaceAddDTO view(String id); PlatSpaceAddDTO view(String id);
List<PlatSpaceAndRoomVO> spaceListExcludeLast(); List<PlatSpaceAndRoomVO> spaceListExcludeLast();
/**
* 空间树 到 床位
* @param dto
* @return
*/
List<PlatSpaceVO> treeByBed(PlatSpaceQueryDTO dto);
List<PlatSpace> listChild(List<String> spaceIds);
} }
...@@ -7,6 +7,7 @@ import com.makeit.common.dto.StatusDTO; ...@@ -7,6 +7,7 @@ import com.makeit.common.dto.StatusDTO;
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.dto.platform.space.*; 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.PlatBed;
import com.makeit.entity.platform.space.PlatRoom; import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatRoomBedDevice; import com.makeit.entity.platform.space.PlatRoomBedDevice;
...@@ -15,12 +16,13 @@ import com.makeit.enums.CommonEnum; ...@@ -15,12 +16,13 @@ import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.auth.PlatOrgEnum; import com.makeit.enums.platform.auth.PlatOrgEnum;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatBedMapper; 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.PlatBedService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService; import com.makeit.service.platform.space.PlatRoomBedDeviceService;
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.PageUtil; import com.makeit.utils.data.convert.PageUtil;
import com.makeit.vo.platform.space.PlatBedPanoramaVO; import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO;
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;
...@@ -183,4 +185,15 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl ...@@ -183,4 +185,15 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
@Override @Override
public long countByOrdIds(List<String> orgIds) { public long countByOrdIds(List<String> orgIds) {
return baseMapper.countByOrdIdsAndType(orgIds, PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue()); return baseMapper.countByOrdIdsAndType(orgIds, PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
}} }
@Override
public List<WorkStationInstitutionBedVO> selectByRoomIds(List<String> roomIds) {
return baseMapper.selectByRoomIds(roomIds);
}
@Override
public List<WorkStationHomeBedVO> selectByCondition(WorkStationQueryDTO dto) {
return baseMapper.selectByCondition(dto);
}
}
...@@ -6,12 +6,14 @@ import com.makeit.dto.platform.space.PlatSpaceAddDTO; ...@@ -6,12 +6,14 @@ 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.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom; import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatSpace; import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.CodeMessageEnum; import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException; import com.makeit.exception.BusinessException;
import com.makeit.mapper.platform.space.PlatSpaceMapper; import com.makeit.mapper.platform.space.PlatSpaceMapper;
import com.makeit.service.platform.auth.PlatOrgService; import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.space.PlatBedService;
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;
...@@ -39,6 +41,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -39,6 +41,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
@Autowired @Autowired
private PlatRoomService platRoomService; private PlatRoomService platRoomService;
@Autowired @Autowired
private PlatBedService platBedService;
@Autowired
private PlatOrgService platOrgService; private PlatOrgService platOrgService;
private void check(PlatSpaceAddDTO dto){ private void check(PlatSpaceAddDTO dto){
...@@ -142,6 +146,81 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -142,6 +146,81 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return baseMapper.spaceListExcludeLast(); return baseMapper.spaceListExcludeLast();
} }
@Override
public List<PlatSpaceVO> treeByBed(PlatSpaceQueryDTO dto) {
//房间
List<PlatRoom> listRoom = platRoomService.list(new LambdaQueryWrapper<>());
//床位
List<PlatBed> listBeds = platBedService.list(new LambdaQueryWrapper<>());
Map<String,List<PlatBed>> mapBed = listBeds.stream().collect(Collectors.groupingBy(PlatBed::getRoomId));
List<PlatSpaceVO> listRoomVo = new ArrayList<>();
listRoom.forEach(item->{
PlatSpaceVO vo = new PlatSpaceVO();
vo.setId(item.getId());
vo.setName(item.getName());
vo.setParentId(item.getSpaceId());
listRoomVo.add(vo);
});
listBeds.forEach(item->{
PlatSpaceVO vo = new PlatSpaceVO();
vo.setId(item.getId());
vo.setName(item.getName());
vo.setParentId(item.getRoomId());
listRoomVo.add(vo);
});
LambdaQueryWrapper<PlatSpace> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()),PlatSpace::getName,dto.getName());
List<PlatSpace> list = this.list(queryWrapper);
List<PlatSpaceVO> listSpaceVo = BeanDtoVoUtils.listVo(list,PlatSpaceVO.class);
listSpaceVo.addAll(listRoomVo);
//父级
List<PlatSpaceVO> listParent = listSpaceVo.stream().filter(item->StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集
List<PlatSpaceVO> listChild = listSpaceVo.stream().filter(item->item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpaceVO>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpaceVO::getParentId));
List<PlatSpaceVO> data = new ArrayList<>();
for(PlatSpaceVO space:listParent){
space = childVo(space,map);
data.add(space);
}
return data;
}
@Override
public List<PlatSpace> listChild(List<String> spaceIds) {
return baseMapper.listChild(spaceIds);
}
private PlatSpaceVO childVo(PlatSpaceVO vo,Map<String,List<PlatSpaceVO>> map) {
if (!map.containsKey(vo.getId())) {
return vo;
}
List<PlatSpaceVO> list = map.get(vo.getId());
List<PlatSpaceVO> listChild = new ArrayList<>();
for (PlatSpaceVO item : list) {
this.childVo(item, map);
listChild.add(item);
}
vo.setChildren(listChild);
return vo;
}
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())){
......
...@@ -2,9 +2,7 @@ package com.makeit.service.platform.workstation; ...@@ -2,9 +2,7 @@ package com.makeit.service.platform.workstation;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO; import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.vo.platform.workstation.WorkStationHomeStatisticsVO; import com.makeit.vo.platform.workstation.*;
import com.makeit.vo.platform.workstation.WorkStationInstitutionRoomVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionStatisticsVO;
import java.util.List; import java.util.List;
...@@ -21,4 +19,6 @@ public interface WorkStationService { ...@@ -21,4 +19,6 @@ public interface WorkStationService {
List<WorkStationInstitutionRoomVO> institutionList(WorkStationQueryDTO dto); List<WorkStationInstitutionRoomVO> institutionList(WorkStationQueryDTO dto);
WorkStationHomeStatisticsVO homeStatistics(WorkStationQueryDTO dto); WorkStationHomeStatisticsVO homeStatistics(WorkStationQueryDTO dto);
List<WorkStationHomeBedVO> homeList(WorkStationQueryDTO dto);
} }
package com.makeit.service.platform.workstation.impl; 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.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.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmRecord; import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.elder.PlatElder; import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatBed; import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatSpace; 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.alarm.PlatAlarmRecordEnum;
import com.makeit.enums.platform.auth.PlatOrgEnum; import com.makeit.enums.platform.auth.PlatOrgEnum;
import com.makeit.enums.platform.space.PlatBedStatusEnum; import com.makeit.enums.platform.space.PlatBedStatusEnum;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.auth.PlatOrgService; import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.elder.PlatElderRealTimeService;
import com.makeit.service.platform.elder.PlatElderService; import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.space.PlatBedService; import com.makeit.service.platform.space.PlatBedService;
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.service.platform.workstation.WorkStationService; import com.makeit.service.platform.workstation.WorkStationService;
import com.makeit.utils.user.plat.PlatUserUtil; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import com.makeit.utils.user.plat.PlatUserVO; import com.makeit.vo.platform.workstation.*;
import com.makeit.vo.platform.workstation.WorkStationHomeStatisticsVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionRoomVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionStatisticsVO;
import jodd.util.StringUtil; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -55,17 +49,17 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -55,17 +49,17 @@ public class WorkStationServiceImpl implements WorkStationService {
private PlatSpaceService platSpaceService; private PlatSpaceService platSpaceService;
@Autowired @Autowired
private PlatOrgService platOrgService; private PlatOrgService platOrgService;
@Autowired
private PlatElderRealTimeService platElderRealTimeService;
@Override @Override
public WorkStationInstitutionStatisticsVO institutionStatistics(WorkStationQueryDTO dto) { public WorkStationInstitutionStatisticsVO institutionStatistics(WorkStationQueryDTO dto) {
WorkStationInstitutionStatisticsVO vo = new WorkStationInstitutionStatisticsVO(); WorkStationInstitutionStatisticsVO vo = new WorkStationInstitutionStatisticsVO();
if(dto.getOrgIds().isEmpty()){ if (dto.getOrgIds().isEmpty()) {
//获取该账号的权限组织 //获取该账号的权限组织
PlatOrg param = new PlatOrg(); List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
param.setType(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
List<PlatOrg> orgs = platOrgService.belongToScopeList(param); if (orgs.isEmpty()) {
if(orgs.isEmpty()){
return vo; return vo;
} }
...@@ -97,12 +91,12 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -97,12 +91,12 @@ public class WorkStationServiceImpl implements WorkStationService {
List<PlatSpace> spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda() List<PlatSpace> spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, dto.getOrgIds())); .in(PlatSpace::getOrgId, dto.getOrgIds()));
List<String> spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList()); List<String> spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList());
if(!spaceIds.isEmpty()){ if (!spaceIds.isEmpty()) {
long spareBedNumber = platBedService.count(new QueryWrapper<PlatBed>().lambda() long spareBedNumber = platBedService.count(new QueryWrapper<PlatBed>().lambda()
.eq(PlatBed::getStatus, PlatBedStatusEnum.BedStatusEnum.SPARE.getValue()) .eq(PlatBed::getStatus, PlatBedStatusEnum.BedStatusEnum.SPARE.getValue())
.in(PlatBed::getSpaceId, spaceIds)); .in(PlatBed::getSpaceId, spaceIds));
vo.setSpareBedNumber(spareBedNumber); vo.setSpareBedNumber(spareBedNumber);
}else { } else {
vo.setSpareBedNumber(0L); vo.setSpareBedNumber(0L);
} }
vo.setUnHandledNumber(unHandledNumber); vo.setUnHandledNumber(unHandledNumber);
...@@ -113,31 +107,35 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -113,31 +107,35 @@ public class WorkStationServiceImpl implements WorkStationService {
return vo; return vo;
} }
private List<PlatOrg> belongToScopeList(String type) {
PlatOrg param = new PlatOrg();
param.setType(type);
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
return orgs;
}
@Override @Override
public List<WorkStationInstitutionRoomVO> institutionList(WorkStationQueryDTO dto) { public List<WorkStationInstitutionRoomVO> institutionList(WorkStationQueryDTO dto) {
List<PlatSpace> spaces = new ArrayList<>(); List<PlatSpace> spaces = new ArrayList<>();
if(dto.getSpaceIds().isEmpty()){
//获取该账号的权限组织 //获取该账号的权限组织
PlatOrg param = new PlatOrg(); List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
param.setType(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue()); if (orgs.isEmpty()) {
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
if(orgs.isEmpty()){
return new ArrayList<>(); return new ArrayList<>();
} }
if (dto.getSpaceIds().isEmpty()) {
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList()); List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda() spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, dto.getOrgIds())); .in(PlatSpace::getOrgId, orgIds));
if(spaces.isEmpty()){ if (spaces.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<String> spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList()); } else {
dto.setSpaceIds(spaceIds); //获取父级的所有子级空间
}else { spaces = platSpaceService.listChild(dto.getSpaceIds());
spaces = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getId, dto.getSpaceIds()));
} }
Map<String, PlatSpace> platSpaceMap = spaces.stream().collect(Collectors.toMap(PlatSpace::getId, Function.identity())); Map<String, String> platSpaceMap = spaces.stream().collect(Collectors.toMap(PlatSpace::getId, PlatSpace::getName));
List<String> elderIdList = new ArrayList<>(); List<String> elderIdList = new ArrayList<>();
List<PlatAlarmRecord> alarmRecords = platAlarmRecordService.list( List<PlatAlarmRecord> alarmRecords = platAlarmRecordService.list(
...@@ -146,27 +144,220 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -146,27 +144,220 @@ public class WorkStationServiceImpl implements WorkStationService {
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue()) .eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue())
.in(PlatAlarmRecord::getOrgId, dto.getOrgIds()) .in(PlatAlarmRecord::getOrgId, dto.getOrgIds())
); );
List<String> elderIds = alarmRecords.stream().filter(t->StringUtil.isNotEmpty(t.getElderIds())) List<String> elderIds = alarmRecords.stream().filter(t -> StringUtil.isNotEmpty(t.getElderIds()))
.map(PlatAlarmRecord::getElderIds).collect(Collectors.toList()); .map(PlatAlarmRecord::getElderIds).collect(Collectors.toList());
if(elderIds.isEmpty()){ if (elderIds.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
elderIds.forEach(e->{ elderIds.forEach(e -> {
elderIdList.addAll(Arrays.asList(e.split(","))); elderIdList.addAll(Arrays.asList(e.split(",")));
}); });
dto.setElderIds(elderIdList);
//长者对应的报警类型
Map<String, Map<String,List<String>>> elderAlarmTypeMap = mapElderAlarmType(alarmRecords);
List<WorkStationInstitutionRoomVO> roomVOList = platRoomService.workStationList(dto); List<WorkStationInstitutionRoomVO> roomVOList = platRoomService.workStationList(dto);
if(roomVOList.isEmpty()){ if (roomVOList.isEmpty()) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<String> roomIds = roomVOList.stream().map(WorkStationInstitutionRoomVO::getRoomId).collect(Collectors.toList()); List<String> roomIds = roomVOList.stream().map(WorkStationInstitutionRoomVO::getRoomId).collect(Collectors.toList());
//获取床号及长者 //获取床号及长者/设备
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();
String pathName = "";
for (String spaceId : Arrays.asList(roomVo.getSpacePath().split(","))) {
if (platSpaceMap.get(spaceId) != null) {
pathName = "".equals(pathName) ? platSpaceMap.get(spaceId) : pathName + "-" + platSpaceMap.get(spaceId);
}
}
pathName = pathName + "-" + roomVo.getRoomName();
vo.setRoomId(roomVo.getRoomId());
vo.setPathName(pathName);
if (bedMap.get(roomVo.getRoomId()) != null) {
List<WorkStationInstitutionBedVO> roomBedVos = bedMap.get(roomVo.getRoomId());
//获取告警类型及老人状态
roomBedVos.forEach(r -> {
if (StringUtil.isNotEmpty(r.getElderId()) ) {
if(elderAlarmTypeMap.containsKey(r.getElderId())){
r.setAlarmTypeMap(elderAlarmTypeMap.get(r.getElderId()));
}
if(StringUtil.isNotEmpty(r.getDeviceId())){
PlatElderIdDTO platElderIdDTO = new PlatElderIdDTO();
platElderIdDTO.setElderId(r.getElderId());
platElderIdDTO.setDeviceId(r.getDeviceId());
PlatElderRealTimeNowVO nowStatus = platElderRealTimeService.nowStatus(platElderIdDTO);
r.setElderStatus(nowStatus.getStatus());
}
}
});
vo.setList(roomBedVos);
}
}
return roomVOList;
}
return null; private Map<String, Map<String,List<String>>> mapElderAlarmType(List<PlatAlarmRecord> alarmRecords) {
Map<String, Map<String,List<String>>> map = new HashMap<>();
alarmRecords.forEach(a -> {
if (StringUtil.isNotEmpty(a.getElderIds())) {
List<String> elderIds = Arrays.asList(a.getElderIds().split(","));
elderIds.forEach(e -> {
if(map.containsKey(e)){
Map<String,List<String>> typeMap = map.get(e);
if(PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue().equals(a.getAlarmType())
|| PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue().equals(a.getAlarmType())
){
if(typeMap.containsKey(a.getAlarmType())){
typeMap.get(a.getAlarmType()).add(a.getRemark());
typeMap.put(a.getAlarmType(),typeMap.get(a.getAlarmType()));
}else {
if(StringUtil.isNotEmpty(a.getRemark())){
List<String> stautsList = new ArrayList<>();
stautsList.add(a.getRemark());
typeMap.put(a.getAlarmType(),stautsList);
}
}
} else {
typeMap.put(a.getAlarmType(), new ArrayList<>());
}
map.put(e, typeMap);
}else {
Map<String,List<String>> typeMap = new HashMap<>();
if(PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue().equals(a.getAlarmType())
|| PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue().equals(a.getAlarmType())
){
if(StringUtil.isNotEmpty(a.getRemark())){
List<String> stautsList = new ArrayList<>();
stautsList.add(a.getRemark());
typeMap.put(a.getAlarmType(),stautsList);
}
} else {
typeMap.put(a.getAlarmType(), new ArrayList<>());
}
map.put(e, typeMap);
}
});
}
});
return map;
} }
@Override @Override
public WorkStationHomeStatisticsVO homeStatistics(WorkStationQueryDTO dto) { public WorkStationHomeStatisticsVO homeStatistics(WorkStationQueryDTO dto) {
WorkStationHomeStatisticsVO vo = new WorkStationHomeStatisticsVO();
if (dto.getOrgIds().isEmpty()) {
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(PlatOrgEnum.OrgTypeEnum.INSTITUTION.getValue());
if (orgs.isEmpty()) {
return vo;
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
}
//长者数
long elderNumber = platElderService.count(new QueryWrapper<PlatElder>().lambda()
.in(PlatElder::getOrgId, dto.getOrgIds()));
//今日告警数
long alarmNumber = platAlarmRecordService.count(new QueryWrapper<PlatAlarmRecord>().lambda()
.between(PlatAlarmRecord::getAlarmDate, dto.getStartTime(), dto.getEndTime())
.in(PlatAlarmRecord::getOrgId, dto.getOrgIds()));
//待处理告警
long unHandledNumber = platAlarmRecordService.count(new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue())
.in(PlatAlarmRecord::getOrgId, dto.getOrgIds()));
//今日已处理告警数
long handledNumber = platAlarmRecordService.count(new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.HANDLED.getValue())
.between(PlatAlarmRecord::getDealDate, dto.getStartTime(), dto.getEndTime())
.in(PlatAlarmRecord::getOrgId, dto.getOrgIds()));
vo.setAlarmNumber(alarmNumber);
vo.setUnHandledNumber(unHandledNumber);
vo.setElderNumber(elderNumber);
vo.setHandledNumber(handledNumber);
return vo;
}
@Override
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<>();
}
return null; 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;
} }
} }
...@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel; ...@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime;
/** /**
* Controller * Controller
* *
...@@ -20,4 +22,10 @@ public class PlatAlarmStatisticsListVo { ...@@ -20,4 +22,10 @@ public class PlatAlarmStatisticsListVo {
private String type; private String type;
@ApiModelProperty(value = "状态") @ApiModelProperty(value = "状态")
private String status; private String status;
@ApiModelProperty(value = "告警日期")
private String alarmDate;
@ApiModelProperty(value = "告警时间")
private String alarmTime;
@ApiModelProperty(value = "路径")
private String path;
} }
...@@ -17,7 +17,7 @@ import java.util.List; ...@@ -17,7 +17,7 @@ import java.util.List;
public class PlatAlarmStatisticsVO { public class PlatAlarmStatisticsVO {
@ApiModelProperty(value = "累计告警") @ApiModelProperty(value = "累计告警")
private Long totla; private Long total;
@ApiModelProperty(value = "已处理数") @ApiModelProperty(value = "已处理数")
private Long handledNumber; private Long handledNumber;
@ApiModelProperty(value = "待处理数") @ApiModelProperty(value = "待处理数")
......
...@@ -17,7 +17,7 @@ import java.util.List; ...@@ -17,7 +17,7 @@ import java.util.List;
public class PlatDeviceStatisticsVO { public class PlatDeviceStatisticsVO {
@ApiModelProperty(value = "总数") @ApiModelProperty(value = "总数")
private Long totla; private Long total;
@ApiModelProperty(value = "在线数") @ApiModelProperty(value = "在线数")
private Long onlineNumber; private Long onlineNumber;
@ApiModelProperty(value = "故障数") @ApiModelProperty(value = "故障数")
......
package com.makeit.vo.platform.workstation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* Controller
*
* @author zm
* @version 2023/9/13
*/
@Data
@ApiModel("WorkStationHomeBedVO对象")
public class WorkStationHomeBedVO {
@ApiModelProperty(value = "房间路径id")
private String spacePath;
@ApiModelProperty(value = "房间id")
private String roomId;
@ApiModelProperty(value = "房间名称")
private String roomName;
@ApiModelProperty(value = "房间路径")
private String pathName;
@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; package com.makeit.vo.platform.workstation;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Controller * Controller
...@@ -14,8 +14,8 @@ import java.util.List; ...@@ -14,8 +14,8 @@ import java.util.List;
* @version 2023/9/13 * @version 2023/9/13
*/ */
@Data @Data
@ApiModel("WorkStationRoomVO对象") @ApiModel("WorkStationInstitutionBedVO对象")
public class WorkStationBedVO { public class WorkStationInstitutionBedVO {
@ApiModelProperty(value = "床号") @ApiModelProperty(value = "床号")
private String bedName; private String bedName;
...@@ -23,6 +23,9 @@ public class WorkStationBedVO { ...@@ -23,6 +23,9 @@ public class WorkStationBedVO {
@ApiModelProperty(value = "床id") @ApiModelProperty(value = "床id")
private String bedId; private String bedId;
@ApiModelProperty(value = "房间id")
private String roomId;
@ApiModelProperty(value = "状态") @ApiModelProperty(value = "状态")
private String stauts; private String stauts;
...@@ -32,9 +35,12 @@ public class WorkStationBedVO { ...@@ -32,9 +35,12 @@ public class WorkStationBedVO {
@ApiModelProperty(value = "长者姓名") @ApiModelProperty(value = "长者姓名")
private String elderName; private String elderName;
@ApiModelProperty(value = "设备id")
private String deviceId;
@ApiModelProperty(value = "长者状态") @ApiModelProperty(value = "长者状态")
private String elderStatus; private String elderStatus;
@ApiModelProperty(value = "告警类型") @ApiModelProperty(value = "告警类型")
private List<String> alarmTypes; private Map<String,List<String>> alarmTypeMap;
} }
...@@ -22,8 +22,11 @@ public class WorkStationInstitutionRoomVO { ...@@ -22,8 +22,11 @@ public class WorkStationInstitutionRoomVO {
@ApiModelProperty(value = "房间id") @ApiModelProperty(value = "房间id")
private String roomId; private String roomId;
@ApiModelProperty(value = "房间名称")
private String roomName;
@ApiModelProperty(value = "房间路径") @ApiModelProperty(value = "房间路径")
private String pathName; private String pathName;
private List<WorkStationBedVO> list; private List<WorkStationInstitutionBedVO> list;
} }
...@@ -49,5 +49,49 @@ ...@@ -49,5 +49,49 @@
</where> </where>
</select> </select>
<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
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
<if test="roomIds != null and roomIds.size() > 0 ">
AND pb.room_id IN
<foreach collection="roomIds" item="item" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
</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> </mapper>
...@@ -27,6 +27,13 @@ ...@@ -27,6 +27,13 @@
#{item} #{item}
</foreach> </foreach>
</if> </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> </where>
</select> </select>
......
...@@ -8,6 +8,19 @@ ...@@ -8,6 +8,19 @@
WHERE ps.id in (SELECT parent_id FROM `plat_space` WHERE del_flag =0) and ps.del_flag = 0 WHERE ps.id in (SELECT parent_id FROM `plat_space` WHERE del_flag =0) and ps.del_flag = 0
</select> </select>
<select id="listChild" resultType="com.makeit.entity.platform.space.PlatSpace">
SELECT id,name,parent_id,type,address,longitude,latitude,parent_path,tenant_id,org_id,attribute
FROM plat_space
<where>
del_flag = 0
<if test="spaceIds != null and spaceIds.size() > 0 ">
AND (
<foreach collection="spaceIds" item="item" separator="or" open="" close="" index="">
FIND_IN_SET(#{item},parent_path) OR id = #{item}
</foreach>
)
</if>
</where>
</select>
</mapper> </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