longz
2026-08-04 d4dceed9ed67d5e2b7ab73f860f2ac894f8e2ed1
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -7159,34 +7159,24 @@
                    .in(TChargingOrder::getChargingGunId, gunIds));//符合条件的充电枪
        }
        vo.setTotal(total.intValue());
        //2.折线图
   /*   // 计算日期范围:前七天(不含今日)直接查找数据量太大,内存报错
      LocalDate today = LocalDate.now();
      LocalDateTime startDate = today.minusDays(7).atStartOfDay();
      LocalDateTime endDate = today.minusDays(1).atTime(LocalTime.MAX);
      // 查询数据库
      List<OrderCountByDate> orderCounts = this.baseMapper.countOrdersByDate(startDate, endDate, gunIds);*/
        List<LocalDate> dates = new ArrayList<>();
        List<Integer> counts = new ArrayList<>();
        LocalDate today = LocalDate.now();
        // 直接查找数据量太大,内存报错,分每天查找
        LocalDateTime startDate = today.minusDays(7).atStartOfDay();
        LocalDateTime endDate = today.minusDays(1).atTime(LocalTime.MAX);
        Map<LocalDate, Long> countByDate = new HashMap<>();
        if (gunIds != null && !gunIds.isEmpty()) {
            List<OrderCountByDate> orderCounts = this.baseMapper.countOrdersByDate(startDate, endDate, gunIds);
            if (orderCounts != null) {
                for (OrderCountByDate orderCount : orderCounts) {
                    countByDate.put(orderCount.getDate(), orderCount.getCount());
                }
            }
        }
        for (int i = 7; i >= 1; i--) {//升序
            LocalDate day = today.minusDays(i);
            LocalDateTime startOfDay = day.atStartOfDay();
            LocalDateTime endOfDay = day.atTime(LocalTime.MAX);
            //统计
            Long count = 0L;
            if (gunIds != null && !gunIds.isEmpty()) {
                count = this.baseMapper.selectCount(new LambdaQueryWrapper<TChargingOrder>()
                        .eq(TChargingOrder::getDelFlag, 0)//未删除
                        .in(TChargingOrder::getStatus, Arrays.asList(3, 5))//充电中、已结束
                        .in(TChargingOrder::getChargingGunId, gunIds)//符合条件的充电枪 站点 超充快充
                        .between(TChargingOrder::getCreateTime, startOfDay, endOfDay));//每天
            }
            dates.add(day);
            counts.add(count.intValue());
            counts.add(countByDate.getOrDefault(day, 0L).intValue());
        }
        vo.setDates(dates);
        vo.setCounts(counts);