|
|
@@ -5076,7 +5076,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
.collect(Collectors.toSet());
|
|
|
List<WbsTreeContract> parentNodes = this.listByIds(parentIds);
|
|
|
Map<Long, WbsTreeContract> parentNodeMap = parentNodes.stream()
|
|
|
- .collect(Collectors.toMap(WbsTreeContract::getId, Function.identity()));
|
|
|
+ .collect(Collectors.toMap(WbsTreeContract::getPKeyId, Function.identity()));
|
|
|
|
|
|
WbsTreeContract moveFatherNode = parentNodeMap.get(list.get(0).getPId());
|
|
|
WbsTreeContract fatherContract = this.getById(dto.getRightPkeyId());
|
|
|
@@ -5125,10 +5125,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
/**
|
|
|
* 优化后的FormulaDataBlock处理
|
|
|
*/
|
|
|
- @Async
|
|
|
public void processFormulaDataBlocksOptimized(WbsTreeContract moveFatherNode, WbsTreeContract fatherContract) {
|
|
|
// 使用单个查询获取两个节点的数据
|
|
|
- String sql = "SELECT * FROM m_formula_data_block WHERE sw_id IN (?, ?) AND contract_id = ? AND type = 0 AND is_deleted = 0";
|
|
|
+ String sql = "SELECT * FROM m_formula_data_block WHERE sw_id IN (?, ?) AND contract_id = ? AND type = 0";
|
|
|
|
|
|
List<FormulaDataBlock> formulaBlocks = jdbcTemplate.query(
|
|
|
sql,
|
|
|
@@ -5173,12 +5172,10 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
Map<Long, WbsTreeContract> parentNodeMap) {
|
|
|
// 收集所有需要更新的节点
|
|
|
List<WbsTreeContract> nodesToUpdate = new ArrayList<>();
|
|
|
- Map<Long, String> oldAncestorsMap = new HashMap<>();
|
|
|
Map<Long, String> oldAncestorsPIdMap = new HashMap<>();
|
|
|
|
|
|
// 预处理移动的节点
|
|
|
for (WbsTreeContract contract : list) {
|
|
|
- oldAncestorsMap.put(contract.getPKeyId(), contract.getAncestors());
|
|
|
oldAncestorsPIdMap.put(contract.getPKeyId(), contract.getAncestorsPId());
|
|
|
|
|
|
// 更新当前节点信息
|
|
|
@@ -5189,37 +5186,33 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
nodesToUpdate.add(contract);
|
|
|
}
|
|
|
-
|
|
|
// 批量查询所有子节点
|
|
|
if (!list.isEmpty()) {
|
|
|
List<Long> parentKeyIds = list.stream()
|
|
|
.map(WbsTreeContract::getPKeyId)
|
|
|
.collect(Collectors.toList());
|
|
|
+ List<WbsTreeContract> allChildContracts=new ArrayList<>();
|
|
|
+ for (Long parentKeyId : parentKeyIds) {
|
|
|
+ List<WbsTreeContract> childContracts = wbsTreeContractMapper.getChildWbsTreeContractsBatch(parentKeyId);
|
|
|
+ allChildContracts.addAll(childContracts);
|
|
|
+ }
|
|
|
|
|
|
- List<WbsTreeContract> allChildContracts = wbsTreeContractMapper.getChildWbsTreeContractsBatch(parentKeyIds);
|
|
|
|
|
|
// 批量处理子节点更新
|
|
|
for (WbsTreeContract childContract : allChildContracts) {
|
|
|
for (WbsTreeContract parentContract : list) {
|
|
|
String oldAncestorsPId = oldAncestorsPIdMap.get(parentContract.getPKeyId());
|
|
|
String newAncestorsPId = parentContract.getAncestorsPId();
|
|
|
- String oldAncestors = oldAncestorsMap.get(parentContract.getPKeyId());
|
|
|
- String newAncestors = parentContract.getAncestors();
|
|
|
-
|
|
|
if (childContract.getAncestorsPId().contains(oldAncestorsPId)) {
|
|
|
childContract.setAncestorsPId(
|
|
|
childContract.getAncestorsPId().replace(oldAncestorsPId, newAncestorsPId)
|
|
|
);
|
|
|
- childContract.setAncestors(
|
|
|
- childContract.getAncestors().replace(oldAncestors, newAncestors)
|
|
|
- );
|
|
|
nodesToUpdate.add(childContract);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 批量更新所有节点
|
|
|
if (!nodesToUpdate.isEmpty()) {
|
|
|
this.updateBatchById(nodesToUpdate);
|