| | |
| | | BigDecimal amountB = b == null || b.getPaymentAmount() == null ? BigDecimal.ZERO : b.getPaymentAmount(); |
| | | return amountB.compareTo(amountA); |
| | | }); |
| | | // 总额用于计算各站点占比,name+value 为服务端拼好的饼图标签文本(站点名 xx.x%) |
| | | BigDecimal total = BigDecimal.ZERO; |
| | | for (SixCircleDto dto : circleDtos) { |
| | | if (dto != null && dto.getPaymentAmount() != null) { |
| | | total = total.add(dto.getPaymentAmount()); |
| | | } |
| | | } |
| | | for (SixCircleDto dto : circleDtos) { |
| | | if (dto == null || dto.getSiteId() == null || dto.getPaymentAmount() == null) { |
| | | continue; |
| | | } |
| | | Map<String, Object> item = new LinkedHashMap<>(); |
| | | item.put("name", siteNameMap.getOrDefault(dto.getSiteId(), "电站" + dto.getSiteId())); |
| | | String name = siteNameMap.getOrDefault(dto.getSiteId(), "电站" + dto.getSiteId()); |
| | | item.put("name", name); |
| | | item.put("value", dto.getPaymentAmount()); |
| | | String percent = total.compareTo(BigDecimal.ZERO) > 0 |
| | | ? dto.getPaymentAmount().multiply(BigDecimal.valueOf(100)).divide(total, 1, RoundingMode.HALF_UP).toPlainString() |
| | | : "0.0"; |
| | | item.put("name+value", name + " " + percent + "%"); |
| | | incomePie.add(item); |
| | | } |
| | | return incomePie; |