|
|
@@ -18,6 +18,7 @@ package org.springblade.manager.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.mixsmart.utils.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
@@ -752,26 +753,65 @@ public class ArchiveTreeContractServiceImpl extends BaseServiceImpl<ArchiveTreeC
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean deleteTree(Long id) {
|
|
|
+// public boolean deleteTree(Long id) {
|
|
|
+// ArchiveTreeContract dstNode = this.getById(id);
|
|
|
+// if (dstNode == null ) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<ArchiveTreeContractVO2> dstTrees = this.tree2Root(AuthUtil.getTenantId(),null,null,dstNode.getProjectId(),null);
|
|
|
+// if (dstTrees == null || dstTrees.size() == 0) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+//
|
|
|
+// ArchiveTreeContractVO2 subTree = ForestNodeMergerEx.getSubTree(dstTrees.get(0),id);
|
|
|
+//
|
|
|
+// List<Long> ids = ForestNodeMergerEx.getChildrenIds(subTree);
|
|
|
+//
|
|
|
+// ids.add(id);
|
|
|
+// this.deleteLogic(ids);
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+
|
|
|
+ public boolean deleteTree(Long id) {
|
|
|
ArchiveTreeContract dstNode = this.getById(id);
|
|
|
- if (dstNode == null ) {
|
|
|
+ if (dstNode == null) {
|
|
|
return false;
|
|
|
}
|
|
|
+ String tenantId = AuthUtil.getTenantId();
|
|
|
+ Long projectId = dstNode.getProjectId();
|
|
|
|
|
|
- List<ArchiveTreeContractVO2> dstTrees = this.tree2Root(AuthUtil.getTenantId(),null,null,dstNode.getProjectId(),null);
|
|
|
- if (dstTrees == null || dstTrees.size() == 0) {
|
|
|
+ // 调用优化后的listAllChildIds(CTE/存储过程均可)
|
|
|
+ List<Long> ids = this.listAllChildIds(id, projectId, tenantId);
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- ArchiveTreeContractVO2 subTree = ForestNodeMergerEx.getSubTree(dstTrees.get(0),id);
|
|
|
-
|
|
|
- List<Long> ids = ForestNodeMergerEx.getChildrenIds(subTree);
|
|
|
-
|
|
|
- ids.add(id);
|
|
|
this.deleteLogic(ids);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ public List<Long> listAllChildIds(Long parentId, Long projectId, String tenantId) {
|
|
|
+ // 1. 构建存储过程入参
|
|
|
+ Map<String, Object> params = new HashMap<>(4);
|
|
|
+ params.put("parentId", parentId);
|
|
|
+ params.put("projectId", projectId);
|
|
|
+ params.put("tenantId", tenantId);
|
|
|
+ params.put("outIds", ""); // 初始化出参
|
|
|
+
|
|
|
+ // 2. 调用存储过程
|
|
|
+ baseMapper.callGetChildIds(params);
|
|
|
+
|
|
|
+ // 3. 解析出参(逗号分隔的ID字符串转Long列表)
|
|
|
+ String outIds = (String) params.get("outIds");
|
|
|
+ if (StringUtils.isEmpty(outIds)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ return Arrays.stream(outIds.split(","))
|
|
|
+ .map(Long::valueOf)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 更轻量的删除节点树,同时删除节点下的案卷和文件
|
|
|
* @param id
|