@ -16,13 +16,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from dept a left join mail_mark b on a.id = b.second_dept_id
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if>
where a.level = '2'
<if test= "deptId != null" >
and a.id = #{deptId}
</if>
group by a.name,a.sort
order by crateNumber desc
) t1
@ -34,13 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) sum
from dept a left join mail_mark b on a.id = b.second_dept_id
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if>
where a.level = '2'
<if test= "deptId != null" >
and a.id = #{deptId}
</if>
group by a.name) t order by rateNumber desc
) t2 on t1.cname = t2.rname
@ -55,13 +51,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
CONCAT(srateNumber,'%') srate
from dept a left join mail_mark b on a.id = b.second_dept_id
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if>
where a.level = '2'
<if test= "deptId != null" >
and a.id = #{deptId}
</if>
group by a.name
order by srateNumber desc
) t4 on t3.cname = t4.sname ORDER BY score desc ,sort
@ -85,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> ) AS total
from mail_mark b left join dept a on a.id=b.second_dept_id where 1=1
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if>
) t1
@ -96,12 +90,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SUM(COALESCE(b.resolved, 0)) resolved,SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) rSum,
(SELECT COUNT(*) FROM mail_mark b where 1=1
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if> ) AS total2
from mail_mark b left join dept a on a.id=b.second_dept_id where 1=1
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if>
) t2 on t1.total = t2.total2
@ -114,12 +108,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) AS Sum,
(SELECT COUNT(*) FROM mail_mark b where 1=1
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if> ) AS total3
from mail_mark b left join dept a on a.id=b.second_dept_id where 1=1
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if>
) t4 on t3.total2 = t4.total3
</select>
@ -135,15 +129,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
CONCAT(crateNumber,'%') crate,
SUM(COALESCE(b.completed, 0)) completed,count(1) csum
from dept a left join mail_mark b on a.id = b.three _dept_id
from dept a left join mail_mark b on a.id = b.second _dept_id
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if>
where a.level = '3'
<if test= "deptId != null" >
and a.pid = #{deptId}
and a.pid = #{deptId} or a.id = #{deptId}
</if>
group by a.name,a.sort
order by crateNumber desc
@ -154,14 +148,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from
(select a.name, SUM(COALESCE(b.resolved, 0)) resolved,
SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) sum
from dept a left join mail_mark b on a.id = b.three _dept_id
from dept a left join mail_mark b on a.id = b.second _dept_id
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if>
where a.level = '3'
<if test= "deptId != null" >
and a.pid = #{deptId}
and a.pid = #{deptId} or a.id = #{deptId}
</if>
group by a.name) t order by rateNumber desc
@ -175,17 +169,87 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) sum,
CASE WHEN sum = 0 THEN 0 ELSE ROUND(sum(COALESCE(b.satisfied, 0))*100/sum,0) END srateNumber,
CONCAT(srateNumber,'%') srate
from dept a left join mail_mark b on a.id = b.three _dept_id
from dept a left join mail_mark b on a.id = b.second _dept_id
<if test= "searchStartTime != null and searchEndTime != null" >
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date( #{searchEndTime}) + interval '1 D')
AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime}
</if>
where a.level = '3'
<if test= "deptId != null" >
and a.pid = #{deptId}
and a.pid = #{deptId} or a.id = #{deptId}
</if>
group by a.name
order by srateNumber desc
) t4 on t3.cname = t4.sname ORDER BY score desc ,sort
</select>
<select id= "selectMailCategoryWithCount" resultType= "java.util.Map" >
SELECT
mc.name,
COALESCE(m.second_dept_name, #{deptName}) As second_dept_name,
COALESCE(m.allcount, 0) as allcount,
COALESCE(m.sumCount, 0) AS sumCount,
COALESCE(m.countRate, '0%') AS countRate
FROM
mail_category mc
LEFT JOIN (
SELECT
mail_first_category AS category,
COUNT(1) AS sumCount,
CONCAT(ROUND(COUNT(1) * 100.0 / (SELECT COUNT(1) FROM mail), 0), '%') AS countRate, mail.second_dept_name,mail.second_dept_id, (SELECT COUNT(1) FROM mail where mail.second_dept_id = #{deptId}) as allcount
FROM
mail
WHERE
1 = 1
and mail.second_dept_id = #{deptId}
GROUP BY
mail_first_category, mail.second_dept_name,mail.second_dept_id
) m ON mc.name = m.category
WHERE
mc.level = 1;
</select>
<select id= "selectMailFirstCategoryWithCount" resultType= "java.util.Map" >
SELECT mc.name,'长沙市公安局' as second_dept_name, COALESCE(m.allcount, 0) as allcount, COALESCE(m.sumCount, 0) AS sumCount,
COALESCE(m.countRate, '0%') AS countRate
FROM mail_category mc LEFT JOIN ( SELECT mail_first_category AS category, COUNT(1) AS sumCount,
CONCAT(ROUND(COUNT(1) * 100.0 / (SELECT COUNT(1) FROM mail), 0), '%') AS countRate,(SELECT COUNT(1) FROM mail) as allcount
FROM mail WHERE 1 = 1 GROUP BY mail_first_category) m ON mc.name = m.category WHERE mc.level = 1;
</select>
<select id= "selectMailThreeCategoryWithCount" resultType= "java.util.Map" >
SELECT
mc.name,
COALESCE(m.three_dept_name, #{deptName}) As second_dept_name,
COALESCE(m.allcount, 0) as allcount,
COALESCE(m.sumCount, 0) AS sumCount,
COALESCE(m.countRate, '0%') AS countRate
FROM
mail_category mc
LEFT JOIN (
SELECT
mail_first_category AS category,
COUNT(1) AS sumCount,
CONCAT(ROUND(COUNT(1) * 100.0 / (SELECT COUNT(1) FROM mail), 0), '%') AS countRate, mail.three_dept_name,mail.three_dept_id, (SELECT COUNT(1) FROM mail where mail.three_dept_id = #{deptId}) as allcount
FROM
mail
WHERE
1 = 1
and mail.three_dept_id = #{deptId}
GROUP BY
mail_first_category, mail.three_dept_name,mail.three_dept_id
) m ON mc.name = m.category
WHERE
mc.level = 1;
</select>
</mapper>