From 0dfe9fb8b3113def4fbc392550b20034ea5339aa Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 18 Aug 2022 16:40:05 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=8A=A5=E8=A1=A8=E3=80=91=E5=8F=88?= =?UTF-8?q?=E8=A6=81=E7=94=A8=E5=A4=9A=E7=BA=BF=E7=A8=8B=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/IcCustomerReportServiceImpl.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) 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