Browse Source

Merge branch 'dev' into pre-production

master
zhaoqiaobo 7 months ago
parent
commit
d161810a44
  1. 10
      blade-service/logpm-report/src/main/java/com/logpm/report/util/ReportExcelUtil.java

10
blade-service/logpm-report/src/main/java/com/logpm/report/util/ReportExcelUtil.java

@ -23,14 +23,12 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
/** /**
* excel导出工具类 * excel导出工具类
@ -109,7 +107,7 @@ public class ReportExcelUtil {
throw new ServiceException("导出数据不能大于50w,请增加检索条件"); throw new ServiceException("导出数据不能大于50w,请增加检索条件");
} }
// 每个 sheet 放多少条数据 // 每个 sheet 放多少条数据
Double sheetDataNum = onceSheetDataNum.doubleValue(); Long sheetDataNum = Math.min(count, onceSheetDataNum);
// 总共要几个 sheet // 总共要几个 sheet
int sheetNum = (int) Math.ceil((count / sheetDataNum)); int sheetNum = (int) Math.ceil((count / sheetDataNum));
// 总共需要查询数据库几次 // 总共需要查询数据库几次
@ -129,9 +127,11 @@ public class ReportExcelUtil {
for (int i = 0; i < sheetNum; i++) { for (int i = 0; i < sheetNum; i++) {
// sheet编号 // sheet编号
int finalI = i + 1; int finalI = i + 1;
// long ceilNum = Math.min(count, 100)
// 还剩多少条数据
long l = count - (sheetDataNum * num);
// 每页需要查几次 // 每页需要查几次
long l = count - (pageSize * num); long ceil = (int) Math.ceil(l / pageSize.doubleValue());
long ceil = l > pageSize ? (int) Math.ceil(onceSheetDataNum / pageSize.doubleValue()) : (int) Math.ceil(l / pageSize.doubleValue());
for (int j = 0; j < ceil; j++) { for (int j = 0; j < ceil; j++) {
// 已经查询过几次了 // 已经查询过几次了
int finalNum = num; int finalNum = num;

Loading…
Cancel
Save