Browse Source

Merge remote-tracking branch 'origin/master'

master
yinhuaiwei 1 month ago
parent
commit
21e8c10151
7 changed files with 33 additions and 15 deletions
  1. +1
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/domain/InspectionReport.java
  2. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/mapper/InspectionReportMapper.java
  3. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/service/IInspectionReportService.java
  4. +4
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/service/impl/InspectionReportServiceImpl.java
  5. +2
    -1
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java
  6. +11
    -14
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java
  7. +11
    -0
      inspect-main/inspect-main-task/src/main/resources/mapper/task/InspectionReportMapper.xml

+ 1
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/domain/InspectionReport.java View File

@ -100,6 +100,7 @@ public class InspectionReport extends BaseEntity {
private Date cycleEndTime; private Date cycleEndTime;
private String taskPatrolledId; private String taskPatrolledId;
private String filter; private String filter;
private List<Long> lineIds;
List<InspectionReportData> ReportDatalist; List<InspectionReportData> ReportDatalist;
private List<InspectionReportData> info; private List<InspectionReportData> info;


+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/mapper/InspectionReportMapper.java View File

@ -17,6 +17,8 @@ public interface InspectionReportMapper {
int updateInspectionReport(InspectionReport report); int updateInspectionReport(InspectionReport report);
int updateInspectionReportFilePath(InspectionReport report);
int deleteInspectionReportByLineId(Long lineId); int deleteInspectionReportByLineId(Long lineId);
int deleteInspectionReportByLineIds(Long[] lineIds); int deleteInspectionReportByLineIds(Long[] lineIds);


+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/service/IInspectionReportService.java View File

@ -15,6 +15,8 @@ public interface IInspectionReportService {
int updateInspectionReport(InspectionReport inspectionReport); int updateInspectionReport(InspectionReport inspectionReport);
int updateInspectionReportFilePath(InspectionReport inspectionReport);
int deleteInspectionReportByLineIds(Long[] lineIds); int deleteInspectionReportByLineIds(Long[] lineIds);
int deleteInspectionReportByLineId(Long lineId); int deleteInspectionReportByLineId(Long lineId);


+ 4
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/service/impl/InspectionReportServiceImpl.java View File

@ -38,6 +38,10 @@ public class InspectionReportServiceImpl implements IInspectionReportService {
return this.inspectionReportMapper.updateInspectionReport(inspectionReport); return this.inspectionReportMapper.updateInspectionReport(inspectionReport);
} }
public int updateInspectionReportFilePath(InspectionReport inspectionReport) {
return this.inspectionReportMapper.updateInspectionReportFilePath(inspectionReport);
}
public int deleteInspectionReportByLineIds(Long[] lineIds) { public int deleteInspectionReportByLineIds(Long[] lineIds) {
return this.inspectionReportMapper.deleteInspectionReportByLineIds(lineIds); return this.inspectionReportMapper.deleteInspectionReportByLineIds(lineIds);
} }


+ 2
- 1
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java View File

@ -520,7 +520,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
@Transactional @Transactional
public List<Long> saveReportShaoxing(PatrolTaskResultMain resultMain, List<Long> lineIds, List<PatrolResult> resultList) { public List<Long> saveReportShaoxing(PatrolTaskResultMain resultMain, List<Long> lineIds, List<PatrolResult> resultList) {
log.info("saveReportShaoxing PatrolTaskResultMain:{},lineIds:{},resultList:{} ", resultMain, lineIds, resultList);
log.info("saveReportShaoxing PatrolTaskResultMain:{},lineIds:{},resultList size:{} ", resultMain, lineIds, resultList.size());
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
List<Long> reportIds = new ArrayList<>(); List<Long> reportIds = new ArrayList<>();
// 获取站信息 // 获取站信息
@ -787,6 +787,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
this.patrolTaskResultMainMapper.updatePatrolTaskResultMain(resultMain); this.patrolTaskResultMainMapper.updatePatrolTaskResultMain(resultMain);
this.patrolResultMapper.updatePatrolResultByMainId(String.valueOf(lineId)); this.patrolResultMapper.updatePatrolResultByMainId(String.valueOf(lineId));
} }
startTime = PrintUtil.useTime("导出报告:全部数据入库", startTime);
return reportIds; return reportIds;
} }


+ 11
- 14
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/controller/PatrolTaskResultMainController.java View File

@ -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);
} }


+ 11
- 0
inspect-main/inspect-main-task/src/main/resources/mapper/task/InspectionReportMapper.xml View File

@ -172,6 +172,17 @@
where line_id = #{lineId} where line_id = #{lineId}
</update> </update>
<update id="updateInspectionReportFilePath" parameterType="InspectionReport">
update inspection_report
<trim prefix="SET" suffixOverrides=",">
<if test="filePath != null">file_path = #{filePath},</if>
</trim>
where line_id in
<foreach item="lineId" collection="lineIds" open="(" separator="," close=")">
#{lineId}
</foreach>
</update>
<delete id="deleteInspectionReportByLineId" parameterType="Long"> <delete id="deleteInspectionReportByLineId" parameterType="Long">
delete delete
from inspection_report from inspection_report


Loading…
Cancel
Save