|
|
|
@ -15,10 +15,12 @@
|
|
|
|
|
count(DISTINCT ei.id) as taskExecNum, |
|
|
|
|
SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) AS taskFinishNum |
|
|
|
|
FROM task_info t |
|
|
|
|
left join enterprise_inspections ei on t.id = ei.task_id |
|
|
|
|
left join inspections_log il on ei.id = il.inspections_id |
|
|
|
|
left join enterprises e on e.id = ei.enterprise_id |
|
|
|
|
left join tag_library tl on tl.id = t.task_type |
|
|
|
|
left join enterprise_inspections ei on t.id = ei.task_id |
|
|
|
|
left join inspections_log il on ei.id = il.inspections_id |
|
|
|
|
left join enterprises e on e.id = ei.enterprise_id |
|
|
|
|
left join tag_library tl on tl.id = t.task_type |
|
|
|
|
left join system_users su on su.id = t.creator |
|
|
|
|
left join system_dept sd on sd.id = su.dept_id |
|
|
|
|
WHERE |
|
|
|
|
t.deleted = 0 and ei.deleted = 0 and ei.status = 2 |
|
|
|
|
<if test="params.userId != null and params.userId != ''"> |
|
|
|
@ -27,15 +29,21 @@
|
|
|
|
|
<if test="params.priority != null and params.priority != ''"> |
|
|
|
|
AND t.priority = #{params.priority} |
|
|
|
|
</if> |
|
|
|
|
<if test="params.createDeptId != null and params.createDeptId != ''"> |
|
|
|
|
AND sd.id = #{params.createDeptId} |
|
|
|
|
</if> |
|
|
|
|
<if test="params.status != null and params.status != ''"> |
|
|
|
|
AND t.status = #{params.status} |
|
|
|
|
</if> |
|
|
|
|
<if test="params.deptId != null and params.deptId != ''"> |
|
|
|
|
AND e.department_id = #{params.deptId} |
|
|
|
|
</if> |
|
|
|
|
<if test="params.endTime != null and params.endTime != ''"> |
|
|
|
|
<if test="params.endTime != null"> |
|
|
|
|
AND t.end_date between #{params.startTime} and #{params.endTime} |
|
|
|
|
</if> |
|
|
|
|
<if test="params.region != null and params.region != ''"> |
|
|
|
|
AND e.region = #{params.region} |
|
|
|
|
</if> |
|
|
|
|
<if test="params.tagList != null and params. tagList != ''"> |
|
|
|
|
AND t.task_type = #{params.tagList} |
|
|
|
|
</if> |
|
|
|
@ -43,6 +51,8 @@
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectPageByEnterpriseId" resultType="cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO"> |
|
|
|
|
SELECT |
|
|
|
|
t.* |
|
|
|
@ -57,6 +67,7 @@
|
|
|
|
|
<select id="selectHomeGroupCount" resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeGroupCountVO"> |
|
|
|
|
SELECT |
|
|
|
|
su.`real_name` as name, |
|
|
|
|
su.`id` as userId, |
|
|
|
|
SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) as finishCount, |
|
|
|
|
COUNT(DISTINCT ei.id) as execCount, |
|
|
|
|
round( SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) /COUNT(DISTINCT ei.id) * 100,1) as completionRate |
|
|
|
@ -70,6 +81,12 @@
|
|
|
|
|
system_users su on su.id = ei.user_id |
|
|
|
|
WHERE |
|
|
|
|
ei.deleted = 0 AND e.deleted = 0 and ei.status = 2 and e.region = #{region} |
|
|
|
|
<if test="time != null"> |
|
|
|
|
AND ei.create_time between |
|
|
|
|
<foreach collection="time" item="item" separator="and" open="" close=""> |
|
|
|
|
#{item} |
|
|
|
|
</foreach> |
|
|
|
|
</if> |
|
|
|
|
GROUP BY |
|
|
|
|
ei.user_id |
|
|
|
|
order by |
|
|
|
@ -78,11 +95,11 @@
|
|
|
|
|
<select id="selectEnterpriseNum" resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO"> |
|
|
|
|
select |
|
|
|
|
DATEDIFF(eq.expiry_date, NOW()) AS count, |
|
|
|
|
e.enterprises_name as name |
|
|
|
|
from |
|
|
|
|
enterprise_qualification eq |
|
|
|
|
LEFT JOIN |
|
|
|
|
enterprises e ON eq.enterprise_id = e.id |
|
|
|
|
e.enterprises_name as name, |
|
|
|
|
su.real_name as realName |
|
|
|
|
from enterprise_qualification eq |
|
|
|
|
LEFT JOIN enterprises e ON eq.enterprise_id = e.id |
|
|
|
|
LEFT JOIN system_users su on su.id = e.user_id |
|
|
|
|
WHERE |
|
|
|
|
e.deleted = 0 and eq.deleted = 0 AND eq.expiry_date < DATE_ADD(NOW(), INTERVAL 16 DAY) and e.region = #{region} |
|
|
|
|
<if test="deptId != null and deptId != ''"> |
|
|
|
@ -97,17 +114,22 @@
|
|
|
|
|
#{i} |
|
|
|
|
</foreach> |
|
|
|
|
</if> |
|
|
|
|
ORDER BY count ASC ; |
|
|
|
|
ORDER BY count ASC |
|
|
|
|
<if test="size != null and size != ''"> |
|
|
|
|
limit #{size} |
|
|
|
|
</if> |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<select id="selectEnterpriseStatus" resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO"> |
|
|
|
|
SELECT |
|
|
|
|
e.enterprises_name as name, |
|
|
|
|
sd.name as deptName, |
|
|
|
|
sum(CASE WHEN il.status=3 THEN 1 ELSE 0 END) as count |
|
|
|
|
FROM |
|
|
|
|
enterprise_inspections ei |
|
|
|
|
LEFT JOIN inspections_log il on il.inspections_id = ei.id |
|
|
|
|
LEFT JOIN enterprises e ON e.id = ei.enterprise_id |
|
|
|
|
LEFT JOIN system_dept sd on sd.id = e.department_id |
|
|
|
|
<where> |
|
|
|
|
ei.deleted = 0 and il.status = 3 and e.region = #{region} |
|
|
|
|
<if test="deptId != null and deptId != ''"> |
|
|
|
@ -120,7 +142,10 @@
|
|
|
|
|
</foreach> |
|
|
|
|
</if> |
|
|
|
|
</where> |
|
|
|
|
GROUP BY e.enterprises_name order by count desc; |
|
|
|
|
GROUP BY e.enterprises_name, sd.name order by count desc |
|
|
|
|
<if test="size != null and size != ''"> |
|
|
|
|
limit #{size} |
|
|
|
|
</if> |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
<select id="selectHomeExecFinish" resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeExecFinishVO"> |
|
|
|
@ -128,11 +153,11 @@
|
|
|
|
|
count( DISTINCT ei.id) as execCount, |
|
|
|
|
SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) AS finishCount |
|
|
|
|
FROM task_info t |
|
|
|
|
left join enterprise_inspections ei on t.id = ei.task_id |
|
|
|
|
left join inspections_log il on ei.id = il.inspections_id |
|
|
|
|
left join enterprises e on e.id = ei.enterprise_id |
|
|
|
|
left join task_tag tt on t.id = tt.task_id |
|
|
|
|
left join tag_library tl on tl.id = tt.tag_id |
|
|
|
|
left join enterprise_inspections ei on t.id = ei.task_id |
|
|
|
|
left join inspections_log il on ei.id = il.inspections_id |
|
|
|
|
left join enterprises e on e.id = ei.enterprise_id |
|
|
|
|
left join task_tag tt on t.id = tt.task_id |
|
|
|
|
left join tag_library tl on tl.id = tt.tag_id |
|
|
|
|
WHERE |
|
|
|
|
t.deleted = 0 and ei.deleted = 0 and ei.status = 2 and e.region = #{region} |
|
|
|
|
<if test="deptId != null and deptId != ''"> |
|
|
|
@ -146,5 +171,81 @@
|
|
|
|
|
</if> |
|
|
|
|
GROUP By t.id |
|
|
|
|
</select> |
|
|
|
|
<select id="appSelectCreateDept" |
|
|
|
|
resultType="cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueLongVO"> |
|
|
|
|
SELECT |
|
|
|
|
DISTINCT sd.id as value, |
|
|
|
|
sd.name as label |
|
|
|
|
FROM task_info t |
|
|
|
|
left join enterprise_inspections ei on t.id = ei.task_id |
|
|
|
|
left join enterprises e on e.id = ei.enterprise_id |
|
|
|
|
left join system_users su on su.id = t.creator |
|
|
|
|
left join system_dept sd on sd.id = su.dept_id |
|
|
|
|
WHERE |
|
|
|
|
t.deleted = 0 and ei.deleted = 0 and ei.status = 2 |
|
|
|
|
<if test="userId != null and userId != ''"> |
|
|
|
|
AND ei.user_id = #{userId} |
|
|
|
|
</if> |
|
|
|
|
<if test="deptId != null and deptId != ''"> |
|
|
|
|
AND e.department_id = #{deptId} |
|
|
|
|
</if> |
|
|
|
|
</select> |
|
|
|
|
<select id="taskNumDoing" |
|
|
|
|
resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeGroupMonthVO"> |
|
|
|
|
SELECT |
|
|
|
|
dates.month, |
|
|
|
|
COALESCE(COUNT(DISTINCT stats.task_id), 0) AS taskCount, |
|
|
|
|
COALESCE(COUNT(DISTINCT stats.inspection_id), 0) AS inspectionCount |
|
|
|
|
FROM ( |
|
|
|
|
-- 手动生成近6个月的月份 |
|
|
|
|
SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 5 MONTH), '%Y-%m') AS month |
|
|
|
|
UNION SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 4 MONTH), '%Y-%m') |
|
|
|
|
UNION SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 3 MONTH), '%Y-%m') |
|
|
|
|
UNION SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 2 MONTH), '%Y-%m') |
|
|
|
|
UNION SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y-%m') |
|
|
|
|
UNION SELECT DATE_FORMAT(NOW(), '%Y-%m') |
|
|
|
|
) dates |
|
|
|
|
LEFT JOIN ( |
|
|
|
|
-- 实际数据统计子查询 |
|
|
|
|
SELECT |
|
|
|
|
DATE_FORMAT(ei.create_time, '%Y-%m') AS month, |
|
|
|
|
t.id AS task_id, |
|
|
|
|
ei.id AS inspection_id |
|
|
|
|
FROM |
|
|
|
|
task_info t |
|
|
|
|
LEFT JOIN enterprise_inspections ei ON t.id = ei.task_id |
|
|
|
|
LEFT JOIN enterprises e ON e.id = ei.enterprise_id |
|
|
|
|
WHERE |
|
|
|
|
t.deleted = 0 |
|
|
|
|
AND ei.deleted = 0 |
|
|
|
|
AND ei.status = 2 |
|
|
|
|
<if test="region != null and region != ''"> |
|
|
|
|
AND e.region = #{region} |
|
|
|
|
</if> |
|
|
|
|
AND ei.create_time >= DATE_SUB(NOW(), INTERVAL 6 MONTH) |
|
|
|
|
) stats ON dates.month = stats.month |
|
|
|
|
GROUP BY dates.month |
|
|
|
|
ORDER BY dates.month |
|
|
|
|
</select> |
|
|
|
|
<select id="selectCorrectionCount" |
|
|
|
|
resultType="java.lang.Long"> |
|
|
|
|
select |
|
|
|
|
count(*) |
|
|
|
|
from inspections_log il |
|
|
|
|
left join enterprise_inspections ei on il.inspections_id = ei.id |
|
|
|
|
where ei.deleted = 0 and il.status = 3 |
|
|
|
|
<if test="region != null and region != ''"> |
|
|
|
|
and ei.enterprise_id in (select id from enterprises where region = #{region}) |
|
|
|
|
</if> |
|
|
|
|
<if test="time != null"> |
|
|
|
|
and il.create_time between |
|
|
|
|
<foreach collection="time" item="item" separator="and" open="" close=""> |
|
|
|
|
#{item} |
|
|
|
|
</foreach> |
|
|
|
|
</if> |
|
|
|
|
<if test="userId != null and userId != ''"> |
|
|
|
|
and il.creator = #{userId} |
|
|
|
|
</if> |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
</mapper> |
|
|
|
|