From 6fa3dc691224a55cd9494f7c1d929ab70b3532fa Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 1 Dec 2021 16:13:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BB=A1=E6=84=8F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/CalGridIndexServiceImpl.java | 42 +++++++------------ 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalGridIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalGridIndexServiceImpl.java index a8c807103a..4a9fbb143e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalGridIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalGridIndexServiceImpl.java @@ -357,33 +357,23 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { // 根据网格分组 Map> groupByGrid = projectEvaluateList.stream().collect(Collectors.groupingBy(ProjectEvaluateResultDTO::getGridId)); groupByGrid.forEach((gridId,projectEvaluateInfoList) -> { - Map scoreMap = new HashMap<>(16); - // 根据项目分组 - Map> groupByProject = projectEvaluateInfoList.stream().collect(Collectors.groupingBy(ProjectEvaluateResultDTO::getProjectId)); - groupByProject.forEach((projectId,projectList) -> { - projectList.forEach(project -> { - switch (project.getActionCode()) { - case ExtractConstant.EVALUATE_BAD: - project.setScore(ProjectEvaluateConstant.BAD); - break; - case ExtractConstant.EVALUATE_GOOD: - project.setScore(ProjectEvaluateConstant.GOOD); - break; - case ExtractConstant.EVALUATE_PERFECT: - project.setScore(ProjectEvaluateConstant.PERFECT); - break; - default: - log.warn("calGridIndexGovernAbility other projectEvaluate,actionCode:{}", project.getActionCode()); - } - }); - Integer projectAllScore = projectList.stream().mapToInt(ProjectEvaluateResultDTO::getScore).sum(); - scoreMap.put(projectId,projectAllScore/projectList.size()); - }); - AtomicReference allScore = new AtomicReference<>(0); - scoreMap.forEach((k,v) -> { - allScore.set(++v); + projectEvaluateInfoList.forEach(p -> { + switch (p.getActionCode()) { + case ExtractConstant.EVALUATE_BAD: + p.setScore(ProjectEvaluateConstant.BAD); + break; + case ExtractConstant.EVALUATE_GOOD: + p.setScore(ProjectEvaluateConstant.GOOD); + break; + case ExtractConstant.EVALUATE_PERFECT: + p.setScore(ProjectEvaluateConstant.PERFECT); + break; + default: + log.warn("calGridIndexGovernAbility other projectEvaluate,actionCode:{}", p.getActionCode()); + } }); - resultSatisfactionScore.put(gridId,getRound(new BigDecimal(allScore.get()/scoreMap.size()))); + Integer projectAllScore = projectEvaluateInfoList.stream().collect(Collectors.summingInt(ProjectEvaluateResultDTO::getScore)); + resultSatisfactionScore.put(gridId,getRound(new BigDecimal(projectAllScore/projectEvaluateInfoList.size()))); }); } String quarterId = DateUtils.getQuarterId(monthId);