两个list直接可以根据两个list中相同的字段直接查询出需要的值
public List<BuildingUnitHouseListVO> getBuildingUnitHouseListVO(String buildCode) {
List<BuildingUnitHouseListVO> listVOS=new ArrayList<>();
List<BuildingUnitVO> buildingUnitVO = buildingHouseMapper.getBuildingUnitVO(buildCode);
List<BuildingUnitHouseVO> buildingUnitHouseVO = buildingHouseMapper.getBuildingUnitHouseVO(buildCode);
for (BuildingUnitVO buildingUnit:buildingUnitVO){
BuildingUnitHouseListVO buildingUnitHouseListVO=new BuildingUnitHouseListVO();
List<BuildingUnitHouseVO> collect = buildingUnitHouseVO.stream().filter(s -> s.getUnit().equals(buildingUnit.getUnit()) && s.getFloor().equals(buildingUnit.getFloor())).collect(Collectors.toList());
buildingUnitHouseListVO.setBuildingUnitHouseVOList(collect);
buildingUnitHouseListVO.setUnit(buildingUnit.getUnit());
buildingUnitHouseListVO.setFloor(buildingUnit.getFloor());
listVOS.add(buildingUnitHouseListVO);
}
return listVOS;
}