From 4ecf2dbe2c255c3b556ff4bfb49b4e2e8285bd17 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Tue, 31 Aug 2021 11:24:45 +0800
Subject: [PATCH] 1.ftp

---
 src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml |  386 +++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 249 insertions(+), 137 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 508a693..f476ca9 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>
 
 
@@ -379,6 +463,8 @@
         WHERE
         YEAR ( s.update_time ) =#{year}
         AND dispatch = 0
+        AND `status`=1
+        AND is_deleted=0
         AND 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'">
@@ -739,7 +825,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 +857,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 +889,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>
@@ -996,6 +1082,7 @@
         IFNULL( G.yicnum, 0 ) AS yicnum,
         A.dept_id,
         d.enterpriseName AS deptname,
+        d.stats,
         j.dept_name AS jurname
         FROM
         ( SELECT COUNT( * ) AS num, dept_id, jurisdiction FROM blade_user WHERE role_id = '1412226235153731586' and
@@ -1082,6 +1169,9 @@
         </if>
         <if test="deptid!=null and deptid!=''">
             and d.dept_name like concat(concat('%', #{deptid}),'%')
+        </if>
+        <if test="stats!=null and stats!=''">
+            and d.stats =#{stats}
         </if>
     </select>
 
@@ -1293,6 +1383,7 @@
         SELECT
         A.enterpriseName,
         A.departmentid,
+        A.stats,
         A.jurisdiction,
         A.dept_name as jurname,
         IFNULL( B.num, 0 ) AS fwnum,
@@ -1302,6 +1393,7 @@
         SELECT
         i.enterpriseName,
         i.departmentid,
+        i.stats,
         i.jurisdiction,
         j.dept_name
         FROM
@@ -1322,12 +1414,31 @@
         <if test="deptid!=null and deptid!=''">
             and A.enterpriseName like concat('%', #{deptid},'%')
         </if>
+        <if test="stats!=null and stats!=''">
+            and A.stats=#{stats}
+        </if>
     </select>
 
     <!--保安人员详情-->
     <select id="selectUIn" resultType="java.util.HashMap">
-        SELECT real_name,securitynumber,cardid,phone,hold,soil,photo,examination_type,dispatch FROM blade_user WHERE
-        role_id='1412226235153731586' AND is_deleted=0 AND `status`=1
+        SELECT
+        u.real_name,
+        u.securitynumber,
+        u.cardid,
+        u.phone,
+        u.hold,
+        u.soil,
+        u.photo,
+        u.examination_type,
+        u.dispatch,
+        i.enterpriseName
+        FROM
+        blade_user u
+        LEFT JOIN sys_information i ON i.departmentid = u.dept_id
+        WHERE
+        u.role_id = '1412226235153731586'
+        AND u.is_deleted = 0
+        AND u.`status` =1
         <if test="deptid!=null and deptid!=''">
             and dept_id=#{deptid}
         </if>
@@ -1412,6 +1523,7 @@
         FROM (
         SELECT u.enterpriseName,
         u.departmentid,
+        u.jurisdiction,
         d.dept_name AS deptname,
         j.dept_name AS jurname
         FROM sys_information u

--
Gitblit v1.9.3