Prechádzať zdrojové kódy

节点参数、电签默认信息同步相关

liuyc 2 rokov pred
rodič
commit
b55f3d6088

+ 16 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -763,7 +763,13 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                     this.wbsParamServiceImpl.updateBatchById(updateList, 1000);
                 }
                 if (insertList.size() > 0) {
-                    this.wbsParamServiceImpl.saveBatch(insertList, 1000);
+                    //异步新增
+                    List<List<WbsParam>> partition1 = Lists.partition(insertList, 1000);
+                    CompletableFuture<Void> handle = CompletableFuture.allOf(partition1.stream().map(addList ->
+                            CompletableFuture.runAsync(() -> {
+                                wbsParamServiceImpl.insertBatch(addList, 1000);
+                            }, executor)).toArray(CompletableFuture[]::new));
+                    handle.join();
                 }
                 return true;
             }
@@ -1459,7 +1465,15 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                 }
 
                 //新增
-                textDictInfoService.insertBatch(insertData, 1000);
+                //textDictInfoService.insertBatch(insertData, 1000);
+
+                //异步新增
+                List<List<TextdictInfo>> partition1 = Lists.partition(insertData, 1000);
+                CompletableFuture<Void> handle = CompletableFuture.allOf(partition1.stream().map(addList ->
+                        CompletableFuture.runAsync(() -> {
+                            textDictInfoService.insertBatch(addList, 1000);
+                        }, executor)).toArray(CompletableFuture[]::new));
+                handle.join();
 
                 return true;
             } else {

+ 24 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

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