| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNotEmpty; |
| | | import static com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNull; |
| | |
| | | } |
| | | return 3; |
| | | } |
| | | |
| | | /** |
| | | * 统计红黄绿码 |
| | | * @return |
| | | */ |
| | | public R selectColorMarkGroup(){ |
| | | //所有 |
| | | List<ComActAcidColorChartsVO> comActAcidColorChartsVOS = this.baseMapper.selectColorMarkGroup(); |
| | | int all = comActAcidColorChartsVOS.stream().mapToInt(ComActAcidColorChartsVO::getCountNum).sum(); |
| | | for (ComActAcidColorChartsVO comActAcidColorChartsVO : comActAcidColorChartsVOS) { |
| | | if (0!=all){ |
| | | BigDecimal countNum = new BigDecimal(comActAcidColorChartsVO.getCountNum()); |
| | | BigDecimal allDecimal = new BigDecimal(all); |
| | | BigDecimal percent = countNum.divide(allDecimal,2, BigDecimal.ROUND_HALF_DOWN); |
| | | comActAcidColorChartsVO.setPercent(percent); |
| | | } |
| | | } |
| | | // Map<String, ComActAcidColorChartsVO> circleMap = comActAcidColorChartsVOS |
| | | // .stream() |
| | | // .collect(Collectors.toMap(ComActAcidColorChartsVO::getColorMark, Function.identity())); |
| | | |
| | | //月份 |
| | | List<ComActAcidColorChartsVO> comActAcidColorChartsVOS1 = this.baseMapper.selectColorMarkGroupByMonth(); |
| | | //按颜色分组求和 |
| | | 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("comActAcidColorChartsVOS",comActAcidColorChartsVOS); |
| | | retMap.put("chartMap",chartMap); |
| | | |
| | | return R.ok(retMap); |
| | | } |
| | | } |