Эх сурвалжийг харах

档案系统-文件收集分页查询 恢复为原始代码,结构有点问题

LHB 3 долоо хоног өмнө
parent
commit
474ff55e2b

+ 8 - 8
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileController.java

@@ -161,15 +161,15 @@ public class ArchiveFileController extends BladeController {
                 queryVo.setExtType(1);
             }
 
-//            List<ArchiveTreeContract> archiveTreeContracts = this.archiveTreeContractClient.queryAllChildByAncestors(queryVo.getNodeIds(), queryVo.getContractId() == null ? null : Long.parseLong(queryVo.getContractId()));
-//            if (archiveTreeContracts != null && archiveTreeContracts.size() > 0) {
-//                List<String> ids = JSONArray.parseArray(JSONObject.toJSONString(archiveTreeContracts.stream().map(ArchiveTreeContract::getId).distinct().collect(Collectors.toList())), String.class);
-//                ids.add(queryVo.getNodeIds());
-//                queryVo.setNodeIdArray(ids);
-//            }
+            List<ArchiveTreeContract> archiveTreeContracts = this.archiveTreeContractClient.queryAllChildByAncestors(queryVo.getNodeIds(), queryVo.getContractId() == null ? null : Long.parseLong(queryVo.getContractId()));
+            if (archiveTreeContracts != null && archiveTreeContracts.size() > 0) {
+                List<String> ids = JSONArray.parseArray(JSONObject.toJSONString(archiveTreeContracts.stream().map(ArchiveTreeContract::getId).distinct().collect(Collectors.toList())), String.class);
+                ids.add(queryVo.getNodeIds());
+                queryVo.setNodeIdArray(ids);
+            }
             //优化
-            String authCode = this.archiveTreeContractClient.getAuthCode(queryVo.getContractId() == null ? null : Long.parseLong(queryVo.getContractId()));
-            queryVo.setAuthCode(authCode);
+//            String authCode = this.archiveTreeContractClient.getAuthCode(queryVo.getContractId() == null ? null : Long.parseLong(queryVo.getContractId()));
+//            queryVo.setAuthCode(authCode);
         }
         return R.data(this.archiveFileClient.selectArchiveFilePage(queryVo));
     }

+ 66 - 38
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ArchiveFileMapper.xml

@@ -74,11 +74,8 @@
         select count(u.id) from u_archive_file u
         <if test="vo.nodeIds != null and vo.nodeIds != ''">
             left join m_archive_tree_contract t on t.id = u.node_id
-            <if test="vo.extType != null">
-                or t.id = u.node_ext_id
-            </if>
         </if>
-        where u.is_deleted = 0 and t.is_deleted = 0
+        where u.is_deleted = 0
         <if test="vo.isApprovalValue != null and vo.isApprovalValue != ''">
             and u.status = #{vo.isApprovalValue}
         </if>
@@ -110,22 +107,39 @@
         <if test="vo.rectification == null and vo.archiveId == null">
             and (u.is_auto_file is null or u.is_auto_file != 1)
         </if>
-<!--        <choose>-->
-<!--            <when test="vo.isArchive != null and vo.isArchive != ''">-->
-<!--                and u.is_auto_file = #{vo.isArchive}-->
-<!--            </when>-->
-<!--            <when test="vo.archiveId != null and vo.archiveId != ''">-->
-<!--                and 1=1-->
-<!--            </when>-->
-<!--            <otherwise>-->
-<!--                and (u.is_auto_file is null or u.is_auto_file != 1)-->
-<!--            </otherwise>-->
-<!--        </choose>-->
+        <!--        <choose>-->
+        <!--            <when test="vo.isArchive != null and vo.isArchive != ''">-->
+        <!--                and u.is_auto_file = #{vo.isArchive}-->
+        <!--            </when>-->
+        <!--            <when test="vo.archiveId != null and vo.archiveId != ''">-->
+        <!--                and 1=1-->
+        <!--            </when>-->
+        <!--            <otherwise>-->
+        <!--                and (u.is_auto_file is null or u.is_auto_file != 1)-->
+        <!--            </otherwise>-->
+        <!--        </choose>-->
         <if test="vo.nodeIds != null and vo.nodeIds != ''">
-            and  (find_in_set(#{vo.nodeIds},t.ancestors) or t.id = #{vo.nodeIds})
-        </if>
-        <if test="vo.authCode != null and vo.authCode != ''">
-            AND (t.tree_code = #{authCode} or t.tree_code = #{contractId} or t.parent_id = 0)
+            and
+            <choose>
+                <!-- 当存在扩展类型时,同时查 node_id 和 node_ext_id -->
+                <when test="vo.extType != null">
+                    (u.node_id in
+                    <foreach collection="vo.nodeIdArray" item="nodeId" open="(" separator="," close=")">
+                        #{nodeId}
+                    </foreach>
+                    OR u.node_ext_id in
+                    <foreach collection="vo.nodeIdArray" item="nodeId" open="(" separator="," close=")">
+                        #{nodeId}
+                    </foreach>)
+                </when>
+                <!-- 默认只查 node_id -->
+                <otherwise>
+                    u.node_id in
+                    <foreach collection="vo.nodeIdArray" item="nodeId" open="(" separator="," close=")">
+                        #{nodeId}
+                    </foreach>
+                </otherwise>
+            </choose>
         </if>
         <if test="vo.queryValue != null and vo.queryValue != ''">
             and (
@@ -143,11 +157,8 @@
         select u.* from u_archive_file u
         <if test="vo.nodeIds != null and vo.nodeIds != ''">
             left join m_archive_tree_contract t on t.id = u.node_id
-                   <if test="vo.extType != null">
-                       or t.id = u.node_ext_id
-                   </if>
         </if>
-        where u.is_deleted = 0 and t.is_deleted = 0
+        where u.is_deleted = 0
         <if test="vo.isApprovalValue != null and vo.isApprovalValue != ''">
             and u.status = #{vo.isApprovalValue}
         </if>
@@ -179,22 +190,39 @@
         <if test="vo.rectification == null and vo.archiveId == null">
             and (u.is_auto_file is null or u.is_auto_file != 1)
         </if>
-<!--        <choose>-->
-<!--            <when test="vo.isArchive != null and vo.isArchive != ''">-->
-<!--                and u.is_auto_file = #{vo.isArchive}-->
-<!--            </when>-->
-<!--            <when test="vo.archiveId != null and vo.archiveId != ''">-->
-<!--                and 1=1-->
-<!--            </when>-->
-<!--            <otherwise>-->
-<!--                and (u.is_auto_file is null or u.is_auto_file != 1)-->
-<!--            </otherwise>-->
-<!--        </choose>-->
+        <!--        <choose>-->
+        <!--            <when test="vo.isArchive != null and vo.isArchive != ''">-->
+        <!--                and u.is_auto_file = #{vo.isArchive}-->
+        <!--            </when>-->
+        <!--            <when test="vo.archiveId != null and vo.archiveId != ''">-->
+        <!--                and 1=1-->
+        <!--            </when>-->
+        <!--            <otherwise>-->
+        <!--                and (u.is_auto_file is null or u.is_auto_file != 1)-->
+        <!--            </otherwise>-->
+        <!--        </choose>-->
         <if test="vo.nodeIds != null and vo.nodeIds != ''">
-            and  (find_in_set(#{vo.nodeIds},t.ancestors) or t.id = #{vo.nodeIds})
-        </if>
-        <if test="vo.authCode != null and vo.authCode != ''">
-            AND (t.tree_code = #{authCode} or t.tree_code = #{contractId} or t.parent_id = 0)
+            and
+            <choose>
+                <!-- 当存在扩展类型时,同时查 node_id 和 node_ext_id -->
+                <when test="vo.extType != null">
+                    (u.node_id in
+                    <foreach collection="vo.nodeIdArray" item="nodeId" open="(" separator="," close=")">
+                        #{nodeId}
+                    </foreach>
+                    OR u.node_ext_id in
+                    <foreach collection="vo.nodeIdArray" item="nodeId" open="(" separator="," close=")">
+                        #{nodeId}
+                    </foreach>)
+                </when>
+                <!-- 默认只查 node_id -->
+                <otherwise>
+                    u.node_id in
+                    <foreach collection="vo.nodeIdArray" item="nodeId" open="(" separator="," close=")">
+                        #{nodeId}
+                    </foreach>
+                </otherwise>
+            </choose>
         </if>
         <if test="vo.queryValue != null and vo.queryValue != ''">
             and (