From 3293bbe787ec29543c85697de56f86177d983103 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 14 Sep 2021 19:32:17 +0800
Subject: [PATCH] 首页统计接口新增

---
 src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml |  221 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 221 insertions(+), 0 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 257fcfb..0a43eb9 100644
--- a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
+++ b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -1765,4 +1765,225 @@
               ) = 1
           AND parent_id!=0
     </select>
+
+    <!--获取保安公司信息(本市保安公司,分公司)包含经纬度-->
+    <select id="getSecurityUnitPositionInfo" resultType="org.springblade.modules.information.vo.InformationVO">
+        select
+        si.*,sj.dept_name jurisdictionName
+        from
+        sys_information si
+        left join
+        sys_jurisdiction sj
+        on
+        si.jurisdiction = sj.id
+        where 1=1
+        and (stats = 2 or stats = 4)
+    </select>
+
+    <!--根据辖区查询保安公司分页信息(本市保安公司,分公司)-->
+    <select id="getSecurityUnitInfoPage" resultType="org.springblade.modules.information.vo.InformationVO">
+        select
+        si.*,sj.dept_name jurisdictionName
+        from
+        sys_information si
+        left join
+        sys_jurisdiction sj
+        on
+        si.jurisdiction = sj.id
+        where 1=1
+        and (stats = 2 or stats = 4)
+        <if test="information.jurisdiction!=null and information.jurisdiction!=''">
+            and (sj.id = #{information.jurisdiction} or sj.parent_id = #{information.jurisdiction})
+        </if>
+    </select>
+
+    <sql id="getSecurity">
+        select
+            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
+    </sql>
+
+    <!--根据辖区查询统计保安公司持证情况分页信息(本市保安公司,分公司)-->
+    <select id="getSecurityUnitHoldInfoPage" resultType="org.springblade.modules.information.vo.InformationVO">
+        select
+            si.*,sj.dept_name jurisdictionName,
+            ifnull(a.count,0) znum,
+            ifnull(b.count,0) cnum,
+            ifnull(c.count,0) pnum
+        from sys_information si
+        left join
+        (
+            <include refid="getSecurity"/>
+            group by dept_id
+        ) a
+        on
+        a.dept_id = si.departmentid
+        left join
+        (
+            <include refid="getSecurity"/>
+            and bu.hold = 1
+            group by dept_id
+        ) b
+        on
+        b.dept_id = si.departmentid
+        left join
+        (
+            <include refid="getSecurity"/>
+            and bu.hold = 2
+            group by dept_id
+        ) c
+        on
+        c.dept_id = si.departmentid
+        left join
+        sys_jurisdiction sj
+        on
+        si.jurisdiction = sj.id
+        where 1=1
+        and (si.stats = 2 or si.stats = 4)
+        <if test="information.jurisdiction!=null and information.jurisdiction!=''">
+            and (sj.id = #{information.jurisdiction} or sj.parent_id = #{information.jurisdiction})
+        </if>
+    </select>
+
+    <!--根据辖区查询统计保安公司(1:持证率低于50% 2:派遣率低于50%  3:缴纳社保率低于50% 的保安公司个数及保安公司分页信息(本市保安公司,分公司)-->
+    <select id="getSecurityUnitLess50Page" resultType="org.springblade.modules.information.vo.InformationVO">
+        select c.*,sj.dept_name jurisdictionName from (
+            select
+            si.*,
+            ifnull(a.count,0) znum,
+            ifnull(b.count,0) cnum,
+            ifnull(FORMAT((b.count/a.count)*100,2),0) pnum
+            from sys_information si
+            left join
+            (
+                <include refid="getSecurity"/>
+                group by dept_id
+            ) a
+            on
+            a.dept_id = si.departmentid
+            left join
+            (
+                <include refid="getSecurity"/>
+                <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
+            b.dept_id = si.departmentid
+        )c
+        left join
+        sys_jurisdiction sj
+        on
+        c.jurisdiction = sj.id
+        where 1=1
+        and (c.stats = 2 or c.stats = 4)
+        and pnum &lt; 50
+        <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
+            and (sj.id = #{information.jurisdiction} or sj.parent_id = #{information.jurisdiction})
+        </if>
+    </select>
+
+    <!--根据辖区查询统计保安公司考试通过率低于50%的保安公司个数及保安公司分页信息(本市保安公司,分公司)-->
+    <select id="getSecurityUnitExamLess50Page" resultType="org.springblade.modules.information.vo.InformationVO">
+        select d.*,sj.dept_name jurisdictionName from (
+            select
+            si.*,
+            ifnull(a.count,0) znum,
+            ifnull(b.count,0) cnum,
+            ifnull(FORMAT((b.count/c.count)*100,2),0) pnum
+            from sys_information si
+            left join
+            (
+            <include refid="getSecurity"/>
+            group by dept_id
+            ) a
+            on
+            a.dept_id = si.departmentid
+            left join
+            (
+                select b1.dept_id,ifnull(b2.count,0) count 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
+                    ) b1
+
+                    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
+                    ) b2
+                on
+                b1.dept_id = b2.dept_id
+            ) b
+            on
+            b.dept_id = si.departmentid
+            left join
+            (
+                select c1.dept_id,ifnull(c2.count,0) count 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
+                ) c1
+
+                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
+                ) c2
+                on
+                c1.dept_id = c2.dept_id
+            ) c
+            on
+            c.dept_id = si.departmentid
+        )d
+        left join
+        sys_jurisdiction sj
+        on
+        d.jurisdiction = sj.id
+        where 1=1
+        and (d.stats = 2 or d.stats = 4)
+        and pnum &lt; 50
+        <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
+            and (sj.id = #{information.jurisdiction} or sj.parent_id = #{information.jurisdiction})
+        </if>
+    </select>
 </mapper>

--
Gitblit v1.9.3