From 61caa3ab3f520b0948d7414e11f125835d990aae Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Fri, 13 Oct 2023 16:50:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A9=BE=E9=A9=B6=E8=88=B1=20=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E9=80=BB=E8=BE=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/task/CockpitStatsStatisticsTask.java | 53 +++++++++++++++------- 1 file changed, 36 insertions(+), 17 deletions(-) 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; }