Browse Source

feat: 可靠性预计

NickOooo 3 tuần trước cách đây
mục cha
commit
bad5b1abca

+ 25 - 25
nationrel-module-rp-biz/src/main/java/com/nationrel/modules/rp/service/impl/PredictionStruTreeServiceImpl.java

@@ -112,7 +112,7 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
         // 查询当前选中节点最后一个结构子节点,取它的右序号+1作为多级添加的起始左序号
         PredictionStruTree lastChildStruNode = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
                 .eq(PredictionStruTree::getPredictionId, predictionId)
-                .eq(PredictionStruTree::getParentStruId, predictionStruTree.getStruId())
+                .eq(PredictionStruTree::getParentStruId, parentStruNode.getStruId())
                 .orderByDesc(PredictionStruTree::getLeftNo)
                 .last("limit 1"));
         Integer rightNo;
@@ -153,24 +153,24 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
 
             }
         }
-        Map<String, PredictionStruTreeImport> rdfmStruTreeMap = this.buildStrutsTree(struChildrenTreeList);
+        Map<String, PredictionStruTreeImport> struTreeMap = this.buildStrutsTree(struChildrenTreeList);
         // 获取根节点
-        PredictionStruTreeImport rdfmRootNode = rdfmStruTreeMap.get(parentStruNode.getStruId());
+        PredictionStruTreeImport rootNode = struTreeMap.get(parentStruNode.getStruId());
         if (ObjectUtils.isNotEmpty(lastChildStruNode)) {
-            updateLeftAndRightNo(rdfmRootNode, lastChildStruNode.getRightNo());
+            updateLeftAndRightNo(rootNode, lastChildStruNode.getRightNo());
         } else {
-            updateLeftAndRightNo(rdfmRootNode, parentStruNode.getLeftNo());
+            updateLeftAndRightNo(rootNode, parentStruNode.getLeftNo());
         }
 
-        updateDeep(rdfmRootNode, parentStruNode.getDeep());
-        updateSeriesNo(rdfmRootNode, parentStruNode.getSeriesNo());
-        updateType(rdfmRootNode);
+        updateDeep(rootNode, parentStruNode.getDeep());
+        updateSeriesNo(rootNode, parentStruNode.getSeriesNo());
+        updateType(rootNode);
 
         // 有需要插入的数据
         if (!CollectionUtils.isEmpty(newStruList)) {
             // 通过TreeMap构建treeList
-            List<PredictionStruTree> rdfmStruTreeList = new ArrayList<>();
-            buildStruTreeList(rdfmRootNode, rdfmStruTreeList, newStruList);
+            List<PredictionStruTree> struTreeList = new ArrayList<>();
+            buildStruTreeList(rootNode, struTreeList, newStruList);
 
             int nodeCnt = newStruList.size() * 2;
             // 2.更新树节点-父级节点类型
@@ -188,7 +188,7 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
 
             // 依次插入已读入的数据
             // 插入结构树数据
-            this.saveStruTree(rdfmStruTreeList, sysUser.getUsername());
+            this.saveStruTree(struTreeList, sysUser.getUsername());
         }
     }
 
@@ -212,9 +212,9 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
             importStruTreeMap.put(struId, importStruTree);
         }
         // 根据上面放进去的节点,将所有节点分父子关系存入map
-        for (PredictionStruTree rdfmStruTree : treeList) {
-            String struId = rdfmStruTree.getStruId();
-            String parentStruId = rdfmStruTree.getParentStruId();
+        for (PredictionStruTree struTree : treeList) {
+            String struId = struTree.getStruId();
+            String parentStruId = struTree.getParentStruId();
             PredictionStruTreeImport importStruTree = importStruTreeMap.get(parentStruId);
             if (importStruTree != null) {
                 List<PredictionStruTreeImport> children = importStruTree.getChildren();
@@ -299,29 +299,29 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
         }
     }
 
-    private void buildStruTreeList(PredictionStruTreeImport predictionStruTreeImport, List<PredictionStruTree> rdfmStruTreeList, List<String> newStruList) {
+    private void buildStruTreeList(PredictionStruTreeImport predictionStruTreeImport, List<PredictionStruTree> struTreeList, List<String> newStruList) {
         List<PredictionStruTreeImport> children = predictionStruTreeImport.getChildren();
         if (newStruList.contains(predictionStruTreeImport.getPredictionStruTree().getStruId())) {
-            rdfmStruTreeList.add(predictionStruTreeImport.getPredictionStruTree());
+            struTreeList.add(predictionStruTreeImport.getPredictionStruTree());
         }
         if (!CollectionUtils.isEmpty(children)) {
             for (PredictionStruTreeImport child : children) {
-                buildStruTreeList(child, rdfmStruTreeList, newStruList);
+                buildStruTreeList(child, struTreeList, newStruList);
             }
         }
     }
 
     /**
      * 插入结构树表
-     * @param rdfmStruTreeList
+     * @param struTreeList
      */
-    private void saveStruTree(List<PredictionStruTree> rdfmStruTreeList, String userName) {
-        List<PredictionStruTree> batchRdfmStruTrees = new ArrayList<>();
-        for (PredictionStruTree rdfmStruTree: rdfmStruTreeList) {
-            rdfmStruTree.setInsertUserBy(userName);
-            rdfmStruTree.setInsertTime(new Date());
-            batchRdfmStruTrees.add(rdfmStruTree);
+    private void saveStruTree(List<PredictionStruTree> struTreeList, String userName) {
+        List<PredictionStruTree> batchStruTrees = new ArrayList<>();
+        for (PredictionStruTree struTree: struTreeList) {
+            struTree.setInsertUserBy(userName);
+            struTree.setInsertTime(new Date());
+            batchStruTrees.add(struTree);
         }
-        this.saveBatch(batchRdfmStruTrees);
+        this.saveBatch(batchStruTrees);
     }
 }