perf: 88047 法规符合性排查性能优化
This commit is contained in:
+21
-11
@@ -84,6 +84,7 @@ import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.jero.modules.activiti.common.ActivitiCommon.*;
|
||||
@@ -446,25 +447,35 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
|
||||
@Override
|
||||
public List<ProcessStandardComplianceCheckDetail> generate(ProcessStandardComplianceCheck scc) throws Exception {
|
||||
String splitFileSource = scc.getSplitFileSource();
|
||||
List<ProcessStandardComplianceCheckDetail> detailInfoList;
|
||||
CompletableFuture<List<ProcessStandardComplianceCheckDetail>> detailInfoListFuture;
|
||||
CompletableFuture<List<ModelExcelVO>> modelExcelVOListFuture;
|
||||
|
||||
// 找到拆分数据
|
||||
if (StrUtil.isBlank(splitFileSource)) {
|
||||
MultipartFile splitFile = this.getFileById(scc.getSplitFile());
|
||||
detailInfoList = this.getSplitData(scc, splitFile);
|
||||
detailInfoListFuture = CompletableFuture.supplyAsync(() -> this.getSplitData(scc, splitFile));
|
||||
} else {
|
||||
detailInfoList = this.getSplitDataByStandard(scc);
|
||||
// 是否与上一般一致
|
||||
detailInfoListFuture = CompletableFuture.supplyAsync(() -> this.getSplitDataByStandard(scc));
|
||||
// 是否与上一版本一致
|
||||
String isSameLastVersion = scc.getIsSameLastVersion();
|
||||
if (YesOrNoEnum.NO.getValue().equals(isSameLastVersion)) {
|
||||
// 过滤出也为否的数据
|
||||
detailInfoList = detailInfoList.stream().filter(detail -> YesOrNoEnum.NO.getValue().equals
|
||||
(detail.getIsSameAsPrevVersion())).collect(Collectors.toList());
|
||||
detailInfoListFuture = detailInfoListFuture.thenApply(details -> details.stream()
|
||||
.filter(detail -> YesOrNoEnum.NO.getValue().equals(detail.getIsSameAsPrevVersion()))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
// 获取两个文件
|
||||
|
||||
// 获取模型文件并转换
|
||||
MultipartFile modelFile = this.getFileById(scc.getModelFile());
|
||||
// 文件内容转换
|
||||
List<ModelExcelVO> modelExcelVOList = this.getModelExcelData(modelFile);
|
||||
modelExcelVOListFuture = CompletableFuture.supplyAsync(() -> this.getModelExcelData(modelFile));
|
||||
|
||||
// 等待两个异步操作完成
|
||||
CompletableFuture.allOf(detailInfoListFuture, modelExcelVOListFuture).join();
|
||||
|
||||
// 结合两个文件的数据
|
||||
List<ProcessStandardComplianceCheckDetail> detailInfoList = detailInfoListFuture.get();
|
||||
List<ModelExcelVO> modelExcelVOList = modelExcelVOListFuture.get();
|
||||
|
||||
// 根据主表数据和车型文件生成子表数据并保存
|
||||
return this.saveAllDetailData(modelExcelVOList, detailInfoList);
|
||||
}
|
||||
@@ -1105,7 +1116,6 @@ public class ProcessStandardComplianceCheckServiceImpl extends ServiceImpl<Proce
|
||||
this.transToDictValue(modelExcelVOList, listDict);
|
||||
}
|
||||
// 转换一下数据
|
||||
|
||||
return modelExcelVOList;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user