智慧保安后台管理-验收版本
tangzy
2021-09-18 6d0909f784a03da5fc4918b759d5bbba16b535c5
1.统计
1 files modified
482 ■■■■ changed files
src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml 482 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -596,29 +596,29 @@
    <!--    </select>-->
    <select id="queryCountB" resultType="java.util.HashMap">
        SELECT IFNULL(A.thisnum, 0) AS thisnum,
               IFNULL(B.lastnum, 0) AS lastnum,
               H.departmentid,
               H.jurisdiction
        IFNULL(B.lastnum, 0) AS lastnum,
        H.departmentid,
        H.jurisdiction
        FROM (SELECT departmentid, jurisdiction FROM sys_information GROUP BY departmentid, jurisdiction) H
                 LEFT JOIN (
            SELECT COUNT(*) AS thisnum,
                   dept_id
            FROM blade_user
            WHERE role_id = '1412226235153731586'
              AND STATUS = 1
              AND is_deleted = 0
              AND DATE_FORMAT(create_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
            GROUP BY dept_id
        LEFT JOIN (
        SELECT COUNT(*) AS thisnum,
        dept_id
        FROM blade_user
        WHERE role_id = '1412226235153731586'
        AND STATUS = 1
        AND is_deleted = 0
        AND DATE_FORMAT(create_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
        GROUP BY dept_id
        ) A ON A.dept_id = H.departmentid
                 LEFT JOIN (
            SELECT COUNT(*) AS lastnum,
                   dept_id
            FROM blade_user
            WHERE role_id = '1412226235153731586'
              AND STATUS = 1
              AND is_deleted = 0
              AND PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(create_time, '%Y%m')) = 1
            GROUP BY dept_id
        LEFT JOIN (
        SELECT COUNT(*) AS lastnum,
        dept_id
        FROM blade_user
        WHERE role_id = '1412226235153731586'
        AND STATUS = 1
        AND is_deleted = 0
        AND PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(create_time, '%Y%m')) = 1
        GROUP BY dept_id
        ) B ON B.dept_id = H.departmentid where 1=1
        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
            and H.jurisdiction =#{jurisdiction}
@@ -804,39 +804,65 @@
    </select>
    <!--保安派遣数量-->
    <!--    <select id="queryCountPq" resultType="java.util.HashMap">-->
    <!--        SELECT C.thisnum,-->
    <!--        C.lastnum,-->
    <!--        d.dept_name as deptname,-->
    <!--        j.dept_name as jurname-->
    <!--        FROM (-->
    <!--        SELECT IFNULL(A.thisnum, 0) AS thisnum,-->
    <!--        IFNULL(B.lastnum, 0) AS lastnum,-->
    <!--        A.dept_id,-->
    <!--        A.jurisdiction-->
    <!--        FROM (-->
    <!--        SELECT SUM(num) AS thisnum,-->
    <!--        dept_id,-->
    <!--        jurisdiction-->
    <!--        FROM sys_dispatcher-->
    <!--        WHERE DATE_FORMAT( dispatcherTime, '%Y%m' ) = DATE_FORMAT( CURDATE( ), '%Y%m' )-->
    <!--        GROUP BY dept_id, jurisdiction-->
    <!--        ) A-->
    <!--        left JOIN (-->
    <!--        SELECT SUM(num) AS lastnum,-->
    <!--        dept_id,-->
    <!--        jurisdiction-->
    <!--        FROM sys_dispatcher-->
    <!--        WHERE PERIOD_DIFF( date_format( now( ), '%Y%m' ), date_format( dispatcherTime, '%Y%m' ) ) = 1-->
    <!--        GROUP BY dept_id, jurisdiction-->
    <!--        ) B ON A.dept_id = B.dept_id) C-->
    <!--        LEFT JOIN blade_dept d ON C.dept_id = d.id-->
    <!--        LEFT JOIN sys_jurisdiction j ON j.id = C.jurisdiction where 1=1-->
    <!--        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">-->
    <!--            and C.jurisdiction =#{jurisdiction}-->
    <!--        </if>-->
    <!--        <if test="deptid!=null and deptid!=''">-->
    <!--            and C.dept_id =#{deptid}-->
    <!--        </if>-->
    <!--    </select> -->
    <select id="queryCountPq" resultType="java.util.HashMap">
        SELECT C.thisnum,
        C.lastnum,
        d.dept_name as deptname,
        j.dept_name as jurname
        FROM (
        SELECT IFNULL(A.thisnum, 0) AS thisnum,
        IFNULL(B.lastnum, 0) AS lastnum,
        A.dept_id,
        A.jurisdiction
        FROM (
        SELECT SUM(num) AS thisnum,
        dept_id,
        jurisdiction
        FROM sys_dispatcher
        WHERE DATE_FORMAT( dispatcherTime, '%Y%m' ) = DATE_FORMAT( CURDATE( ), '%Y%m' )
        GROUP BY dept_id, jurisdiction
        ) A
        left JOIN (
        SELECT SUM(num) AS lastnum,
        dept_id,
        jurisdiction
        FROM sys_dispatcher
        WHERE PERIOD_DIFF( date_format( now( ), '%Y%m' ), date_format( dispatcherTime, '%Y%m' ) ) = 1
        GROUP BY dept_id, jurisdiction
        ) B ON A.dept_id = B.dept_id) C
        LEFT JOIN blade_dept d ON C.dept_id = d.id
        LEFT JOIN sys_jurisdiction j ON j.id = C.jurisdiction where 1=1
        SELECT IFNULL(G.thisnum, 0) AS thisnum,
               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
        ) 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
        ) J ON J.dept_id = H.departmentid
        WHERE 1 = 1
        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
            and C.jurisdiction =#{jurisdiction}
            and H.jurisdiction =#{jurisdiction}
        </if>
        <if test="deptid!=null and deptid!=''">
            and C.dept_id =#{deptid}
            and H.departmentid =#{deptid}
        </if>
    </select>
@@ -1413,7 +1439,7 @@
        SELECT COUNT(*) AS pnum,
        dept_id
        FROM blade_user
        WHERE  dispatch = 0
        WHERE dispatch = 0
        AND STATUS = 1
        AND is_deleted = 0
        GROUP BY dept_id
@@ -2278,200 +2304,202 @@
    <!--统计表现差的信息-->
    <select id="getSecurityPerformanceGroupCountList" resultType="org.springblade.modules.information.vo.ResponseVo">
        select
            a.id,a.dept_name name,ifnull(b.count,0) num
        from
            (select id,dept_name from sys_jurisdiction where parent_id = 1372091709474910209) a
        left join
        (
            select
                sj.id,sj.parent_id,count(*) count
                from sys_performance sp
                left join
                blade_user bu
                on
                bu.id = sp.securityId
                left join
                sys_information si
                on
                bu.dept_id = si.departmentid
                left join
                sys_jurisdiction sj
                on
                sj.id = si.jurisdiction
                where
                1=1
                and (si.stats = 2 or si.stats =4)
                and bu.is_deleted = 0
                and bu.`status` = 1
                and sp.score = 3
                group by si.jurisdiction
         ) b
              on
        a.id = b.parent_id
        select a.id,
               a.dept_name        name,
               ifnull(b.count, 0) num
        from (select id, dept_name from sys_jurisdiction where parent_id = 1372091709474910209) a
                 left join
             (
                 select sj.id,
                        sj.parent_id,
                        count(*) count
                 from sys_performance sp
                     left join
                     blade_user bu
                 on
                     bu.id = sp.securityId
                     left join
                     sys_information si
                     on
                     bu.dept_id = si.departmentid
                     left join
                     sys_jurisdiction sj
                     on
                     sj.id = si.jurisdiction
                 where
                     1=1
                   and (si.stats = 2
                    or si.stats =4)
                   and bu.is_deleted = 0
                   and bu.`status` = 1
                   and sp.score = 3
                 group by si.jurisdiction
             ) b
             on
                 a.id = b.parent_id
    </select>
    <!--统计资格审查异常信息-->
    <select id="getSecurityExaminationGroupCountList" resultType="org.springblade.modules.information.vo.ResponseVo">
        select a.id,a.dept_name name,ifnull(b.count,0) num
            from
        (select id,dept_name from sys_jurisdiction where parent_id = 1372091709474910209) a
            left join
        (
        select
                sj.id,sj.parent_id,count(*) count
                from
                blade_user bu
                left join
                sys_information si
                on
                bu.dept_id = si.departmentid
                left join
                sys_jurisdiction sj
                on
                sj.id = si.jurisdiction
                where
                1=1
                and (si.stats = 2 or si.stats =4)
                and bu.is_deleted = 0
                and bu.`status` = 1
                and bu.examination_type = 1
                group by si.jurisdiction
         ) b
            on
        a.id = b.parent_id
        select a.id, a.dept_name name, ifnull(b.count, 0) num
        from (select id, dept_name from sys_jurisdiction where parent_id = 1372091709474910209) a
                 left join
             (
                 select sj.id,
                        sj.parent_id,
                        count(*) count
                 from
                     blade_user bu
                     left join
                     sys_information si
                 on
                     bu.dept_id = si.departmentid
                     left join
                     sys_jurisdiction sj
                     on
                     sj.id = si.jurisdiction
                 where
                     1=1
                   and (si.stats = 2
                    or si.stats =4)
                   and bu.is_deleted = 0
                   and bu.`status` = 1
                   and bu.examination_type = 1
                 group by si.jurisdiction
             ) b
             on
                 a.id = b.parent_id
    </select>
    <!--考试通过率低于50%-->
    <select id="getSecurityExamPassingGroupCountList" 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 e.id, e.parent_id, count(*) count
                 from (
                     select d.*, ifnull(FORMAT((num2/num1)*100, 2), 0) num3, sj.* from (
                     select a.dept_id, ifnull(b.count, 0) num1, ifnull(c.count, 0) num2 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 a.dept_id = c.dept_id
                     ) d
                     left join
                     sys_information si
                     on
                     si.departmentid = d.dept_id
                     left join
                     sys_jurisdiction sj
                     on
                     sj.id = si.jurisdiction
                     where d.num1!=0
                     and (stats = 2 or stats=4)
                     ) e
                 where e.num3 &lt; 50
                 group by e.id
             ) f
             on
                 g.id = f.parent_id
    </select>
    <!--持证率低于50%,社保缴纳率低于50%,派遣率低于50%-->
    <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 e.id,e.parent_id,count(*) count from (
                select d.*,ifnull(FORMAT((num2/num1)*100,2),0) num3,sj.* from (
                select a.dept_id,ifnull(b.count,0) num1,ifnull(c.count,0) num2 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 e.id,e.parent_id,count(*) count from (
        select d.*,ifnull(FORMAT((num2/num1)*100,2),0) num3,sj.* from (
        select a.dept_id,ifnull(a.count,0) num1,ifnull(b.count,0) num2 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 a.dept_id = c.dept_id
                )d
                left join
                sys_information si
                on
                si.departmentid = d.dept_id
                left join
                sys_jurisdiction sj
                on
                sj.id = si.jurisdiction
                where d.num1!=0
                and (stats = 2 or stats=4)
            )e
            where e.num3 &lt; 50
            group by e.id
        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
        )d
        left join
        sys_information si
        on
        si.departmentid = d.dept_id
        left join
        sys_jurisdiction sj
        on
        sj.id = si.jurisdiction
        and (stats = 2 or stats=4)
        )e
        where e.num3 &lt; 50
        group by e.id
        ) f
        on
        g.id = f.parent_id
    </select>
    <!--持证率低于50%,社保缴纳率低于50%,派遣率低于50%-->
    <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 e.id,e.parent_id,count(*) count from (
                select d.*,ifnull(FORMAT((num2/num1)*100,2),0) num3,sj.* from (
                    select a.dept_id,ifnull(a.count,0) num1,ifnull(b.count,0) num2 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
                )d
                left join
                sys_information si
                on
                si.departmentid = d.dept_id
                left join
                sys_jurisdiction sj
                on
                sj.id = si.jurisdiction
                and (stats = 2 or stats=4)
            )e
            where e.num3 &lt; 50
            group by e.id
        ) f
            on
        g.id = f.parent_id
    </select>