liuyc 2 rokov pred
rodič
commit
8ba608779e

+ 32 - 37
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeMapper.xml

@@ -258,20 +258,21 @@
     </select>
 
     <select id="tree2" resultMap="treeNodeResultMap2">
-        SELECT d.id,
-        d.tenant_id AS "tenantId",
-        d.parent_id AS "parentId",
-        d.node_name AS title,
-        d.type AS "type",
-        d.id AS "value",
-        d.id AS "key",
-        d.node_type AS "nodeType",
-        d.is_exist_form AS "isExistForm",
-        a.wbs_type AS "wbsType"
+        SELECT
+            d.id,
+            d.tenant_id AS "tenantId",
+            d.parent_id AS "parentId",
+            d.node_name AS title,
+            d.type AS "type",
+            d.id AS "value",
+            d.id AS "key",
+            d.node_type AS "nodeType",
+            d.is_exist_form AS "isExistForm",
+            a.wbs_type AS "wbsType"
         FROM m_wbs_tree d INNER JOIN m_wbs_info a ON a.id = #{wbsId}
         WHERE
-        d.is_deleted = 0
-        AND d.status = 1
+            d.is_deleted = 0
+            AND d.status = 1
         <if test="wbsId!=null and wbsId!=''">
             AND d.wbs_id = #{wbsId}
         </if>
@@ -287,35 +288,29 @@
 
     <select id="lazyTree" resultMap="treeNodeResultMap">
         SELECT
-        t.type AS "type",
-        t.node_type AS "nodeType",
-        t.is_exist_form AS "isExistForm",
-        t.table_type,
-        t.id,
-        t.parent_id,
-        t.node_name AS title,
-        t.id AS "value",
-        t.id AS "key",
-        t.ancestors AS "ancestors",
-        (
-        SELECT
-        CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
+            (select wbs_type from m_wbs_info where id = #{wbsId}) AS wbsType,
+            t.type AS "type",
+            t.node_type AS "nodeType",
+            t.is_exist_form AS "isExistForm",
+            t.table_type,
+            t.id,
+            t.parent_id,
+            t.node_name AS title,
+            t.id AS "value",
+            t.id AS "key",
+            t.ancestors AS "ancestors",
+            (select case when count(1) > 0 then 1 else 0 end from m_wbs_tree where parent_id = t.id and is_deleted = 0) AS "has_children"
         FROM
-        m_wbs_tree
+            m_wbs_tree t
         WHERE
-        parent_id = t.id and is_deleted = 0
-        ) AS "has_children"
-        FROM
-        m_wbs_tree t
-        WHERE
-        t.parent_id = #{parentId} AND t.is_deleted = 0
+            t.parent_id = #{parentId} AND t.is_deleted = 0
         <if test="tenantId!=null and tenantId!=''">
-            and t.tenant_id = #{tenantId}
+            AND t.tenant_id = #{tenantId}
         </if>
-        AND t.wbs_id = #{wbsId}
-        AND t.type = 1
-        AND status = 1
-        ORDER BY t.sort
+            AND t.wbs_id = #{wbsId}
+            AND t.type = 1
+            AND status = 1
+            ORDER BY t.sort
     </select>
 
     <select id="selectByNodeTable" resultMap="selectByNodeTableMap">

+ 2 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

@@ -72,7 +72,8 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
         if (AuthUtil.isAdministrator()) {
             tenantId = StringPool.EMPTY;
         }
-        return ForestNodeMerger.merge(baseMapper.lazyTree(wbsId, tenantId, parentId));
+        List<WbsTreeVO> wbsTreeVOS = baseMapper.lazyTree(wbsId, tenantId, parentId);
+        return ForestNodeMerger.merge(wbsTreeVOS);
     }
 
     @Override