From 3af37ddd5059f60bf8dc15ad7cf942714f2d90bb Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Sat, 28 Aug 2021 15:29:57 +0800
Subject: [PATCH] 1.首页接口调整

---
 src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml |  374 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 225 insertions(+), 149 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 2aaeb78..a01bafc 100644
--- a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
+++ b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -175,160 +175,244 @@
         </if>
     </select>
 
+    <!--    &lt;!&ndash;统计上个月和这个月交社保的人数以及缴纳金额&ndash;&gt;-->
+    <!--    <select id="selectTo" resultType="java.util.HashMap">-->
+    <!--        SELECT IFNULL(A.lastmonth, 0) AS lastmonth,-->
+    <!--        IFNULL(B.thismouth, 0) AS thismouth,-->
+    <!--        IFNULL(A.amount, 0) AS lastamount,-->
+    <!--        IFNULL(B.amount, 0) AS thisamount,-->
+    <!--        IFNULL( C.userthismouth, 0 ) AS userthismouth,-->
+    <!--        IFNULL( D.userlastmouth, 0 ) AS userlastmouth,-->
+    <!--        IFNULL( E.userpcthismouth, 0 ) AS userpcthismouth,-->
+    <!--        IFNULL( F.userpclastmouth, 0 ) AS userpclastmouth-->
+    <!--        FROM (-->
+    <!--        SELECT COUNT(*) AS lastmonth,-->
+    <!--        amount,-->
+    <!--        deptid-->
+    <!--        FROM-->
+    <!--        sys_socil-->
+    <!--        WHERE-->
+    <!--        deptid IN ( SELECT i.departmentid FROM sys_information i LEFT JOIN sys_jurisdiction j ON j.id= i.jurisdiction-->
+    <!--        where 1=1-->
+    <!--        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">-->
+    <!--            and i.jurisdiction =#{jurisdiction}-->
+    <!--        </if>-->
+    <!--        GROUP BY i.departmentid )-->
+    <!--        AND PERIOD_DIFF( date_format( now( ), '%Y%m' ), date_format( insuredtime, '%Y%m' ) ) = 1-->
+    <!--        <if test="deptid!=null and deptid!=''">-->
+    <!--            and deptid =#{deptid}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        amount,-->
+    <!--        deptid-->
+    <!--        ) A-->
+    <!--        left JOIN (-->
+    <!--        SELECT COUNT(*) AS thismouth,-->
+    <!--        amount,-->
+    <!--        deptid-->
+    <!--        FROM-->
+    <!--        sys_socil-->
+    <!--        WHERE-->
+    <!--        deptid IN ( SELECT i.departmentid FROM sys_information i LEFT JOIN sys_jurisdiction j ON j.id= i.jurisdiction-->
+    <!--        where 1=1-->
+    <!--        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">-->
+    <!--            and i.jurisdiction =#{jurisdiction}-->
+    <!--        </if>-->
+    <!--        GROUP BY i.departmentid )-->
+    <!--        AND DATE_FORMAT( insuredtime, '%Y%m' ) = DATE_FORMAT( CURDATE( ), '%Y%m' )-->
+    <!--        <if test="deptid!=null and deptid!=''">-->
+    <!--            and deptid =#{deptid}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        amount,-->
+    <!--        deptid-->
+    <!--        ) B ON A.deptid = B.deptid-->
+    <!--        LEFT JOIN (-->
+    <!--        SELECT COUNT(*) AS userthismouth,-->
+    <!--        dept_id-->
+    <!--        FROM-->
+    <!--        blade_user-->
+    <!--        WHERE-->
+    <!--        dept_id IN (-->
+    <!--        SELECT-->
+    <!--        i.departmentid-->
+    <!--        FROM-->
+    <!--        sys_information i-->
+    <!--        LEFT JOIN sys_jurisdiction j ON j.id = i.jurisdiction-->
+    <!--        where 1=1-->
+    <!--        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">-->
+    <!--            and i.jurisdiction =#{jurisdiction}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        i.departmentid-->
+    <!--        )-->
+    <!--        AND DATE_FORMAT( update_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ), '%Y%m' ) AND status=1-->
+    <!--        <if test="deptid!=null and deptid!=''">-->
+    <!--            and dept_id =#{deptid}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        dept_id-->
+    <!--        ) C ON C.dept_id = A.deptid-->
+    <!--        LEFT JOIN(-->
+    <!--        SELECT COUNT(*) AS userlastmouth,-->
+    <!--        dept_id-->
+    <!--        FROM-->
+    <!--        blade_user-->
+    <!--        WHERE-->
+    <!--        dept_id IN (-->
+    <!--        SELECT-->
+    <!--        i.departmentid-->
+    <!--        FROM-->
+    <!--        sys_information i-->
+    <!--        LEFT JOIN sys_jurisdiction j ON j.id = i.jurisdiction-->
+    <!--        where 1=1-->
+    <!--        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">-->
+    <!--            and i.jurisdiction =#{jurisdiction}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        i.departmentid-->
+    <!--        )-->
+    <!--        AND PERIOD_DIFF( date_format( now( ), '%Y%m' ), date_format( update_time, '%Y%m' ) ) = 1 AND status=1-->
+    <!--        <if test="deptid!=null and deptid!=''">-->
+    <!--            and dept_id =#{deptid}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        dept_id-->
+    <!--        ) D ON D.dept_id = A.deptid-->
+    <!--        LEFT JOIN (-->
+    <!--        SELECT COUNT(*) AS userpcthismouth,-->
+    <!--        dept_id-->
+    <!--        FROM-->
+    <!--        blade_user-->
+    <!--        WHERE-->
+    <!--        dept_id IN (-->
+    <!--        SELECT-->
+    <!--        i.departmentid-->
+    <!--        FROM-->
+    <!--        sys_information i-->
+    <!--        LEFT JOIN sys_jurisdiction j ON j.id = i.jurisdiction-->
+    <!--        where 1=1-->
+    <!--        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">-->
+    <!--            and i.jurisdiction =#{jurisdiction}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        i.departmentid-->
+    <!--        )-->
+    <!--        AND DATE_FORMAT( update_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ), '%Y%m' ) AND dispatch=0-->
+    <!--        <if test="deptid!=null and deptid!=''">-->
+    <!--            and dept_id =#{deptid}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        dept_id-->
+    <!--        ) E ON E.dept_id = A.deptid-->
+    <!--        LEFT JOIN(-->
+    <!--        SELECT COUNT(*) AS userpclastmouth,dept_id-->
+    <!--        FROM-->
+    <!--        blade_user-->
+    <!--        WHERE-->
+    <!--        dept_id IN (-->
+    <!--        SELECT i.departmentid-->
+    <!--        FROM-->
+    <!--        sys_information i-->
+    <!--        LEFT JOIN sys_jurisdiction j ON j.id = i.jurisdiction-->
+    <!--        where 1=1-->
+    <!--        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">-->
+    <!--            and i.jurisdiction =#{jurisdiction}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        i.departmentid-->
+    <!--        )-->
+    <!--        AND PERIOD_DIFF( date_format( now( ), '%Y%m' ), date_format( update_time, '%Y%m' ) ) = 1 AND dispatch=0-->
+    <!--        <if test="deptid!=null and deptid!=''">-->
+    <!--            and dept_id =#{deptid}-->
+    <!--        </if>-->
+    <!--        GROUP BY-->
+    <!--        dept_id-->
+    <!--        ) F ON F.dept_id = A.deptid-->
+    <!--    </select> -->
     <!--统计上个月和这个月交社保的人数以及缴纳金额-->
     <select id="selectTo" resultType="java.util.HashMap">
         SELECT IFNULL(A.lastmonth, 0) AS lastmonth,
         IFNULL(B.thismouth, 0) AS thismouth,
-        IFNULL(A.amount, 0) AS lastamount,
-        IFNULL(B.amount, 0) AS thisamount,
-        IFNULL( C.userthismouth, 0 ) AS userthismouth,
-        IFNULL( D.userlastmouth, 0 ) AS userlastmouth,
-        IFNULL( E.userpcthismouth, 0 ) AS userpcthismouth,
-        IFNULL( F.userpclastmouth, 0 ) AS userpclastmouth
-        FROM (
+        IFNULL(C.thisamount, 0) AS thisamount,
+        IFNULL(D.lastamount, 0) AS lastamount,
+        IFNULL(E.userthismouth, 0) AS userthismouth,
+        IFNULL(F.userlastmouth, 0) AS userlastmouth,
+        IFNULL(G.userpcthismouth, 0) AS userpcthismouth,
+        IFNULL(J.userpclastmouth, 0) AS userpclastmouth
+        FROM (SELECT departmentid, jurisdiction FROM sys_information GROUP BY departmentid, jurisdiction) H
+        LEFT JOIN (
         SELECT COUNT(*) AS lastmonth,
-        amount,
         deptid
-        FROM
-        sys_socil
-        WHERE
-        deptid IN ( SELECT i.departmentid FROM sys_information i LEFT JOIN sys_jurisdiction j ON j.id= i.jurisdiction
-        where 1=1
-        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">
-            and i.jurisdiction =#{jurisdiction}
-        </if>
-        GROUP BY i.departmentid )
-        AND PERIOD_DIFF( date_format( now( ), '%Y%m' ), date_format( insuredtime, '%Y%m' ) ) = 1
-        <if test="deptid!=null and deptid!=''">
-            and deptid =#{deptid}
-        </if>
-        GROUP BY
-        amount,
-        deptid
-        ) A
-        left JOIN (
+        FROM sys_socil
+        WHERE PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(insuredtime, '%Y%m')) = 1
+        GROUP BY deptid
+        ) A ON A.deptid = H.departmentid
+        LEFT JOIN (
         SELECT COUNT(*) AS thismouth,
-        amount,
         deptid
-        FROM
-        sys_socil
-        WHERE
-        deptid IN ( SELECT i.departmentid FROM sys_information i LEFT JOIN sys_jurisdiction j ON j.id= i.jurisdiction
-        where 1=1
-        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">
-            and i.jurisdiction =#{jurisdiction}
-        </if>
-        GROUP BY i.departmentid )
-        AND DATE_FORMAT( insuredtime, '%Y%m' ) = DATE_FORMAT( CURDATE( ), '%Y%m' )
-        <if test="deptid!=null and deptid!=''">
-            and deptid =#{deptid}
-        </if>
-        GROUP BY
-        amount,
+        FROM sys_socil
+        WHERE DATE_FORMAT(insuredtime, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
+        GROUP BY deptid
+        ) B ON B.deptid = H.departmentid
+        LEFT JOIN (
+        SELECT SUM(amount) AS thisamount,
         deptid
-        ) B ON A.deptid = B.deptid
+        FROM sys_socil
+        WHERE DATE_FORMAT(insuredtime, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
+        GROUP BY deptid
+        ) C ON C.deptid = H.departmentid
+        LEFT JOIN (
+        SELECT SUM(amount) AS lastamount,
+        deptid
+        FROM sys_socil
+        WHERE PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(insuredtime, '%Y%m')) = 1
+        GROUP BY deptid
+        ) D ON D.deptid = H.departmentid
         LEFT JOIN (
         SELECT COUNT(*) AS userthismouth,
         dept_id
-        FROM
-        blade_user
-        WHERE
-        dept_id IN (
-        SELECT
-        i.departmentid
-        FROM
-        sys_information i
-        LEFT JOIN sys_jurisdiction j ON j.id = i.jurisdiction
-        where 1=1
-        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">
-            and i.jurisdiction =#{jurisdiction}
-        </if>
-        GROUP BY
-        i.departmentid
-        )
-        AND DATE_FORMAT( update_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ), '%Y%m' ) AND status=1
-        <if test="deptid!=null and deptid!=''">
-            and dept_id =#{deptid}
-        </if>
-        GROUP BY
-        dept_id
-        ) C ON C.dept_id = A.deptid
-        LEFT JOIN(
+        FROM blade_user
+        WHERE DATE_FORMAT(update_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
+        AND STATUS = 1
+        AND is_deleted = 0
+        GROUP BY dept_id
+        ) E ON E.dept_id = H.departmentid
+        LEFT JOIN (
         SELECT COUNT(*) AS userlastmouth,
         dept_id
-        FROM
-        blade_user
-        WHERE
-        dept_id IN (
-        SELECT
-        i.departmentid
-        FROM
-        sys_information i
-        LEFT JOIN sys_jurisdiction j ON j.id = i.jurisdiction
-        where 1=1
-        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">
-            and i.jurisdiction =#{jurisdiction}
-        </if>
-        GROUP BY
-        i.departmentid
-        )
-        AND PERIOD_DIFF( date_format( now( ), '%Y%m' ), date_format( update_time, '%Y%m' ) ) = 1 AND status=1
-        <if test="deptid!=null and deptid!=''">
-            and dept_id =#{deptid}
-        </if>
-        GROUP BY
-        dept_id
-        ) D ON D.dept_id = A.deptid
+        FROM blade_user
+        WHERE PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(update_time, '%Y%m')) = 1
+        AND STATUS = 1
+        AND is_deleted = 0
+        GROUP BY dept_id
+        ) F ON F.dept_id = H.departmentid
         LEFT JOIN (
         SELECT COUNT(*) AS userpcthismouth,
         dept_id
-        FROM
-        blade_user
-        WHERE
-        dept_id IN (
-        SELECT
-        i.departmentid
-        FROM
-        sys_information i
-        LEFT JOIN sys_jurisdiction j ON j.id = i.jurisdiction
-        where 1=1
-        <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">
-            and i.jurisdiction =#{jurisdiction}
-        </if>
-        GROUP BY
-        i.departmentid
-        )
-        AND DATE_FORMAT( update_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ), '%Y%m' ) AND dispatch=0
-        <if test="deptid!=null and deptid!=''">
-            and dept_id =#{deptid}
-        </if>
-        GROUP BY
+        FROM blade_user
+        WHERE DATE_FORMAT(update_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
+        AND dispatch = 0
+        AND STATUS = 1
+        AND is_deleted = 0
+        GROUP BY dept_id
+        ) G ON G.dept_id = H.departmentid
+        LEFT JOIN (
+        SELECT COUNT(*) AS userpclastmouth,
         dept_id
-        ) E ON E.dept_id = A.deptid
-        LEFT JOIN(
-        SELECT COUNT(*) AS userpclastmouth,dept_id
-        FROM
-        blade_user
-        WHERE
-        dept_id IN (
-        SELECT i.departmentid
-        FROM
-        sys_information i
-        LEFT JOIN sys_jurisdiction j ON j.id = i.jurisdiction
-        where 1=1
+        FROM blade_user
+        WHERE PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(update_time, '%Y%m')) = 1
+        AND dispatch = 0
+        AND STATUS = 1
+        AND is_deleted = 0
+        GROUP BY dept_id
+        ) J ON J.dept_id = H.departmentid where 1=1
         <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">
-            and i.jurisdiction =#{jurisdiction}
+            and H.jurisdiction =#{jurisdiction}
         </if>
-        GROUP BY
-        i.departmentid
-        )
-        AND PERIOD_DIFF( date_format( now( ), '%Y%m' ), date_format( update_time, '%Y%m' ) ) = 1 AND dispatch=0
         <if test="deptid!=null and deptid!=''">
-            and dept_id =#{deptid}
+            and H.departmentid =#{deptid}
         </if>
-        GROUP BY
-        dept_id
-        ) F ON F.dept_id = A.deptid
     </select>
 
 
@@ -739,7 +823,7 @@
         GROUP BY
         i.departmentid
         )
-        AND role_id='1412226235153731586'
+        AND role_id='1412226235153731586' and status=1 and is_deleted=0
         <if test="deptid!=null and deptid!=''">
             and dept_id =#{deptid}
         </if>
@@ -771,7 +855,7 @@
         GROUP BY
         i.departmentid
         )
-        AND role_id='1412226235153731586' AND examination_type=0
+        AND role_id='1412226235153731586' AND examination_type=0 and status=1 and is_deleted=0
         <if test="deptid!=null and deptid!=''">
             and dept_id =#{deptid}
         </if>
@@ -803,7 +887,7 @@
         GROUP BY
         i.departmentid
         )
-        AND role_id='1412226235153731586' AND hold=1
+        AND role_id='1412226235153731586' AND hold=1 and status=1 and is_deleted=0
         <if test="deptid!=null and deptid!=''">
             and dept_id =#{deptid}
         </if>
@@ -1379,16 +1463,12 @@
     <!--单位处罚数量-->
     <select id="selectCf" resultType="java.util.HashMap">
         SELECT COUNT(*) AS num,
-        i.enterpriseName,
-        j.dept_name as jurname,
-        i.departmentid
-        FROM `sys_punish` p
-        LEFT JOIN sys_information i ON i.departmentid = p.deptid
-        LEFT JOIN sys_jurisdiction j ON j.id = p.jurisdiction where 1=1
+        deptid
+        FROM `sys_punish` where 1=1
         <if test="jurisdiction!=null and jurisdiction!='' and jurisdiction!='1123598813738675201'">
-            and p.jurisdiction =#{jurisdiction}
+            and jurisdiction =#{jurisdiction}
         </if>
-        GROUP BY i.enterpriseName, i.departmentid, j.dept_name
+        GROUP BY deptid
     </select>
 
     <!--单位材料不全数量-->
@@ -1410,14 +1490,13 @@
     <!--违规经营-->
     <select id="selectWg" resultType="java.util.HashMap">
         SELECT A.enterpriseName,
-        A.deptname,
-        A.jurname,
         IFNULL(B.cznum, 0) AS cznum,
         IFNULL(C.sbnum, 0) AS sbnum,
         IFNULL(D.znum, 0) AS znum
         FROM (
         SELECT u.enterpriseName,
         u.departmentid,
+        u.jurisdiction,
         d.dept_name AS deptname,
         j.dept_name AS jurname
         FROM sys_information u
@@ -1458,7 +1537,7 @@
         SELECT
         i.departmentid,
         i.enterpriseName,
-        IFNULL( d.num, 0 ) AS num,
+        IFNULL( d.num, 0 ) AS fwnum,
         IFNULL( B.cznum, 0 ) AS cznum,
         IFNULL( C.painum, 0 ) AS painum,
         IFNULL( D.znum, 0 ) AS znum
@@ -1517,15 +1596,12 @@
         SELECT
         i.departmentid,
         i.enterpriseName,
-        IFNULL( d.num, 0 ) AS num,
         IFNULL( B.cznum, 0 ) AS cznum,
         IFNULL( C.painum, 0 ) AS painum,
         IFNULL( D.znum, 0 ) AS znum,
         IFNULL( E.fwnum, 0 ) AS fwnum
         FROM
         sys_information i
-        LEFT JOIN ( SELECT COUNT( * ) num, dept_id FROM blade_user WHERE role_id = '1412226235153731586' AND `status` =
-        1 AND is_deleted = 0 GROUP BY dept_id ) d ON i.departmentid = d.dept_id
         LEFT JOIN (
         SELECT
         COUNT( * ) AS cznum,

--
Gitblit v1.9.3