| | |
| | | query.setSiteIds(siteIds); |
| | | } |
| | | |
| | | private void fillElectronicProportion(List<ChargingOrderVO> list) { |
| | | List<Long> orderIds = list.stream().map(ChargingOrderVO::getId).filter(Objects::nonNull).collect(Collectors.toList()); |
| | | if (orderIds.isEmpty()) { |
| | | return; |
| | | } |
| | | List<Map<String, Object>> capacityRows = new ArrayList<>(); |
| | | int batchSize = 500; |
| | | for (int i = 0; i < orderIds.size(); i += batchSize) { |
| | | List<Long> batchIds = orderIds.subList(i, Math.min(i + batchSize, orderIds.size())); |
| | | capacityRows.addAll(Optional.ofNullable(baseMapper.capacitySummaryByOrderIds(batchIds)) |
| | | .orElse(Collections.emptyList())); |
| | | } |
| | | Map<Long, Map<String, Object>> capacityByOrderId = capacityRows.stream() |
| | | .filter(item -> item.get("orderId") != null) |
| | | .collect(Collectors.toMap(item -> Long.valueOf(item.get("orderId").toString()), item -> item, (a, b) -> a)); |
| | | for (ChargingOrderVO order : list) { |
| | | Map<String, Object> capacity = capacityByOrderId.get(order.getId()); |
| | | Map<String, BigDecimal> summary = emptyAccountingSummary(); |
| | | if (capacity != null) { |
| | | for (String key : new String[]{"capacityTotal", "capacity1", "capacity2", "capacity3", "capacity4"}) { |
| | | summary.put(key, summaryDecimal(capacity, key)); |
| | | } |
| | | } |
| | | order.setElectronicProportion(buildProportion(summary, "capacity")); |
| | | } |
| | | } |
| | | |
| | | private void fillPageExtra(List<ChargingOrderVO> list) { |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | | } |
| | | fillElectronicProportion(list); |
| | | List<Integer> siteIds = list.stream().map(ChargingOrderVO::getSiteId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); |
| | | List<Integer> gunIds = list.stream().map(ChargingOrderVO::getChargingGunId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); |
| | | List<Long> carIds = list.stream().map(ChargingOrderVO::getAppUserCarId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); |