|
|
@ -4,6 +4,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
|
|
<mapper namespace="org.dromara.business.mapper.BusinessAlertMapper"> |
|
|
|
|
|
|
|
<sql id="searchSql"> |
|
|
|
and ba.handle_type != 'verify' |
|
|
|
<if test="param.createTime != null and param.createTime != ''"> |
|
|
|
and DATE_FORMAT(ba.create_time,'%Y-%m') = DATE_FORMAT(#{param.createTime},'%Y-%m') |
|
|
|
</if> |
|
|
|
<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> |
|
|
|
</sql> |
|
|
|
|
|
|
|
<select id="pageBusinessAlert" resultType="org.dromara.business.domain.BusinessAlert"> |
|
|
|
select |
|
|
|
ba.*, |
|
|
@ -14,6 +27,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
${ew.getCustomSqlSegment} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="pageBusinessAlertCancel" resultType="org.dromara.business.domain.BusinessAlert"> |
|
|
|
select |
|
|
|
ba.*, |
|
|
|
b.flow_status flowStatus, |
|
|
|
b.business_id businessId |
|
|
|
from dk_business.business_alert ba |
|
|
|
left join dk_workflow.flow_instance b on ba.id = b.business_id |
|
|
|
${ew.getCustomSqlSegment} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="pageAlertFinish" resultType="org.dromara.business.domain.BusinessAlert"> |
|
|
|
select |
|
|
|
ba.*, |
|
|
@ -45,142 +68,81 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
</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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(DATE_ADD(CURDATE(), 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 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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT DATE_FORMAT(CURDATE(), '%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> |
|
|
|
|
|
|
|
<include refid="searchSql"></include> |
|
|
|
</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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
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 |
|
|
|
SELECT LAST_DAY(DATE_SUB(NOW(), INTERVAL 11 MONTH)) AS dateMonth |
|
|
|
UNION ALL |
|
|
|
SELECT DATE_ADD(dateMonth, INTERVAL 1 MONTH) |
|
|
|
SELECT LAST_DAY(DATE_ADD(dateMonth, INTERVAL 1 MONTH)) |
|
|
|
FROM months |
|
|
|
WHERE <![CDATA[ dateMonth < LAST_DAY(MAKEDATE(YEAR(NOW()), 1) + INTERVAL 10 MONTH) ]]> |
|
|
|
WHERE <![CDATA[ dateMonth < LAST_DAY(NOW()) ]]> |
|
|
|
) |
|
|
|
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 |
|
|
|
IFNULL(COUNT(ba.id), 0) AS total, |
|
|
|
IFNULL(SUM(ba.handle_type = 'waiting'), 0) AS todoCount, |
|
|
|
IFNULL(SUM(ba.handle_type = 'finish'), 0) AS finishCount, |
|
|
|
IFNULL(SUM( ba.handle_type = 'cancel' ),0) AS cancelCount |
|
|
|
FROM months m |
|
|
|
LEFT JOIN business_alert ba |
|
|
|
ON DATE_FORMAT(ba.create_time, '%Y-%m') = DATE_FORMAT(m.dateMonth, '%Y-%m') |
|
|
|
<include refid="searchSql"></include> |
|
|
|
GROUP BY m.dateMonth |
|
|
|
ORDER BY m.dateMonth |
|
|
|
</select> |
|
|
@ -190,25 +152,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
ba.dept_name deptName, |
|
|
|
ba.dept_id deptId, |
|
|
|
count( 1 ) total, |
|
|
|
SUM( handle_type = 'waiting' ) AS todoCount, |
|
|
|
SUM( handle_type = 'finish' ) AS finishCount |
|
|
|
IFNULL(SUM( handle_type = 'waiting' ),0) AS todoCount, |
|
|
|
IFNULL(SUM( handle_type = 'finish' ),0) AS finishCount, |
|
|
|
IFNULL(SUM( ba.handle_type = 'cancel' ),0) AS cancelCount |
|
|
|
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> |
|
|
|
<include refid="searchSql"></include> |
|
|
|
GROUP BY |
|
|
|
ba.dept_name,ba.dept_id |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="countAlertCompare" resultType="java.util.Map"> |
|
|
|
WITH RECURSIVE months AS ( |
|
|
|
SELECT MAKEDATE(COALESCE(#{param.year}, YEAR(NOW())), 1) AS dateMonth |
|
|
|
SELECT LAST_DAY( |
|
|
|
IFNULL( |
|
|
|
MAKEDATE(#{param.year}, 1), |
|
|
|
DATE_SUB(NOW(), INTERVAL 11 MONTH) |
|
|
|
) |
|
|
|
) AS dateMonth |
|
|
|
UNION ALL |
|
|
|
SELECT DATE_ADD(dateMonth, INTERVAL 1 MONTH) |
|
|
|
SELECT LAST_DAY(DATE_ADD(dateMonth, INTERVAL 1 MONTH)) |
|
|
|
FROM months |
|
|
|
WHERE <![CDATA[ dateMonth < MAKEDATE(COALESCE(#{param.year}, YEAR(NOW())), 1) + INTERVAL 11 MONTH ]]> |
|
|
|
WHERE <![CDATA[ dateMonth < LAST_DAY( |
|
|
|
IFNULL( |
|
|
|
MAKEDATE(#{param.year}, 1) + INTERVAL 11 MONTH, |
|
|
|
NOW() |
|
|
|
) |
|
|
|
)]]> |
|
|
|
), |
|
|
|
param_departments AS ( |
|
|
|
SELECT dept_id, dept_name,tenant_id |
|
|
@ -237,13 +208,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
DATE_FORMAT(md.dateMonth, '%Y-%m') AS date, |
|
|
|
COUNT(DISTINCT ba.id) AS total, |
|
|
|
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount, |
|
|
|
IFNULL(SUM( ba.handle_type = 'finish' ),0) AS finishCount |
|
|
|
IFNULL(SUM( ba.handle_type = 'finish' ),0) AS finishCount, |
|
|
|
IFNULL(SUM( ba.handle_type = 'cancel' ),0) AS cancelCount |
|
|
|
FROM month_department md |
|
|
|
LEFT JOIN business_alert ba |
|
|
|
ON md.dept_id = ba.dept_id |
|
|
|
AND DATE_FORMAT(ba.create_time, '%Y-%m') = DATE_FORMAT(md.dateMonth, '%Y-%m') |
|
|
|
AND ba.handle_type != 'verify' |
|
|
|
GROUP BY md.dept_id, md.dateMonth, md.dept_name |
|
|
|
ORDER BY md.dept_id, md.dateMonth |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="countPanelAlert" resultType="java.util.Map"> |
|
|
|
select COUNT(DISTINCT ba.id) AS total, |
|
|
|
IFNULL(SUM( ba.handle_type = 'waiting' ),0) AS todoCount, |
|
|
|
IFNULL(SUM( ba.handle_type = 'finish' ),0) AS finishCount, |
|
|
|
IFNULL(SUM( ba.handle_type = 'cancel' ),0) AS cancelCount |
|
|
|
from business_alert ba |
|
|
|
where 1=1 |
|
|
|
<include refid="searchSql"></include> |
|
|
|
</select> |
|
|
|
|
|
|
|
</mapper> |
|
|
|