From ece45eab5576677410b8bd5460d231afb399bc38 Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 28 Nov 2023 17:58:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/manage/FundStatisticsManage.java | 58 ++++++++++++++-------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java index 138599c..3649986 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java @@ -413,36 +413,50 @@ public class FundStatisticsManage { List applies, List approves, List procures) { //申报项目颗粒度 - List orgAmounts = projects.stream().map(p -> { + Map> groupProjectMap = projects.stream() + .collect(Collectors.groupingBy(Project::getBuildOrgCode)); + List projectAmounts = Lists.newArrayList(); + for(Map.Entry> entry : groupProjectMap.entrySet()){ FundStatisticsVO.AmountData orgAmount = new FundStatisticsVO.AmountData(); - orgAmount.setName(p.getBuildOrgName()); - orgAmount.setAmount(completeDeductionAmount(Lists.newArrayList(p), + List ps = entry.getValue(); + if(CollUtil.isNotEmpty(ps)){ + orgAmount.setName(ps.get(0).getBuildOrgName()); + } + orgAmount.setAmount(completeDeductionAmount(entry.getValue(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList())); - return orgAmount; - }).collect(Collectors.toList()); - - Map> applyMap = applies.stream().collect(Collectors - .groupingBy(GovBizProjectApply::getBaseProjId)); - Map> approveMap = approves.stream().collect(Collectors - .groupingBy(GovBizProjectApprove::getBaseProjId)); - Map> procureMap = procures.stream().collect(Collectors - .groupingBy(GovBizProjectProcure::getBaseProjId)); + projectAmounts.add(orgAmount); + } //项目归集颗粒度 - List orgAmountsGov = baseInfos.stream().map(p -> { - FundStatisticsVO.AmountData orgAmount = new FundStatisticsVO.AmountData(); - orgAmount.setName(p.getBaseBuildDeprt()); - List appliesThis = applyMap.getOrDefault(p.getBaseProjId(), Collections.emptyList()); - List approvesThis = approveMap.getOrDefault(p.getBaseProjId(), Collections.emptyList()); - List procuresThis = procureMap.getOrDefault(p.getBaseProjId(), Collections.emptyList()); - orgAmount.setAmount(completeDeductionAmount(Collections.emptyList(), + Map> groupGovMap = baseInfos.stream() + .collect(Collectors.groupingBy(GovBizProjectBaseinfo::getBaseBuildDeprtDing)); + List govAmounts = Lists.newArrayList(); + for(Map.Entry> entry : groupGovMap.entrySet()){ + FundStatisticsVO.AmountData govAmount = new FundStatisticsVO.AmountData(); + List bs = entry.getValue(); + List baseProjIds = Lists.newArrayList(); + if(CollUtil.isNotEmpty(bs)){ + govAmount.setName(bs.get(0).getBaseBuildDeprt()); + baseProjIds = bs.stream().map(GovBizProjectBaseinfo::getBaseProjId) + .collect(Collectors.toList()); + } + + List finalBaseProjIds = baseProjIds; + List appliesThis = applies.stream().filter(a -> Objects.nonNull(a.getBaseProjId()) + && finalBaseProjIds.contains(a.getBaseProjId())).collect(Collectors.toList()); + List approvesThis = approves.stream().filter(a -> Objects.nonNull(a.getBaseProjId()) + && finalBaseProjIds.contains(a.getBaseProjId())).collect(Collectors.toList()); + List procuresThis = procures.stream().filter(a -> Objects.nonNull(a.getBaseProjId()) + && finalBaseProjIds.contains(a.getBaseProjId())).collect(Collectors.toList()); + govAmount.setAmount(completeDeductionAmount(Collections.emptyList(), appliesThis, approvesThis,procuresThis)); - return orgAmount; - }).collect(Collectors.toList()); + govAmounts.add(govAmount); + } //求出TOP10 - List res = Stream.concat(orgAmounts.stream(), orgAmountsGov.stream()) + List res = Stream.concat(projectAmounts.stream(), + govAmounts.stream()) .sorted(Comparator.comparing(FundStatisticsVO.AmountData::getAmount).reversed()) .limit(10).collect(Collectors.toList());