|
@@ -86,42 +86,7 @@ public class WebTenantGatewayImpl implements WebTenantGateway {
|
|
|
Page<TblTenant> tenantList = tblTenantService.queryTenantList(req);
|
|
|
// 换为目标VO
|
|
|
List<TenantDto> targets = CopyUtils.copyList(tenantList.getRecords(), TenantDto.class);
|
|
|
- if (!req.isEnabled() || CollectionUtils.isEmpty(targets)) {
|
|
|
- return CopyUtils.copyPage(tenantList, targets);
|
|
|
- }
|
|
|
|
|
|
- // 如果需要级联查询 查询三级信息 租户信息 --》 楼栋信息 --》 楼层信息
|
|
|
- List<TblTenantInfo> list = tblTenantInfoService.queryByTenantIds(targets.stream().map(TenantDto::getTenantId).collect(Collectors.toList()));
|
|
|
- Map<Long, Map<String, List<TblTenantInfo>>> map = list.stream().collect(Collectors.groupingBy(
|
|
|
- info -> Optional.ofNullable(info.getTenantId()).orElse(-1L),
|
|
|
- Collectors.groupingBy(
|
|
|
- info -> Optional.ofNullable(info.getTinfoType()).orElse("DEFAULT"),
|
|
|
- Collectors.toList()
|
|
|
- )
|
|
|
- ));
|
|
|
-
|
|
|
- for (TenantDto target : targets) {
|
|
|
- Map<String, List<TblTenantInfo>> tenantInfoMap = map.get(target.getTenantId());
|
|
|
- if (!CollectionUtils.isEmpty(tenantInfoMap)) {
|
|
|
-
|
|
|
- List<TblTenantInfo> buildings = tenantInfoMap.get(TinfoType.COMMUNITY_BUILDING.getCode());
|
|
|
- List<TblTenantInfo> floors = tenantInfoMap.get(TinfoType.UNIT_FLOOR.getCode());
|
|
|
- Map<Long, List<TblTenantInfo>> floorMap = new HashMap<>();
|
|
|
- if (!CollectionUtils.isEmpty(floors)) {
|
|
|
- floorMap = floors.stream().collect(Collectors.groupingBy(TblTenantInfo::getParentId));
|
|
|
- }
|
|
|
-
|
|
|
- if (!CollectionUtils.isEmpty(buildings)) {
|
|
|
- List<TenantInfoDto> buildingList = new ArrayList<>();
|
|
|
- for (TblTenantInfo building : buildings) {
|
|
|
- TenantInfoDto copy = CopyUtils.copy(building, TenantInfoDto.class);
|
|
|
- copy.setChildren(CopyUtils.copyList(floorMap.get(building.getTinfoId()), TenantInfoDto.class));
|
|
|
- buildingList.add(copy);
|
|
|
- }
|
|
|
- target.setChildren(buildingList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
return CopyUtils.copyPage(tenantList, targets);
|
|
|
}
|
|
|
|
|
@@ -209,4 +174,40 @@ public class WebTenantGatewayImpl implements WebTenantGateway {
|
|
|
userRole.setRoleId(req.getRoleId());
|
|
|
tblUserRoleService.save(userRole);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TenantInfoDto> queryTenantInfo(Long tenantId) {
|
|
|
+
|
|
|
+ TblTenant tblTenant = tblTenantService.getById(tenantId);
|
|
|
+ if (tblTenant == null) {
|
|
|
+ throw new BizException(ErrorEnum.DATA_NOT_EXISTS.getErrorCode(), ErrorEnum.DATA_NOT_EXISTS.getErrorMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TblTenantInfo> list = tblTenantInfoService.queryByTenantIds(Arrays.asList(tenantId));
|
|
|
+
|
|
|
+ Map<String, List<TblTenantInfo>> tenantInfoMap = list.stream().collect(
|
|
|
+ Collectors.groupingBy(
|
|
|
+ info -> Optional.ofNullable(info.getTinfoType()).orElse("DEFAULT"),
|
|
|
+ Collectors.toList()
|
|
|
+ ));
|
|
|
+
|
|
|
+ List<TblTenantInfo> buildings = tenantInfoMap.get(TinfoType.COMMUNITY_BUILDING.getCode());
|
|
|
+ List<TblTenantInfo> floors = tenantInfoMap.get(TinfoType.UNIT_FLOOR.getCode());
|
|
|
+
|
|
|
+ List<TenantInfoDto> buildingList = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(buildings)) {
|
|
|
+ Map<Long, List<TblTenantInfo>> floorMap = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(floors)) {
|
|
|
+ floorMap = floors.stream().collect(Collectors.groupingBy(TblTenantInfo::getParentId));
|
|
|
+ }
|
|
|
+ for (TblTenantInfo building : buildings) {
|
|
|
+ TenantInfoDto copy = CopyUtils.copy(building, TenantInfoDto.class);
|
|
|
+ copy.setChildren(CopyUtils.copyList(floorMap.get(building.getTinfoId()), TenantInfoDto.class));
|
|
|
+ buildingList.add(copy);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return buildingList;
|
|
|
+ }
|
|
|
}
|