Browse Source

feat: 可靠性预计

NickOooo 1 week ago
parent
commit
75590dd574

+ 2 - 0
nationrel-module-rp-api/src/main/java/com/nationrel/modules/rp/constant/RpConstant.java

@@ -52,4 +52,6 @@ public class RpConstant {
     public static final String MOVE_UP = "2";
     /** 下移 */
     public static final String MOVE_DOWN = "3";
+
+    public static final String DEFAULT_COUNT = "1";
 }

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

@@ -313,6 +313,12 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
                 parentTreeNode.setUpdateTime(new Date());
                 predictionStruTreeMapper.updateById(parentTreeNode);
             }
+            List<PredictionTable> predictionTables = predictionTableMapper.selectList(new LambdaQueryWrapper<PredictionTable>()
+                    .eq(PredictionTable::getPredictionId, predictionId)
+                    .eq(PredictionTable::getStruId, struId));
+            if (!CollectionUtils.isEmpty(predictionTables)) {
+                predictionTableMapper.deleteBatchIds(predictionTables.stream().map(PredictionTable::getId).toList());
+            }
         }
         return predictionInfo;
     }
@@ -354,13 +360,13 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
             }
         }
 
-        // 查询指定结构下第一个结构的左序号
+        // 查询指定结构下最大结构的左序号
         PredictionStruTree firstStruTree = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
                 .eq(PredictionStruTree::getPredictionId, pasteStructureReq.getPredictionId())
                 .ne(PredictionStruTree::getIsDelete, RpConstant.IS_DELETE)
                 .eq(PredictionStruTree::getParentStruId, selectStruTree.getStruId())
-                .orderByAsc(PredictionStruTree::getLeftNo)
-                .last("limit 0, 1"));
+                .orderByDesc(PredictionStruTree::getLeftNo)
+                .last("limit 1"));
 
         PredictionStruTree parentStruTree = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
                 .eq(PredictionStruTree::getPredictionId, pasteStructureReq.getPredictionId())
@@ -370,7 +376,7 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
         if (pasteStructureReq.getOptType() == 1) {
             int no = 0;
             if (ObjectUtils.isNotEmpty(firstStruTree)) {
-                no = firstStruTree.getRightNo();
+                no = firstStruTree.getRightNo() + 1;
             } else {
                 no = selectStruTree.getRightNo();
             }
@@ -635,7 +641,8 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
                 .eq(PredictionStruTree::getPredictionId, copyPredictionId)
                 .eq(PredictionStruTree::getIsDelete, RpConstant.NOT_DELETE)
                 .ge(PredictionStruTree::getLeftNo, copyLeftNo)
-                .le(PredictionStruTree::getLeftNo, copyRightNo));
+                .le(PredictionStruTree::getLeftNo, copyRightNo)
+                .orderByAsc(PredictionStruTree::getLeftNo));
 
         // 父级节点
         Map<String, String> parentMapFlag = new HashMap<String, String>();

+ 15 - 0
nationrel-module-rp-biz/src/main/java/com/nationrel/modules/rp/service/impl/PredictionTableServiceImpl.java

@@ -2,14 +2,18 @@ package com.nationrel.modules.rp.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.nationrel.modules.rp.aop.UpdatePrediction;
+import com.nationrel.modules.rp.constant.RpConstant;
+import com.nationrel.modules.rp.entity.PredictionColumns;
 import com.nationrel.modules.rp.entity.PredictionInfo;
 import com.nationrel.modules.rp.entity.PredictionTable;
+import com.nationrel.modules.rp.mapper.PredictionColumnsMapper;
 import com.nationrel.modules.rp.mapper.PredictionInfoMapper;
 import com.nationrel.modules.rp.mapper.PredictionTableMapper;
 import com.nationrel.modules.rp.service.IPredictionTableService;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -31,6 +35,8 @@ public class PredictionTableServiceImpl extends ServiceImpl<PredictionTableMappe
     private PredictionTableMapper predictionTableMapper;
     @Autowired
     private PredictionInfoMapper predictionInfoMapper;
+    @Autowired
+    private PredictionColumnsMapper predictionColumnsMapper;
 
     /**
      * @Description 保存表格数据
@@ -59,6 +65,15 @@ public class PredictionTableServiceImpl extends ServiceImpl<PredictionTableMappe
             predictionTable.setCreateBy(sysUser.getUsername());
             predictionTable.setCreateTime(new Date());
             predictionTableMapper.insert(predictionTable);
+            PredictionColumns predictionColumns = predictionColumnsMapper.selectOne(new LambdaQueryWrapper<PredictionColumns>()
+                    .eq(PredictionColumns::getPredictionId, predictionTable.getPredictionId())
+                    .eq(PredictionColumns::getColName, RpConstant.DEFAULT_COLUMNS.get(5).getColumnName()));
+            PredictionTable countTable = new PredictionTable();
+            BeanUtils.copyProperties(predictionTable, countTable);
+            countTable.setId(null);
+            countTable.setColumnsId(predictionColumns.getId());
+            countTable.setValue(RpConstant.DEFAULT_COUNT);
+            predictionTableMapper.insert(countTable);
         }
         return predictionInfo;
     }