yanghui
2022-12-06 a2c75aa1db003388659aee759314e8cc34e1e180
#feat 百分数计算
3个文件已修改
43 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActAcidRecordMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
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,15 +648,38 @@
                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()
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActEasyPhotoServiceImpl.java
@@ -1104,7 +1104,7 @@
            if (0!=all){
                BigDecimal countNum = new BigDecimal(statisticsPhotoVO.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));
                statisticsPhotoVO.setPercent(percent);
            }
        }
@@ -1129,7 +1129,7 @@
                if (0L!=sum) {
                    BigDecimal countNum = new BigDecimal(statisticsPhotoVO.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));
                    statisticsPhotoVO.setPercent(percent);
                }
            }
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActAcidRecordMapper.xml
@@ -441,7 +441,7 @@
    <select id="selectColorMarkGroupByMonth"
            resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidColorChartsVO">
        SELECT COUNT(1) count_num,date_format(create_time,'%Y-%m')   as count_name,color_mark FROM `com_act_acid_record`
        WHERE date_format(create_time,'%Y-%m') >= date_format(date_sub(now(), INTERVAL 5 MONTH),'%Y-%m') GROUP BY  count_name,color_mark
        WHERE date_format(create_time,'%Y-%m') >= date_format(date_sub(now(), INTERVAL 4 MONTH),'%Y-%m') GROUP BY  count_name,color_mark
    </select>
</mapper>