From 6402b58adab36c22482d27025555f345b9e0d9a6 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Thu, 02 Dec 2021 20:44:10 +0800
Subject: [PATCH] 业务统计修改

---
 src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml |  177 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 144 insertions(+), 33 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 29c3ce8..7f53bb9 100644
--- a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
+++ b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -1683,18 +1683,18 @@
 
 
     <!--业务统计情况-->
-    <select id="selectYw" resultType="java.util.HashMap">
+    <select id="selectYw" resultType="org.springblade.modules.information.vo.InformationStatisticsVO">
         SELECT
         A.enterpriseName,
         A.departmentid,
         A.stats,
         A.jurisdiction,
         j.dept_name as jurname,
-        IFNULL( B.num, 0 ) AS fwnum,
         IFNULL( C.znum, 0 ) AS znum,
-        IFNULL( D.dqnum, 0 ) AS dqnum,
         IFNULL( E.cznum, 0 ) AS cznum,
-        IFNULL( F.pqnum, 0 ) AS pqnum
+        IFNULL( F.pqnum, 0 ) AS pqnum,
+        IFNULL( B.num, 0 ) AS fwnum,
+        IFNULL( D.dqnum, 0 ) AS dqnum
         FROM
         (
         SELECT enterpriseName,jurisdiction, departmentid,stats FROM sys_information WHERE stats!=1 GROUP BY
@@ -1710,17 +1710,6 @@
         LEFT JOIN
         (
         SELECT
-        J.znum+J.fznum as znum,
-        J.dept_id
-        FROM
-        (
-        SELECT
-        A.znum,
-        IFNULL( B.znum, 0 ) AS fznum,
-        A.dept_id
-        FROM
-        (
-        SELECT
         COUNT( * ) AS znum,
         bu.dept_id
         FROM
@@ -1731,22 +1720,6 @@
         AND bu.role_id = '1412226235153731586'
         GROUP BY
         bu.dept_id
-        ) A
-        LEFT JOIN (
-        SELECT
-        IFNULL( COUNT( * ), 0 ) AS znum,
-        bd.parent_id
-        FROM
-        blade_user bu
-        LEFT JOIN blade_dept bd ON bu.dept_id = bd.id
-        WHERE
-        bu.`status` = 1
-        AND bu.is_deleted = 0
-        AND bu.role_id = '1412226235153731586'
-        GROUP BY
-        bd.parent_id
-        ) B ON B.parent_id = A.dept_id
-        ) J
         ) C
         ON A.departmentid = C.dept_id
         LEFT JOIN
@@ -1767,10 +1740,15 @@
         LEFT JOIN
         (
         SELECT
-        SUM(num) AS pqnum,
+        count(*) AS pqnum,
         dept_id
         FROM
-        sys_dispatcher
+        blade_user
+        where 1=1
+        and status = 1
+        and is_deleted = 0
+        and role_id = "1412226235153731586"
+        and dispatch = 0
         GROUP BY
         dept_id
         ) F
@@ -3203,4 +3181,137 @@
             and i.jurisdiction in(${jurisdiction})
         </if>
     </select>
+
+    <!--查询当前单位是否有子级单位-->
+    <select id="getDeptHashChildren" resultType="org.springblade.modules.system.entity.Dept">
+        select * from blade_dept where is_deleted = 0 and parent_id = #{information.departmentid}
+        and dept_category !=2
+    </select>
+
+    <!--查询单位的人数-->
+    <select id="selectInformationUserNumCount" resultType="java.lang.Integer">
+        SELECT COUNT( * ) FROM blade_user
+        WHERE 1=1
+        and role_id = '1412226235153731586'
+        and is_deleted = 0
+        AND status=1
+        and dept_id in
+            (
+                SELECT
+                id
+                FROM
+                (
+                SELECT
+                t1.id,t1.parent_id,t1.dept_name,
+                IF
+                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
+                FROM
+                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
+                ( SELECT @pids := #{dept.id} ) t2
+                ) t3
+                WHERE
+                ischild != 0
+            )
+    </select>
+
+    <!--查询单位的已派遣人数-->
+    <select id="selectInformationDispatcherNumCount" resultType="java.lang.Integer">
+        SELECT COUNT( * ) FROM blade_user
+        WHERE 1=1
+        and role_id = '1412226235153731586'
+        and is_deleted = 0
+        AND status=1
+        AND dispatch=0
+        and dept_id in
+            (
+                SELECT
+                id
+                FROM
+                (
+                SELECT
+                t1.id,t1.parent_id,t1.dept_name,
+                IF
+                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
+                FROM
+                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
+                ( SELECT @pids := #{dept.id} ) t2
+                ) t3
+                WHERE
+                ischild != 0
+            )
+    </select>
+
+    <!--查询单位持证的人数-->
+    <select id="selectInformationHoldNumCount" resultType="java.lang.Integer">
+        SELECT COUNT( * ) FROM blade_user
+        WHERE 1=1
+        and role_id = '1412226235153731586'
+        and is_deleted = 0
+        AND status=1
+        AND hold=1
+        and dept_id in
+            (
+                SELECT
+                id
+                FROM
+                (
+                SELECT
+                t1.id,t1.parent_id,t1.dept_name,
+                IF
+                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
+                FROM
+                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
+                ( SELECT @pids := #{dept.id} ) t2
+                ) t3
+                WHERE
+                ischild != 0
+            )
+    </select>
+
+    <!--查询服务单位数-->
+    <select id="selectInformationUnitNumCount" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM sys_dispatcher_unit
+        where
+        start_time &lt;= now() and end_time &gt; now()
+        and dept_id in
+            (
+                SELECT
+                id
+                FROM
+                (
+                SELECT
+                t1.id,t1.parent_id,t1.dept_name,
+                IF
+                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
+                FROM
+                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
+                ( SELECT @pids := #{dept.id} ) t2
+                ) t3
+                WHERE
+                ischild != 0
+            )
+    </select>
+
+    <!--查询服务单位到期数-->
+    <select id="selectInformationUnitExpireNumCount" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM sys_dispatcher_unit
+        where end_time &lt; now()
+        and dept_id in
+            (
+                SELECT
+                id
+                FROM
+                (
+                SELECT
+                t1.id,t1.parent_id,t1.dept_name,
+                IF
+                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
+                FROM
+                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
+                ( SELECT @pids := #{dept.id} ) t2
+                ) t3
+                WHERE
+                ischild != 0
+            )
+    </select>
 </mapper>

--
Gitblit v1.9.3