From 179c4d64313c9b7572778da4aaaf6c6584fe457d Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期二, 20 五月 2025 23:48:08 +0800 Subject: [PATCH] 修改文件上传类型限制 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java | 39 ++++++++++++++++++++++++++++++++------- 1 files changed, 32 insertions(+), 7 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 e9b979f..72bf5de 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 @@ -11,6 +11,7 @@ import com.panzhihua.common.model.dtos.community.acid.BatchCheckAcidRecordDTO; import com.panzhihua.common.model.dtos.community.acid.ComActAcidRecordDTO; import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.StatisticsPhotoVO; import com.panzhihua.common.model.vos.community.acid.*; import com.panzhihua.common.service.user.UserService; import com.panzhihua.common.utlis.DateUtils; @@ -29,6 +30,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; +import java.time.LocalDate; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -622,7 +624,7 @@ if (0!=all){ BigDecimal countNum = new BigDecimal(comActAcidColorChartsVO.getCountNum()); BigDecimal allDecimal = new BigDecimal(all); - BigDecimal percent = countNum.divide(allDecimal,2, BigDecimal.ROUND_HALF_DOWN); + BigDecimal percent = countNum.divide(allDecimal,4, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(100)); comActAcidColorChartsVO.setPercent(percent); } } @@ -646,18 +648,41 @@ if (0L!=sum) { BigDecimal countNum = new BigDecimal(comActAcidColorChartsVO.getCountNum()); BigDecimal sumDecimal = new BigDecimal(sum); - BigDecimal percent = countNum.divide(sumDecimal, 2, BigDecimal.ROUND_HALF_DOWN); + BigDecimal percent = countNum.divide(sumDecimal, 4, BigDecimal.ROUND_HALF_DOWN).multiply(new BigDecimal(100)); comActAcidColorChartsVO.setPercent(percent); } } } -// Map<String, Map<String, ComActAcidColorChartsVO>> chartMap = comActAcidColorChartsVOS1 -// .stream() -// .collect(Collectors.groupingBy(ComActAcidColorChartsVO::getCountName, -// Collectors.toMap(ComActAcidColorChartsVO::getColorMark, Function.identity()))); + Map<String, Map<String, ComActAcidColorChartsVO>> colletMap = comActAcidColorChartsVOS1 + .stream() + .collect(Collectors.groupingBy(ComActAcidColorChartsVO::getCountName, + Collectors.toMap(ComActAcidColorChartsVO::getColorMark, Function.identity()))); + + String[] statusArr = {"红码","黄码","绿码"}; + List<String> latest5Month = DateUtils.getLatest12Month(LocalDate.now(), 5); + for (String month : latest5Month) { + Map<String, ComActAcidColorChartsVO> map1; + if(colletMap.containsKey(month)){ + map1 = colletMap.get(month); + }else { + map1 = new HashMap<>(); + } + for (String status : statusArr) { + if (!map1.containsKey(status)){ + ComActAcidColorChartsVO comActAcidColorChartsVO = new ComActAcidColorChartsVO(); + comActAcidColorChartsVO.setCountNum(0); + comActAcidColorChartsVO.setCountName(month); + comActAcidColorChartsVO.setColorMark(status); + comActAcidColorChartsVOS1.add(comActAcidColorChartsVO); + map1.put(status,comActAcidColorChartsVO); + } + } + colletMap.put(month,map1); + } + Map<String, List<ComActAcidColorChartsVO>> chartMap = comActAcidColorChartsVOS1 - .stream() + .stream().sorted(Comparator.comparing(ComActAcidColorChartsVO::getCountName)) .collect(Collectors.groupingBy(ComActAcidColorChartsVO::getColorMark)); Map<String,Object> retMap = new HashMap<>(); -- Gitblit v1.7.1