diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/CockpitStatsStatisticsTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/CockpitStatsStatisticsTask.java index 9e70aa2..4f531cb 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/CockpitStatsStatisticsTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/CockpitStatsStatisticsTask.java @@ -33,10 +33,7 @@ import java.math.BigDecimal; import java.net.InetAddress; import java.net.UnknownHostException; import java.time.LocalDateTime; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -253,7 +250,7 @@ public class CockpitStatsStatisticsTask { cockpitStats.setTopApprovalProjectsNum(approvalNum); cockpitStats.setTopApprovalProjectsAmount(BigDecimal.valueOf(approvalAmount)); //3.3 平均建设周期 - Double average = projects.stream().mapToInt(p -> { + OptionalDouble od = projects.stream().mapToInt(p -> { if (StringUtils.isNotBlank(p.getBuildCycle())) { try { Integer buildCycle = Integer.valueOf(p.getBuildCycle()); @@ -263,7 +260,8 @@ public class CockpitStatsStatisticsTask { } } return 0; - }).average().getAsDouble(); + }).average(); + Double average = od.isPresent() ? od.getAsDouble() : 0.0; cockpitStats.setTopAverageConstructionPeriod(average.intValue()); //3.4 在建项目数 采购备案后的项目 Integer contructionNum = projects.stream().filter(p -> { @@ -380,45 +378,46 @@ public class CockpitStatsStatisticsTask { //9.绩效 List projectCodes = projects.stream().map(Project::getProjectCode).collect(Collectors.toList()); Map projectMap = projects.stream().filter(p -> Objects.nonNull(p.getProjectCode())).collect(Collectors.toMap(Project::getProjectCode, Project::getProjectName)); - List performanceAll = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .in(PerformanceAppraisalProject::getProjectCode, projectCodes)); - List verified = performanceAll.stream().filter(p -> { - if (Objects.nonNull(p.getVerifyTotalScore())) { - return Boolean.TRUE; + if(CollUtil.isNotEmpty(projectCodes)){ + List performanceAll = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .in(PerformanceAppraisalProject::getProjectCode, projectCodes)); + List verified = performanceAll.stream().filter(p -> { + if (Objects.nonNull(p.getVerifyTotalScore())) { + return Boolean.TRUE; + } + return Boolean.FALSE; + }).sorted(Comparator.comparing(PerformanceAppraisalProject::getVerifyTotalScore).reversed()) + .collect(Collectors.toList()); + cockpitStats.setPerformanceTotal(performanceAll.size()); + cockpitStats.setPerformanceReviewedTotal(verified.size()); + cockpitStats.setPerformanceTobeReviewTotal(performanceAll.size() - verified.size()); + + if(verified.size() > 0){ + cockpitStats.setPerformanceTop1Name(projectMap.get(verified.get(0).getProjectCode())); + cockpitStats.setPerformanceTop1Score(verified.get(0).getVerifyTotalScore()); } - return Boolean.FALSE; - }).sorted(Comparator.comparing(PerformanceAppraisalProject::getVerifyTotalScore).reversed()) - .collect(Collectors.toList()); - cockpitStats.setPerformanceTotal(performanceAll.size()); - cockpitStats.setPerformanceReviewedTotal(verified.size()); - cockpitStats.setPerformanceTobeReviewTotal(performanceAll.size() - verified.size()); - - if(verified.size() > 0){ - cockpitStats.setPerformanceTop1Name(projectMap.get(verified.get(0).getProjectCode())); - cockpitStats.setPerformanceTop1Score(verified.get(0).getVerifyTotalScore()); - } - if(verified.size() > 1){ - cockpitStats.setPerformanceTop2Name(verified.get(1).getProjectCode()); - cockpitStats.setPerformanceTop2Score(verified.get(1).getVerifyTotalScore()); - } + if(verified.size() > 1){ + cockpitStats.setPerformanceTop2Name(verified.get(1).getProjectCode()); + cockpitStats.setPerformanceTop2Score(verified.get(1).getVerifyTotalScore()); + } - if(verified.size() > 2){ - cockpitStats.setPerformanceTop3Name(verified.get(2).getProjectCode()); - cockpitStats.setPerformanceTop3Score(verified.get(2).getVerifyTotalScore()); - } + if(verified.size() > 2){ + cockpitStats.setPerformanceTop3Name(verified.get(2).getProjectCode()); + cockpitStats.setPerformanceTop3Score(verified.get(2).getVerifyTotalScore()); + } - if(verified.size() > 3){ - cockpitStats.setPerformanceTop4Name(verified.get(3).getProjectCode()); - cockpitStats.setPerformanceTop4Score(verified.get(3).getVerifyTotalScore()); - } + if(verified.size() > 3){ + cockpitStats.setPerformanceTop4Name(verified.get(3).getProjectCode()); + cockpitStats.setPerformanceTop4Score(verified.get(3).getVerifyTotalScore()); + } - if(verified.size() > 4){ - cockpitStats.setPerformanceTop5Name(verified.get(4).getProjectCode()); - cockpitStats.setPerformanceTop5Score(verified.get(4).getVerifyTotalScore()); + if(verified.size() > 4){ + cockpitStats.setPerformanceTop5Name(verified.get(4).getProjectCode()); + cockpitStats.setPerformanceTop5Score(verified.get(4).getVerifyTotalScore()); + } } - return cockpitStats; } } diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java index a811d1d..4f6abe3 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/projectCollection/ProjectCollectionTest.java @@ -75,7 +75,7 @@ public class ProjectCollectionTest extends AppTests { @Test public void test(){ - List baseProjIds = Lists.newArrayList("33110000020230100021"); + List baseProjIds = Lists.newArrayList("33110000020210100194","33110000020220100194"); for(String baseProjId : baseProjIds){ GovBizProjectBaseinfo baseinfo = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) .eq(GovBizProjectBaseinfo::getBaseProjId, baseProjId)