diff --git a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/OverviewServiceImpl.java b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/OverviewServiceImpl.java index fd5363d..c0f302c 100644 --- a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/OverviewServiceImpl.java +++ b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/OverviewServiceImpl.java @@ -95,6 +95,12 @@ public class OverviewServiceImpl implements OverviewService { MonitoringPointCategorySearchParams categorySearchParam = new MonitoringPointCategorySearchParams(); categorySearchParam.setCompanyIdList(List.of(companyId)); List categoryList = monitoringPointCategoryMapperExt.getListPage(categorySearchParam); + + List allCategoryIds = categoryList.stream() + .map(MonitoringPointCategoryPageVO::getMonitoringPointCategoryId) + .filter(Objects::nonNull) + .toList(); + //所有楼宇的监测点分类 Map allCategoryParamMap = new HashMap<>(); allCategoryParamMap.put("companyId", companyId); @@ -113,16 +119,17 @@ public class OverviewServiceImpl implements OverviewService { )); Map> notExistingCategoryMap = new HashMap<>(); - existingCategoryMap.forEach((buildingId, existingCategoryIds) -> { - List missingCategoryIds = - categoryList.stream() - .map(MonitoringPointCategoryPageVO::getMonitoringPointCategoryId) - .filter(Objects::nonNull) - .filter(id -> !existingCategoryIds.contains(id)) - .collect(Collectors.toList()); - - notExistingCategoryMap.put(buildingId, missingCategoryIds); - }); + for (OverviewVO building : buildingInfoList) { + Long buildingId = building.getBuildingId(); + Set existingIds = existingCategoryMap.getOrDefault(buildingId, Collections.emptySet()); + List missingIds = new ArrayList<>(); + for (Long categoryId : allCategoryIds) { + if (!existingIds.contains(categoryId)) { + missingIds.add(categoryId); + } + } + notExistingCategoryMap.put(buildingId, missingIds); + } return notExistingCategoryMap; }