Browse Source

查询统计》按年归档统计查询逻辑调整修复

hanzhen 3 years ago
parent
commit
c46cf04d4f
1 changed files with 9 additions and 33 deletions
  1. 9 33
      src/main/resources/mapper/selectStatisticsMapper.xml

+ 9 - 33
src/main/resources/mapper/selectStatisticsMapper.xml

@@ -36,46 +36,22 @@
     </select>
     </select>
 
 
     <select id="selectArchiveYearStatistics" resultType="com.gz.rvo.statistics.ArchiveYearStatisticsRVO">
     <select id="selectArchiveYearStatistics" resultType="com.gz.rvo.statistics.ArchiveYearStatisticsRVO">
-        SELECT a1.gdnd
-             , (
-            SELECT count(a.id)
-            FROM tab_archives a
-            WHERE a1.`gdnd` = a.gdnd
-              AND a.deleted = 0
+        select t1.gdnd, count(t1.id) archive_count,sum(file_count) file_count
+        from tab_archives t1
+        left join (select archive_id,count(id) file_count
+        from tab_archive_file t where t.deleted = 0
+        ) t2 on t1.id = t2.archive_id
+        where t1.deleted = 0
         <if test="mlCodes != null and mlCodes.size > 0">
         <if test="mlCodes != null and mlCodes.size > 0">
-            AND a.ml in
+            AND t1.ml in
             <foreach collection="mlCodes" item="item" index="index" open="(" close=")" separator=",">
             <foreach collection="mlCodes" item="item" index="index" open="(" close=")" separator=",">
                 #{item}
                 #{item}
             </foreach>
             </foreach>
         </if>
         </if>
         <if test="bgqx != null and bgqx != ''">
         <if test="bgqx != null and bgqx != ''">
-            and a.bgqx=#{bgqx}
+            and t1.bgqx=#{bgqx}
         </if>
         </if>
-        ) AS archive_count
-             , (
-            SELECT count(af.id)
-            FROM tab_archives a
-                     LEFT JOIN tab_archive_file af ON a.id = af.archive_id
-            WHERE a1.`gdnd` = a.gdnd
-              AND a.deleted = 0
-              AND af.deleted = 0
-            <if test="mlCodes != null and mlCodes.size > 0">
-                AND a.ml in
-                <foreach collection="mlCodes" item="item" index="index" open="(" close=")" separator=",">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="bgqx != null and bgqx != ''">
-                and a.bgqx=#{bgqx}
-            </if>
-        ) AS file_count
-        FROM tab_archives a1
-        <where>
-            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
-                AND a1.gdnd BETWEEN #{startTime} AND #{endTime}
-            </if>
-        </where>
-        GROUP BY a1.gdnd
+        group by t1.gdnd
     </select>
     </select>
 
 
     <select id="selectBorrowStatistics" resultType="com.gz.rvo.statistics.BorrowStatisticsRVO">
     <select id="selectBorrowStatistics" resultType="com.gz.rvo.statistics.BorrowStatisticsRVO">