This commit is contained in:
YAS\29473
2026-01-05 11:38:13 +08:00
parent 1e6f8edd96
commit 06ff787cea
2 changed files with 110 additions and 96 deletions

View File

@@ -6302,10 +6302,32 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
long orderCount = pageInfo.getTotal();
// 3. 统计总金额(使用聚合 SQL避免查询所有数据到内存
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
BigDecimal totalOrderAmount = statistics != null && statistics.getOrderAmount() != null
? statistics.getOrderAmount() : BigDecimal.ZERO;
// 3. 统计总金额 (分批处理)
BigDecimal totalOrderAmount = BigDecimal.ZERO;
int batchSize = 500; // 每批最多 500 个站点ID
if (stationIdList.size() > batchSize) {
// 分批查询统计
List<List<String>> batches = Lists.partition(stationIdList, batchSize);
for (List<String> batch : batches) {
QueryOrderDTO batchDTO = QueryOrderDTO.builder()
.stationIdList(batch)
.startTime(dto.getCreateTime())
.endTime(dto.getEndTime())
.orderStatus(dto.getOrderStatus())
.startMode(dto.getStartMode())
.stationName(dto.getStationName())
.build();
OrderStatisticsVO batchStatistics = orderBasicInfoMapper.countBusinessOrderStatistics(batchDTO);
if (batchStatistics != null && batchStatistics.getOrderAmount() != null) {
totalOrderAmount = totalOrderAmount.add(batchStatistics.getOrderAmount());
}
}
} else {
// 直接查询
OrderStatisticsVO statistics = orderBasicInfoMapper.countBusinessOrderStatistics(queryOrderDTO);
totalOrderAmount = statistics != null && statistics.getOrderAmount() != null
? statistics.getOrderAmount() : BigDecimal.ZERO;
}
//4. 转换为 BusinessOrderListVO
List<BusinessOrderListVO> businessOrderList = orderListVOS.stream()