diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java index 4f6277d886..f9a1707342 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java @@ -55,6 +55,8 @@ import java.nio.file.Path; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -390,21 +392,20 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl> idParts = ListUtils.partition(idList, 100); // 1. 循环下载所有id对应的excel(积木报表的导出接口有并发问题,多线程会导出空表,暂时不用多线程了) - //CountDownLatch cdl = new CountDownLatch(idParts.size()); + CountDownLatch cdl = new CountDownLatch(idParts.size()); for (List idPart : idParts) { - downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files); - //CompletableFuture.runAsync(() -> { - // downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); - //}, executorService); + CompletableFuture.runAsync(() -> { + downloadXlsByBatchByBizId(reportId, idPart, param, xlsxStorePath, files, cdl); + }, executorService); } // 等待多线程执行完成,再执行打包 - //try { - // cdl.await(); - //} catch (InterruptedException e) { - // log.error(ExceptionUtils.getErrorStackTrace(e)); - // throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); - //} + try { + cdl.await(); + } catch (InterruptedException e) { + log.error(ExceptionUtils.getErrorStackTrace(e)); + throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); + } // 2,打包 Path zipFile = storePath.resolve(reportName + "_" + currentTimeStr + ".zip"); @@ -472,7 +473,8 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizIds, Map idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files) { + public void downloadXlsByBatchByBizId(String reportId, List bizIds, JimuReportExportRequestDTO param, + Path xlsxStorePath, Map files, CountDownLatch cdl) { for (String id : bizIds) { try { @@ -506,7 +508,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl