From c168f544ecd041760e7d0fba66c48e06b9ab67dc Mon Sep 17 00:00:00 2001 From: yanghui <2536613402@qq.com> Date: 星期一, 05 十二月 2022 16:51:21 +0800 Subject: [PATCH] Merge branch 'local_20221104' into huacheng_test --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java | 31 +++++++++++++++++++++++++++---- 1 files changed, 27 insertions(+), 4 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java index b86132c..6cc8590 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java @@ -626,17 +626,40 @@ comActAcidColorChartsVO.setPercent(percent); } } - Map<String, ComActAcidColorChartsVO> circleMap = comActAcidColorChartsVOS.stream().collect(Collectors.toMap(ComActAcidColorChartsVO::getCountName, Function.identity())); + Map<String, ComActAcidColorChartsVO> circleMap = comActAcidColorChartsVOS + .stream() + .collect(Collectors.toMap(ComActAcidColorChartsVO::getColorMark, Function.identity())); //月份 List<ComActAcidColorChartsVO> comActAcidColorChartsVOS1 = this.baseMapper.selectColorMarkGroupByMonth(); - Map<String, List<ComActAcidColorChartsVO>> colorMap = comActAcidColorChartsVOS1.stream().collect(Collectors.groupingBy(ComActAcidColorChartsVO::getColorMark)); + //按颜色分组求和 + Map<String, IntSummaryStatistics> colorCollect = comActAcidColorChartsVOS1 + .stream() + .collect(Collectors.groupingBy(ComActAcidColorChartsVO::getColorMark, + Collectors.summarizingInt(ComActAcidColorChartsVO::getCountNum))); - + for (ComActAcidColorChartsVO comActAcidColorChartsVO : comActAcidColorChartsVOS1) { + String colorMark = comActAcidColorChartsVO.getColorMark(); + if (colorCollect.containsKey(colorMark)){ + IntSummaryStatistics intSummaryStatistics = colorCollect.get(colorMark); + long sum = intSummaryStatistics.getSum(); + if (0L!=sum) { + BigDecimal countNum = new BigDecimal(comActAcidColorChartsVO.getCountNum()); + BigDecimal sumDecimal = new BigDecimal(sum); + BigDecimal percent = countNum.divide(sumDecimal, 2, BigDecimal.ROUND_HALF_DOWN); + comActAcidColorChartsVO.setPercent(percent); + } + } + } + Map<String, Map<String, ComActAcidColorChartsVO>> chartMap = comActAcidColorChartsVOS1 + .stream() + .collect(Collectors.groupingBy(ComActAcidColorChartsVO::getCountName, + Collectors.toMap(ComActAcidColorChartsVO::getColorMark, Function.identity()))); Map<String,Object> retMap = new HashMap<>(); retMap.put("circleMap",circleMap); + retMap.put("chartMap",chartMap); - return R.ok(); + return R.ok(retMap); } } -- Gitblit v1.7.1