You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
183 lines
6.8 KiB
183 lines
6.8 KiB
3 years ago
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||
|
<!DOCTYPE mapper
|
||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
|
<mapper namespace="com.ruoyi.archives.mapper.ArchiveStatisticInfoMapper">
|
||
|
<resultMap id="archiveStatisticInfoMap" type="com.ruoyi.archives.domain.ArchiveStatisticInfoModel">
|
||
|
<id property="type" column="type"/>
|
||
|
<result property="year" column="year"/>
|
||
|
<result property="totalNum" column="totalNum"/>
|
||
|
<result property="archiveCategory" column="archiveCategory"/>
|
||
|
<result property="totalRecords" column="totalRecords"/>
|
||
|
<result property="totalFiles" column="totalFiles"/>
|
||
|
<result property="permanentRecords" column="permanentRecords"/>
|
||
|
<result property="permanentFiles" column="permanentFiles"/>
|
||
|
<result property="longRecords" column="longRecords"/>
|
||
|
<result property="longFiles" column="longFiles"/>
|
||
|
<result property="shortRecords" column="shortRecords"/>
|
||
|
<result property="shortFiles" column="shortFiles"/>
|
||
|
<result property="importRecords" column="importRecords"/>
|
||
|
<result property="editRecords" column="editRecords"/>
|
||
|
<result property="electronicRecords" column="electronicRecords"/>
|
||
|
<result property="electronicFils" column="electronicFils"/>
|
||
|
<result property="department" column="department"/>
|
||
|
<result property="crtrmonth" column="crtrmonth"/>
|
||
|
<result property="crtyear" column="crtyear"/>
|
||
|
</resultMap>
|
||
|
|
||
|
<select id="statisticOfRepository" parameterType="ArchiveStatisticVo" resultMap="archiveStatisticInfoMap">
|
||
|
SELECT
|
||
|
0 AS type,
|
||
|
t.crtyear AS YEAR,
|
||
|
t.crtmonth AS MONTH,
|
||
|
t.archive_category AS archiveCategory,
|
||
|
SUM( CASE WHEN t.recordNum IS NOT NULL THEN t.recordNum ELSE 0 END ) AS totalRecords,
|
||
|
SUM( CASE WHEN t.fileNum IS NOT NULL THEN t.fileNum ELSE 0 END ) AS totalFiles,
|
||
|
SUM( CASE WHEN t.storage_time < '30' AND t.storage_time !='YJ' THEN t.recordNum ELSE 0 END ) AS shortRecords,
|
||
|
SUM( CASE WHEN t.storage_time < '30' AND t.storage_time !='YJ' THEN t.fileNum ELSE 0 END ) AS shortFiles,
|
||
|
SUM( CASE WHEN t.storage_time > '29' AND '99' > t.storage_time THEN t.recordNum ELSE 0 END ) AS longRecords,
|
||
|
SUM( CASE WHEN t.storage_time > '29' AND '99' > t.storage_time THEN t.fileNum ELSE 0 END ) AS longFiles,
|
||
|
SUM( CASE WHEN t.storage_time = 'YJ' THEN t.recordNum ELSE 0 END ) AS permanentRecords,
|
||
|
SUM( CASE WHEN t.storage_time = 'YJ' THEN t.fileNum ELSE 0 END ) AS permanentFiles
|
||
|
FROM
|
||
|
(
|
||
|
SELECT
|
||
|
bs.crtyear,
|
||
|
bs.crtmonth,
|
||
|
bs.archive_category,
|
||
|
dt.storage_time,
|
||
|
dt.recordNum,
|
||
|
dt.fileNum
|
||
|
FROM
|
||
|
(
|
||
|
SELECT
|
||
|
y.crtyear,
|
||
|
y.crtmonth,
|
||
|
bsca.archive_category
|
||
|
FROM
|
||
|
(
|
||
|
SELECT
|
||
|
q.crtyear,
|
||
|
q.crtmonth
|
||
|
FROM
|
||
|
(
|
||
|
SELECT
|
||
|
SUBSTR( create_time, 1, 4 ) AS crtyear,
|
||
|
SUBSTR( create_time, 6, 2 ) AS crtmonth
|
||
|
FROM
|
||
|
"PUBLIC"."archive_record_info"
|
||
|
WHERE
|
||
|
STATUS = 6
|
||
|
<if test="startDate != null and startDate != ''">
|
||
|
and create_time > #{startDate,jdbcType=VARCHAR}
|
||
|
</if>
|
||
|
<if test="endDate != null and endDate != ''">
|
||
|
and #{endDate,jdbcType=VARCHAR} > create_time
|
||
|
</if>
|
||
|
) q
|
||
|
GROUP BY
|
||
|
q.crtyear,
|
||
|
q.crtmonth
|
||
|
) y,(
|
||
|
SELECT
|
||
|
ca.CODE AS archive_category
|
||
|
FROM
|
||
|
"PUBLIC"."archive_category_info" ca
|
||
|
WHERE
|
||
|
ca.parent_id = 1
|
||
|
AND ca.del_flag = 0
|
||
|
) bsca
|
||
|
) bs
|
||
|
LEFT JOIN (
|
||
|
SELECT
|
||
|
r.id,
|
||
|
SUBSTR( r.create_time, 1, 4 ) AS crtyear,
|
||
|
SUBSTR( r.create_time, 6, 2 ) AS crtmonth,
|
||
|
r.archive_category,
|
||
|
r.storage_time,
|
||
|
1 AS recordNum,
|
||
|
COUNT( f.id ) fileNum
|
||
|
FROM
|
||
|
"PUBLIC"."archive_record_info" r
|
||
|
LEFT JOIN "PUBLIC"."archive_file_info" f ON ( r.id = f.ar_id AND f.del_flag = 0 )
|
||
|
WHERE r.STATUS = 6
|
||
|
<if test="startDate != null and startDate != ''">
|
||
|
and r.create_time > #{startDate,jdbcType=VARCHAR}
|
||
|
</if>
|
||
|
<if test="endDate != null and endDate != ''">
|
||
|
and #{endDate,jdbcType=VARCHAR} > r.create_time
|
||
|
</if>
|
||
|
GROUP BY
|
||
|
r.id,r.create_time,r.archive_category,r.storage_time
|
||
|
) dt ON (
|
||
|
dt.archive_category = bs.archive_category
|
||
|
AND dt.crtyear = bs.crtyear
|
||
|
AND dt.crtmonth = bs.crtmonth
|
||
|
)
|
||
|
) t
|
||
|
GROUP BY
|
||
|
t.crtyear,
|
||
|
t.crtmonth,
|
||
|
t.archive_category
|
||
|
ORDER BY
|
||
|
t.crtyear DESC,
|
||
|
t.crtmonth DESC,
|
||
|
t.archive_category ASC
|
||
|
|
||
|
</select>
|
||
|
|
||
|
<select id="statisticOfArchivesOverTheYears" parameterType="ArchiveStatisticVo" resultMap="archiveStatisticInfoMap">
|
||
|
select 1 as type,t.year,t.archive_category as archiveCategory,
|
||
|
SUM(CASE WHEN t.recordNum is not null THEN t.recordNum ELSE 0 END ) as totalRecords,
|
||
|
SUM(CASE WHEN t.fileNum is not null THEN t.fileNum ELSE 0 END ) as totalFiles,
|
||
|
SUM( CASE WHEN t.storage_time < '30' AND t.storage_time !='YJ' THEN t.recordNum ELSE 0 END ) AS shortRecords,
|
||
|
SUM( CASE WHEN t.storage_time < '30' AND t.storage_time !='YJ' THEN t.fileNum ELSE 0 END ) AS shortFiles,
|
||
|
SUM( CASE WHEN t.storage_time > '29' AND '99' > t.storage_time THEN t.recordNum ELSE 0 END ) AS longRecords,
|
||
|
SUM( CASE WHEN t.storage_time > '29' AND '99' > t.storage_time THEN t.fileNum ELSE 0 END ) AS longFiles,
|
||
|
SUM( CASE WHEN t.storage_time = 'YJ' THEN t.recordNum ELSE 0 END ) AS permanentRecords,
|
||
|
SUM( CASE WHEN t.storage_time = 'YJ' THEN t.fileNum ELSE 0 END ) AS permanentFiles
|
||
|
from (
|
||
|
select bs.year,bs.archive_category,dt.storage_time,dt.recordNum,dt.fileNum from (
|
||
|
SELECT y.year,bsca.archive_category from (select year from "PUBLIC"."archive_record_info" where status=6
|
||
|
<if test="year != null">
|
||
|
and year=#{yearNum,jdbcType=INTEGER}
|
||
|
</if>
|
||
|
group by year) y,(select ca.code as archive_category from "PUBLIC"."archive_category_info" ca
|
||
|
where ca.parent_id=1 and ca.del_flag=0
|
||
|
) bsca
|
||
|
) bs
|
||
|
left join (
|
||
|
select r.id,r.year,r.archive_category,r.storage_time,1 as recordNum,COUNT(f.id) fileNum from "PUBLIC"."archive_record_info"
|
||
|
r
|
||
|
left join "PUBLIC"."archive_file_info" f on (r.id=f.ar_id and f.del_flag=0)
|
||
|
where r.status=6
|
||
|
<if test="year != null">
|
||
|
and r.year=#{yearNum,jdbcType=INTEGER}
|
||
|
</if>
|
||
|
GROUP BY r.id,r.year,r.archive_category,r.storage_time) dt on ( dt.archive_category=bs.archive_category and dt.year=bs.year)
|
||
|
) t
|
||
|
GROUP BY t.year,t.archive_category
|
||
|
order by t.year desc,t.archive_category asc
|
||
|
</select>
|
||
|
|
||
|
|
||
|
<select id="statisticOfTurnOver" parameterType="ArchiveStatisticVo" resultMap="archiveStatisticInfoMap">
|
||
|
SELECT 2 as type,
|
||
|
count(t.record_id) as totalRecords,
|
||
|
sum(t.number) as totalFiles,
|
||
|
r.archive_category as archiveCategory,
|
||
|
SUBSTR( t.create_time, 1, 4 ) AS crtyear,
|
||
|
SUBSTR( t.create_time, 6, 2 ) AS crtrmonth
|
||
|
FROM "PUBLIC"."archive_turnover_info" t,"PUBLIC"."archive_record_info" r
|
||
|
where t.record_id =r.id
|
||
|
<if test="startDate != null and startDate != ''">
|
||
|
and t.create_time > #{startDate,jdbcType=VARCHAR}
|
||
|
</if>
|
||
|
<if test="endDate != null and endDate != ''">
|
||
|
and #{endDate,jdbcType=VARCHAR} > t.create_time
|
||
|
</if>
|
||
|
group by crtyear,crtrmonth,r.archive_category
|
||
|
order by archive_category
|
||
|
</select>
|
||
|
</mapper>
|