mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.panzhihua.service_user.dao.SysUserInputDAO">
    <resultMap id="baseResult" type="com.panzhihua.service_user.model.dos.SysUserInputDO">
        <id property="id" column="id"/>
        <result property="doorNumber" column="door_number"/>
        <result property="isRent" column="is_rent"/>
        <result property="name" column="name"/>
        <result property="nation" column="nation"/>
        <result property="politicalOutlook" column="political_outlook"/>
        <result property="maritalStatus" column="marital_status"/>
        <result property="phone" column="phone"/>
        <result property="education" column="education"/>
        <result property="idCard" column="id_card"/>
        <result property="company" column="company"/>
        <result property="residence" column="residence"/>
        <result property="isPanzhihua" column="is_panzhihua"/>
        <result property="situation" column="situation"/>
        <result property="isContact" column="is_contact"/>
        <result property="major" column="major"/>
        <result property="soldier" column="soldier"/>
        <result property="lowIncomeHouseholds" column="low_income_households"/>
        <result property="lowIncomePeople" column="low_income_people"/>
        <result property="oldPeople" column="old_people"/>
        <result property="specialServiceFamily" column="special_service_family"/>
        <result property="keyPersonnel" column="key_personnel"/>
        <result property="communityId" column="community_id"/>
        <result property="areaId" column="area_id"/>
        <result property="createAt" column="create_at"/>
        <result property="updateAt" column="update_at"/>
        <result property="houseCode" column="house_code"/>
        <result property="disability" column="disability"/>
        <result property="tags" column="tags"/>
 
    </resultMap>
    <sql id="columns">
        `id`,`door_number`,`is_rent`,`name`,`nation`,`political_outlook`,`marital_status`,`phone`,`education`,`id_card`,`company`,`residence`,`is_panzhihua`,`situation`,`is_contact`,`major`,`soldier`,`low_income_households`,`low_income_people`,`old_people`,`special_service_family`,`key_personnel`,`community_id`,`area_id`,`create_at`,`update_at`,`house_code`,`disability`,`tags`
    </sql>
 
 
    <select id="selectUserHouseList" resultType="com.panzhihua.common.model.vos.community.ComMngStructHouseVO">
       SELECT  t1.house_code houseCode,  t1.house_name houseName,  t1.square,  t1.state FROM  sys_user_input t   LEFT JOIN com_mng_struct_house t1 ON t.house_code = t1.house_code  WHERE t.id_card = #{idCard}
    </select>
 
    <select id="selectHouserByareaName" resultType="com.panzhihua.common.model.vos.community.ComMngStructHouseVO">
        SELECT  REPLACE(REPLACE(REPLACE(REPLACE(h.house_name,a.address_detail,''),'栋','-'),'单元','-'),'层','-')houseName, h.house_code FROM  com_mng_struct_area a   join com_mng_struct_house h on h.house_name like CONCAT(a.address_detail,'%') and h.type=5 WHERE  a.area_name = #{areaName}
    </select>
 
    <select id="selectComMngStructArea" resultType="com.panzhihua.common.model.vos.community.ComMngStructAreaVO">
        select a.id,a.community_id,a.area_name,address_detail from com_mng_struct_area a where a.community_id = #{communityId}
    </select>
 
    <select id="specialUserExport" resultType="com.panzhihua.common.model.dtos.user.EexcelUserDTO">
        SELECT u.id 'order', c.`area_name` areaName, u.door_number doorNumber, if(u.is_rent=1,'租住','自主')isRent, u.name,
        u.nation, case u.political_outlook when 1 then '党员' when 2 then '团员' else '群众' end politicalOutlook,
        if(u.marital_status=1,'已婚','未婚')maritalStatus, u.phone, u.education, u.id_card, u.company, u.residence,
        if(u.is_panzhihua=1,'是','否') isPanZhiHua, u.situation, if(is_contact=1,'是','否') isContact, if(u.major=1,'是','否')
        major, if(u.soldier=1,'是','否') soldier, if(u.disability=1,'是','否') disability,
        if(u.low_income_households=1,'是','否') lowIncomeHouseholds, if(u.low_income_people=1,'是','否') lowIncomePeople,
        if(u.old_people=1,'是','否') oldPeople, if(u.special_service_family=1,'是','否') specialServiceFamily,
        if(u.key_personnel=1,'是','否') keyPersonnel, u.tags FROM sys_user_input u JOIN com_mng_struct_area c ON u.area_id
        = c.id where u.community_id = #{exportSpecialUserDTO.communityId}
        <if
                test='exportSpecialUserDTO.areaName != null and exportSpecialUserDTO.areaName.trim() != &quot;&quot;'>
            AND
            c.`area_name` like concat(#{exportUserDTO.areaName},'%')
        </if>
        <if test='exportSpecialUserDTO.name != null and exportSpecialUserDTO.name.trim() != &quot;&quot;'>and u.`name`
            like concat(#{exportSpecialUserDTO.name},'%')
        </if>
        <if test='exportSpecialUserDTO.name != null and exportSpecialUserDTO.name.trim() != &quot;&quot;'>and u.`name`
            like concat(#{exportSpecialUserDTO.name},'%')
        </if>
        <if test='exportSpecialUserDTO.tags != null and exportSpecialUserDTO.tags.trim() != &quot;&quot;'>CONCAT( IF (
            t.soldier = 1, '军人,', '' ), IF ( t.low_income_households = 1, '低保户,', '' ), IF ( t.low_income_people = 1,
            '低收入,', '' ), IF ( t.old_people = 1, '特服家庭,', '' ), IF ( t.key_personnel = 1, '重点人员,', '' ),
            IFNULL(t.tags,'') ) like concat(#{exportSpecialUserDTO.tags},'%')
        </if>
    </select>
 
    <select id="selectExport" resultType="com.panzhihua.common.model.dtos.user.EexcelUserDTO">
        SELECT u.id 'order', c.`area_name` areaName, u.door_number doorNumber, if(u.is_rent=1,'租住','自主')isRent, u.name,
        u.nation, case u.political_outlook when 1 then '党员' when 2 then '团员' else '群众' end politicalOutlook,
        if(u.marital_status=1,'已婚','未婚')maritalStatus, u.phone, u.education, u.id_card, u.company, u.residence,
        if(u.is_panzhihua=1,'是','否') isPanZhiHua, u.situation, if(is_contact=1,'是','否') isContact, if(u.major=1,'是','否')
        major, if(u.soldier=1,'是','否') soldier, if(u.disability=1,'是','否') disability,
        if(u.low_income_households=1,'是','否') lowIncomeHouseholds, if(u.low_income_people=1,'是','否') lowIncomePeople,
        if(u.old_people=1,'是','否') oldPeople, if(u.special_service_family=1,'是','否') specialServiceFamily,
        if(u.key_personnel=1,'是','否') keyPersonnel, u.tags FROM sys_user_input u where
        u.community_id = #{exportUserDTO.communityId}
        <if
                test='exportUserDTO.areaName != null and exportUserDTO.areaName.trim() != &quot;&quot;'>JOIN
            com_mng_struct_area c ON u.area_id = c.id
        </if>
        <if test='exportUserDTO.areaName == null or exportUserDTO.areaName.trim() == &quot;&quot;'>LEFT JOIN
            com_mng_struct_area c ON u.area_id = c.id
        </if>
        <if test='exportUserDTO.areaName != null and exportUserDTO.areaName.trim() != &quot;&quot;'>AND c.`area_name`
            like concat(#{exportUserDTO.areaName},'%')
        </if>
        <if test='exportUserDTO.phone != null and exportUserDTO.phone.trim() != &quot;&quot;'>AND u.phone like
            concat(#{exportUserDTO.phone},'%')
        </if>
        <if test='exportUserDTO.name != null and exportUserDTO.name.trim() != &quot;&quot;'>and u.`name` like
            concat(#{exportUserDTO.name},'%')
        </if>
    </select>
 
    <select id="pageInputUser" resultType="com.panzhihua.common.model.vos.user.InputUserInfoVO">
        SELECT t.id, t.`name`, CASE IF ( length( t.id_card ) = 18, cast( substring( t.id_card, 17, 1 ) AS UNSIGNED ) %
        2, IF ( length( t.id_card ) = 15, cast( substring( t.id_card, 15, 1 ) AS UNSIGNED ) % 2, 3 ) ) WHEN 1 THEN 1
        WHEN 0 THEN 2 ELSE 0 END AS sex, t.phone, YEAR ( now( ) ) - YEAR ( substring( t.id_card, 7, 8 ) ) age,
        t1.area_name as areaName, t.political_outlook politicalOutlook, CONCAT( IF ( t.soldier = 1, '军人,', '' ), IF (
        t.low_income_households = 1, '低保户,', '' ), IF ( t.low_income_people = 1, '低收入,', '' ), IF ( t.old_people = 1,
        '特服家庭,', '' ), IF ( t.key_personnel = 1, '重点人员,', '' ) ) tags, t.create_at as createAt FROM sys_user_input t
        LEFT JOIN com_mng_struct_area t1 ON t.area_id = t1.id WHERE t.community_id = #{pageInputUserDTO.communityId}
        <if
                test='pageInputUserDTO.name != null and pageInputUserDTO.name.trim() != &quot;&quot;'>and t.`name` like
            concat(#{pageInputUserDTO.name},'%')
        </if>
        <if test='pageInputUserDTO.phone != null and pageInputUserDTO.phone.trim() != &quot;&quot;'>and t.phone like
            concat(#{pageInputUserDTO.phone},'%')
        </if>
        <if test='pageInputUserDTO.areaName != null and pageInputUserDTO.areaName.trim() != &quot;&quot;'>AND
            t1.`area_name` like concat(#{pageInputUserDTO.areaName},'%')
        </if>
        group by t.id_card
    </select>
 
    <select id="specialInputUser" resultType="com.panzhihua.common.model.vos.user.InputUserInfoVO">
        SELECT * FROM ( SELECT t.id, t.`name`, CASE IF ( length( t.id_card ) = 18, cast( substring( t.id_card, 17, 1 )
        AS UNSIGNED ) % 2, IF ( length( t.id_card ) = 15, cast( substring( t.id_card, 15, 1 ) AS UNSIGNED ) % 2, 3 ) )
        WHEN 1 THEN 1 WHEN 0 THEN 2 ELSE 0 END AS sex, t.phone, YEAR ( now( ) ) - YEAR ( substring( t.id_card, 7, 8 ) )
        age, t1.area_name as areaName, t.political_outlook politicalOutlook, CONCAT( IF ( t.soldier = 1, '军人,', '' ), IF
        ( t.low_income_households = 1, '低保户,', '' ), IF ( t.low_income_people = 1, '低收入,', '' ), IF ( t.old_people = 1,
        '特服家庭,', '' ), IF ( t.key_personnel = 1, '重点人员,', '' ), IFNULL(t.tags,'') ) tags, t2.house_name as address,
        t.create_at as createAt FROM sys_user_input t LEFT JOIN com_mng_struct_area t1 ON t.area_id = t1.id LEFT JOIN
        com_mng_struct_house t2 ON t.house_code = t2.house_code WHERE t.community_id = #{pageInputUserDTO.communityId}
        AND (t.soldier=1 OR t.low_income_households=1 OR t.low_income_people=1 or t.old_people=1 OR
        t.special_service_family=1 OR t.key_personnel=1 OR
        (t.tags IS NOT NULL AND TRIM(t.tags)!=''))
        <if test='pageInputUserDTO.name != null and pageInputUserDTO.name.trim() != &quot;&quot;'>
            and t.`name` like concat(#{pageInputUserDTO.name},'%')
        </if>
        <if test='pageInputUserDTO.phone != null and pageInputUserDTO.phone.trim() != &quot;&quot;'>
            and t.phone like concat(#{pageInputUserDTO.phone},'%')
        </if>
        <if test='pageInputUserDTO.areaName != null and pageInputUserDTO.areaName.trim() != &quot;&quot;'>
            AND t1.`area_name` like concat(#{pageInputUserDTO.areaName},'%')
        </if>
        group by t.id_card ) tt WHERE 1=1
        <if test='pageInputUserDTO.tags != null and pageInputUserDTO.tags.trim() != &quot;&quot;'>
            and tt.tags like concat('%',#{pageInputUserDTO.tags},'%')
        </if>
    </select>
 
    <select id="selectListFamily" resultType="com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO">
        SELECT  p.name, p.id, if(p.is_rent=1,'合租','家人')relationship, p.id_card, p.phone, year(curdate())-if(length(p.id_card)=18,substring(p.id_card,7,4),if(length(p.id_card)=15,concat('19',substring(p.id_card,7,2)),null)) as age, p.create_at FROM  sys_user_input p  WHERE  p.door_number = #{doorNumber}   AND p.id !=#{userId}
    </select>
 
    <select id="selectByAreaName" resultType="com.panzhihua.common.model.vos.community.ComMngStructAreaVO">
        select a.id,a.community_id from com_mng_struct_area a where a.area_name=#{areaName}
    </select>
 
 
</mapper>