From 6d7b64bfb11bd582467032c408ca3b1799d1d423 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Sat, 18 Sep 2021 17:37:24 +0800
Subject: [PATCH] 1.统计
---
src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml | 825 +++++++++++++++++++++++++++++++---------------------------
1 files changed, 445 insertions(+), 380 deletions(-)
diff --git a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
index a6d1996..0d7733e 100644
--- a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
+++ b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -841,21 +841,21 @@
<!-- </select> -->
<select id="queryCountPq" resultType="java.util.HashMap">
SELECT IFNULL(G.thisnum, 0) AS thisnum,
- IFNULL(J.lastnum, 0) AS lastnum
+ IFNULL(J.lastnum, 0) AS lastnum
FROM (SELECT departmentid, jurisdiction FROM sys_information GROUP BY departmentid, jurisdiction) H
- LEFT JOIN (
- SELECT SUM(num) AS thisnum,
- dept_id
- FROM sys_dispatcher
- WHERE DATE_FORMAT(dispatcherTime, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
- GROUP BY dept_id
+ LEFT JOIN (
+ SELECT SUM(num) AS thisnum,
+ dept_id
+ FROM sys_dispatcher
+ WHERE DATE_FORMAT(dispatcherTime, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
+ GROUP BY dept_id
) G ON G.dept_id = H.departmentid
- LEFT JOIN (
- SELECT SUM(num) AS lastnum,
- dept_id
- FROM sys_dispatcher
- WHERE PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(dispatcherTime, '%Y%m')) = 1
- GROUP BY dept_id
+ LEFT JOIN (
+ SELECT SUM(num) AS lastnum,
+ dept_id
+ FROM sys_dispatcher
+ WHERE PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(dispatcherTime, '%Y%m')) = 1
+ GROUP BY dept_id
) J ON J.dept_id = H.departmentid
WHERE 1 = 1
<if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
@@ -1030,55 +1030,87 @@
<!--资格审查异常数量-->
+ <!-- <select id="selectExtype" resultType="java.util.HashMap">-->
+ <!-- SELECT COUNT-->
+ <!-- (*) as num,-->
+ <!-- d.dept_name,-->
+ <!-- u.real_name,-->
+ <!-- j.dept_name AS jurname-->
+ <!-- FROM blade_user u-->
+ <!-- LEFT JOIN blade_dept d ON d.id = u.dept_id-->
+ <!-- LEFT JOIN sys_jurisdiction j ON j.id = u.jurisdiction-->
+ <!-- WHERE u.examination_type = 1 and u.is_deleted=0 and u.status = 1-->
+ <!-- <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">-->
+ <!-- and u.jurisdiction in (${jurisdiction})-->
+ <!-- </if>-->
+ <!-- <if test="deptid!=null and deptid!=''">-->
+ <!-- and u.dept_id =#{deptid}-->
+ <!-- </if>-->
+ <!-- <if test="type!=null and type=='1'.toString()">-->
+ <!-- and to_days(u.update_time) = to_days(now())-->
+ <!-- </if>-->
+ <!-- <if test="type!=null and type=='2'.toString()">-->
+ <!-- and DATE_FORMAT(u.update_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )-->
+ <!-- </if>-->
+ <!-- GROUP BY d.dept_name,u.real_name,-->
+ <!-- j.dept_name-->
+ <!-- </select>-->
<select id="selectExtype" resultType="java.util.HashMap">
- SELECT COUNT
- (*) as num,
- d.dept_name,
- u.real_name,
- j.dept_name AS jurname
- FROM blade_user u
- LEFT JOIN blade_dept d ON d.id = u.dept_id
- LEFT JOIN sys_jurisdiction j ON j.id = u.jurisdiction
- WHERE u.examination_type = 1 and u.is_deleted=0 and u.status = 1
- <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
- and u.jurisdiction in (${jurisdiction})
- </if>
- <if test="deptid!=null and deptid!=''">
- and u.dept_id =#{deptid}
- </if>
+ SELECT
+ IFNULL( J.num, 0 ) AS num
+ FROM
+ ( SELECT departmentid, jurisdiction FROM sys_information GROUP BY departmentid, jurisdiction ) H
+ LEFT JOIN (
+ SELECT
+ COUNT( * ) AS num,
+ dept_id
+ FROM
+ blade_user
+ WHERE
+ examination_type = 1
+ AND is_deleted = 0
+ AND STATUS = 1
<if test="type!=null and type=='1'.toString()">
- and to_days(u.update_time) = to_days(now())
+ and to_days(audit_time) = to_days(now())
</if>
<if test="type!=null and type=='2'.toString()">
- and DATE_FORMAT(u.update_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
+ and DATE_FORMAT(audit_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</if>
- GROUP BY d.dept_name,u.real_name,
- j.dept_name
+ GROUP BY
+ dept_id
+ ) J ON J.dept_id = H.departmentid
+ WHERE 1 = 1
+ <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
+ AND H.jurisdiction in(${jurisdiction})
+ </if>
+ <if test="deptid!=null and deptid!=''">
+ AND H.departmentid = #{deptid}
+ </if>
</select>
<!--表现差的数量-->
- <select id="selectBx" resultType="java.util.HashMap">
- SELECT IFNULL(COUNT( * ),0) AS num,
- d.dept_name,
- j.dept_name AS jurname
- FROM sys_performance u
- LEFT JOIN blade_dept d ON d.id = u.departmentid
- LEFT JOIN sys_jurisdiction j ON j.id = u.jurisdiction
- WHERE score = 3
- <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
- and u.jurisdiction in(${jurisdiction})
- </if>
- <if test="deptid!=null and deptid!=''">
- and u.departmentid =#{deptid}
- </if>
- <if test="type!=null and type=='1'.toString()">
- and to_days(u.time) = to_days(now())
- </if>
- <if test="type!=null and type=='2'.toString()">
- and DATE_FORMAT(u.time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
- </if>
- GROUP BY d.dept_name,
- j.dept_name
- </select>
+ <!-- <select id="selectBx" resultType="java.util.HashMap">
+ SELECT IFNULL(COUNT( * ),0) AS num,
+ d.dept_name,
+ j.dept_name AS jurname
+ FROM sys_performance u
+ LEFT JOIN blade_dept d ON d.id = u.departmentid
+ LEFT JOIN sys_jurisdiction j ON j.id = u.jurisdiction
+ WHERE score = 3
+ <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
+ and u.jurisdiction in(${jurisdiction})
+ </if>
+ <if test="deptid!=null and deptid!=''">
+ and u.departmentid =#{deptid}
+ </if>
+ <if test="type!=null and type=='1'.toString()">
+ and to_days(u.time) = to_days(now())
+ </if>
+ <if test="type!=null and type=='2'.toString()">
+ and DATE_FORMAT(u.time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
+ </if>
+ GROUP BY d.dept_name,
+ j.dept_name
+ </select>-->
<!-- <!–查询出所有辖区信息–>-->
<!-- <select id="selectJur" resultType="java.util.HashMap">-->
@@ -1086,6 +1118,36 @@
<!-- FROM sys_jurisdiction-->
<!-- WHERE id!=1372091709474910209-->
<!-- </select> -->
+
+ <select id="selectBx" resultType="java.util.HashMap">
+ SELECT
+ IFNULL( J.num, 0 ) AS num
+ FROM
+ ( SELECT departmentid, jurisdiction FROM sys_information GROUP BY departmentid, jurisdiction ) H
+ LEFT JOIN (
+ SELECT
+ IFNULL( COUNT( * ), 0 ) AS num,
+ u.dept_id
+ FROM
+ sys_performance p
+ INNER JOIN blade_user u ON p.securityId = u.id WHERE 1=1
+ <if test="type!=null and type=='1'.toString()">
+ and to_days(p.time) = to_days(now())
+ </if>
+ <if test="type!=null and type=='2'.toString()">
+ and DATE_FORMAT(p.time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
+ </if>
+ GROUP BY
+ dept_id
+ ) J ON J.dept_id = H.departmentid
+ WHERE 1 = 1
+ <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
+ AND H.jurisdiction in(${jurisdiction})
+ </if>
+ <if test="deptid!=null and deptid!=''">
+ AND H.departmentid = #{deptid}
+ </if>
+ </select>
<select id="selectExtypeUser" resultType="java.lang.Integer">
SELECT COUNT(CASE WHEN (examination_mx IS NOT NULL OR examination_mx != "") THEN 1 END) AS sum
@@ -2197,24 +2259,24 @@
<!--根据辖区查询统计当前辖区下的保安公司(本市保安公司,分公司)预警信息,包含(未持证,现实表现差,未缴纳社保,资格审查异常)-->
<select id="getSubstationWarnInfoPage" resultType="org.springblade.modules.information.vo.InformationVO">
(select
- sj1.dept_name jurisdictionName,
- si1.enterpriseName enterprisename,
- "表现差" detail,
- a.count znum
+ sj1.dept_name jurisdictionName,
+ si1.enterpriseName enterprisename,
+ "表现差" detail,
+ a.count znum
from (
- select
- bu.dept_id,count(*) count
- from sys_performance sp
- left join
- blade_user bu
- on
- bu.id = sp.securityId
- where
- 1=1
- and bu.is_deleted = 0
- and bu.`status` = 1
- and sp.score = 3
- GROUP BY bu.dept_id
+ select
+ bu.dept_id,count(*) count
+ from sys_performance sp
+ left join
+ blade_user bu
+ on
+ bu.id = sp.securityId
+ where
+ 1=1
+ and bu.is_deleted = 0
+ and bu.`status` = 1
+ and sp.score = 3
+ GROUP BY bu.dept_id
) a
left join
sys_information si1
@@ -2234,36 +2296,36 @@
union
(
- select
- sj1.dept_name jurisdictionName,
- si1.enterpriseName enterprisename,
- "资格审查异常" detail,
- a.count znum
- from (
- select
- bu.dept_id,count(*) count
- from
- blade_user bu
- where
- 1=1
- and bu.is_deleted = 0
- and bu.`status` = 1
- and bu.examination_type = 1
- GROUP BY bu.dept_id
- ) a
- left join
- sys_information si1
- on
- a.dept_id = si1.departmentid
- left join
- sys_jurisdiction sj1
- on
- sj1.id = si1.jurisdiction
- where 1=1
- and (si1.stats = 2 or si1.stats =4)
- <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
- and (sj1.id = #{information.jurisdiction} or sj1.parent_id = #{information.jurisdiction})
- </if>
+ select
+ sj1.dept_name jurisdictionName,
+ si1.enterpriseName enterprisename,
+ "资格审查异常" detail,
+ a.count znum
+ from (
+ select
+ bu.dept_id,count(*) count
+ from
+ blade_user bu
+ where
+ 1=1
+ and bu.is_deleted = 0
+ and bu.`status` = 1
+ and bu.examination_type = 1
+ GROUP BY bu.dept_id
+ ) a
+ left join
+ sys_information si1
+ on
+ a.dept_id = si1.departmentid
+ left join
+ sys_jurisdiction sj1
+ on
+ sj1.id = si1.jurisdiction
+ where 1=1
+ and (si1.stats = 2 or si1.stats =4)
+ <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
+ and (sj1.id = #{information.jurisdiction} or sj1.parent_id = #{information.jurisdiction})
+ </if>
)
union
@@ -2276,50 +2338,51 @@
e.count znum
from
(
- select d.dept_id,count(*) count from (
- select a.dept_id, ifnull(b.count, 0) num1, ifnull(c.count, 0) num2,ifnull(FORMAT((c.count/b.count)*100, 2), 0) num3 from
- (
- select
- bu.dept_id, ifnull(count(*), 0) count
- from blade_user bu
- left join blade_role br
- on bu.role_id = br.id
- where
- role_alias = "安保人员"
- and bu.is_deleted = 0
- and bu.`status` = 1
- group by dept_id
- ) a
- left join
- (
- select count(*) count, bu.dept_id from
- exam_score es
- left join
- blade_user bu
- on
- bu.id = es.user_id
- where 1=1 group by bu.dept_id
- ) b
- on
- a.dept_id = b.dept_id
- left join
- (
- select count(*) count, bu.dept_id from
- exam_score es
- left join
- blade_user bu
- on
- bu.id = es.user_id
- where qualified = 0 group by bu.dept_id
- ) c
- on
- c.dept_id = a.dept_id
- where 1=1
- ) d
- where 1=1
- and num1!=0
- and num3 < 50
- GROUP BY dept_id
+ select d.dept_id,count(*) count from (
+ select a.dept_id, ifnull(b.count, 0) num1, ifnull(c.count, 0) num2,ifnull(FORMAT((c.count/b.count)*100, 2), 0)
+ num3 from
+ (
+ select
+ bu.dept_id, ifnull(count(*), 0) count
+ from blade_user bu
+ left join blade_role br
+ on bu.role_id = br.id
+ where
+ role_alias = "安保人员"
+ and bu.is_deleted = 0
+ and bu.`status` = 1
+ group by dept_id
+ ) a
+ left join
+ (
+ select count(*) count, bu.dept_id from
+ exam_score es
+ left join
+ blade_user bu
+ on
+ bu.id = es.user_id
+ where 1=1 group by bu.dept_id
+ ) b
+ on
+ a.dept_id = b.dept_id
+ left join
+ (
+ select count(*) count, bu.dept_id from
+ exam_score es
+ left join
+ blade_user bu
+ on
+ bu.id = es.user_id
+ where qualified = 0 group by bu.dept_id
+ ) c
+ on
+ c.dept_id = a.dept_id
+ where 1=1
+ ) d
+ where 1=1
+ and num1!=0
+ and num3 < 50
+ GROUP BY dept_id
) e
left join
sys_information si1
@@ -2339,199 +2402,199 @@
union
(
- select
- sj1.dept_name jurisdictionName,
- si1.enterpriseName enterprisename,
- "持证率低于50%" detail,
- e.count znum
- from
- (
- select c.dept_id,count(*) count from (
- SELECT
- a.dept_id,
- ifnull(a.count,0) num1,
- ifnull(b.count,0) num2,
- ifnull(FORMAT((b.count/a.count)*100,2),0) num3
- FROM (
- SELECT
- bu.dept_id,
- ifnull(count(*),0) count
- FROM
- blade_user bu
- LEFT JOIN blade_role br ON bu.role_id = br.id
- WHERE
- role_alias = "安保人员"
- AND bu.is_deleted = 0
- AND bu.`status` = 1
- GROUP BY
- dept_id
- ) a
+ select
+ sj1.dept_name jurisdictionName,
+ si1.enterpriseName enterprisename,
+ "持证率低于50%" detail,
+ e.count znum
+ from
+ (
+ select c.dept_id,count(*) count from (
+ SELECT
+ a.dept_id,
+ ifnull(a.count,0) num1,
+ ifnull(b.count,0) num2,
+ ifnull(FORMAT((b.count/a.count)*100,2),0) num3
+ FROM (
+ SELECT
+ bu.dept_id,
+ ifnull(count(*),0) count
+ FROM
+ blade_user bu
+ LEFT JOIN blade_role br ON bu.role_id = br.id
+ WHERE
+ role_alias = "安保人员"
+ AND bu.is_deleted = 0
+ AND bu.`status` = 1
+ GROUP BY
+ dept_id
+ ) a
- LEFT JOIN (
- SELECT
- bu.dept_id,
- ifnull(count(*),0) count
- FROM
- blade_user bu
- LEFT JOIN blade_role br ON bu.role_id = br.id
- WHERE
- role_alias = "安保人员"
- AND bu.is_deleted = 0
- AND bu.`status` = 1
- AND bu.hold = 1
- GROUP BY
- dept_id
- ) b ON a.dept_id = b.dept_id
- ) c
- where 1=1
- and num3 < 50
- GROUP BY c.dept_id
- ) e
- left join
- sys_information si1
- on
- e.dept_id = si1.departmentid
- left join
- sys_jurisdiction sj1
- on
- sj1.id = si1.jurisdiction
- where 1=1
- AND ( stats = 2 OR stats = 4 )
- <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
- and (sj1.id = #{information.jurisdiction} or sj1.parent_id = #{information.jurisdiction})
- </if>
+ LEFT JOIN (
+ SELECT
+ bu.dept_id,
+ ifnull(count(*),0) count
+ FROM
+ blade_user bu
+ LEFT JOIN blade_role br ON bu.role_id = br.id
+ WHERE
+ role_alias = "安保人员"
+ AND bu.is_deleted = 0
+ AND bu.`status` = 1
+ AND bu.hold = 1
+ GROUP BY
+ dept_id
+ ) b ON a.dept_id = b.dept_id
+ ) c
+ where 1=1
+ and num3 < 50
+ GROUP BY c.dept_id
+ ) e
+ left join
+ sys_information si1
+ on
+ e.dept_id = si1.departmentid
+ left join
+ sys_jurisdiction sj1
+ on
+ sj1.id = si1.jurisdiction
+ where 1=1
+ AND ( stats = 2 OR stats = 4 )
+ <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
+ and (sj1.id = #{information.jurisdiction} or sj1.parent_id = #{information.jurisdiction})
+ </if>
)
union
(
- select
- sj1.dept_name jurisdictionName,
- si1.enterpriseName enterprisename,
- "社保缴纳率低于50%" detail,
- e.count znum
- from
- (
- select c.dept_id,count(*) count from (
- SELECT
- a.dept_id,
- ifnull(a.count,0) num1,
- ifnull(b.count,0) num2,
- ifnull(FORMAT((b.count/a.count)*100,2),0) num3
- FROM (
- SELECT
- bu.dept_id,
- ifnull(count(*),0) count
- FROM
- blade_user bu
- LEFT JOIN blade_role br ON bu.role_id = br.id
- WHERE
- role_alias = "安保人员"
- AND bu.is_deleted = 0
- AND bu.`status` = 1
- GROUP BY
- dept_id
- ) a
+ select
+ sj1.dept_name jurisdictionName,
+ si1.enterpriseName enterprisename,
+ "社保缴纳率低于50%" detail,
+ e.count znum
+ from
+ (
+ select c.dept_id,count(*) count from (
+ SELECT
+ a.dept_id,
+ ifnull(a.count,0) num1,
+ ifnull(b.count,0) num2,
+ ifnull(FORMAT((b.count/a.count)*100,2),0) num3
+ FROM (
+ SELECT
+ bu.dept_id,
+ ifnull(count(*),0) count
+ FROM
+ blade_user bu
+ LEFT JOIN blade_role br ON bu.role_id = br.id
+ WHERE
+ role_alias = "安保人员"
+ AND bu.is_deleted = 0
+ AND bu.`status` = 1
+ GROUP BY
+ dept_id
+ ) a
- LEFT JOIN (
- SELECT
- bu.dept_id,
- ifnull(count(*),0) count
- FROM
- blade_user bu
- LEFT JOIN blade_role br ON bu.role_id = br.id
- WHERE
- role_alias = "安保人员"
- AND bu.is_deleted = 0
- AND bu.`status` = 1
- AND bu.soil = 0
- GROUP BY
- dept_id
- ) b ON a.dept_id = b.dept_id
- ) c
- where 1=1
- and num3 < 50
- GROUP BY c.dept_id
- ) e
- left join
- sys_information si1
- on
- e.dept_id = si1.departmentid
- left join
- sys_jurisdiction sj1
- on
- sj1.id = si1.jurisdiction
- where 1=1
- AND ( stats = 2 OR stats = 4 )
- <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
- and (sj1.id = #{information.jurisdiction} or sj1.parent_id = #{information.jurisdiction})
- </if>
+ LEFT JOIN (
+ SELECT
+ bu.dept_id,
+ ifnull(count(*),0) count
+ FROM
+ blade_user bu
+ LEFT JOIN blade_role br ON bu.role_id = br.id
+ WHERE
+ role_alias = "安保人员"
+ AND bu.is_deleted = 0
+ AND bu.`status` = 1
+ AND bu.soil = 0
+ GROUP BY
+ dept_id
+ ) b ON a.dept_id = b.dept_id
+ ) c
+ where 1=1
+ and num3 < 50
+ GROUP BY c.dept_id
+ ) e
+ left join
+ sys_information si1
+ on
+ e.dept_id = si1.departmentid
+ left join
+ sys_jurisdiction sj1
+ on
+ sj1.id = si1.jurisdiction
+ where 1=1
+ AND ( stats = 2 OR stats = 4 )
+ <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
+ and (sj1.id = #{information.jurisdiction} or sj1.parent_id = #{information.jurisdiction})
+ </if>
)
union
(
- select
- sj1.dept_name jurisdictionName,
- si1.enterpriseName enterprisename,
- "派遣率低于50%" detail,
- e.count znum
- from
- (
- select c.dept_id,count(*) count from (
- SELECT
- a.dept_id,
- ifnull(a.count,0) num1,
- ifnull(b.count,0) num2,
- ifnull(FORMAT((b.count/a.count)*100,2),0) num3
- FROM (
- SELECT
- bu.dept_id,
- ifnull(count(*),0) count
- FROM
- blade_user bu
- LEFT JOIN blade_role br ON bu.role_id = br.id
- WHERE
- role_alias = "安保人员"
- AND bu.is_deleted = 0
- AND bu.`status` = 1
- GROUP BY
- dept_id
- ) a
+ select
+ sj1.dept_name jurisdictionName,
+ si1.enterpriseName enterprisename,
+ "派遣率低于50%" detail,
+ e.count znum
+ from
+ (
+ select c.dept_id,count(*) count from (
+ SELECT
+ a.dept_id,
+ ifnull(a.count,0) num1,
+ ifnull(b.count,0) num2,
+ ifnull(FORMAT((b.count/a.count)*100,2),0) num3
+ FROM (
+ SELECT
+ bu.dept_id,
+ ifnull(count(*),0) count
+ FROM
+ blade_user bu
+ LEFT JOIN blade_role br ON bu.role_id = br.id
+ WHERE
+ role_alias = "安保人员"
+ AND bu.is_deleted = 0
+ AND bu.`status` = 1
+ GROUP BY
+ dept_id
+ ) a
- LEFT JOIN (
- SELECT
- bu.dept_id,
- ifnull(count(*),0) count
- FROM
- blade_user bu
- LEFT JOIN blade_role br ON bu.role_id = br.id
- WHERE
- role_alias = "安保人员"
- AND bu.is_deleted = 0
- AND bu.`status` = 1
- AND bu.dispatch = 0
- GROUP BY
- dept_id
- ) b ON a.dept_id = b.dept_id
- ) c
- where 1=1
- and num3 < 50
- GROUP BY c.dept_id
- ) e
- left join
- sys_information si1
- on
- e.dept_id = si1.departmentid
- left join
- sys_jurisdiction sj1
- on
- sj1.id = si1.jurisdiction
- where 1=1
- AND ( stats = 2 OR stats = 4 )
- <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
- and (sj1.id = #{information.jurisdiction} or sj1.parent_id = #{information.jurisdiction})
- </if>
+ LEFT JOIN (
+ SELECT
+ bu.dept_id,
+ ifnull(count(*),0) count
+ FROM
+ blade_user bu
+ LEFT JOIN blade_role br ON bu.role_id = br.id
+ WHERE
+ role_alias = "安保人员"
+ AND bu.is_deleted = 0
+ AND bu.`status` = 1
+ AND bu.dispatch = 0
+ GROUP BY
+ dept_id
+ ) b ON a.dept_id = b.dept_id
+ ) c
+ where 1=1
+ and num3 < 50
+ GROUP BY c.dept_id
+ ) e
+ left join
+ sys_information si1
+ on
+ e.dept_id = si1.departmentid
+ left join
+ sys_jurisdiction sj1
+ on
+ sj1.id = si1.jurisdiction
+ where 1=1
+ AND ( stats = 2 OR stats = 4 )
+ <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
+ and (sj1.id = #{information.jurisdiction} or sj1.parent_id = #{information.jurisdiction})
+ </if>
)
</select>
@@ -2584,7 +2647,7 @@
<!--统计表现差的信息-->
<select id="getSecurityPerformanceGroupCountList" resultType="org.springblade.modules.information.vo.ResponseVo">
select a.id,
- a.dept_name name,
+ a.dept_name name,
ifnull(b.count, 0) num
from (select id, dept_name from sys_jurisdiction where parent_id = 1372091709474910209) a
left join
@@ -2615,7 +2678,7 @@
group by si.jurisdiction
) b
on
- a.id = b.parent_id
+ a.id = b.parent_id
</select>
@@ -2783,63 +2846,65 @@
<!--持证率低于50%,社保缴纳率低于50%,派遣率低于50%-->
- <select id="getSecurityHoldAndSoidAndDispatchGroupCountList" resultType="org.springblade.modules.information.vo.ResponseVo">
+ <select id="getSecurityHoldAndSoidAndDispatchGroupCountList"
+ resultType="org.springblade.modules.information.vo.ResponseVo">
select g.id,g.dept_name name,ifnull(f.count,0) num
from
(select id,dept_name from sys_jurisdiction where parent_id = 1372091709474910209) g
left join
(
- select c.id,c.parent_id,count(*) count from (
- select si.enterpriseName,sj.id,sj.parent_id,a.dept_id,ifnull(a.count,0) num1,ifnull(b.count,0) num2,ifnull(FORMAT((b.count/a.count)*100,2),0) num3 from
- (
- select
- bu.dept_id,ifnull(count(*),0) count
- from blade_user bu
- left join blade_role br
- on bu.role_id = br.id
- where
- role_alias = "安保人员"
- and bu.is_deleted = 0
- and bu.`status` = 1
- group by dept_id
- ) a
- left join
- (
- select
- bu.dept_id,ifnull(count(*),0) count
- from blade_user bu
- left join blade_role br
- on bu.role_id = br.id
- where
- role_alias = "安保人员"
- and bu.is_deleted = 0
- and bu.`status` = 1
- <if test="type==1">
- and bu.hold = 1
- </if>
- <if test="type==2">
- and bu.dispatch = 0
- </if>
- <if test="type==3">
- and bu.soil = 0
- </if>
- group by dept_id
- ) b
- on
- a.dept_id = b.dept_id
- left join
- sys_information si
- on
- a.dept_id = si.departmentid
- left join
- sys_jurisdiction sj
- on
- sj.id = si.jurisdiction
- where 1=1
- and (stats = 2 or stats=4)
- )c
- where c.num3 < 50
- group by c.id
+ select c.id,c.parent_id,count(*) count from (
+ select si.enterpriseName,sj.id,sj.parent_id,a.dept_id,ifnull(a.count,0) num1,ifnull(b.count,0)
+ num2,ifnull(FORMAT((b.count/a.count)*100,2),0) num3 from
+ (
+ select
+ bu.dept_id,ifnull(count(*),0) count
+ from blade_user bu
+ left join blade_role br
+ on bu.role_id = br.id
+ where
+ role_alias = "安保人员"
+ and bu.is_deleted = 0
+ and bu.`status` = 1
+ group by dept_id
+ ) a
+ left join
+ (
+ select
+ bu.dept_id,ifnull(count(*),0) count
+ from blade_user bu
+ left join blade_role br
+ on bu.role_id = br.id
+ where
+ role_alias = "安保人员"
+ and bu.is_deleted = 0
+ and bu.`status` = 1
+ <if test="type==1">
+ and bu.hold = 1
+ </if>
+ <if test="type==2">
+ and bu.dispatch = 0
+ </if>
+ <if test="type==3">
+ and bu.soil = 0
+ </if>
+ group by dept_id
+ ) b
+ on
+ a.dept_id = b.dept_id
+ left join
+ sys_information si
+ on
+ a.dept_id = si.departmentid
+ left join
+ sys_jurisdiction sj
+ on
+ sj.id = si.jurisdiction
+ where 1=1
+ and (stats = 2 or stats=4)
+ )c
+ where c.num3 < 50
+ group by c.id
) f
on
g.id = f.parent_id
--
Gitblit v1.9.3