Commit 2cf25453 by 李小龙 Committed by huangjy

fix:29482 平台端-长者管理-新增:当前入住的数据源未与账号的所在组织匹配,目前还有下级组织的空间

parent 4170a3e7
......@@ -4,7 +4,6 @@ import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.common.vo.ExcelImportVo;
import com.makeit.dto.platform.elder.PlatElderImportDTO;
import com.makeit.dto.platform.space.PlatSpaceAddDTO;
import com.makeit.dto.platform.space.PlatSpaceImportDTO;
import com.makeit.dto.platform.space.PlatSpaceQueryDTO;
......@@ -12,14 +11,17 @@ import com.makeit.dto.platform.space.PlatSpaceVO;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.FileSuffixEnum;
import com.makeit.exception.BusinessException;
import com.makeit.global.annotation.Action;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.data.excel.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
......@@ -83,7 +85,7 @@ public class PlatSpaceController {
@ApiOperation("树-到床位(未住人床位)")
@PostMapping("listTreeAuthIgnoreByBed")
public ApiResponseEntity<List<PlatSpaceVO>> listTreeAuthIgnoreByBed(@RequestBody PlatSpaceQueryDTO dto) {
List<PlatSpaceVO> data = spaceService.listBedTree(dto,true);
List<PlatSpaceVO> data = spaceService.listTreeAuthIgnoreByBed(dto,true);
return ApiResponseUtils.success(data);
}
......
......@@ -83,6 +83,8 @@ public interface PlatSpaceService extends IService<PlatSpace> {
List<PlatSpaceVO> listBedTree(PlatSpaceQueryDTO dto, boolean flag);
List<PlatSpaceVO> listTreeAuthIgnoreByBed(PlatSpaceQueryDTO dto, boolean flag);
/**
* 根据老人组织过滤空间
......
......@@ -798,6 +798,79 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return data;
}
@Override
public List<PlatSpaceVO> listTreeAuthIgnoreByBed(PlatSpaceQueryDTO dto, boolean flag) {
//29482 平台端-长者管理-新增:当前入住的数据源未与账号的所在组织匹配,目前还有下级组织的空间
PlatUserVO userVO = PlatUserUtil.getUserVO();
// List<PlatOrg> platOrgs = platOrgService.belongToScopeList(new PlatOrg());
// if(platOrgs.isEmpty()){
// return new ArrayList<>();
// }
// List<String> orgIds = platOrgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
List<String> orgIds = new ArrayList<>();
orgIds.add(userVO.getOrgId());
//床位
LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>();
if(flag){
queryWrapper1.eq(PlatBed::getStatus, CommonEnum.YES.getValue());
}
List<PlatBed> listBeds = platBedService.list(queryWrapper1);
if(listBeds.isEmpty()){
return new ArrayList<>();
}
List<String> roomIds = listBeds.stream().map(PlatBed::getRoomId).collect(Collectors.toList());
List<PlatRoom> listRoom = platRoomService.list(new QueryWrapper<PlatRoom>().lambda()
.in(PlatRoom::getId, roomIds));
List<String> spaceIds = listRoom.stream().map(PlatRoom::getSpacePath).collect(Collectors.toList());
Set<String> spaceIdList = new HashSet<>();
for(String spaceId : spaceIds){
spaceIdList.addAll(Arrays.asList(spaceId.split(",")));
}
spaceIdList.add("-1");
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());
queryWrapper.in(PlatSpace::getId, spaceIdList);
queryWrapper.in(PlatSpace::getOrgId, orgIds);
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<PlatSpaceVO> listBedTreeByElderGroup(PlatSpaceQueryDTO dto, boolean flag) {
......
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