Browse Source

Merge branch 'dev_jmreport'

# Conflicts:
#	epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
master
wangxianzhang 3 years ago
parent
commit
991f6c7464
  1. 40
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java

40
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.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -390,21 +392,20 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
List<List<String>> idParts = ListUtils.partition(idList, 100); List<List<String>> idParts = ListUtils.partition(idList, 100);
// 1. 循环下载所有id对应的excel(积木报表的导出接口有并发问题,多线程会导出空表,暂时不用多线程了) // 1. 循环下载所有id对应的excel(积木报表的导出接口有并发问题,多线程会导出空表,暂时不用多线程了)
//CountDownLatch cdl = new CountDownLatch(idParts.size()); CountDownLatch cdl = new CountDownLatch(idParts.size());
for (List<String> idPart : idParts) { for (List<String> idPart : idParts) {
downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files); CompletableFuture.runAsync(() -> {
//CompletableFuture.runAsync(() -> { downloadXlsByBatchByBizId(reportId, idPart, param, xlsxStorePath, files, cdl);
// downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); }, executorService);
//}, executorService);
} }
// 等待多线程执行完成,再执行打包 // 等待多线程执行完成,再执行打包
//try { try {
// cdl.await(); cdl.await();
//} catch (InterruptedException e) { } catch (InterruptedException e) {
// log.error(ExceptionUtils.getErrorStackTrace(e)); log.error(ExceptionUtils.getErrorStackTrace(e));
// throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); throw new EpmetException("【报表批量导出】CountDownLatch等待被中断");
//} }
// 2,打包 // 2,打包
Path zipFile = storePath.resolve(reportName + "_" + currentTimeStr + ".zip"); Path zipFile = storePath.resolve(reportName + "_" + currentTimeStr + ".zip");
@ -472,20 +473,9 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
* @param xlsxStorePath * @param xlsxStorePath
* @param files * @param files
*/ */
public void downloadXlsByBatchByBizId(String reportId, List<String> bizIds, Map<String, String> idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map<String, File> files) { public void downloadXlsByBatchByBizId(String reportId, List<String> bizIds, JimuReportExportRequestDTO param,
Path xlsxStorePath, Map<String, File> files, CountDownLatch cdl) {
for (String id : bizIds) { for (String id : bizIds) {
try {
Thread.sleep(200l);
} catch (InterruptedException e) {
final String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【报表批量导出】循环导出-请求jmreport,等待过程中睡眠发生意外:{}", errorMsg);
}
//if (!Arrays.asList("1501821697823608834","1501821694665297922","1501821695114088450","1501821695177003009","1501821695269277697","1501821695344775169","1501821695579656193","1501821695676125186","1501821695755816962","1501821695843897346","1501821695978115074","1501821696108138497","1501821696179441665","1501821696229773313","1501821696284299266","1501821696334630913","1501821696393351170","1501821696452071426","1501821696502403073","1501821696582094849","1501821696645009409","1501821696758255617","1501821696871501826","1501821696917639169","1501821696955387906","1501821696993136641","1501821697135742977","1501821697181880321","1501821697232211969","1501821697274155009").contains(id)) {
// continue;
//}
param.getQueryParam().setId(id); param.getQueryParam().setId(id);
final Response response = jiMuReportOpenFeignClient.exportAllExcelStream(param); final Response response = jiMuReportOpenFeignClient.exportAllExcelStream(param);
// 取出文件后缀 // 取出文件后缀
@ -506,7 +496,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
} }
} }
//cdl.countDown(); cdl.countDown();
} }
/** /**

Loading…
Cancel
Save