longz
2026-07-20 8c1b6f26fdd8429b9833211ef69165a0e2ff2712
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -1213,8 +1213,9 @@
        List<Integer> siteIds = resolvePlatformRevenueSiteIds(userId, sysUser, siteId);
        LocalDate sixBefore = PreviousSixMonths.get();
        //通过siteIds进行sql查询统计
        List<SixChargingDto> sixChargingDtos = generateLastSixMonths();
        List<SixChargingDto> chargingDtos = chargingOrderService.charge(sixBefore, siteIds, partnerView);
        LocalDate statisticsEndMonth = resolveStatisticsEndMonth(LocalDate.now(), chargingDtos);
        List<SixChargingDto> sixChargingDtos = generateLastSixMonths(statisticsEndMonth);
        for (SixChargingDto sixChargingDto : sixChargingDtos) {
            for (SixChargingDto chargingDto : chargingDtos) {
                if (sixChargingDto.getMonth().equals(chargingDto.getMonth())){
@@ -1230,12 +1231,15 @@
    public static List<SixChargingDto> generateLastSixMonths() {
        LocalDate today = LocalDate.now();
        return generateLastSixMonths(LocalDate.now());
    }
    static List<SixChargingDto> generateLastSixMonths(LocalDate endMonth) {
        List<SixChargingDto> months = new ArrayList<>();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM");
        for (int i = 5; i >= 0; i--) {
            LocalDate date = today.minusMonths(i);
            LocalDate date = endMonth.minusMonths(i);
            String month = date.format(formatter);
            SixChargingDto sixChargingDto = new SixChargingDto();
            sixChargingDto.setMonth(month);
@@ -1244,6 +1248,24 @@
        return months;
    }
    static LocalDate resolveStatisticsEndMonth(LocalDate currentDate, List<SixChargingDto> statistics) {
        if (statistics == null || statistics.isEmpty()) {
            return currentDate;
        }
        int nextMonth = currentDate.plusMonths(1).getMonthValue();
        boolean hasNextMonthData = statistics.stream()
                .map(SixChargingDto::getMonth)
                .filter(Objects::nonNull)
                .anyMatch(month -> {
                    try {
                        return Integer.parseInt(month) == nextMonth;
                    } catch (NumberFormatException ignored) {
                        return false;
                    }
                });
        return hasNextMonthData ? currentDate.plusMonths(1) : currentDate;
    }
    
    @RequiresPermissions(value = {"/platformRevenueAnalysis"}, logical = Logical.OR)
    @ResponseBody