|
|
@ -68,14 +68,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
uu.processed_by approver, |
|
|
|
a.id flowTaskId, |
|
|
|
b.id instanceId, |
|
|
|
fn.permissions, |
|
|
|
fnData.permissions, |
|
|
|
a.node_type |
|
|
|
from dk_business.business_alert ba |
|
|
|
inner join dk_workflow.flow_instance b on ba.id = b.business_id |
|
|
|
left join dk_workflow.flow_task a on a.instance_id = b.id |
|
|
|
left join dk_workflow.flow_user uu on uu.associated = a.id |
|
|
|
left join dk_workflow.flow_definition c on a.definition_id = c.id |
|
|
|
left join dk_workflow.flow_node fn on fn.node_code = b.node_code |
|
|
|
LEFT JOIN LATERAL ( |
|
|
|
SELECT |
|
|
|
fn.permissions |
|
|
|
FROM dk_workflow.flow_node fn |
|
|
|
WHERE |
|
|
|
fn.node_code = b.node_code |
|
|
|
and fn.definition_id = c.id |
|
|
|
and fn.del_flag = '0' |
|
|
|
LIMIT 1 |
|
|
|
) AS fnData ON TRUE |
|
|
|
where a.node_type = 1 |
|
|
|
and a.del_flag = '0' |
|
|
|
and uu.del_flag = '0' |
|
|
@ -135,8 +144,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="listDepartAlert" resultType="java.util.Map"> |
|
|
|
WITH RECURSIVE districts AS ( |
|
|
|
SELECT dept_id, dept_name,tenant_id FROM dk_cloud.sys_dept <where> |
|
|
|
WITH RECURSIVE sub_depts AS ( |
|
|
|
SELECT |
|
|
|
dept_id, |
|
|
|
dept_name, |
|
|
|
parent_id, |
|
|
|
tenant_id |
|
|
|
FROM |
|
|
|
dk_cloud.sys_dept |
|
|
|
<where> |
|
|
|
<if test="param.deptId != null and param.deptId != ''"> |
|
|
|
parent_id = #{param.deptId} |
|
|
|
</if> |
|
|
@ -144,11 +160,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0') |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
UNION ALL |
|
|
|
-- 递归查询:获取所有下级部门 |
|
|
|
SELECT |
|
|
|
d.dept_id, |
|
|
|
d.dept_name, |
|
|
|
d.parent_id, |
|
|
|
d.tenant_id |
|
|
|
FROM |
|
|
|
dk_cloud.sys_dept d |
|
|
|
INNER JOIN sub_depts st ON d.parent_id = st.dept_id |
|
|
|
), |
|
|
|
sub_depts AS ( |
|
|
|
-- 第一级子部门(包含 dept_name) |
|
|
|
SELECT dept_id, dept_name, parent_id, tenant_id |
|
|
|
FROM dk_cloud.sys_dept |
|
|
|
-- 获取直接子部门(用于最终显示) |
|
|
|
districts AS ( |
|
|
|
SELECT |
|
|
|
dept_id, |
|
|
|
dept_name, |
|
|
|
parent_id, |
|
|
|
tenant_id |
|
|
|
FROM |
|
|
|
dk_cloud.sys_dept |
|
|
|
<where> |
|
|
|
<if test="param.deptId != null and param.deptId != ''"> |
|
|
|
parent_id = #{param.deptId} |
|
|
@ -157,30 +188,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0') |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
UNION ALL |
|
|
|
-- 递归查询下级部门(同样包含 dept_name) |
|
|
|
SELECT d.dept_id, d.dept_name, d.parent_id, d.tenant_id |
|
|
|
FROM dk_cloud.sys_dept d |
|
|
|
INNER JOIN sub_depts st ON d.parent_id = st.dept_id |
|
|
|
), |
|
|
|
warning_summary AS ( |
|
|
|
SELECT |
|
|
|
d.dept_id AS district_id, |
|
|
|
dc.dept_id AS district_id, |
|
|
|
COUNT(ba.id) AS total_warnings |
|
|
|
FROM |
|
|
|
business_alert ba |
|
|
|
INNER JOIN sub_depts d ON ba.dept_id = d.dept_id |
|
|
|
districts dc |
|
|
|
LEFT JOIN sub_depts sd ON sd.parent_id = dc.dept_id OR sd.dept_id = dc.dept_id |
|
|
|
LEFT JOIN business_alert ba ON ba.dept_id = sd.dept_id |
|
|
|
<include refid="searchSql"></include> |
|
|
|
GROUP BY |
|
|
|
d.dept_id |
|
|
|
dc.dept_id |
|
|
|
) |
|
|
|
SELECT |
|
|
|
d.dept_id deptId, |
|
|
|
d.dept_name deptName, |
|
|
|
COALESCE ( w.total_warnings, 0 ) AS total |
|
|
|
dc.dept_id deptId, |
|
|
|
dc.dept_name deptName, |
|
|
|
COALESCE(ws.total_warnings, 0) AS total |
|
|
|
FROM |
|
|
|
districts d |
|
|
|
LEFT JOIN warning_summary w ON d.dept_id = w.district_id |
|
|
|
districts dc |
|
|
|
LEFT JOIN warning_summary ws ON dc.dept_id = ws.district_id |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="listMonthAlertStatus" resultType="java.util.Map"> |
|
|
@ -206,8 +233,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="listDepartAlertStatus" resultType="java.util.Map"> |
|
|
|
WITH RECURSIVE districts AS ( |
|
|
|
SELECT dept_id, dept_name,tenant_id FROM dk_cloud.sys_dept <where> |
|
|
|
WITH RECURSIVE sub_depts AS ( |
|
|
|
SELECT |
|
|
|
dept_id, |
|
|
|
dept_name, |
|
|
|
parent_id, |
|
|
|
tenant_id |
|
|
|
FROM |
|
|
|
dk_cloud.sys_dept |
|
|
|
<where> |
|
|
|
<if test="param.deptId != null and param.deptId != ''"> |
|
|
|
parent_id = #{param.deptId} |
|
|
|
</if> |
|
|
@ -215,11 +249,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0') |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
UNION ALL |
|
|
|
-- 递归查询:获取所有下级部门 |
|
|
|
SELECT |
|
|
|
d.dept_id, |
|
|
|
d.dept_name, |
|
|
|
d.parent_id, |
|
|
|
d.tenant_id |
|
|
|
FROM |
|
|
|
dk_cloud.sys_dept d |
|
|
|
INNER JOIN sub_depts st ON d.parent_id = st.dept_id |
|
|
|
), |
|
|
|
sub_depts AS ( |
|
|
|
-- 第一级子部门(包含 dept_name) |
|
|
|
SELECT dept_id, dept_name, parent_id, tenant_id |
|
|
|
FROM dk_cloud.sys_dept |
|
|
|
-- 获取直接子部门(用于最终显示) |
|
|
|
districts AS ( |
|
|
|
SELECT |
|
|
|
dept_id, |
|
|
|
dept_name, |
|
|
|
parent_id, |
|
|
|
tenant_id |
|
|
|
FROM |
|
|
|
dk_cloud.sys_dept |
|
|
|
<where> |
|
|
|
<if test="param.deptId != null and param.deptId != ''"> |
|
|
|
parent_id = #{param.deptId} |
|
|
@ -228,37 +277,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
parent_id in (select dsd.dept_id from dk_cloud.sys_dept dsd where dsd.parent_id = '0') |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
UNION ALL |
|
|
|
-- 递归查询下级部门(同样包含 dept_name) |
|
|
|
SELECT d.dept_id, d.dept_name, d.parent_id, d.tenant_id |
|
|
|
FROM dk_cloud.sys_dept d |
|
|
|
INNER JOIN sub_depts st ON d.parent_id = st.dept_id |
|
|
|
), |
|
|
|
warning_summary AS ( |
|
|
|
SELECT |
|
|
|
d.dept_id AS district_id, |
|
|
|
dc.dept_id AS district_id, |
|
|
|
COUNT(ba.id) AS total_warnings, |
|
|
|
IFNULL(SUM(handle_type = 'waiting'), 0) AS todoCount, |
|
|
|
IFNULL(SUM(handle_type = 'finish'), 0) AS finishCount, |
|
|
|
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 |
|
|
|
INNER JOIN sub_depts d ON ba.dept_id = d.dept_id |
|
|
|
AND ba.handle_type != 'verify' |
|
|
|
districts dc |
|
|
|
LEFT JOIN sub_depts sd ON sd.parent_id = dc.dept_id OR sd.dept_id = dc.dept_id |
|
|
|
LEFT JOIN business_alert ba ON ba.dept_id = sd.dept_id |
|
|
|
<include refid="searchSql"></include> |
|
|
|
GROUP BY |
|
|
|
d.dept_id |
|
|
|
dc.dept_id |
|
|
|
) |
|
|
|
SELECT |
|
|
|
d.dept_id deptId, |
|
|
|
d.dept_name deptName, |
|
|
|
IFNULL(w.total_warnings, 0) AS total, |
|
|
|
IFNULL(w.todoCount, 0) AS todoCount, |
|
|
|
IFNULL(w.finishCount, 0) AS finishCount, |
|
|
|
IFNULL(w.cancelCount, 0) AS cancelCount |
|
|
|
dc.dept_id deptId, |
|
|
|
dc.dept_name deptName, |
|
|
|
COALESCE(ws.total_warnings, 0) AS total, |
|
|
|
IFNULL(ws.todoCount, 0) AS todoCount, |
|
|
|
IFNULL(ws.finishCount, 0) AS finishCount, |
|
|
|
IFNULL(ws.cancelCount, 0) AS cancelCount |
|
|
|
FROM |
|
|
|
districts d |
|
|
|
LEFT JOIN warning_summary w ON d.dept_id = w.district_id |
|
|
|
districts dc |
|
|
|
LEFT JOIN warning_summary ws ON dc.dept_id = ws.district_id |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="countAlertCompare" resultType="java.util.Map"> |
|
|
|