|
@@ -172,9 +172,9 @@
|
|
|
<result column="reviewer" property="reviewer"/>
|
|
|
<result column="specification" property="specification"/>
|
|
|
<result column="archive_name_suffix" property="archiveNameSuffix"/>
|
|
|
- <!-- <result column="tree_number" property="treeNumber"/>-->
|
|
|
- <association property="treeNumber" javaType="java.lang.Integer" select="selectFileNumber"
|
|
|
- column="{id=id,projectId=project_id,code=code,contractId=contract_id,extType=ext_type}"/>
|
|
|
+ <result column="tree_number" property="treeNumber"/>
|
|
|
+<!-- <association property="treeNumber" javaType="java.lang.Integer" select="selectFileNumber"-->
|
|
|
+<!-- column="{id=id,projectId=project_id,code=code,contractId=contract_id,extType=ext_type}"/>-->
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
@@ -272,11 +272,45 @@
|
|
|
d.specification,
|
|
|
d.archive_name_suffix,
|
|
|
d.contract_id,
|
|
|
- d.project_id,
|
|
|
- #{code} as code,
|
|
|
+ IFNULL(SUM(file_counts.count), 0) AS tree_number,
|
|
|
(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_archive_tree_contract WHERE parent_id = d.id and is_deleted = 0 and project_id = #{projectId}) AS "has_children"
|
|
|
FROM
|
|
|
m_archive_tree_contract d
|
|
|
+ LEFT JOIN (
|
|
|
+ -- 合并两个统计查询
|
|
|
+ SELECT
|
|
|
+ a.id,
|
|
|
+ a.ancestors,
|
|
|
+ SUM(b.count) AS count
|
|
|
+ FROM
|
|
|
+ m_archive_tree_contract a
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT node_id AS id, COUNT(*) AS count
|
|
|
+ FROM u_archive_file
|
|
|
+ WHERE project_id = #{projectId}
|
|
|
+ AND is_deleted = 0
|
|
|
+ AND (is_auto_file IS NULL OR is_auto_file != 1)
|
|
|
+ GROUP BY node_id
|
|
|
+ <if test="extType > 0">
|
|
|
+ UNION ALL
|
|
|
+
|
|
|
+ SELECT node_ext_id AS id, COUNT(*) AS count
|
|
|
+ FROM u_archive_file
|
|
|
+ WHERE project_id = #{projectId}
|
|
|
+ AND is_deleted = 0
|
|
|
+ AND (is_auto_file IS NULL OR is_auto_file != 1)
|
|
|
+ GROUP BY node_ext_id
|
|
|
+ </if>
|
|
|
+ ) b ON b.id = a.id
|
|
|
+ WHERE
|
|
|
+ a.is_deleted = 0
|
|
|
+ <if test="code!=null and code!=''">
|
|
|
+ AND (a.tree_code = #{code} or a.tree_code = #{contractId} or a.parent_id = 0)
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ a.id
|
|
|
+ ) file_counts ON file_counts.id = d.id
|
|
|
+ OR file_counts.ancestors like concat(d.ancestors,',',d.id,'%')
|
|
|
WHERE
|
|
|
d.parent_id = #{parentId} AND d.is_deleted = 0 and project_id = #{projectId}
|
|
|
<if test="tenantId!=null and tenantId!=''">
|
|
@@ -285,6 +319,8 @@
|
|
|
<if test="code!=null and code!=''">
|
|
|
AND (d.tree_code = #{code} or d.tree_code = #{contractId} or d.parent_id = 0)
|
|
|
</if>
|
|
|
+ GROUP BY
|
|
|
+ d.id
|
|
|
ORDER BY d.tree_sort, d.sort
|
|
|
</select>
|
|
|
<!-- 归档数不带文件数量 -->
|
|
@@ -980,4 +1016,7 @@
|
|
|
#{id}
|
|
|
</foreach>
|
|
|
</select>
|
|
|
+ <select id="selectExtTypeByParentId" resultType="java.lang.Integer">
|
|
|
+ select count(0) from m_archive_tree_contract where project_id = #{projectId} and ext_type = 2 and is_deleted = 0 and FIND_IN_SET(#{parentId},ancestors)
|
|
|
+ </select>
|
|
|
</mapper>
|