From eb55b4133ae6b3df80d8d14fbc5b32928f296fd7 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Tue, 26 Dec 2023 14:17:07 +0800
Subject: [PATCH] bug修复

---
 src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml |   91 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 75 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml b/src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
index 693bec8..5228875 100644
--- a/src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
+++ b/src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
@@ -114,16 +114,55 @@
 
     <!--自定义分页数据查询-->
     <select id="selectHouseholdPage" resultMap="householdPageAndLabelMap">
-        select
-        jh.*,
+        SELECT
+        jh.id,
+        jh.house_code,
+        jh.NAME,
+        jh.phone_number,
+        jh.associated_user_id,
+        jh.role_type,
+        jh.associated_user_name,
+        jh.relationship,
+        jh.is_primary_contact,
+        jh.residential_status,
+        jh.birthday,
+        jh.id_card,
+        jh.hkmt_pass,
+        jh.passport,
+        ifnull( jh.gender, CASE WHEN substring( jh.id_card, 17, 1 )% 2 = 1 THEN 1 ELSE 0 END ) AS gender,
+        jh.ethnicity,
+        jh.education,
+        jh.hukou_registration,
+        jh.work_status,
+        employer,
+        jh.marital_status,
+        jh.card_number,
+        jh.other_contact,
+        jh.current_address,
+        jh.disability_cert,
+        jh.party_ember,
+        jh.create_user,
+        jh.create_time,
+        jh.update_user,
+        jh.update_time,
+        jh.remark,
         jhs.district_name aoiName,
-        concat(jhs.building," ",unit," ",room) as address,
-        jda.town_street_name as townStreetName,jda.nei_name as neiName
-        from
+        concat( jhs.building, " ", unit, " ", room ) AS address,
+        jda.town_street_name AS townStreetName,
+        jda.nei_name AS neiName,
+        jg.grid_name
+        FROM
         jczz_household jh
-        join jczz_house jhs on jh.house_code = jhs.house_code and jhs.is_deleted = 0
-        left join jczz_doorplate_address jda on jda.address_code = jh.house_code
-        where jh.is_deleted = 0
+        LEFT JOIN jczz_house jhs ON jh.house_code = jhs.house_code and jhs.is_deleted = 0
+        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jh.house_code
+        LEFT JOIN jczz_grid_range jgr on jgr.house_code=jda.address_code
+        LEFT JOIN jczz_grid jg on jg.id = jgr.grid_id
+        LEFT JOIN jczz_gridman jgm on jgm.grid_id=jg.id
+        WHERE
+        jh.is_deleted = 0
+        <if test="household.userId!=null">
+            and jgm.user_id = #{household.userId}
+        </if>
         <if test="household.name!=null and household.name !=''">
             and jh.name like concat('%',#{household.name},'%')
         </if>
@@ -151,6 +190,13 @@
         <if test="household.housingRentalId != null ">
             and jh.housing_rental_id = #{household.housingRentalId}
         </if>
+        <if test="household.startTime != null and household.startTime != '' and household.endTime != null and household.endTime != '' ">
+            AND jh.create_time BETWEEN #{household.startTime} and #{household.endTime}
+        </if>
+        <if test="household.regionCode!=null and household.regionCode!=''">
+            and jg.community_code like concat('%',#{household.regionCode},'%')
+        </if>
+        order by jh.create_time desc
     </select>
 
     <!--查询房屋集合信息-->
@@ -224,16 +270,29 @@
 
     <select id="statistics" resultType="java.lang.Integer">
         SELECT
-            count(1)
+        count( 1 )
         FROM
-            jczz_grid_range jgr
+        jczz_household jh
+        LEFT JOIN jczz_doorplate_address jda ON jh.house_code = jda.address_code
+        <where>
+            <if test="neiCode != null and neiCode != ''">
+                and jda.nei_code = #{neiCode}
+            </if>
+            <if test="userId != null">
+                AND jh.house_code IN (
+                SELECT
+                jgr.house_code
+                FROM
+                jczz_grid_range jgr
                 LEFT JOIN jczz_grid jg ON jg.id = jgr.grid_id
-                LEFT JOIN jczz_gridman jgm on jg.id = jgm.grid_id
-                LEFT JOIN jczz_household jh on jh.house_code=jgr.house_code
-        WHERE
-            jg.is_deleted = 0
-          and jh.confirm_flag = 0
-          AND jgm.user_id = #{userId}
+                LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
+                WHERE
+                jg.is_deleted = 0
+                AND jgm.user_id = #{userId} )
+            </if>
+            and jh.is_deleted = 0
+            and jh.confirm_flag = 0
+        </where>
     </select>
 
     <!--查询物业-->

--
Gitblit v1.9.3