linwe
2024-06-27 a7f2813fda788b63ad7757cd4a9a71b5fd212153
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<?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="org.springblade.modules.place.mapper.PlacePractitionerMapper">
 
    <!--自定义分页查询-->
    <select id="selectPlacePractitionerPage" resultType="org.springblade.modules.place.vo.PlacePractitionerVO">
        SELECT
        jpp.id,
        jpp.place_id,
        jpp.name,
        jpp.telephone,
        jpp.temp_address,
        TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) as age,
        jpp.gender,
        jpp.id_card,
        jp.place_name employer,
        jpp.employer_img,
        jpp.create_time,
        jpp.ethnicity,
        jpp.is_deleted,
        jpp.criminal_record_flag,
        jpp.fake_id_card,
        jpp.employment_time,
        jpp.resignation_time,
        jpp.resignation_flag,
        jpp.confirm_user_id,
        jpp.confirm_flag,
        jpp.confirm_time,
        jpp.confirm_notion,
        br.town_name as townStreetName,
        br.name as neiName,
        jp.place_name,
        jp.location,
        jc.category_name
        FROM
        jczz_place_practitioner jpp
        LEFT JOIN jczz_place jp ON jp.id = jpp.place_id
        LEFT JOIN jczz_place_poi_label jppl on jppl.place_id = jp.id and type = 3
        LEFT JOIN jczz_category jc on jc.category_no = jppl.poi_code
        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        left join blade_region br on br.code = jpag.community_code
        <where>
            <if test="placePractitioner.townStreetName!=null and placePractitioner.townStreetName!=''">
                and br.town_name like concat('%',#{placePractitioner.townStreetName},'%')
            </if>
            <if test="placePractitioner.neiName!=null and placePractitioner.neiName!=''">
                and br.name like concat('%',#{placePractitioner.neiName},'%')
            </if>
            <if test="placePractitioner.id != null ">and jpp.id = #{placePractitioner.id}</if>
            <if test="placePractitioner.placeId != null ">and jpp.place_id = #{placePractitioner.placeId}</if>
            <if test="placePractitioner.name != null  and placePractitioner.name != ''">and jpp.name like concat('%',
                #{placePractitioner.name},'%')
 
            </if>
            <if test="placePractitioner.telephone != null  and placePractitioner.telephone != ''">and jpp.telephone like
                concat('%', #{placePractitioner.telephone},'%')
            </if>
            <if test="placePractitioner.tempAddress != null  and placePractitioner.tempAddress != ''">and
                jpp.temp_address =
                #{placePractitioner.tempAddress}
            </if>
            <if test="placePractitioner.age != null ">and jpp.age = #{placePractitioner.age}</if>
            <if test="placePractitioner.gender != null ">and jpp.gender = #{placePractitioner.gender}</if>
            <if test="placePractitioner.idCard != null  and placePractitioner.idCard != ''">and jpp.id_card =
                #{placePractitioner.idCard}
            </if>
            <if test="placePractitioner.resignationFlag != null  and placePractitioner.resignationFlag !='' ">
                and jpp.resignation_flag = #{placePractitioner.resignationFlag}
            </if>
 
            <if test="placePractitioner.employerImg != null  and placePractitioner.employerImg != ''">and
                jpp.employer_img =
                #{placePractitioner.employerImg}
            </if>
 
            <if test="placePractitioner.createTime != null ">and jpp.create_time = #{placePractitioner.createTime}</if>
            <if test="placePractitioner.ethnicity != null ">and jpp.ethnicity = #{placePractitioner.ethnicity}</if>
 
            <if test="placePractitioner.confirmUserId != null "> and confirm_user_id = #{placePractitioner.confirmUserId}</if>
            <if test="placePractitioner.confirmFlag != null "> and confirm_flag = #{placePractitioner.confirmFlag}</if>
            <if test="placePractitioner.confirmTime != null "> and confirm_time = #{placePractitioner.confirmTime}</if>
            <if test="placePractitioner.confirmNotion != null  and placePractitioner.confirmNotion != ''"> and confirm_notion = #{placePractitioner.confirmNotion}</if>
 
            <if test="placePractitioner.type == 1">
                and TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18
                and jc.category_no in (180202,180201,180200)
            </if>
            <if test="placePractitioner.type == 2">
                and jpp.ethnicity != 1
                and jc.category_no in (180202,180201,180200)
            </if>
            <if test="placePractitioner.type == 3">
                and (TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18  or jpp.ethnicity != 1)
                and jc.category_no in (180202,180201,180200)
            </if>
 
            <if test="isAdministrator==2">
                <choose>
                    <when test="placePractitioner.roleName != null and placePractitioner.roleName != ''">
                        <if test="placePractitioner.roleName=='wgy'">
                            <choose>
                                <when test="gridCodeList !=null and gridCodeList.size()>0">
                                    and jp.grid_code in
                                    <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jp.grid_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                        <if test="placePractitioner.roleName=='mj'">
                            <choose>
                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                    and jpag.community_code in
                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jpag.community_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                    </when>
                </choose>
            </if>
            and jpp.is_deleted = 0
            GROUP BY jpp.place_id
            order by jpp.id desc
        </where>
    </select>
 
 
    <resultMap type="org.springblade.modules.place.dto.PlacePractitionerDTO" id="JczzPlacePractitionerDTOResult">
        <result property="id" column="id"/>
        <result property="placeId" column="place_id"/>
        <result property="name" column="name"/>
        <result property="telephone" column="telephone"/>
        <result property="tempAddress" column="temp_address"/>
        <result property="age" column="age"/>
        <result property="gender" column="gender"/>
        <result property="idCard" column="id_card"/>
        <result property="jobNature" column="job_nature"/>
        <result property="employerImg" column="employer_img"/>
        <result property="createTime" column="create_time"/>
        <result property="ethnicity" column="ethnicity"/>
        <result property="isDeleted" column="is_deleted"/>
        <result property="criminalRecordFlag" column="criminal_record_flag"/>
        <result property="fakeIdCard" column="fake_id_card"/>
        <result property="anoTypeName" column="ano_type_name"/>
        <result property="employmentTime" column="employment_time"/>
        <result property="resignationTime" column="resignation_time"/>
    </resultMap>
 
    <sql id="selectJczzPlacePractitioner">
        select id,
               place_id,
               name,
               telephone,
               temp_address,
               age,
               gender,
               id_card,
               job_nature,
               employer_img,
               create_time,
               ethnicity,
               is_deleted,
               criminal_record_flag,
               fake_id_card,
               ano_type_name,
               employment_time,
               resignation_time
        from jczz_place_practitioner
    </sql>
 
    <select id="selectPlaceCountByType" parameterType="long" resultType="integer">
        select
        count(1)
        from
        jczz_place_practitioner jpp
        LEFT JOIN jczz_place jp ON jp.id = jpp.place_id
        LEFT JOIN jczz_place_poi_label jppl on jppl.place_id = jp.id and type = 3
        LEFT JOIN jczz_category jc on jc.category_no = jppl.poi_code
        <where>
            <if test="placePractitioner.type == 1">
                and TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18
                and jc.category_no in (180202,180201,180200)
            </if>
            <if test="placePractitioner.type == 2">
                and jpp.ethnicity != 1
                and jc.category_no in (180202,180201,180200)
            </if>
            <if test="placePractitioner.id != null ">and jpp.id = #{placePractitioner.id}</if>
            <if test="placePractitioner.placeId != null ">and jpp.place_id = #{placePractitioner.placeId}</if>
            <if test="placePractitioner.name != null  and placePractitioner.name != ''">and jpp.name like concat('%',
                #{placePractitioner.name},'%')
            </if>
            <if test="placePractitioner.telephone != null  and placePractitioner.telephone != ''">and jpp.telephone like
                concat('%', #{placePractitioner.telephone},'%')
 
            </if>
            <if test="placePractitioner.tempAddress != null  and placePractitioner.tempAddress != ''">and
                jpp.temp_address =
                #{placePractitioner.tempAddress}
            </if>
            <if test="placePractitioner.age != null ">and jpp.age = #{placePractitioner.age}</if>
            <if test="placePractitioner.gender != null ">and jpp.gender = #{placePractitioner.gender}</if>
            <if test="placePractitioner.idCard != null  and placePractitioner.idCard != ''">and jpp.id_card =
                #{placePractitioner.idCard}
            </if>
            <if test="placePractitioner.resignationFlag != null  and placePractitioner.resignationFlag !='' ">
                and jpp.resignation_flag = #{placePractitioner.resignationFlag}
            </if>
            and jpp.is_deleted = 0
        </where>
    </select>
 
 
    <select id="selectPlacePractitionerCount" resultType="java.lang.Integer">
        SELECT count(1) from ( SELECT
        count(1)
        FROM
        jczz_place_practitioner jpp
        LEFT JOIN jczz_place jp ON jp.id = jpp.place_id
        LEFT JOIN jczz_place_poi_label jppl on jppl.place_id = jp.id and type = 3
        LEFT JOIN jczz_category jc on jc.category_no = jppl.poi_code
        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        left join blade_region br on br.code = jpag.community_code
        <where>
            <if test="placePractitioner.townStreetName!=null and placePractitioner.townStreetName!=''">
                and br.town_name like concat('%',#{placePractitioner.townStreetName},'%')
            </if>
            <if test="placePractitioner.neiName!=null and placePractitioner.neiName!=''">
                and br.name like concat('%',#{placePractitioner.neiName},'%')
            </if>
            <if test="placePractitioner.id != null ">and jpp.id = #{placePractitioner.id}</if>
            <if test="placePractitioner.placeId != null ">and jpp.place_id = #{placePractitioner.placeId}</if>
            <if test="placePractitioner.name != null  and placePractitioner.name != ''">and jpp.name like concat('%',
                #{placePractitioner.name},'%')
 
            </if>
            <if test="placePractitioner.telephone != null  and placePractitioner.telephone != ''">and jpp.telephone like
                concat('%', #{placePractitioner.telephone},'%')
            </if>
            <if test="placePractitioner.tempAddress != null  and placePractitioner.tempAddress != ''">and
                jpp.temp_address =
                #{placePractitioner.tempAddress}
            </if>
            <if test="placePractitioner.age != null ">and jpp.age = #{placePractitioner.age}</if>
            <if test="placePractitioner.gender != null ">and jpp.gender = #{placePractitioner.gender}</if>
            <if test="placePractitioner.idCard != null  and placePractitioner.idCard != ''">and jpp.id_card =
                #{placePractitioner.idCard}
            </if>
            <if test="placePractitioner.resignationFlag != null  and placePractitioner.resignationFlag !='' ">
                and jpp.resignation_flag = #{placePractitioner.resignationFlag}
            </if>
 
            <if test="placePractitioner.employerImg != null  and placePractitioner.employerImg != ''">and
                jpp.employer_img =
                #{placePractitioner.employerImg}
            </if>
 
            <if test="placePractitioner.createTime != null ">and jpp.create_time = #{placePractitioner.createTime}</if>
            <if test="placePractitioner.ethnicity != null ">and jpp.ethnicity = #{placePractitioner.ethnicity}</if>
 
            <if test="placePractitioner.confirmUserId != null ">and confirm_user_id =
                #{placePractitioner.confirmUserId}
            </if>
            <if test="placePractitioner.confirmFlag != null ">and confirm_flag = #{placePractitioner.confirmFlag}</if>
            <if test="placePractitioner.confirmTime != null ">and confirm_time = #{placePractitioner.confirmTime}</if>
            <if test="placePractitioner.confirmNotion != null  and placePractitioner.confirmNotion != ''">and
                confirm_notion = #{placePractitioner.confirmNotion}
            </if>
 
            <if test="placePractitioner.type == 1">
                and TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18
                and jc.category_no in (180202,180201,180200)
            </if>
            <if test="placePractitioner.type == 2">
                and jpp.ethnicity != 1
                and jc.category_no in (180202,180201,180200)
            </if>
            <if test="placePractitioner.type == 3">
                and (TIMESTAMPDIFF(year, substring(jpp.id_card, 7, 8), now()) &lt; 18 or jpp.ethnicity != 1)
                and jc.category_no in (180202,180201,180200)
            </if>
 
            <if test="isAdministrator==2">
                <choose>
                    <when test="placePractitioner.roleName != null and placePractitioner.roleName != ''">
                        <if test="placePractitioner.roleName=='wgy'">
                            <choose>
                                <when test="gridCodeList !=null and gridCodeList.size()>0">
                                    and jp.grid_code in
                                    <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jp.grid_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                        <if test="placePractitioner.roleName=='mj'">
                            <choose>
                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                    and jpag.community_code in
                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")"
                                             separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jpag.community_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                    </when>
                </choose>
            </if>
            and jpp.is_deleted = 0
            GROUP BY jpp.place_id
            ) a
        </where>
    </select>
 
 
</mapper>