|
@@ -34,9 +34,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -60,6 +63,9 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
private final ITableInfoService tableInfoService;
|
|
|
|
|
|
+ @Resource(name = "taskExecutor1")
|
|
|
+ private ThreadPoolExecutor executor;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<WbsTreeVO> selectWbsTreePage(IPage<WbsTreeVO> page, WbsTreeVO wbsTree) {
|
|
|
return page.setRecords(baseMapper.selectWbsTreePage(page, wbsTree));
|
|
@@ -769,9 +775,15 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
|
|
|
if (pawDTO.getReferenceType().equals("public")) {
|
|
|
-
|
|
|
- this.insertBatch(insertData1, 1000);
|
|
|
-
|
|
|
+ //异步新增
|
|
|
+ List<List<WbsTreePrivate>> partition1 = Lists.partition(insertData1, 1000);
|
|
|
+ CompletableFuture<Void> handle = CompletableFuture.allOf(partition1.stream().map(addList ->
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ wbsTreePrivateService.insertBatch(addList,1000);
|
|
|
+ }, executor)).toArray(CompletableFuture[]::new));
|
|
|
+ handle.join();
|
|
|
+
|
|
|
+ //修改状态
|
|
|
if (pawDTO.getWbsType() == 1) {
|
|
|
projectInfoMapper.updateTemplateInfoQuality(pawDTO.getProjectId(), pawDTO.getWbsId(), "public");
|
|
|
}
|
|
@@ -780,9 +792,15 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
|
|
|
} else if (pawDTO.getReferenceType().equals("private")) {
|
|
|
-
|
|
|
- this.insertBatch(insertData2, 1000);
|
|
|
-
|
|
|
+ //异步新增
|
|
|
+ List<List<WbsTreePrivate>> partition1 = Lists.partition(insertData2, 1000);
|
|
|
+ CompletableFuture<Void> handle = CompletableFuture.allOf(partition1.stream().map(addList ->
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ wbsTreePrivateService.insertBatch(addList,1000);
|
|
|
+ }, executor)).toArray(CompletableFuture[]::new));
|
|
|
+ handle.join();
|
|
|
+
|
|
|
+ //修改状态
|
|
|
if (pawDTO.getWbsType() == 1) {
|
|
|
projectInfoMapper.updateTemplateInfoQuality(pawDTO.getProjectId(), pawDTO.getPrimaryKeyId(), "private");
|
|
|
}
|