|
|
@ -275,7 +275,6 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
logger.info("-----------patrolTaskResultMains: {}", patrolTaskResultMains); |
|
|
logger.info("-----------patrolTaskResultMains: {}", patrolTaskResultMains); |
|
|
if (patrolTaskResultMains.size() == 0) { |
|
|
if (patrolTaskResultMains.size() == 0) { |
|
|
logger.error("[归档]失败, 数据采集中..."); |
|
|
logger.error("[归档]失败, 数据采集中..."); |
|
|
// return AjaxResult.error("数据采集中请稍后...."); |
|
|
|
|
|
} |
|
|
} |
|
|
List<Long> lineIds = patrolTaskResultMains.stream().map(PatrolTaskResultMain::getLineId).collect(Collectors.toList()); |
|
|
List<Long> lineIds = patrolTaskResultMains.stream().map(PatrolTaskResultMain::getLineId).collect(Collectors.toList()); |
|
|
List<Long> longs = patrolTaskResultMainService.selectLineIdsByList(lineIds); |
|
|
List<Long> longs = patrolTaskResultMainService.selectLineIdsByList(lineIds); |
|
|
@ -286,7 +285,6 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
List<PatrolResult> resultList = patrolResultService.selectPatrolResultListByMainIds(lineIds); |
|
|
List<PatrolResult> resultList = patrolResultService.selectPatrolResultListByMainIds(lineIds); |
|
|
if (resultList.isEmpty()) { |
|
|
if (resultList.isEmpty()) { |
|
|
logger.error("[归档]失败, 数据采集中..."); |
|
|
logger.error("[归档]失败, 数据采集中..."); |
|
|
// return AjaxResult.error("数据采集中请稍后...."); |
|
|
|
|
|
} |
|
|
} |
|
|
List<Long> finalLineIds = lineIds; |
|
|
List<Long> finalLineIds = lineIds; |
|
|
PrintUtil.useTime("查询统计数据", finalStartTime); |
|
|
PrintUtil.useTime("查询统计数据", finalStartTime); |
|
|
@ -297,6 +295,7 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
return Collections.emptyList(); |
|
|
return Collections.emptyList(); |
|
|
}); |
|
|
}); |
|
|
startTime = PrintUtil.useTime("保存报告数据", startTime); |
|
|
startTime = PrintUtil.useTime("保存报告数据", startTime); |
|
|
|
|
|
|
|
|
// 当saveReport完成后,再异步处理所有导出任务 |
|
|
// 当saveReport完成后,再异步处理所有导出任务 |
|
|
saveReportFuture.thenAcceptAsync(reportIds -> { |
|
|
saveReportFuture.thenAcceptAsync(reportIds -> { |
|
|
logger.info("-----------[ARCHIVE] Saved export reportIds: {}", reportIds); |
|
|
logger.info("-----------[ARCHIVE] Saved export reportIds: {}", reportIds); |
|
|
@ -304,19 +303,14 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
logger.warn("No reports to export"); |
|
|
logger.warn("No reports to export"); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
// 为每个reportId创建异步导出任务 |
|
|
|
|
|
CompletableFuture<?>[] exportFutures = reportIds.stream() |
|
|
|
|
|
.map(reportId -> CompletableFuture.runAsync(() -> { |
|
|
|
|
|
logger.info("[EXPORT] Start export for reportId: {}", reportId); |
|
|
|
|
|
// exportExcelWordAndZipLingzhou(String.valueOf(reportId)); |
|
|
|
|
|
exportExcelWordAndZipShaoxing(String.valueOf(reportId)); |
|
|
|
|
|
}, executor)) |
|
|
|
|
|
.toArray(CompletableFuture[]::new); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CompletableFuture.runAsync(() -> exportExcelWordAndZipShaoxing(reportIds), executor); |
|
|
|
|
|
|
|
|
}, executor).exceptionally(ex -> { |
|
|
}, executor).exceptionally(ex -> { |
|
|
logger.error("Error occurred during saveReport: ", ex); |
|
|
logger.error("Error occurred during saveReport: ", ex); |
|
|
return null; |
|
|
return null; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
PrintUtil.useTime("导出报告数据", startTime); |
|
|
PrintUtil.useTime("导出报告数据", startTime); |
|
|
return toAjax(1); |
|
|
return toAjax(1); |
|
|
|
|
|
|
|
|
@ -1477,7 +1471,7 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
|
|
|
|
|
|
CompletableFuture.allOf(zipUploadFuture, excelUploadFuture, wordUploadFuture).whenComplete((v, t) -> { |
|
|
CompletableFuture.allOf(zipUploadFuture, excelUploadFuture, wordUploadFuture).whenComplete((v, t) -> { |
|
|
try { |
|
|
try { |
|
|
inspectionReport.setFilePath(basePath + reportName + ".xls"); |
|
|
|
|
|
|
|
|
inspectionReport.setFilePath(basePath + reportName + ".xls" ); |
|
|
inspectionReportService.updateInspectionReport(inspectionReport); |
|
|
inspectionReportService.updateInspectionReport(inspectionReport); |
|
|
} finally { |
|
|
} finally { |
|
|
// 清理资源 |
|
|
// 清理资源 |
|
|
@ -1491,12 +1485,14 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void exportExcelWordAndZipShaoxing(String lineId) { |
|
|
|
|
|
|
|
|
public void exportExcelWordAndZipShaoxing(List<Long> reportIds) { |
|
|
|
|
|
// 合并报告,所有报告都是一样的,所以随便取一个报告导出,这样就避免多次生成同样报告,影响性能 |
|
|
|
|
|
Long lineId = reportIds.get(0); |
|
|
logMemoryUsage("START exportExcelWordAndZipShaoxing"); |
|
|
logMemoryUsage("START exportExcelWordAndZipShaoxing"); |
|
|
List<String> images = new ArrayList<>(); |
|
|
List<String> images = new ArrayList<>(); |
|
|
Map<String, String> imgSrcToFileNameMap = new HashMap<>(); |
|
|
Map<String, String> imgSrcToFileNameMap = new HashMap<>(); |
|
|
InspectionReport inspectionReport = |
|
|
InspectionReport inspectionReport = |
|
|
inspectionReportService.selectInspectionReportByLineId(Long.valueOf(lineId)); |
|
|
|
|
|
|
|
|
inspectionReportService.selectInspectionReportByLineId(lineId); |
|
|
InspectionReportData inspectionReportData = new InspectionReportData(); |
|
|
InspectionReportData inspectionReportData = new InspectionReportData(); |
|
|
inspectionReportData.setReportId(String.valueOf(inspectionReport.getLineId())); |
|
|
inspectionReportData.setReportId(String.valueOf(inspectionReport.getLineId())); |
|
|
List<InspectionReportData> inspectionReportDataList = |
|
|
List<InspectionReportData> inspectionReportDataList = |
|
|
@ -1624,7 +1620,8 @@ public class PatrolTaskResultMainController extends BaseController { |
|
|
CompletableFuture.allOf(zipUploadFuture, excelUploadFuture, wordUploadFuture).whenComplete((v, t) -> { |
|
|
CompletableFuture.allOf(zipUploadFuture, excelUploadFuture, wordUploadFuture).whenComplete((v, t) -> { |
|
|
try { |
|
|
try { |
|
|
inspectionReport.setFilePath(basePath + reportName + ".xls"); |
|
|
inspectionReport.setFilePath(basePath + reportName + ".xls"); |
|
|
inspectionReportService.updateInspectionReport(inspectionReport); |
|
|
|
|
|
|
|
|
inspectionReport.setLineIds(reportIds); |
|
|
|
|
|
inspectionReportService.updateInspectionReportFilePath(inspectionReport); |
|
|
} finally { |
|
|
} finally { |
|
|
closeResources(finalSxssfWorkbook, finalWordDocument, tempFiles); |
|
|
closeResources(finalSxssfWorkbook, finalWordDocument, tempFiles); |
|
|
} |
|
|
} |
|
|
|