diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java index 0a5a3a4f2..c317a079b 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/controller/order/HardOrderTotalController.java @@ -249,9 +249,7 @@ public class HardOrderTotalController { if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("商户不存在"); Long count = hardOrderMapper.count(dto, DataScope.of()); - if (count > 5000) throw new RuntimeException("导出数据超出5000条,请缩小查询范围"); - List list = hardOrderService.scopeList(dto, DataScope.of()); - List excelList = BeanUtils.toBean(list, HardMchOrderExcelVo.class); + if (count > 10 * 10000) throw new RuntimeException("导出数据超出100000条,请缩小查询范围"); try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/商户交易流水导出.xlsx")).build()) { WriteSheet writeSheet = EasyExcel.writerSheet().build(); @@ -263,12 +261,23 @@ public class HardOrderTotalController { map.put("endTime", LocalDateTimeUtil.format(dto.getPayTimeList()[1], DatePattern.NORM_DATETIME_PATTERN)); } map.put("merchantName", mch.getName()); - if (ObjectUtil.isNotEmpty(excelList)) { - BigDecimal totalPriceSum = BigDecimal.ZERO; - BigDecimal extraPriceSum = BigDecimal.ZERO; - BigDecimal payPriceSum = BigDecimal.ZERO; - BigDecimal refundPriceSum = BigDecimal.ZERO; - Long lineNumber = 1L; + // 统计 + BigDecimal totalPriceSum = BigDecimal.ZERO; + BigDecimal extraPriceSum = BigDecimal.ZERO; + BigDecimal payPriceSum = BigDecimal.ZERO; + BigDecimal refundPriceSum = BigDecimal.ZERO; + // 列号 + Long lineNumber = 1L; + // 分页相关 + long currentPage = 1; + long pageSize = 1000; + + while (true) { + Page page = hardOrderService.scopePageList(new Page(currentPage, pageSize), dto, DataScope.of()); + List records = page.getRecords(); + if (ObjectUtil.isEmpty(records)) break; + List excelList = BeanUtils.toBean(records, HardMchOrderExcelVo.class); + // 处理excel start for (HardMchOrderExcelVo v : excelList) { v.setLineNumber(lineNumber); lineNumber++; @@ -295,13 +304,17 @@ public class HardOrderTotalController { } } } - map.put("totalPriceSum", totalPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); - map.put("extraPriceSum", extraPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); - map.put("payPriceSum", payPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); - map.put("refundPriceSum", refundPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + excelWriter.fill(excelList, fillConfig, writeSheet); + // 处理excel end + if (page.getTotal() < pageSize) break; + currentPage++; } + map.put("totalPriceSum", totalPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("extraPriceSum", extraPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("payPriceSum", payPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + map.put("refundPriceSum", refundPriceSum.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString()); + excelWriter.fill(map, writeSheet); - excelWriter.fill(excelList, fillConfig, writeSheet); } }