lvy 1 сар өмнө
parent
commit
fd52c3f9f8

+ 25 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ExcelTabMapper.xml

@@ -230,19 +230,31 @@
         </foreach>
     </select>
     <select id="selectRootExcelTab" resultType="org.springblade.manager.vo.ExcelTabVO">
-        SELECT project_id as projectId, project_name as projectName, root_id as id from m_project_info a RIGHT JOIN  (
-            SELECT project_id, SUBSTRING_INDEX(alias,',',1) as root_id from m_wbs_tree_private a LEFT JOIN m_excel_tab b on a.excel_id = b.id where a.type = 2 and a.is_deleted =0 and a.excel_id is not null
-            <if test="projectId !=null and projectId > 0">
-                and project_id = #{projectId}
-            </if>
-            GROUP BY root_id,project_id
-            <if test="rootIds !=null">
-                and root_id in
-                <foreach collection="rootIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-        ) as t on a.id = t.project_id where project_id is not null
+        SELECT
+        t.project_id as projectId,
+        p.project_name as projectName,
+        t.root_id as id
+        FROM (
+        SELECT
+        project_id,
+        SUBSTRING_INDEX(alias, ',', 1) as root_id
+        FROM m_wbs_tree_private a
+        LEFT JOIN m_excel_tab b ON a.excel_id = b.id
+        WHERE a.type = 2
+        AND a.is_deleted = 0
+        AND a.excel_id IS NOT NULL
+        <if test="projectId != null and projectId > 0">
+            AND project_id = #{projectId}
+        </if>
+        GROUP BY project_id, root_id
+        <if test="rootIds != null and rootIds.size() > 0">
+            HAVING root_id IN
+            <foreach collection="rootIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) t
+        INNER JOIN m_project_info p ON p.id = t.project_id where project_id is not null
     </select>
     <select id="getByIds" resultType="org.springblade.manager.vo.ExcelTabVO">
         select *, (select name from blade_user where id = a.create_user) as createUserName, (SELECT bdb.dict_value from blade_dict_biz bdb WHERE code = 'table_template_type' AND dict_key = a.table_template_type) as tableTemplateTypeName