Commit 4ca0ae19 by 朱淼

修改bug

parent 5682ce89
Showing with 461 additions and 19 deletions
...@@ -54,5 +54,7 @@ public class WechatUserInfo implements Serializable { ...@@ -54,5 +54,7 @@ public class WechatUserInfo implements Serializable {
private String token; private String token;
private String isTenant;
} }
package com.makeit.module.controller.wechat.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.wechat.elder.PlatElderCenterQueryDTO;
import com.makeit.service.wechat.PlatElderCenterWechatService;
import com.makeit.vo.wechat.elder.PlatElderCenterHomeVo;
import com.makeit.vo.wechat.elder.PlatElderCenterInstitutionRoomVO;
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;
/**
* Controller
*
* @author zm
* @version 2023/9/15
*/
@Api(tags = "平台端小程序-长者中心")
@RestController
@RequestMapping("/wechat/elder/center")
public class PlatElderCenterWechatController {
@Autowired
private PlatElderCenterWechatService platElderCenterWechatService;
@ApiOperation("居家统计列表")
@PostMapping("homeStatistics")
public ApiResponseEntity<PlatElderCenterHomeVo> homeStatistics(@RequestBody PlatElderCenterQueryDTO dto) {
return ApiResponseUtils.success(platElderCenterWechatService.homeStatistics(dto));
}
@ApiOperation("机构统计列表")
@PostMapping("institutionStatistics")
public ApiResponseEntity<PlatElderCenterInstitutionRoomVO> institutionStatistics(@RequestBody PlatElderCenterQueryDTO dto) {
return ApiResponseUtils.success(platElderCenterWechatService.institutionStatistics(dto));
}
}
...@@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* Controller * Controller
* *
...@@ -59,4 +61,11 @@ public class PlatBedWechatController { ...@@ -59,4 +61,11 @@ public class PlatBedWechatController {
platBedService.del(baseIdDTO.getId()); platBedService.del(baseIdDTO.getId());
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@ApiOperation("列表-无权限(未绑定设备床位)")
@PostMapping("listAuthIgnore")
public ApiResponseEntity<List<PlatBed>> listAuthIgnore(@RequestBody PlatBedQueryDTO dto) {
List<PlatBed> data = platBedService.list(dto);
return ApiResponseUtils.success(data);
}
} }
...@@ -3,10 +3,16 @@ package com.makeit.module.controller.wechat.space; ...@@ -3,10 +3,16 @@ package com.makeit.module.controller.wechat.space;
import com.makeit.common.dto.BaseIdDTO; import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.auth.PlatOrgDTO;
import com.makeit.dto.platform.space.PlatSpaceAddDTO; 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.space.PlatSpace;
import com.makeit.service.platform.space.PlatSpaceService; import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.user.plat.PlatUserVO;
import com.makeit.utils.user.wechat.WechatUserInfo;
import com.makeit.utils.user.wechat.WechatUserUtil;
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;
...@@ -66,4 +72,13 @@ public class PlatSpaceWechatController { ...@@ -66,4 +72,13 @@ public class PlatSpaceWechatController {
List<PlatSpaceVO> data = spaceService.tree(dto); List<PlatSpaceVO> data = spaceService.tree(dto);
return ApiResponseUtils.success(data); return ApiResponseUtils.success(data);
} }
@ApiOperation("一级空间列表(该账号权限下)")
@PostMapping("oneLevelList")
public ApiResponseEntity<List<PlatSpaceAddDTO>> oneLevelList(@RequestBody PlatOrgDTO dto) {
List<PlatSpaceAddDTO> data = spaceService.oneLevelList(dto);
return ApiResponseUtils.success(data);
}
} }
...@@ -2,6 +2,8 @@ package com.makeit.module.controller.workstation; ...@@ -2,6 +2,8 @@ package com.makeit.module.controller.workstation;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.auth.PlatOrgDTO;
import com.makeit.dto.platform.space.PlatSpaceVO;
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.*; import com.makeit.vo.platform.workstation.*;
...@@ -46,4 +48,10 @@ public class WorkStationController { ...@@ -46,4 +48,10 @@ public class WorkStationController {
public ApiResponseEntity<List<WorkStationHomeBedVO>> homeList(@RequestBody WorkStationQueryDTO dto) { public ApiResponseEntity<List<WorkStationHomeBedVO>> homeList(@RequestBody WorkStationQueryDTO dto) {
return ApiResponseUtils.success(workStationService.homeList(dto)); return ApiResponseUtils.success(workStationService.homeList(dto));
} }
@ApiOperation("空间树")
@PostMapping("spaceTree")
public ApiResponseEntity<List<PlatSpaceVO>> spaceTree(@RequestBody PlatOrgDTO dto) {
return ApiResponseUtils.success(workStationService.spaceTree(dto));
}
} }
package com.makeit.dto.platform.auth;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/15
*/
@Data
@ApiModel("PlatOrgDTO参数")
public class PlatOrgDTO {
@ApiModelProperty(value = "类型 1-居家 2-机构")
private String type;
}
...@@ -15,7 +15,7 @@ import java.util.List; ...@@ -15,7 +15,7 @@ import java.util.List;
* @version 2023/9/11 * @version 2023/9/11
*/ */
@Data @Data
@ApiModel("PlatDataScreenQueryDto参数") @ApiModel("WorkStationQueryDTO参数")
public class WorkStationQueryDTO { public class WorkStationQueryDTO {
@ApiModelProperty("组织ids") @ApiModelProperty("组织ids")
......
package com.makeit.dto.wechat.elder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/15
*/
@Data
@ApiModel("PlatElderCenterQueryDTO参数")
public class PlatElderCenterQueryDTO {
@ApiModelProperty("空间id")
private String spaceId;
}
...@@ -25,5 +25,5 @@ public interface PlatBedMapper extends BaseMapper<PlatBed> { ...@@ -25,5 +25,5 @@ public interface PlatBedMapper extends BaseMapper<PlatBed> {
List<WorkStationInstitutionBedVO> selectByRoomIds(@Param("roomIds")List<String> roomIds); List<WorkStationInstitutionBedVO> selectByRoomIds(@Param("roomIds")List<String> roomIds);
List<WorkStationHomeBedVO> selectByCondition(WorkStationQueryDTO dto); List<WorkStationHomeBedVO> selectByCondition(@Param("dto")WorkStationQueryDTO dto);
} }
...@@ -459,7 +459,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg> ...@@ -459,7 +459,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
@Override @Override
public List<PlatOrg> belongToScopeList(PlatOrg param) { public List<PlatOrg> belongToScopeList(PlatOrg param) {
PlatUserVO userVO = PlatUserUtil.getUserVO(); PlatUserVO userVO = PlatUserUtil.getUserVOCanNull();
String isTenant = userVO.getIsTenant(); String isTenant = userVO.getIsTenant();
//如果是租户账号 则有所有权限 //如果是租户账号 则有所有权限
if (StringUtils.equals(isTenant, CommonEnum.YES.getValue())) { if (StringUtils.equals(isTenant, CommonEnum.YES.getValue())) {
......
package com.makeit.service.platform.space; package com.makeit.service.platform.space;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.dto.platform.auth.PlatOrgDTO;
import com.makeit.dto.platform.space.PlatSpaceAddDTO; 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.utils.user.wechat.WechatUserInfo;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO; import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Author:lzy * @Author:lzy
...@@ -58,4 +61,10 @@ public interface PlatSpaceService extends IService<PlatSpace> { ...@@ -58,4 +61,10 @@ public interface PlatSpaceService extends IService<PlatSpace> {
List<PlatSpaceVO> treeByBed(PlatSpaceQueryDTO dto); List<PlatSpaceVO> treeByBed(PlatSpaceQueryDTO dto);
List<PlatSpace> listChild(List<String> spaceIds); List<PlatSpace> listChild(List<String> spaceIds);
List<PlatSpaceAddDTO> oneLevelList(PlatOrgDTO dtom);
PlatSpaceVO child(PlatSpaceVO vo, Map<String,List<PlatSpace>> map);
PlatSpaceVO convertToVO(PlatSpace space);
} }
...@@ -56,6 +56,7 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService { ...@@ -56,6 +56,7 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
//空间下的房间 //空间下的房间
List<PlatRoom> rooms = platRoomService.list(new QueryWrapper<PlatRoom>().lambda() List<PlatRoom> rooms = platRoomService.list(new QueryWrapper<PlatRoom>().lambda()
.in(PlatRoom::getSpaceId,spaceIds)); .in(PlatRoom::getSpaceId,spaceIds));
Map<String,List<PlatRoom>> spaceRoomMap = rooms.stream().collect(Collectors.groupingBy(PlatRoom::getSpaceId));
List<String> roomIds = rooms.stream().map(PlatRoom::getId).collect(Collectors.toList()); List<String> roomIds = rooms.stream().map(PlatRoom::getId).collect(Collectors.toList());
List<PlatBed> beds = platBedService.list(new QueryWrapper<PlatBed>().lambda() List<PlatBed> beds = platBedService.list(new QueryWrapper<PlatBed>().lambda()
.in(PlatBed::getRoomId,roomIds)); .in(PlatBed::getRoomId,roomIds));
...@@ -65,10 +66,13 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService { ...@@ -65,10 +66,13 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
platRoomPanoramaVO.setSpaceName(space.getName()); platRoomPanoramaVO.setSpaceName(space.getName());
platRoomPanoramaVO.setSpaceId(dto.getId()); platRoomPanoramaVO.setSpaceId(dto.getId());
List<PlatRoomVO> roomVOList = new ArrayList<>(); List<PlatRoomVO> roomVOList = new ArrayList<>();
for(PlatRoom room : rooms){ if(spaceRoomMap.get(space.getId())!=null){
for(PlatRoom room : spaceRoomMap.get(space.getId())){
PlatRoomVO vo = convertToVO(room,bedMap); PlatRoomVO vo = convertToVO(room,bedMap);
roomVOList.add(vo); roomVOList.add(vo);
} }
}
platRoomPanoramaVO.setChildren(roomVOList); platRoomPanoramaVO.setChildren(roomVOList);
list.add(platRoomPanoramaVO); list.add(platRoomPanoramaVO);
} }
......
package com.makeit.service.platform.space.impl; package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.dto.platform.auth.PlatOrgDTO;
import com.makeit.dto.platform.space.PlatSpaceAddDTO; 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;
...@@ -19,6 +21,8 @@ import com.makeit.service.platform.space.PlatSpaceService; ...@@ -19,6 +21,8 @@ import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.user.plat.PlatUserUtil; import com.makeit.utils.user.plat.PlatUserUtil;
import com.makeit.utils.user.plat.PlatUserVO; import com.makeit.utils.user.plat.PlatUserVO;
import com.makeit.utils.user.wechat.WechatUserInfo;
import com.makeit.utils.user.wechat.WechatUserUtil;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO; 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;
...@@ -203,6 +207,23 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -203,6 +207,23 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
} }
@Override
public List<PlatSpaceAddDTO> oneLevelList(PlatOrgDTO dto) {
//获取该账号的权限组织
PlatOrg param = new PlatOrg();
param.setType(dto.getType());
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
if(orgs.isEmpty()){
return new ArrayList<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
List<PlatSpace> spaces = list(new QueryWrapper<PlatSpace>().lambda()
.isNull(PlatSpace::getParentId)
.in(PlatSpace::getOrgId, orgIds));
return BeanDtoVoUtils.listVo(spaces, PlatSpaceAddDTO.class);
}
private PlatSpaceVO childVo(PlatSpaceVO vo,Map<String,List<PlatSpaceVO>> map) { private PlatSpaceVO childVo(PlatSpaceVO vo,Map<String,List<PlatSpaceVO>> map) {
if (!map.containsKey(vo.getId())) { if (!map.containsKey(vo.getId())) {
...@@ -220,8 +241,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -220,8 +241,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
} }
@Override
private PlatSpaceVO child(PlatSpaceVO vo,Map<String,List<PlatSpace>> map){ public PlatSpaceVO child(PlatSpaceVO vo,Map<String,List<PlatSpace>> map){
if(!map.containsKey(vo.getId())){ if(!map.containsKey(vo.getId())){
return vo; return vo;
...@@ -238,7 +259,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -238,7 +259,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return vo; return vo;
} }
private PlatSpaceVO convertToVO(PlatSpace space){ @Override
public PlatSpaceVO convertToVO(PlatSpace space){
PlatSpaceVO vo = new PlatSpaceVO(); PlatSpaceVO vo = new PlatSpaceVO();
vo.setName(space.getName()); vo.setName(space.getName());
......
package com.makeit.service.platform.workstation; package com.makeit.service.platform.workstation;
import com.makeit.dto.platform.auth.PlatOrgDTO;
import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO; import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.vo.platform.workstation.*; import com.makeit.vo.platform.workstation.*;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Controller * Controller
...@@ -21,4 +25,8 @@ public interface WorkStationService { ...@@ -21,4 +25,8 @@ public interface WorkStationService {
WorkStationHomeStatisticsVO homeStatistics(WorkStationQueryDTO dto); WorkStationHomeStatisticsVO homeStatistics(WorkStationQueryDTO dto);
List<WorkStationHomeBedVO> homeList(WorkStationQueryDTO dto); List<WorkStationHomeBedVO> homeList(WorkStationQueryDTO dto);
List<PlatSpaceVO> spaceTree(PlatOrgDTO dto);
Map<String, Map<String,List<String>>> mapElderAlarmType(List<PlatAlarmRecord> alarmRecords);
} }
package com.makeit.service.platform.workstation.impl; package com.makeit.service.platform.workstation.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.auth.PlatOrgDTO;
import com.makeit.dto.platform.elder.PlatElderIdDTO; import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.dto.platform.space.PlatSpaceVO;
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;
...@@ -199,7 +201,8 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -199,7 +201,8 @@ public class WorkStationServiceImpl implements WorkStationService {
return roomVOList; return roomVOList;
} }
private Map<String, Map<String,List<String>>> mapElderAlarmType(List<PlatAlarmRecord> alarmRecords) { @Override
public Map<String, Map<String,List<String>>> mapElderAlarmType(List<PlatAlarmRecord> alarmRecords) {
Map<String, Map<String,List<String>>> map = new HashMap<>(); Map<String, Map<String,List<String>>> map = new HashMap<>();
alarmRecords.forEach(a -> { alarmRecords.forEach(a -> {
if (StringUtil.isNotEmpty(a.getElderIds())) { if (StringUtil.isNotEmpty(a.getElderIds())) {
...@@ -355,4 +358,34 @@ public class WorkStationServiceImpl implements WorkStationService { ...@@ -355,4 +358,34 @@ public class WorkStationServiceImpl implements WorkStationService {
} }
return list; return list;
} }
@Override
public List<PlatSpaceVO> spaceTree(PlatOrgDTO dto) {
List<PlatSpaceVO> data = new ArrayList<>();
//获取该账号的权限组织
PlatOrg param = new PlatOrg();
param.setType(dto.getType());
List<PlatOrg> orgs = platOrgService.belongToScopeList(param);
if(orgs.isEmpty()){
return data;
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
List<PlatSpace> list = platSpaceService.list(new QueryWrapper<PlatSpace>().lambda()
.in(PlatSpace::getOrgId, orgIds));
//父级
List<PlatSpace> listParent = list.stream().filter(item->StringUtil.isEmpty(item.getParentId())).collect(Collectors.toList());
//子集
List<PlatSpace> listChild = list.stream().filter(item->item.getParentId() != null).collect(Collectors.toList());
Map<String,List<PlatSpace>> map = listChild.stream().collect(Collectors.groupingBy(PlatSpace::getParentId));
for(PlatSpace space:listParent){
PlatSpaceVO vo = platSpaceService.convertToVO(space);
vo = platSpaceService.child(vo,map);
data.add(vo);
}
return data;
}
} }
package com.makeit.service.wechat;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.dto.wechat.elder.PlatElderCenterQueryDTO;
import com.makeit.vo.wechat.elder.PlatElderCenterHomeVo;
import com.makeit.vo.wechat.elder.PlatElderCenterInstitutionRoomVO;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
public interface PlatElderCenterWechatService {
PlatElderCenterHomeVo homeStatistics(PlatElderCenterQueryDTO dto);
PlatElderCenterInstitutionRoomVO institutionStatistics(PlatElderCenterQueryDTO dto);
}
package com.makeit.service.wechat.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.dto.platform.workstation.WorkStationQueryDTO;
import com.makeit.dto.wechat.elder.PlatElderCenterQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmConfig;
import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.platform.alarm.PlatAlarmRecordEnum;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.elder.PlatElderRealTimeService;
import com.makeit.service.platform.elder.PlatElderService;
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.service.wechat.PlatElderCenterWechatService;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO;
import com.makeit.vo.platform.workstation.WorkStationInstitutionRoomVO;
import com.makeit.vo.wechat.elder.PlatElderCenterHomeVo;
import com.makeit.vo.wechat.elder.PlatElderCenterInstitutionRoomVO;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* Controller
*
* @author zm
* @version 2023/9/7
*/
@Service
public class PlatElderCenterWechatServiceImpl implements PlatElderCenterWechatService {
@Autowired
private PlatSpaceService platSpaceService;
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatAlarmRecordService platAlarmRecordService;
@Autowired
private WorkStationService workStationService;
@Autowired
private PlatElderRealTimeService platElderRealTimeService;
@Autowired
private PlatBedService platBedService;
@Autowired
private PlatRoomService platRoomService;
@Override
public PlatElderCenterHomeVo homeStatistics(PlatElderCenterQueryDTO dto) {
PlatElderCenterHomeVo homeVo = new PlatElderCenterHomeVo();
PlatSpace space = platSpaceService.getById(dto.getSpaceId());
//获取空间老人
List<PlatElder> elders = platElderService.list(new QueryWrapper<PlatElder>().lambda()
.apply(StringUtils.isNotBlank(dto.getSpaceId()), "find_in_set('" + dto.getSpaceId() + "',space_path)")
);
if(elders.isEmpty()){
homeVo.setList(new ArrayList<>());
homeVo.setElderNumber(0);
return homeVo;
}
List<String> elderIds = elders.stream().map(PlatElder::getId).collect(Collectors.toList());
//获取父级的所有子级空间
List<PlatSpace> spaces = platSpaceService.listChild(Arrays.asList(dto.getSpaceId()));
List<String> spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList());
List<PlatAlarmRecord> alarmRecords = platAlarmRecordService.list(
new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue())
.eq(PlatAlarmRecord::getOrgId, space.getOrgId())
);
//长者对应的报警类型
Map<String, Map<String,List<String>>> elderAlarmTypeMap = workStationService.mapElderAlarmType(alarmRecords);
WorkStationQueryDTO queryDTO = new WorkStationQueryDTO();
queryDTO.setSpaceIds(spaceIds);
queryDTO.setElderIds(elderIds);
List<WorkStationHomeBedVO> list = platBedService.selectByCondition(queryDTO);
JoinUtil.joinSplit(list, platSpaceService, WorkStationHomeBedVO::getSpacePath, PlatSpace::getId, (e, l) -> {
e.setPathName(StreamUtil.join(l, Objects::nonNull, PlatSpace::getName, "-"));
});
for(WorkStationHomeBedVO vo : list){
vo.setPathName(vo.getPathName() + "-" + vo.getRoomName());
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());
}
}
}
homeVo.setElderNumber(elders.size());
homeVo.setList(list);
return homeVo;
}
@Override
public PlatElderCenterInstitutionRoomVO institutionStatistics(PlatElderCenterQueryDTO dto) {
PlatElderCenterInstitutionRoomVO institutionRoomVO = new PlatElderCenterInstitutionRoomVO();
PlatSpace space = platSpaceService.getById(dto.getSpaceId());
//获取空间老人
List<PlatElder> elders = platElderService.list(new QueryWrapper<PlatElder>().lambda()
.apply(StringUtils.isNotBlank(dto.getSpaceId()), "find_in_set('" + dto.getSpaceId() + "',space_path)")
);
List<String> elderIds = elders.stream().map(PlatElder::getId).collect(Collectors.toList());
//获取父级的所有子级空间
List<PlatSpace> spaces = platSpaceService.listChild(Arrays.asList(dto.getSpaceId()));
List<String> spaceIds = spaces.stream().map(PlatSpace::getId).collect(Collectors.toList());
List<PlatAlarmRecord> alarmRecords = platAlarmRecordService.list(
new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getStatus, PlatAlarmRecordEnum.AlarmRecordStatusEnum.UNHANDLED.getValue())
.eq(PlatAlarmRecord::getOrgId, space.getOrgId())
);
WorkStationQueryDTO queryDTO = new WorkStationQueryDTO();
queryDTO.setSpaceIds(spaceIds);
queryDTO.setElderIds(elderIds);
List<WorkStationInstitutionRoomVO> roomVOList = platRoomService.workStationList(queryDTO);
if (roomVOList.isEmpty()) {
institutionRoomVO.setList(new ArrayList<>());
institutionRoomVO.setElderNumber(0);
return institutionRoomVO;
}
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));
JoinUtil.joinSplit(roomVOList, platSpaceService, WorkStationInstitutionRoomVO::getSpacePath, PlatSpace::getId, (e, l) -> {
e.setPathName(StreamUtil.join(l, Objects::nonNull, PlatSpace::getName, "-"));
});
//长者对应的报警类型
Map<String, Map<String,List<String>>> elderAlarmTypeMap = workStationService.mapElderAlarmType(alarmRecords);
for (WorkStationInstitutionRoomVO roomVo : roomVOList) {
WorkStationInstitutionRoomVO vo = new WorkStationInstitutionRoomVO();
vo.setRoomId(roomVo.getRoomId());
vo.setPathName(vo.getPathName() + "-" + vo.getRoomName());
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);
}
}
institutionRoomVO.setElderNumber(elders.size());
institutionRoomVO.setList(roomVOList);
return institutionRoomVO;
}
}
...@@ -23,7 +23,7 @@ public class PlatSpaceAndRoomVO extends BaseIdDTO { ...@@ -23,7 +23,7 @@ public class PlatSpaceAndRoomVO extends BaseIdDTO {
@ApiModelProperty("父级Id") @ApiModelProperty("父级Id")
private String parentId; private String parentId;
@ApiModelProperty("类型 0-空间 1-房间") @ApiModelProperty("类型 1-空间 2-房间")
private String type; private String type;
@ApiModelProperty("子集") @ApiModelProperty("子集")
......
package com.makeit.vo.wechat.elder;
import com.makeit.vo.platform.workstation.WorkStationHomeBedVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/15
*/
@Data
public class PlatElderCenterHomeVo {
@ApiModelProperty(value = "长者数")
private Integer elderNumber;
private List<WorkStationHomeBedVO> list;
}
package com.makeit.vo.wechat.elder;
import com.makeit.vo.platform.workstation.WorkStationInstitutionRoomVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* Controller
*
* @author zm
* @version 2023/9/15
*/
@Data
public class PlatElderCenterInstitutionRoomVO {
@ApiModelProperty(value = "长者数")
private Integer elderNumber;
private List<WorkStationInstitutionRoomVO> list;
}
...@@ -50,12 +50,12 @@ ...@@ -50,12 +50,12 @@
</select> </select>
<select id="selectByRoomIds" resultType="com.makeit.vo.platform.workstation.WorkStationInstitutionBedVO"> <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 SELECT pb.`name` as bedName, pb.id as bedId, pb.room_id as roomId , pe.id as elderId, pb.name as elderName, prbd.device_id as deviceId
FROM plat_bed pb FROM plat_bed pb
LEFT JOIN plat_elder pe ON pe.bed_id = pb.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 LEFT JOIN plat_room_bed_device prbd ON prbd.bed_id = pb.id
<where> <where>
pb.del_flag = 0 and pe.del_flag = 0 and rpbd.del_flag = 0 pb.del_flag = 0 and pe.del_flag = 0 and prbd.del_flag = 0
<if test="roomIds != null and roomIds.size() > 0 "> <if test="roomIds != null and roomIds.size() > 0 ">
AND pb.room_id IN AND pb.room_id IN
<foreach collection="roomIds" item="item" separator="," open="(" close=")" index=""> <foreach collection="roomIds" item="item" separator="," open="(" close=")" index="">
...@@ -68,12 +68,12 @@ ...@@ -68,12 +68,12 @@
<select id="selectByCondition" resultType="com.makeit.vo.platform.workstation.WorkStationHomeBedVO"> <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 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 FROM plat_bed pb
LEFT JOIN plat_room pr ON pr.id = pb.room_id LEFT JOIN plat_room pm ON pm.id = pb.room_id
LEFT JOIN plat_space ps ON ps.id = pr.space_id LEFT JOIN plat_space ps ON ps.id = pm.space_id
LEFT JOIN plat_elder pe ON pe.bed_id = pb.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 LEFT JOIN plat_room_bed_device prbd ON prbd.bed_id = pb.id
<where> <where>
pb.del_flag = 0 and pe.del_flag = 0 and rpbd.del_flag = 0 and pb.status = 0 pb.del_flag = 0 and pe.del_flag = 0 and prbd.del_flag = 0 and pb.status = 0
<if test="dto.elderName != null and dto.elderName != ''"> <if test="dto.elderName != null and dto.elderName != ''">
AND pe.naem LIKE CONCAT('%',#{dto.elderName},'%') AND pe.naem LIKE CONCAT('%',#{dto.elderName},'%')
</if> </if>
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
</foreach> </foreach>
</if> </if>
</where> </where>
order by pr.room_id order by pb.room_id
</select> </select>
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.makeit.mapper.platform.space.PlatRoomMapper"> <mapper namespace="com.makeit.mapper.platform.space.PlatRoomMapper">
<select id="spaceAndRoomList" resultType="com.makeit.vo.platform.space.PlatSpaceAndRoomVO"> <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 SELECT ps.id,ps.`name`,ps.parent_id as parentId,'1' as type FROM plat_space ps
WHERE ps.del_flag = 0 WHERE ps.del_flag = 0
UNION UNION
SELECT pr.id,pr.`name`,pr.space_id as parentId,'1' as type FROM plat_room pr SELECT pr.id,pr.`name`,pr.space_id as parentId,'2' as type FROM plat_room pr
WHERE pr.del_flag = 0 WHERE pr.del_flag = 0
</select> </select>
......
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