|
@@ -88,23 +88,28 @@ public class ImportExcelServiceImpl implements ImportExcelService {
|
|
|
public void dataSaveAndPostProcessing(List<SwWaterUsageEntryDo> saveList, String dskey, Map<String, SwUserManagementDo> ownerMap) {
|
|
|
long asyncTasksStart = System.currentTimeMillis();
|
|
|
List<List<SwWaterUsageEntryDo>> partition = Lists.partition(saveList, 1000); // 动态分片
|
|
|
- CompletableFuture<Void> allFutures = CompletableFuture.allOf(
|
|
|
- partition.stream()
|
|
|
- .map(data ->
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
- waterUsageEntryService.getBaseMapper().ListBatchSave(data, dskey);
|
|
|
- log.debug("数据保存耗时: {}ms,总条数:{}", System.currentTimeMillis() - startTime, data.size());
|
|
|
- },
|
|
|
- asyncTaskExecutor).whenComplete((result, ex) -> {
|
|
|
- }))
|
|
|
- .toArray(CompletableFuture[]::new)
|
|
|
- );
|
|
|
- allFutures.thenRun(() -> {
|
|
|
+ for (List<SwWaterUsageEntryDo> data : partition) {
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ waterUsageEntryService.getBaseMapper().ListBatchSave(data, dskey);
|
|
|
+ log.debug("数据保存耗时: {}ms,总条数:{}", System.currentTimeMillis() - startTime, data.size());
|
|
|
+ }
|
|
|
+ // CompletableFuture<Void> allFutures = CompletableFuture.allOf(
|
|
|
+ // partition.stream()
|
|
|
+ // .map(data ->
|
|
|
+ // CompletableFuture.runAsync(() -> {
|
|
|
+ // long startTime = System.currentTimeMillis();
|
|
|
+ // waterUsageEntryService.getBaseMapper().ListBatchSave(data, dskey);
|
|
|
+ // log.debug("数据保存耗时: {}ms,总条数:{}", System.currentTimeMillis() - startTime, data.size());
|
|
|
+ // },
|
|
|
+ // asyncTaskExecutor).whenComplete((result, ex) -> {
|
|
|
+ // }))
|
|
|
+ // .toArray(CompletableFuture[]::new)
|
|
|
+ // );
|
|
|
+ // allFutures.thenRun(() -> {
|
|
|
ContextHolder.setValue("dsKey", dskey);
|
|
|
billGenerationService.asyncGenerateBill(saveList, ownerMap); // 同步生成账单
|
|
|
log.debug("数据保存总耗时: {}ms", System.currentTimeMillis() - asyncTasksStart);
|
|
|
- });
|
|
|
+ // });
|
|
|
}
|
|
|
|
|
|
public File readFile(String fileId) {
|