|
@@ -294,7 +294,7 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
|
|
|
.orderByAsc(PredictionStruTree::getLeftNo)
|
|
|
.last("limit 0, 1"));
|
|
|
|
|
|
- PredictionStruTree parentRdfmStruTree = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
|
|
|
+ PredictionStruTree parentStruTree = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
|
|
|
.eq(PredictionStruTree::getPredictionId, pasteStructureReq.getPredictionId())
|
|
|
.eq(PredictionStruTree::getStruId, pasteStructureReq.getStruId()));
|
|
|
|
|
@@ -308,11 +308,11 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
|
|
|
}
|
|
|
|
|
|
// 拷贝
|
|
|
- this.copy(sysUser, parentRdfmStruTree, pasteStructureReq.getPredictionId(),
|
|
|
+ this.copy(sysUser, parentStruTree, pasteStructureReq.getPredictionId(),
|
|
|
pasteStructureReq.getStruId(), copyStruTree,
|
|
|
pasteStructureReq.getSrcStruId(), no);
|
|
|
} else if (pasteStructureReq.getOptType() == 2) {
|
|
|
-
|
|
|
+ this.cut(sysUser, parentStruTree, pasteStructureReq.getPredictionId(), parentStruTree.getStruId(), copyStruTree, copyStruTree.getStruId());
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -595,4 +595,71 @@ public class PredictionStruTreeServiceImpl extends ServiceImpl<PredictionStruTre
|
|
|
importingTree.clear();
|
|
|
return newStruIdMap;
|
|
|
}
|
|
|
+
|
|
|
+ private void cut(LoginUser user, PredictionStruTree parentStruTree, String predictionId,
|
|
|
+ String parentStruId, PredictionStruTree copyStruTree, String copyStruId) throws Exception {
|
|
|
+ PredictionStruTree rootStructNode = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
|
|
|
+ .eq(PredictionStruTree::getPredictionId, predictionId)
|
|
|
+ .eq(PredictionStruTree::getParentStruId, RpConstant.ROOTNODE_PARENT));
|
|
|
+
|
|
|
+ // (2.1)将拷贝节点排除在树外(排除方法左右序号都+根结点右序号+前次假删的节点数*2)。便于以后更新。
|
|
|
+ predictionStruTreeMapper.updateLeftRightNoBecauseRemove(predictionId, copyStruTree.getLeftNo(),
|
|
|
+ copyStruTree.getRightNo(), rootStructNode.getRightNo(), 0);
|
|
|
+ int offset = copyStruTree.getRightNo() - copyStruTree.getLeftNo() + 1;
|
|
|
+
|
|
|
+ // (2.2)将拷贝节点排除在树外,余下节点左右序号重新顺处理;
|
|
|
+ predictionStruTreeMapper.updateLeftNoInPartTree(predictionId, copyStruTree.getLeftNo(), rootStructNode.getRightNo(), -offset);
|
|
|
+ predictionStruTreeMapper.updateRightNoInPartTree(predictionId, copyStruTree.getRightNo(), rootStructNode.getRightNo(), -offset);
|
|
|
+
|
|
|
+ // (2.3)将拷贝节点排除在树外,原上级节点类型更改
|
|
|
+ PredictionStruTree copyParentStruTree = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
|
|
|
+ .eq(PredictionStruTree::getPredictionId, predictionId)
|
|
|
+ .eq(PredictionStruTree::getStruId, copyStruTree.getParentStruId()));
|
|
|
+ if (copyParentStruTree.getRightNo() - copyParentStruTree.getLeftNo() == 1) {
|
|
|
+ copyParentStruTree.setType(RpConstant.TREENODE_TYPE_LEAF);
|
|
|
+ copyParentStruTree.setUpdateUserBy(user.getUsername());
|
|
|
+ copyParentStruTree.setUpdateTime(new Date());
|
|
|
+ predictionStruTreeMapper.updateById(copyParentStruTree);
|
|
|
+ }
|
|
|
+
|
|
|
+ // (2.5) 被粘贴节点的类型更改
|
|
|
+ parentStruTree = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
|
|
|
+ .eq(PredictionStruTree::getPredictionId, predictionId)
|
|
|
+ .eq(PredictionStruTree::getStruId, parentStruId));
|
|
|
+ if (RpConstant.TREENODE_TYPE_LEAF.equals(parentStruTree.getType())) {
|
|
|
+ parentStruTree.setType(RpConstant.TREENODE_TYPE_NONLEAF);
|
|
|
+ parentStruTree.setUpdateUserBy(user.getUsername());
|
|
|
+ parentStruTree.setUpdateTime(new Date());
|
|
|
+ predictionStruTreeMapper.updateById(parentStruTree);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 取得剪切节点在新上级节点下的位置
|
|
|
+ int rightNo = parentStruTree.getRightNo();
|
|
|
+ PredictionStruTree sonNodeOfStruTree = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
|
|
|
+ .eq(PredictionStruTree::getPredictionId, predictionId)
|
|
|
+ .eq(PredictionStruTree::getParentStruId, parentStruId)
|
|
|
+ .gt(PredictionStruTree::getLeftNo, parentStruTree.getLeftNo())
|
|
|
+ .lt(PredictionStruTree::getRightNo, parentStruTree.getRightNo())
|
|
|
+ .orderByDesc(PredictionStruTree::getLeftNo)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotEmpty(sonNodeOfStruTree)) {
|
|
|
+ // 兄弟节点的最大右序号
|
|
|
+ rightNo = sonNodeOfStruTree.getRightNo() + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // (2.6) 被粘贴节点下, 左右序号,被剪切节点数量的预留
|
|
|
+ predictionStruTreeMapper.updateLeftNoInPartTree(predictionId, rightNo, rootStructNode.getRightNo(), offset);
|
|
|
+ predictionStruTreeMapper.updateRightNoInPartTree(predictionId, rightNo, rootStructNode.getRightNo(), offset);
|
|
|
+
|
|
|
+ copyStruTree = predictionStruTreeMapper.selectOne(new LambdaQueryWrapper<PredictionStruTree>()
|
|
|
+ .eq(PredictionStruTree::getPredictionId, predictionId)
|
|
|
+ .eq(PredictionStruTree::getStruId, copyStruId));
|
|
|
+ int minusOffset = copyStruTree.getLeftNo() - (rightNo);
|
|
|
+ // (2.7) 剪切节点的上级节点修改, 左右序号,深度,序号
|
|
|
+ predictionStruTreeMapper.updateParentStructureId(predictionId, copyStruTree.getLeftNo(), copyStruTree.getRightNo(),
|
|
|
+ copyStruTree.getParentStruId(), parentStruId);
|
|
|
+
|
|
|
+ predictionStruTreeMapper.updateLeftRightNoBecauseRemove(predictionId, copyStruTree.getLeftNo(),
|
|
|
+ copyStruTree.getRightNo(), -minusOffset, parentStruTree.getDeep() - copyStruTree.getDeep() + 1);
|
|
|
+ }
|
|
|
}
|