| | |
| | | } |
| | | } else { |
| | | List<SixChargingDto> settlementIncome = this.baseMapper.chargeSettlement(sixBeforeValue, siteIds); |
| | | if (settlementIncome != null) { |
| | | result.addAll(settlementIncome); |
| | | } |
| | | List<SixChargingDto> orderHistoryIncome = this.baseMapper.chargeOrderHistory(sixBeforeValue, siteIds); |
| | | result.addAll(mergeMissingMonthlyIncome(settlementIncome, orderHistoryIncome)); |
| | | String siteIdsCsv = siteIds == null ? null : siteIds.stream() |
| | | .filter(Objects::nonNull) |
| | | .map(String::valueOf) |
| | |
| | | return result; |
| | | } |
| | | |
| | | static List<SixChargingDto> mergeMissingMonthlyIncome(List<SixChargingDto> settlementIncome, |
| | | List<SixChargingDto> orderHistoryIncome) { |
| | | List<SixChargingDto> merged = new ArrayList<>(); |
| | | Set<Integer> settledMonths = new HashSet<>(); |
| | | if (settlementIncome != null) { |
| | | for (SixChargingDto item : settlementIncome) { |
| | | if (item == null) { |
| | | continue; |
| | | } |
| | | merged.add(item); |
| | | Integer month = incomeMonth(item); |
| | | if (month != null) { |
| | | settledMonths.add(month); |
| | | } |
| | | } |
| | | } |
| | | if (orderHistoryIncome != null) { |
| | | for (SixChargingDto item : orderHistoryIncome) { |
| | | Integer month = incomeMonth(item); |
| | | if (item != null && month != null && settledMonths.add(month)) { |
| | | merged.add(item); |
| | | } |
| | | } |
| | | } |
| | | return merged; |
| | | } |
| | | |
| | | private static Integer incomeMonth(SixChargingDto item) { |
| | | if (item == null || item.getMonth() == null) { |
| | | return null; |
| | | } |
| | | try { |
| | | int month = Integer.parseInt(item.getMonth()); |
| | | return month >= 1 && month <= 12 ? month : null; |
| | | } catch (NumberFormatException ignored) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<SixCircleDto> circle(List<Integer> siteIds, LocalDate sixBefore, Boolean partnerView) { |
| | | List<SixCircleDto> result = this.baseMapper.circle(siteIds, sixBefore, partnerView); |