From d7d4ae6cfb28adf7ef92f44332ff492f0cc7069c Mon Sep 17 00:00:00 2001
From: longz <longzhaoz@qq.com>
Date: 星期五, 07 八月 2026 15:44:41 +0800
Subject: [PATCH] feat: 完善大屏与光储监控接口

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java |   39 +++++++++++++++++++++------------------
 1 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
index 38a1afb..af8c9c9 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -7082,26 +7082,27 @@
         if (cached != null) {
             return cached;
         }
-        LocalDate currentMonth = LocalDate.now().withDayOfMonth(1);
+        LocalDate currentDay = LocalDate.now();
         List<SixChargingDto> result = new ArrayList<>();
         try {
-            String sixBeforeMonth = sixBefore.withDayOfMonth(1).format(LARGE_SCREEN_MONTH_FMT);
-            List<SixChargingDto> incomeList = this.baseMapper.incomeTrendFromStat(siteIds, sixBeforeMonth);
-            Map<String, SixChargingDto> incomeByMonth = new HashMap<>();
+            List<SixChargingDto> incomeList = this.baseMapper.incomeTrendFromOrders(siteIds,
+                    sixBefore.atStartOfDay().format(LARGE_SCREEN_SQL_FMT),
+                    currentDay.plusDays(1).atStartOfDay().format(LARGE_SCREEN_SQL_FMT));
+            Map<String, SixChargingDto> incomeByDay = new HashMap<>();
             if (incomeList != null) {
                 for (SixChargingDto income : incomeList) {
                     if (income != null && income.getMonth() != null) {
-                        incomeByMonth.put(income.getMonth(), income);
+                        incomeByDay.put(income.getMonth(), income);
                     }
                 }
             }
-            LocalDate month = sixBefore.withDayOfMonth(1);
-            while (!month.isAfter(currentMonth)) {
-                SixChargingDto income = incomeByMonth.get(month.format(LARGE_SCREEN_MONTH_FMT));
+            LocalDate day = sixBefore;
+            while (!day.isAfter(currentDay)) {
+                SixChargingDto income = incomeByDay.get(day.format(LARGE_SCREEN_DAY_FMT));
                 if (income == null) {
                     income = new SixChargingDto();
                 }
-                income.setMonth(String.format("%02d", month.getMonthValue()));
+                income.setMonth(day.format(LARGE_SCREEN_DAY_FMT));
                 if (income.getElectrovalence() == null) {
                     income.setElectrovalence(BigDecimal.ZERO);
                 }
@@ -7109,18 +7110,18 @@
                     income.setServiceCharge(BigDecimal.ZERO);
                 }
                 result.add(income);
-                month = month.plusMonths(1);
+                day = day.plusDays(1);
             }
         } catch (Exception e) {
             log.warn("大屏收入趋势读取预聚合表失败, siteIds={}, sixBefore={}", siteIds, sixBefore, e);
-            LocalDate month = sixBefore.withDayOfMonth(1);
-            while (!month.isAfter(currentMonth)) {
+            LocalDate day = sixBefore;
+            while (!day.isAfter(currentDay)) {
                 SixChargingDto income = new SixChargingDto();
-                income.setMonth(String.format("%02d", month.getMonthValue()));
+                income.setMonth(day.format(LARGE_SCREEN_DAY_FMT));
                 income.setElectrovalence(BigDecimal.ZERO);
                 income.setServiceCharge(BigDecimal.ZERO);
                 result.add(income);
-                month = month.plusMonths(1);
+                day = day.plusDays(1);
             }
         }
         redisService.setCacheObject(cacheKey, result, LARGE_SCREEN_CACHE_SECONDS, TimeUnit.SECONDS);
@@ -7333,9 +7334,11 @@
             stat.put("orderCount", decimalValue(row, "order_count"));
             stat.put("userCount", BigDecimal.ZERO);
             stat.put("capacity", BigDecimal.ZERO);
-            stat.put("electricFee", BigDecimal.ZERO);
-            stat.put("serviceFee", BigDecimal.ZERO);
-            stat.put("income", BigDecimal.ZERO);
+            BigDecimal electricFee = decimalValue(row, "electric_fee");
+            BigDecimal serviceFee = decimalValue(row, "service_fee");
+            stat.put("electricFee", electricFee);
+            stat.put("serviceFee", serviceFee);
+            stat.put("income", electricFee.add(serviceFee));
             stat.put("totalPower", decimalValue(row, "total_power"));
             stat.put("registeredUserCount", 0L);
             statRows.add(stat);
@@ -7804,7 +7807,7 @@
         List<LocalDate> dates = new ArrayList<>();
         List<Integer> counts = new ArrayList<>();
         LocalDate today = LocalDate.now();
-        for (int i = 7; i >= 1; i--) {//升序
+        for (int i = 6; i >= 0; i--) {//升序,最近七日(含当天)
             LocalDate day = today.minusDays(i);
             LocalDateTime dayStart = day.atStartOfDay();
             LocalDateTime dayEnd = day.plusDays(1).atStartOfDay();

--
Gitblit v1.7.1