以下是代码的优化版本:\n\npublic static Map<String, CalculationResultDTO> statisticsOverallAppraisal(final List computeResultExports) {\n return computeResultExports.stream()\n .map(ExcelConvertUtil::overallAppraisalCompute)\n .collect(Collectors.groupingBy(\n CalculationResultDTO::getScoreItemId,\n LinkedHashMap::new,\n Collectors.reducing(new CalculationResultDTO(),\n (cal1, cal2) -> {\n BigDecimal calculationResultValue = cal1.getCalculationResultValue();\n cal1.setCalculationResultValue(calculationResultValue.add(cal2.getCalculationResultValue()));\n return cal1;\n })\n ));\n}

Java代码优化: 使用Stream和Collectors统计汇总评分结果

原文地址: https://www.cveoy.top/t/topic/qEAd 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录