Commit 8fd1b67e authored by lixuan's avatar lixuan

feat: 房源

parent 4f8b071c
Pipeline #145588 canceled with stages
...@@ -391,55 +391,78 @@ public class HouseResourceServiceImpl implements HouseResourceService { ...@@ -391,55 +391,78 @@ public class HouseResourceServiceImpl implements HouseResourceService {
return new BusinessEntityStatisticsDetail(); return new BusinessEntityStatisticsDetail();
} }
BusinessEntityStatisticsDetail businessEntityStatisticsDetail = new BusinessEntityStatisticsDetail(); BusinessEntityStatisticsDetail businessEntityStatisticsDetail = new BusinessEntityStatisticsDetail();
businessEntityStatisticsDetail.setLyCount(list.stream().filter(x -> x.getType() == 1).count());
businessEntityStatisticsDetail.setJdCount(list.stream().filter(x -> x.getType() == 4).count()); CompletableFuture<Long> lyCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 1).count(), executor);
businessEntityStatisticsDetail.setJqCount(list.stream().filter(x -> x.getType() == 5).count()); CompletableFuture<Long> jdCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 4).count(), executor);
businessEntityStatisticsDetail.setZhtCount(list.stream().filter(x -> x.getType() == 6).count()); CompletableFuture<Long> jqCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 5).count(), executor);
businessEntityStatisticsDetail.setScCount(list.stream().filter(x -> x.getType() == 7).count()); CompletableFuture<Long> zhtCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 6).count(), executor);
CompletableFuture<Long> scCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 7).count(), executor);
businessEntityStatisticsDetail.setSjLyCount(list.stream().filter(x -> x.getType() == 1).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size());
businessEntityStatisticsDetail.setSjJdCount(list.stream().filter(x -> x.getType() == 4).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size()); CompletableFuture<Integer> sjLyCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 1).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size(), executor);
businessEntityStatisticsDetail.setSjJqCount(list.stream().filter(x -> x.getType() == 5).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size()); CompletableFuture<Integer> sjJdCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 4).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size(), executor);
businessEntityStatisticsDetail.setSjZhtCount(list.stream().filter(x -> x.getType() == 6).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size()); CompletableFuture<Integer> sjJqCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 5).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size(), executor);
businessEntityStatisticsDetail.setSjScCount(list.stream().filter(x -> x.getType() == 7).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size()); CompletableFuture<Integer> sjZhtCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 6).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size(), executor);
CompletableFuture<Integer> sjScCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getType() == 7).collect(Collectors.groupingBy(HouseResourcePage::getThree)).size(), executor);
businessEntityStatisticsDetail.setZlCount(list.stream().filter(x -> x.getHouseResourceAttribute() == 0).count());
businessEntityStatisticsDetail.setZyCount(list.stream().filter(x -> x.getHouseResourceAttribute() == 2).count()); CompletableFuture<Long> zlCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getHouseResourceAttribute() == 0).count(), executor);
businessEntityStatisticsDetail.setQtCount(list.stream().filter(x -> x.getHouseResourceAttribute() == 1).count()); CompletableFuture<Long> zyCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getHouseResourceAttribute() == 2).count(), executor);
CompletableFuture<Long> qtCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getHouseResourceAttribute() == 1).count(), executor);
businessEntityStatisticsDetail.setZaiyingCount(list.stream().filter(x -> x.getHouseResourceType() == 0).count());
businessEntityStatisticsDetail.setXzCount(list.stream().filter(x -> x.getHouseResourceType() == 1).count()); CompletableFuture<Long> zaiyingCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getHouseResourceType() == 0).count(), executor);
businessEntityStatisticsDetail.setGkCount(list.stream().filter(x -> x.getHouseResourceType() == 2).count()); CompletableFuture<Long> xzCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getHouseResourceType() == 1).count(), executor);
businessEntityStatisticsDetail.setSbCount(list.stream().filter(x -> x.getHouseResourceType() == 3).count()); CompletableFuture<Long> gkCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getHouseResourceType() == 2).count(), executor);
businessEntityStatisticsDetail.setZyzyCount(list.stream().filter(x -> x.getHouseResourceType() == 4).count()); CompletableFuture<Long> sbCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getHouseResourceType() == 3).count(), executor);
CompletableFuture<Long> zyzyCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> x.getHouseResourceType() == 4).count(), executor);
businessEntityStatisticsDetail.setXsCount(list.stream().map(HouseResourcePage::getIncome).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
businessEntityStatisticsDetail.setSsCount(list.stream().map(HouseResourcePage::getTaxCount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)); CompletableFuture<BigDecimal> xsCountFuture = CompletableFuture.supplyAsync(() -> list.stream().map(HouseResourcePage::getIncome).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add), executor);
businessEntityStatisticsDetail.setGsCount(list.stream().filter(x -> Objects.nonNull(x.getGs())).filter(x -> x.getGs().equals(Boolean.TRUE)).count()); CompletableFuture<BigDecimal> ssCountFuture = CompletableFuture.supplyAsync(() -> list.stream().map(HouseResourcePage::getTaxCount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add), executor);
CompletableFuture<Long> gsCountFuture = CompletableFuture.supplyAsync(() -> list.stream().filter(x -> Objects.nonNull(x.getGs()) && x.getGs().equals(Boolean.TRUE)).count(), executor);
List<String> houseResourceIds = list.stream().map(HouseResourcePage::getId).collect(Collectors.toList()); List<String> houseResourceIds = list.stream().map(HouseResourcePage::getId).collect(Collectors.toList());
List<HouseResourceBusinessEntityInfoMapping> houseResourceMappings = houseResourceBusinessEntityInfoMappingMapper.selectByHouseResourceIds(houseResourceIds); List<HouseResourceBusinessEntityInfoMapping> houseResourceMappings = houseResourceBusinessEntityInfoMappingMapper.selectByHouseResourceIds(houseResourceIds);
if (CollectionUtils.isEmpty(houseResourceMappings)) { List<BusinessEntityInfo> businessEntityInfos = CollectionUtils.isEmpty(houseResourceMappings) ? Collections.emptyList() :
return businessEntityStatisticsDetail; businessEntityInfoMapper.selectByIdList(houseResourceMappings.stream().map(HouseResourceBusinessEntityInfoMapping::getBusinessEntityInfoId).collect(Collectors.toList()));
}
List<BusinessEntityInfo> businessEntityInfos = businessEntityInfoMapper.selectByIdList(houseResourceMappings.stream().map(HouseResourceBusinessEntityInfoMapping::getBusinessEntityInfoId).collect(Collectors.toList()));
if (CollectionUtils.isEmpty(businessEntityInfos)) {
return businessEntityStatisticsDetail;
}
businessEntityStatisticsDetail.setZtCount(businessEntityInfos.size()); businessEntityStatisticsDetail.setZtCount(businessEntityInfos.size());
Map<String, BigDecimal> industrySellMap = Arrays.asList("工业", "建筑业", "批发", "零售", "住宿", "餐饮", "服务业", "其他") List<String> industries = Arrays.asList("工业", "建筑业", "批发", "零售", "住宿", "餐饮", "服务业", "其他");
.parallelStream() Map<String, CompletableFuture<BigDecimal>> industrySellFutures = industries.stream()
.collect(Collectors.toMap(industry -> industry, industry -> getIndustrySellCount(businessEntityInfos, industry, businessEntitySellMapper))); .collect(Collectors.toMap(industry -> industry,
industry -> CompletableFuture.supplyAsync(() -> getIndustrySellCount(businessEntityInfos, industry, businessEntitySellMapper), executor)));
businessEntityStatisticsDetail.setGyCount(industrySellMap.getOrDefault("工业", BigDecimal.ZERO));
businessEntityStatisticsDetail.setJzyCount(industrySellMap.getOrDefault("建筑业", BigDecimal.ZERO)); businessEntityStatisticsDetail.setLyCount(lyCountFuture.join());
businessEntityStatisticsDetail.setPfCount(industrySellMap.getOrDefault("批发", BigDecimal.ZERO)); businessEntityStatisticsDetail.setJdCount(jdCountFuture.join());
businessEntityStatisticsDetail.setLsCount(industrySellMap.getOrDefault("零售", BigDecimal.ZERO)); businessEntityStatisticsDetail.setJqCount(jqCountFuture.join());
businessEntityStatisticsDetail.setZsCount(industrySellMap.getOrDefault("住宿", BigDecimal.ZERO)); businessEntityStatisticsDetail.setZhtCount(zhtCountFuture.join());
businessEntityStatisticsDetail.setCyCount(industrySellMap.getOrDefault("餐饮", BigDecimal.ZERO)); businessEntityStatisticsDetail.setScCount(scCountFuture.join());
businessEntityStatisticsDetail.setFwyCount(industrySellMap.getOrDefault("服务业", BigDecimal.ZERO));
businessEntityStatisticsDetail.setQtjjfzCount(industrySellMap.getOrDefault("其他", BigDecimal.ZERO)); businessEntityStatisticsDetail.setSjLyCount(sjLyCountFuture.join());
businessEntityStatisticsDetail.setSjJdCount(sjJdCountFuture.join());
businessEntityStatisticsDetail.setSjJqCount(sjJqCountFuture.join());
businessEntityStatisticsDetail.setSjZhtCount(sjZhtCountFuture.join());
businessEntityStatisticsDetail.setSjScCount(sjScCountFuture.join());
businessEntityStatisticsDetail.setZlCount(zlCountFuture.join());
businessEntityStatisticsDetail.setZyCount(zyCountFuture.join());
businessEntityStatisticsDetail.setQtCount(qtCountFuture.join());
businessEntityStatisticsDetail.setZaiyingCount(zaiyingCountFuture.join());
businessEntityStatisticsDetail.setXzCount(xzCountFuture.join());
businessEntityStatisticsDetail.setGkCount(gkCountFuture.join());
businessEntityStatisticsDetail.setSbCount(sbCountFuture.join());
businessEntityStatisticsDetail.setZyzyCount(zyzyCountFuture.join());
businessEntityStatisticsDetail.setXsCount(xsCountFuture.join());
businessEntityStatisticsDetail.setSsCount(ssCountFuture.join());
businessEntityStatisticsDetail.setGsCount(gsCountFuture.join());
businessEntityStatisticsDetail.setGyCount(industrySellFutures.get("工业").join());
businessEntityStatisticsDetail.setJzyCount(industrySellFutures.get("建筑业").join());
businessEntityStatisticsDetail.setPfCount(industrySellFutures.get("批发").join());
businessEntityStatisticsDetail.setLsCount(industrySellFutures.get("零售").join());
businessEntityStatisticsDetail.setZsCount(industrySellFutures.get("住宿").join());
businessEntityStatisticsDetail.setCyCount(industrySellFutures.get("餐饮").join());
businessEntityStatisticsDetail.setFwyCount(industrySellFutures.get("服务业").join());
businessEntityStatisticsDetail.setQtjjfzCount(industrySellFutures.get("其他").join());
businessEntityStatisticsDetail.setJjzl(businessEntityStatisticsDetail.getGyCount() businessEntityStatisticsDetail.setJjzl(businessEntityStatisticsDetail.getGyCount()
.add(businessEntityStatisticsDetail.getJzyCount()) .add(businessEntityStatisticsDetail.getJzyCount())
......
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 to comment