liuyc 2 rokov pred
rodič
commit
0f08c2d7a2

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -1613,10 +1613,10 @@ public class InformationWriteQueryController extends BladeController {
     private void reBuildAncestors(List<WbsTreeContract> result, WbsTreeContract needCopyNodeRoot) {
         for (WbsTreeContract wbsTreeContract : result) {
             //根节点
-            if (ObjectUtil.isNotEmpty(needCopyNodeRoot) && wbsTreeContract.getOldId().equals(needCopyNodeRoot.getId().toString())) {
+            if (needCopyNodeRoot != null && wbsTreeContract.getOldId().equals(needCopyNodeRoot.getId().toString())) {
                 wbsTreeContract.setAncestors(needCopyNodeRoot.getAncestors());
             }//非根节点
-            if (ObjectUtil.isNotEmpty(wbsTreeContract.getParentId()) && ObjectUtil.isNotEmpty(wbsTreeContract.getAncestors()) && !wbsTreeContract.getAncestors().contains(wbsTreeContract.getParentId() + "")) {
+            if (wbsTreeContract != null && ObjectUtil.isNotEmpty(wbsTreeContract.getParentId()) && ObjectUtil.isNotEmpty(wbsTreeContract.getAncestors()) && !wbsTreeContract.getAncestors().contains(wbsTreeContract.getParentId() + "")) {
                 String[] split = wbsTreeContract.getAncestors().split(",");
                 String s = split[split.length - 1];
                 wbsTreeContract.setAncestors(wbsTreeContract.getAncestors().replace(s, wbsTreeContract.getParentId() + ""));

+ 10 - 54
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -67,9 +67,6 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
     private final TextdictInfoServiceImpl textDictInfoService;
     private final InformationQueryClient informationQueryClient;
 
-    //创建线程池任务
-    private final ExecutorService executor = Executors.newFixedThreadPool(4);
-
     @Override
     public List<WbsTreePrivateVO> tree(String wbsId, String projectId) {
         WbsInfo wbsInfo = wbsInfoMapper.selectOne(Wrappers.<WbsInfo>query().lambda().eq(WbsInfo::getId, wbsId));
@@ -810,32 +807,12 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                 this.wbsParamServiceImpl.updateBatchById(updateList, 1000);
             }
             if (insertList.size() > 0) {
-                try {
-                    List<List<WbsParam>> partition1 = Lists.partition(insertList, 1000);
-                    CompletionService<Void> completionService = new ExecutorCompletionService<>(executor);
-                    for (List<WbsParam> addList : partition1) {
-                        completionService.submit(() -> {
-                            wbsParamServiceImpl.insertBatch(addList, 1000);
-                            return null;
-                        });
-                    }
-                    for (int i = 0; i < partition1.size(); i++) {
-                        try {
-                            completionService.take().get();
-                        } catch (ExecutionException e) {
-                            // 异常处理
-                            e.printStackTrace();
-                        }
-                    }
-                } catch (Exception e) {
-                    e.printStackTrace();
-                } finally {
-                    //释放线程
-                    executor.shutdown();
+                List<List<WbsParam>> partition1 = Lists.partition(insertList, 1000);
+                for (List<WbsParam> addList : partition1) {
+                    wbsParamServiceImpl.insertBatch(addList, 1000);
                 }
-
+                return true;
             }
-            return true;
         }
         return false;
     }
@@ -1148,36 +1125,15 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                     jdbcTemplate.execute(delSql);
                 }
 
-                try {
-                    List<List<TextdictInfo>> partition1 = Lists.partition(insertData, 1000);
-                    CompletionService<Void> completionService = new ExecutorCompletionService<>(executor);
-                    for (List<TextdictInfo> addList : partition1) {
-                        completionService.submit(() -> {
-                            textDictInfoService.insertBatch(addList, 1000);
-                            return null;
-                        });
-                    }
-                    for (int i = 0; i < partition1.size(); i++) {
-                        try {
-                            completionService.take().get();
-                        } catch (ExecutionException e) {
-                            // 异常处理
-                            e.printStackTrace();
-                        }
-                    }
-                } catch (Exception e) {
-                    e.printStackTrace();
-                } finally {
-                    //释放线程
-                    executor.shutdown();
+                List<List<TextdictInfo>> partition1 = Lists.partition(insertData, 1000);
+                for (List<TextdictInfo> addList : partition1) {
+                    textDictInfoService.insertBatch(addList, 1000);
                 }
-
-                return true;
-            } else {
-                throw new ServiceException("当前项目关联的wbs树不是私有关联");
             }
+            return true;
+        } else {
+            throw new ServiceException("当前项目关联的wbs树不是私有关联");
         }
-        return false;
     }
 
     @Override

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

@@ -61,9 +61,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
     private final JdbcTemplate jdbcTemplate;
     private final ITableInfoService tableInfoService;
 
-    //创建线程池任务
-    private final ExecutorService executor = Executors.newFixedThreadPool(4);
-
     @Override
     public IPage<WbsTreeVO> selectWbsTreePage(IPage<WbsTreeVO> page, WbsTreeVO wbsTree) {
         return page.setRecords(baseMapper.selectWbsTreePage(page, wbsTree));
@@ -801,28 +798,9 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                     }
 
                     if (pawDTO.getReferenceType().equals("public")) {
-                        try {
-                            List<List<WbsTreePrivate>> partition1 = Lists.partition(insertData1, 1000);
-                            CompletionService<Void> completionService = new ExecutorCompletionService<>(executor);
-                            for (List<WbsTreePrivate> addList : partition1) {
-                                completionService.submit(() -> {
-                                    wbsTreePrivateService.insertBatch(addList, 1000);
-                                    return null;
-                                });
-                            }
-                            for (int i = 0; i < partition1.size(); i++) {
-                                try {
-                                    completionService.take().get();
-                                } catch (ExecutionException e) {
-                                    // 异常处理
-                                    e.printStackTrace();
-                                }
-                            }
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        } finally {
-                            //释放线程
-                            executor.shutdown();
+                        List<List<WbsTreePrivate>> partition1 = Lists.partition(insertData1, 1000);
+                        for (List<WbsTreePrivate> addList : partition1) {
+                            wbsTreePrivateService.insertBatch(addList, 1000);
                         }
 
                         //修改状态
@@ -834,28 +812,9 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                         }
 
                     } else if (pawDTO.getReferenceType().equals("private")) {
-                        try {
-                            List<List<WbsTreePrivate>> partition1 = Lists.partition(insertData2, 1000);
-                            CompletionService<Void> completionService = new ExecutorCompletionService<>(executor);
-                            for (List<WbsTreePrivate> addList : partition1) {
-                                completionService.submit(() -> {
-                                    wbsTreePrivateService.insertBatch(addList, 1000);
-                                    return null;
-                                });
-                            }
-                            for (int i = 0; i < partition1.size(); i++) {
-                                try {
-                                    completionService.take().get();
-                                } catch (ExecutionException e) {
-                                    // 异常处理
-                                    e.printStackTrace();
-                                }
-                            }
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        } finally {
-                            //释放线程
-                            executor.shutdown();
+                        List<List<WbsTreePrivate>> partition1 = Lists.partition(insertData2, 1000);
+                        for (List<WbsTreePrivate> addList : partition1) {
+                            wbsTreePrivateService.insertBatch(addList, 1000);
                         }
 
                         //异步修改htmlUrl ,数据都在insertData2里