|
|
@ -44,4 +44,162 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
${ew.getCustomSqlSegment} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="listMonthAlert" resultType="java.util.Map"> |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 0 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 0 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 1 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 1 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 2 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 2 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 3 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 3 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 4 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 4 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 5 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 5 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 6 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 6 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 7 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 7 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 8 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 8 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 9 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 9 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 10 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 10 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
union all |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 11 MONTH), '%Y-%m') AS dateMonth,count(1) total from business_alert ba |
|
|
|
where DATE_FORMAT(ba.create_time, '%Y-%m' ) = DATE_FORMAT(DATE_ADD(DATE_FORMAT(CURDATE(), '%Y-01-01'), INTERVAL 11 MONTH), '%Y-%m') |
|
|
|
<if test="param.deptIdList != null and param.deptIdList.size > 0"> |
|
|
|
and ba.dept_id in |
|
|
|
<foreach collection="param.deptIdList" item="item" open="(" close=")" separator=","> |
|
|
|
item |
|
|
|
</foreach> |
|
|
|
</if> |
|
|
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="listDepartAlert" resultType="java.util.Map"> |
|
|
|
select ba.dept_name deptName, ba.dept_id deptId,count(1) total |
|
|
|
from business_alert ba |
|
|
|
where 1=1 |
|
|
|
<if test="param.createTime != null and param.createTime != ''"> |
|
|
|
and DATE_FORMAT(ba.create_time,'%Y-%m') = DATE_FORMAT(#{param.createTime},'%Y-%m') |
|
|
|
</if> |
|
|
|
GROUP BY ba.dept_name,ba.dept_id |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="listMonthAlertStatus" resultType="java.util.Map"> |
|
|
|
WITH RECURSIVE months AS ( |
|
|
|
SELECT MAKEDATE(YEAR(NOW()), 1) AS dateMonth |
|
|
|
UNION ALL |
|
|
|
SELECT DATE_ADD(dateMonth, INTERVAL 1 MONTH) |
|
|
|
FROM months |
|
|
|
WHERE <![CDATA[ dateMonth < LAST_DAY(MAKEDATE(YEAR(NOW()), 1) + INTERVAL 10 MONTH) ]]> |
|
|
|
) |
|
|
|
SELECT |
|
|
|
DATE_FORMAT(m.dateMonth, '%Y-%m') AS dateMonth, |
|
|
|
COALESCE(COUNT(ba.id), 0) AS total, |
|
|
|
COALESCE(SUM(ba.handle_type = 'waiting'), 0) AS todoCount, |
|
|
|
COALESCE(SUM(ba.handle_type = 'finish'), 0) AS finishCount |
|
|
|
FROM months m |
|
|
|
LEFT JOIN business_alert ba |
|
|
|
ON DATE_FORMAT(ba.create_time, '%Y-%m') = DATE_FORMAT(m.dateMonth, '%Y-%m') |
|
|
|
GROUP BY m.dateMonth |
|
|
|
ORDER BY m.dateMonth |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="listDepartAlertStatus" resultType="java.util.Map"> |
|
|
|
SELECT |
|
|
|
ba.dept_name deptName, |
|
|
|
ba.dept_id deptId, |
|
|
|
count( 1 ) total, |
|
|
|
SUM( handle_type = 'waiting' ) AS todoCount, |
|
|
|
SUM( handle_type = 'finish' ) AS finishCount |
|
|
|
FROM |
|
|
|
business_alert ba |
|
|
|
where 1=1 |
|
|
|
<if test="param.createTime != null and param.createTime != ''"> |
|
|
|
and DATE_FORMAT(ba.create_time,'%Y-%m') = DATE_FORMAT(#{param.createTime},'%Y-%m') |
|
|
|
</if> |
|
|
|
GROUP BY |
|
|
|
ba.dept_name,ba.dept_id |
|
|
|
</select> |
|
|
|
|
|
|
|
</mapper> |
|
|
|