From 48679fc5bb7e8dc8b8d45a5d2373bd11dc612413 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Fri, 26 Nov 2021 10:02:27 +0800
Subject: [PATCH] 1.统计

---
 src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml |  107 +++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 86 insertions(+), 21 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 d8a5c81..7a68e7b 100644
--- a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
+++ b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -40,23 +40,83 @@
     <select id="selectInformationPage" resultMap="informationResultMap">
         SELECT
         i.*,
-        IFNULL(A.znum ,0) as znum,
-        IFNULL(B.cnum ,0) as cnum,
-        IFNULL(C.pnum ,0) as pnum,
+        IFNULL( A.znum, 0 ) AS znum,
+        IFNULL( B.cnum, 0 ) AS cnum,
+        IFNULL( C.pnum, 0 ) AS pnum,
         sj.dept_name jurisdictionName
         FROM
         sys_information i
-        left join
-        sys_jurisdiction sj
-        on
-        sj.id = i.jurisdiction
-        LEFT JOIN ( SELECT COUNT( * ) AS znum, dept_id FROM blade_user WHERE role_id = '1412226235153731586' AND
-        status=1 and is_deleted = 0 GROUP BY dept_id ) A ON A.dept_id = i.departmentid
-        LEFT JOIN ( SELECT COUNT( * ) AS cnum, dept_id FROM blade_user WHERE role_id = '1412226235153731586' AND
-        status=1 AND hold=1 and is_deleted = 0 GROUP BY dept_id ) B ON B.dept_id = i.departmentid
-        LEFT JOIN ( SELECT COUNT( * ) AS pnum, dept_id FROM blade_user WHERE role_id = '1412226235153731586' AND
-        status=1 AND dispatch=0 and is_deleted = 0 GROUP BY dept_id ) C ON C.dept_id = i.departmentid
-        where 1=1
+        LEFT JOIN sys_jurisdiction sj ON sj.id = i.jurisdiction
+        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
+        blade_user bu
+        WHERE
+        bu.`status` = 1
+        AND bu.is_deleted = 0
+        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
+        ) A ON A.dept_id = i.departmentid
+        LEFT JOIN (
+        SELECT
+        COUNT( * ) AS cnum,
+        dept_id
+        FROM
+        blade_user
+        WHERE
+        role_id = '1412226235153731586'
+        AND STATUS = 1
+        AND hold = 1
+        AND is_deleted = 0
+        GROUP BY
+        dept_id
+        ) B ON B.dept_id = i.departmentid
+        LEFT JOIN (
+        SELECT
+        COUNT( * ) AS pnum,
+        dept_id
+        FROM
+        blade_user
+        WHERE
+        role_id = '1412226235153731586'
+        AND STATUS = 1
+        AND dispatch = 0
+        AND is_deleted = 0
+        GROUP BY
+        dept_id
+        ) C ON C.dept_id = i.departmentid
+        WHERE
+        1 =1
         <if test="information.enterprisename!=null and information.enterprisename!=''">
             and i.enterpriseName like concat(concat('%', #{information.enterprisename}),'%')
         </if>
@@ -498,9 +558,11 @@
         SELECT IFNULL(A.thisnum, 0) AS thisnum,
         IFNULL(B.lastnum, 0) AS lastnum,
         IFNULL( C.num, 0 ) AS num,
+        IFNULL( C.fznum, 0 ) AS fznum,
         H.departmentid,
         H.jurisdiction
-        FROM (SELECT departmentid, jurisdiction FROM sys_information GROUP BY departmentid, jurisdiction) H
+        FROM (SELECT departmentid, jurisdiction FROM sys_information WHERE stats!=1 GROUP BY departmentid, jurisdiction)
+        H
         LEFT JOIN (
         SELECT COUNT(*) AS thisnum,
         dept_id
@@ -523,6 +585,7 @@
         ) B ON B.dept_id = H.departmentid
         LEFT JOIN (
         SELECT
+        J.fznum,
         J.znum+J.fznum as num,
         J.dept_id
         FROM
@@ -1015,7 +1078,7 @@
         i.departmentid
         FROM
         sys_information i
-        LEFT JOIN sys_jurisdiction j ON j.id= i.jurisdiction where 1=1
+        LEFT JOIN sys_jurisdiction j ON j.id= i.jurisdiction where 1=1 and s.status=0
         <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
             and i.jurisdiction =#{jurisdiction}
         </if>
@@ -1073,7 +1136,7 @@
         u.dept_id
         FROM
         sys_performance p
-        INNER JOIN blade_user u ON p.securityId = u.id WHERE 1=1
+        INNER JOIN blade_user u ON p.cardid = u.cardid WHERE 1=1
         <if test="type!=null and type=='1'.toString()">
             and to_days(p.time) = to_days(now())
         </if>
@@ -1083,9 +1146,11 @@
         GROUP BY
         dept_id
         ) J ON J.dept_id = H.departmentid
-        WHERE 1 = 1
+        LEFT JOIN blade_dept d ON H.departmentid = d.id
+        LEFT JOIN sys_jurisdiction j ON j.id = H.jurisdiction
+        WHERE 1 =1
         <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1372091709474910209'">
-            AND H.jurisdiction in(${jurisdiction})
+            and (j.id = #{jurisdiction} or j.parent_id = #{jurisdiction})
         </if>
         <if test="deptid!=null and deptid!=''">
             AND H.departmentid = #{deptid}
@@ -1194,7 +1259,7 @@
         A.stats,
         j.dept_name AS jurname
         FROM
-        ( SELECT jurisdiction, departmentid,enterpriseName,stats,create_time FROM sys_information where state !=1) A
+        ( SELECT jurisdiction, departmentid,enterpriseName,stats,create_time FROM sys_information where stats !=1) A
         LEFT JOIN (
         SELECT
         J.znum+J.fznum as num,
@@ -2979,7 +3044,7 @@
         SELECT COUNT(*) AS pnum,
         dept_id
         FROM sys_dispatcher
-        WHERE  STATUS = 0
+        WHERE STATUS = 0
         GROUP BY dept_id
         ) G ON G.dept_id = H.departmentid
         LEFT JOIN (

--
Gitblit v1.9.3