|
@@ -194,8 +194,16 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
public List<WbsTreeContractVO> addNodeTree(String pKeyId) {
|
|
|
WbsTreeContract parentNodeRoot = wbsTreeContractMapper.selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, pKeyId).eq(WbsTreeContract::getStatus, 1));
|
|
|
if (parentNodeRoot != null) {
|
|
|
+ //oldId不等于空,说明是复制节点,通过oldId,去获取原始树节点
|
|
|
+ if (parentNodeRoot.getOldId() != null) {
|
|
|
+ parentNodeRoot = this.recursionFindResourceRootNode(parentNodeRoot);
|
|
|
+ }
|
|
|
List<WbsTreeContract> allNodes = this.getChildNodes(parentNodeRoot);
|
|
|
+ if (allNodes == null) {
|
|
|
+ allNodes = new ArrayList<>();
|
|
|
+ }
|
|
|
allNodes.add(parentNodeRoot);
|
|
|
+
|
|
|
List<WbsTreeContractVO> resultAllNodes = BeanUtil.copyProperties(allNodes, WbsTreeContractVO.class);
|
|
|
return buildWbsTreeByStreamChildNodeTree(resultAllNodes, parentNodeRoot);
|
|
|
}
|
|
@@ -221,17 +229,32 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
}
|
|
|
|
|
|
private List<WbsTreeContract> getChildNodes(WbsTreeContract obj) {
|
|
|
- if (obj != null) {
|
|
|
- List<WbsTreeContract> wbsTreeContracts = Collections.singletonList(obj);
|
|
|
- List<WbsTreeContract> result = new ArrayList<>();
|
|
|
- this.recursionGetChildNodes(wbsTreeContracts, result, obj.getContractId());
|
|
|
- if (result.size() > 0) {
|
|
|
- return result;
|
|
|
- }
|
|
|
+ List<WbsTreeContract> wbsTreeContracts = Collections.singletonList(obj);
|
|
|
+ List<WbsTreeContract> result = new ArrayList<>();
|
|
|
+ this.recursionGetChildNodes(wbsTreeContracts, result, obj.getContractId());
|
|
|
+ if (result.size() > 0) {
|
|
|
+ return result;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private WbsTreeContract recursionFindResourceRootNode(WbsTreeContract obj) {
|
|
|
+ if (obj.getOldId() != null) {
|
|
|
+ WbsTreeContract obj1 = wbsTreeContractMapper.selectOne(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
+ .eq(WbsTreeContract::getId, obj.getOldId())
|
|
|
+ .eq(WbsTreeContract::getContractId, obj.getContractId()));
|
|
|
+ if (obj1 != null && obj1.getOldId() != null) {
|
|
|
+ obj1 = this.recursionFindResourceRootNode(obj1);
|
|
|
+ } else {
|
|
|
+ // 已经到达原始节点,返回当前节点的id
|
|
|
+ return obj1 != null ? obj1 : obj;
|
|
|
+ }
|
|
|
+ obj = obj1;
|
|
|
+ }
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void recursionGetChildNodes(List<WbsTreeContract> list, List<WbsTreeContract> result, String contractId) {
|
|
|
List<Long> ids = list.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
|
if (ids.size() > 0) {
|