Commit baef3ddd by lzy

空间树到床位

parent 18be80ee
...@@ -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);
}
} }
...@@ -49,4 +49,11 @@ public interface PlatSpaceService extends IService<PlatSpace> { ...@@ -49,4 +49,11 @@ 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);
} }
...@@ -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,73 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace ...@@ -142,6 +146,73 @@ 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;
}
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())){
......
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