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 445a9e5..51b6025 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 @@ -183,12 +183,16 @@ public class CockpitStatsStatisticsTask { Double totalSafytyAmount = projects.stream().mapToDouble(p -> { if(Objects.nonNull(p.getSafetyInputDescribe())){ final Double[] total = {0.0}; - JSONArray array = JSON.parseArray(p.getSafetyInputDescribe()); - array.forEach(j -> { - JSONObject json = JSON.parseObject(JSON.toJSONString(j)); - Double safetyInputAmount = json.getDouble(DashboardConstant.Protrait.FEILD_SAFETYMONEY); - total[0] += safetyInputAmount; - }); + try{ + JSONArray array = JSON.parseArray(p.getSafetyInputDescribe()); + array.forEach(j -> { + JSONObject json = JSON.parseObject(JSON.toJSONString(j)); + Double safetyInputAmount = json.getDouble(DashboardConstant.Protrait.FEILD_SAFETYMONEY); + total[0] += safetyInputAmount; + }); + }catch (Exception e){ + + } return total[0]; } return 0.0; @@ -373,7 +377,7 @@ public class CockpitStatsStatisticsTask { //9.绩效 List projectCodes = projects.stream().map(Project::getProjectCode).collect(Collectors.toList()); - Map projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode, Project::getProjectName)); + 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 -> { @@ -387,16 +391,31 @@ public class CockpitStatsStatisticsTask { cockpitStats.setPerformanceReviewedTotal(verified.size()); cockpitStats.setPerformanceTobeReviewTotal(performanceAll.size() - verified.size()); - cockpitStats.setPerformanceTop1Name(projectMap.get(verified.get(0).getProjectCode())); - cockpitStats.setPerformanceTop1Score(verified.get(0).getVerifyTotalScore()); - cockpitStats.setPerformanceTop2Name(verified.get(1).getProjectCode()); - cockpitStats.setPerformanceTop2Score(verified.get(1).getVerifyTotalScore()); - cockpitStats.setPerformanceTop3Name(verified.get(2).getProjectCode()); - cockpitStats.setPerformanceTop3Score(verified.get(2).getVerifyTotalScore()); - cockpitStats.setPerformanceTop4Name(verified.get(3).getProjectCode()); - cockpitStats.setPerformanceTop4Score(verified.get(3).getVerifyTotalScore()); - cockpitStats.setPerformanceTop5Name(verified.get(4).getProjectCode()); - cockpitStats.setPerformanceTop5Score(verified.get(4).getVerifyTotalScore()); + 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() > 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() > 4){ + cockpitStats.setPerformanceTop5Name(verified.get(4).getProjectCode()); + cockpitStats.setPerformanceTop5Score(verified.get(4).getVerifyTotalScore()); + } + return cockpitStats; }