From 2a212f983f35e1c569dfec3a172fb5f0c9f85fac Mon Sep 17 00:00:00 2001 From: lidongdong <1459917685@qq.com> Date: 星期二, 06 十二月 2022 13:43:43 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/haucheng_panzhihua' into haucheng_panzhihua --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoServiceImpl.java | 73 +++++++++++++++++++++++++++++++++++- 1 files changed, 70 insertions(+), 3 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoServiceImpl.java index 6720ccd..ce4b094 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoServiceImpl.java @@ -1,9 +1,10 @@ package com.panzhihua.service_community.service.impl; import java.math.BigDecimal; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.time.LocalDate; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; import javax.annotation.Resource; @@ -11,6 +12,7 @@ import cn.hutool.core.util.DesensitizedUtil; import com.panzhihua.common.model.dtos.common.PageComActEasyPhotoEvaluateDto; import com.panzhihua.common.model.vos.common.ComActEasyPhotoHandlerVo; +import com.panzhihua.common.model.vos.community.acid.ComActAcidColorChartsVO; import com.panzhihua.common.model.vos.community.easyPhoto.BannerVO; import com.panzhihua.service_community.entity.ComActEasyPhotoEvaluate; import com.panzhihua.service_community.entity.ComActEasyPhotoHandler; @@ -1093,4 +1095,69 @@ return R.ok(easyPhotoRewardVO); } + @Override + public R selectStatisticsPhoto(){ + //所有分组 + List<StatisticsPhotoVO> statisticsPhotoVOS = this.baseMapper.selectPhotoAll(); + int all = statisticsPhotoVOS.stream().mapToInt(StatisticsPhotoVO::getCountNum).sum(); + for (StatisticsPhotoVO statisticsPhotoVO : statisticsPhotoVOS) { + if (0!=all){ + BigDecimal countNum = new BigDecimal(statisticsPhotoVO.getCountNum()); + BigDecimal allDecimal = new BigDecimal(all); + BigDecimal percent = countNum.divide(allDecimal,2, BigDecimal.ROUND_HALF_DOWN); + statisticsPhotoVO.setPercent(percent); + } + } + Map<String, StatisticsPhotoVO> circleMap = statisticsPhotoVOS + .stream() + .collect(Collectors.toMap(StatisticsPhotoVO::getCountName, Function.identity())); + + //按月份查询 + List<StatisticsPhotoVO> statisticsPhotoVOS1 = this.baseMapper.selectPhotoByMonth(); + //按类型分组求和 + Map<String, IntSummaryStatistics> statusCollect = statisticsPhotoVOS1 + .stream() + .collect(Collectors.groupingBy(StatisticsPhotoVO::getCountName, + Collectors.summarizingInt(StatisticsPhotoVO::getCountNum))); + + for (StatisticsPhotoVO statisticsPhotoVO : statisticsPhotoVOS1) { + String countName = statisticsPhotoVO.getCountName(); + if (statusCollect.containsKey(countName)){ + IntSummaryStatistics intSummaryStatistics = statusCollect.get(countName); + long sum = intSummaryStatistics.getSum(); + if (0L!=sum) { + BigDecimal countNum = new BigDecimal(statisticsPhotoVO.getCountNum()); + BigDecimal sumDecimal = new BigDecimal(sum); + BigDecimal percent = countNum.divide(sumDecimal, 2, BigDecimal.ROUND_HALF_DOWN); + statisticsPhotoVO.setPercent(percent); + } + } + } + Map<String, Map<String, StatisticsPhotoVO>> chartMap = statisticsPhotoVOS1.stream().collect(Collectors.groupingBy(StatisticsPhotoVO::getStatisticsDate, Collectors.toMap(StatisticsPhotoVO::getCountName, Function.identity()))); + + // 状态 1待处理 2进行中 3已驳回 4待评价 5.已完成 + String[] statusArr = {"dcl","jxz","ybh","dpj","ywc"}; + List<String> latest12Month = DateUtils.getLatest12Month(LocalDate.now(), 10); + for (String month : latest12Month) { + Map<String, StatisticsPhotoVO> map1; + if(chartMap.containsKey(month)){ + map1 = chartMap.get(month); + }else { + map1 = new HashMap<>(); + } + for (String status : statusArr) { + if (!map1.containsKey(status)){ + StatisticsPhotoVO statisticsPhotoVO = new StatisticsPhotoVO(); + statisticsPhotoVO.setCountNum(0); + statisticsPhotoVO.setStatisticsDate(month); + statisticsPhotoVO.setCountName(status); + map1.put(status,statisticsPhotoVO); + } + } + chartMap.put(month,map1); + } + + return R.ok(); + } + } -- Gitblit v1.7.1