|
@@ -73,42 +73,17 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
|
|
|
* 手动导出
|
|
|
*/
|
|
|
public Workbook exportXlsToFile(InterlockHistoryQueryDTO dto, List<InterlockHistoryDistinctZZXTVO> zzxtvoList, Class<InterlockSummaryHistoryVO> clazz) throws IOException {
|
|
|
- ExecutorService executor = Executors.newFixedThreadPool(5);
|
|
|
-
|
|
|
- CompletionService<Void> completionService = new ExecutorCompletionService<>(executor);
|
|
|
-
|
|
|
SXSSFWorkbook workbook = new SXSSFWorkbook();
|
|
|
Map<String,CellStyle> cellStyleMap = getCellStyle(workbook);
|
|
|
|
|
|
- try{
|
|
|
- if (zzxtvoList != null) {
|
|
|
+ if (zzxtvoList != null) {
|
|
|
|
|
|
- for (InterlockHistoryDistinctZZXTVO zzxtvo : zzxtvoList) {
|
|
|
- String sheetName =generateSheetName(zzxtvo) ;
|
|
|
+ for (InterlockHistoryDistinctZZXTVO zzxtvo : zzxtvoList) {
|
|
|
|
|
|
- // 提交每个sheet页的处理任务到线程池
|
|
|
- completionService.submit(() -> {
|
|
|
- try {
|
|
|
- processSheet(workbook, cellStyleMap, sheetName, dto, zzxtvo);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace(); // 处理IOException异常
|
|
|
- }
|
|
|
- }, null);
|
|
|
- }
|
|
|
+ String sheetName =generateSheetName(zzxtvo) ;
|
|
|
+ processSheet(workbook, cellStyleMap, sheetName, dto, zzxtvo);
|
|
|
|
|
|
- // 等待所有任务完成
|
|
|
- for (int i = 0; i < zzxtvoList.size(); i++) {
|
|
|
- try {
|
|
|
- completionService.take().get();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (ExecutionException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
- }finally {
|
|
|
- executor.shutdown(); // 关闭线程池
|
|
|
}
|
|
|
|
|
|
return workbook;
|