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
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<?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_community.dao.ComElderAuthRecordsDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComElderAuthRecordsDO">
                <id column="id" property="id" />
                <result column="elderlies_id" property="elderliesId" />
                <result column="auth_period" property="authPeriod" />
                <result column="auth_method" property="authMethod" />
                <result column="verification_result" property="verificationResult" />
                <result column="submit_user_id" property="submitUserId" />
                <result column="auth_video" property="authVideo" />
                <result column="address" property="address" />
                <result column="approver_id" property="approverId" />
                <result column="approval_status" property="approvalStatus" />
                <result column="approval_date" property="approvalDate" />
                <result column="mark" property="mark" />
                <result column="reject_reason" property="rejectReason" />
                <result column="auth_status" property="authStatus" />
                <result column="auth_date" property="authDate" />
                <result column="create_at" property="createAt" />
                <result column="update_at" property="updateAt" />
                <result column="community_id" property="communityId" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, elderlies_id, auth_period, auth_method, verification_result, submit_user_id, auth_video, address, approver_id, approval_status, approval_date, mark, reject_reason, auth_status, auth_date, create_at, update_at, community_id
    </sql>
 
    <select id="pageElderAuthRecords" resultType="com.panzhihua.common.model.vos.community.ComElderAuthRecordVO">
        SELECT
            cear.id,
            su.`name` submitUserName,
            ceae.phone,
            ceae.`name`,
            ceae.id_card,
            ceae.sex,
            ceae.birthday,
            ceae.personnel_category,
            cear.address,
            ceae.is_alive,
            cear.auth_method,
            cear.auth_period,
            cear.auth_video,
            cear.auth_date,
            cear.mark,
            cear.approval_status,
            cear.approver_id,
            su1.`name` as approverName,
            cear.approval_date,
            cear.auth_status
        FROM
            com_elder_auth_records cear
                LEFT JOIN com_elder_auth_elderlies ceae ON cear.elderlies_id = ceae.id
                LEFT JOIN sys_user su ON cear.submit_user_id = su.user_id
                LEFT JOIN sys_user su1 ON cear.approver_id = su1.user_id
        WHERE
            ceae.community_id = ${pageElderAuthRecordsDTO.communityId}
        <if test="pageElderAuthRecordsDTO.authPeriod != null and pageElderAuthRecordsDTO.authPeriod !=''">
            and cear.auth_period = #{pageElderAuthRecordsDTO.authPeriod}
        </if>
        <if test="pageElderAuthRecordsDTO.authMethod != null and pageElderAuthRecordsDTO.authMethod != 0">
            and cear.auth_method = #{pageElderAuthRecordsDTO.authMethod}
        </if>
        <if test="pageElderAuthRecordsDTO.authDateBegin != null and pageElderAuthRecordsDTO.authDateBegin != ''">
            and cear.auth_date <![CDATA[ >= ]]> #{pageElderAuthRecordsDTO.authDateBegin}
        </if>
        <if test="pageElderAuthRecordsDTO.authDateEnd != null and pageElderAuthRecordsDTO.authDateEnd != ''">
            and cear.auth_date <![CDATA[ <= ]]> #{pageElderAuthRecordsDTO.authDateEnd}
        </if>
        <if test="pageElderAuthRecordsDTO.approvalStatus != null and pageElderAuthRecordsDTO.approvalStatus != 0">
            and cear.approval_status = #{pageElderAuthRecordsDTO.approvalStatus}
        </if>
        <if test="pageElderAuthRecordsDTO.authStatus != null and pageElderAuthRecordsDTO.authStatus != 0">
            and cear.auth_status = #{pageElderAuthRecordsDTO.authStatus}
        </if>
        <if test="pageElderAuthRecordsDTO.personnelCategory != null and pageElderAuthRecordsDTO.personnelCategory != 0">
            and ceae.personnel_category = #{pageElderAuthRecordsDTO.personnelCategory}
        </if>
        <if test="pageElderAuthRecordsDTO.isAlive != null">
            and ceae.is_alive = #{pageElderAuthRecordsDTO.isAlive}
        </if>
        <if test="pageElderAuthRecordsDTO.searchKey != null and pageElderAuthRecordsDTO.searchKey != ''">
            and (ceae.`name` like concat ('%', #{pageElderAuthRecordsDTO.searchKey}, '%')
            or cear.mark like concat ('%', #{pageElderAuthRecordsDTO.searchKey}, '%')
            or ceae.id_card = #{pageElderAuthRecordsDTO.idCard})
        </if>
        order by cear.create_at desc
    </select>
 
    <select id="export" resultType="com.panzhihua.common.model.vos.community.ComElderAuthRecordExcleVO">
        SELECT
        cear.id,
        su.`name` submitUserName,
        ceae.phone,
        ceae.`name`,
        ceae.id_card,
        case when su.sex = 1 then '男' when su.sex = 2 then '女'  end
        sex,
        ceae.birthday,
        case when ceae.personnel_category = 1 then '80-89周岁' when ceae.personnel_category = 2 then '90-99周岁' when ceae.personnel_category = 3 then '100周岁(含)以上' end
        personnel_category,
        cear.address,
        case when ceae.is_alive = 1 then '是' when ceae.is_alive = 2 then '否'  end
        is_alive,
        case when cear.auth_method = 1 then '视频认证' when cear.auth_method = 2 then '人脸认证' when cear.auth_method = 3 then '线下认证' end
        auth_method,
        cear.auth_period,
        cear.auth_video,
        cear.auth_date,
        cear.mark,
        case when cear.approval_status = 1 then '待审核' when cear.approval_status = 2 then '驳回' when cear.approval_status = 3 then '通过'  end
        approval_status,
        cear.approver_id,
        su1.`name` as approverName,
        cear.approval_date,
        cear.auth_status
        FROM
        com_elder_auth_records cear
        LEFT JOIN com_elder_auth_elderlies ceae ON cear.elderlies_id = ceae.id
        LEFT JOIN sys_user su ON cear.submit_user_id = su.user_id
        LEFT JOIN sys_user su1 ON cear.approver_id = su1.user_id
        WHERE
        ceae.community_id = ${pageElderAuthRecordsDTO.communityId}
        <if test="pageElderAuthRecordsDTO.authPeriod != null and pageElderAuthRecordsDTO.authPeriod !=''">
            and cear.auth_period = #{pageElderAuthRecordsDTO.authPeriod}
        </if>
        <if test="pageElderAuthRecordsDTO.authMethod != null and pageElderAuthRecordsDTO.authMethod != 0">
            and cear.auth_method = #{pageElderAuthRecordsDTO.authMethod}
        </if>
        <if test="pageElderAuthRecordsDTO.authDateBegin != null and pageElderAuthRecordsDTO.authDateBegin != ''">
            and cear.auth_date <![CDATA[ >= ]]> #{pageElderAuthRecordsDTO.authDateBegin}
        </if>
        <if test="pageElderAuthRecordsDTO.authDateEnd != null and pageElderAuthRecordsDTO.authDateEnd != ''">
            and cear.auth_date <![CDATA[ <= ]]> #{pageElderAuthRecordsDTO.authDateEnd}
        </if>
        <if test="pageElderAuthRecordsDTO.approvalStatus != null and pageElderAuthRecordsDTO.approvalStatus != 0">
            and cear.approval_status = #{pageElderAuthRecordsDTO.approvalStatus}
        </if>
        <if test="pageElderAuthRecordsDTO.authStatus != null and pageElderAuthRecordsDTO.authStatus != 0">
            and cear.auth_status = #{pageElderAuthRecordsDTO.authStatus}
        </if>
        <if test="pageElderAuthRecordsDTO.personnelCategory != null and pageElderAuthRecordsDTO.personnelCategory != 0">
            and ceae.personnel_category = #{pageElderAuthRecordsDTO.personnelCategory}
        </if>
        <if test="pageElderAuthRecordsDTO.isAlive != null and pageElderAuthRecordsDTO.isAlive != 0">
            and ceae.is_alive = #{pageElderAuthRecordsDTO.isAlive}
        </if>
        <if test="pageElderAuthRecordsDTO.searchKey != null and pageElderAuthRecordsDTO.searchKey != ''">
            and (ceae.`name` like concat ('%', #{pageElderAuthRecordsDTO.searchKey}, '%')
            or cear.mark like concat ('%', #{pageElderAuthRecordsDTO.searchKey}, '%')
            or ceae.id_card = #{pageElderAuthRecordsDTO.idCard})
        </if>
        order by cear.create_at desc
    </select>
 
<!--    <select id="export" resultType="com.panzhihua.common.model.vos.community.ComElderAuthRecordVO">-->
<!--        SELECT-->
<!--        cear.id,-->
<!--        su.`name` submitUserName,-->
<!--        ceae.phone,-->
<!--        ceae.`name`,-->
<!--        ceae.id_card,-->
<!--        ceae.sex,-->
<!--        ceae.birthday,-->
<!--        ceae.personnel_category,-->
<!--        cear.address,-->
<!--        ceae.is_alive,-->
<!--        cear.auth_method,-->
<!--        cear.auth_period,-->
<!--        cear.auth_video,-->
<!--        cear.auth_date,-->
<!--        cear.mark,-->
<!--        cear.approval_status,-->
<!--        cear.approver_id,-->
<!--        su1.`name` as approverName,-->
<!--        cear.approval_date,-->
<!--        cear.auth_status-->
<!--        FROM-->
<!--        com_elder_auth_records cear-->
<!--        LEFT JOIN com_elder_auth_elderlies ceae ON cear.elderlies_id = ceae.id-->
<!--        LEFT JOIN sys_user su ON cear.submit_user_id = su.user_id-->
<!--        LEFT JOIN sys_user su1 ON cear.approver_id = su1.user_id-->
<!--        WHERE-->
<!--        ceae.community_id = ${pageElderAuthRecordsDTO.communityId}-->
<!--        <if test="pageElderAuthRecordsDTO.authPeriod != null and pageElderAuthRecordsDTO.authPeriod !=''">-->
<!--            and cear.auth_period = #{pageElderAuthRecordsDTO.authPeriod}-->
<!--        </if>-->
<!--        <if test="pageElderAuthRecordsDTO.authMethod != null and pageElderAuthRecordsDTO.authMethod != 0">-->
<!--            and cear.auth_method = #{pageElderAuthRecordsDTO.authMethod}-->
<!--        </if>-->
<!--        <if test="pageElderAuthRecordsDTO.authDateBegin != null and pageElderAuthRecordsDTO.authDateBegin != ''">-->
<!--            and cear.auth_date <![CDATA[ >= ]]> #{pageElderAuthRecordsDTO.authDateBegin}-->
<!--        </if>-->
<!--        <if test="pageElderAuthRecordsDTO.authDateEnd != null and pageElderAuthRecordsDTO.authDateEnd != ''">-->
<!--            and cear.auth_date <![CDATA[ <= ]]> #{pageElderAuthRecordsDTO.authDateEnd}-->
<!--        </if>-->
<!--        <if test="pageElderAuthRecordsDTO.approvalStatus != null and pageElderAuthRecordsDTO.approvalStatus != 0">-->
<!--            and cear.approval_status = #{pageElderAuthRecordsDTO.approvalStatus}-->
<!--        </if>-->
<!--        <if test="pageElderAuthRecordsDTO.authStatus != null and pageElderAuthRecordsDTO.authStatus != 0">-->
<!--            and cear.auth_status = #{pageElderAuthRecordsDTO.authStatus}-->
<!--        </if>-->
<!--        <if test="pageElderAuthRecordsDTO.personnelCategory != null and pageElderAuthRecordsDTO.personnelCategory != 0">-->
<!--            and ceae.personnel_category = #{pageElderAuthRecordsDTO.personnelCategory}-->
<!--        </if>-->
<!--        <if test="pageElderAuthRecordsDTO.isAlive != null and pageElderAuthRecordsDTO.isAlive != 0">-->
<!--            and ceae.is_alive = #{pageElderAuthRecordsDTO.isAlive}-->
<!--        </if>-->
<!--        <if test="pageElderAuthRecordsDTO.searchKey != null and pageElderAuthRecordsDTO.searchKey != ''">-->
<!--            and (ceae.`name` like concat ('%', #{pageElderAuthRecordsDTO.searchKey}, '%')-->
<!--            or cear.mark like concat ('%', #{pageElderAuthRecordsDTO.searchKey}, '%')-->
<!--            or ceae.id_card = #{pageElderAuthRecordsDTO.idCard})-->
<!--        </if>-->
<!--        order by cear.create_at desc-->
<!--    </select>-->
 
    <select id="detailElderAuthRecords" resultType="com.panzhihua.common.model.vos.community.ComElderAuthRecordVO">
        SELECT
            su.`name` submitUserName,
            ceae.phone,
            cear.id,
            ceae.`name`,
            ceae.id_card,
            ceae.sex,
            ceae.birthday,
            ceae.personnel_category,
            cear.address,
            ceae.is_alive,
            cear.auth_method,
            cear.auth_period,
            cear.auth_date,
            cear.mark,
            cear.auth_video,
            cear.approval_status,
            cear.community_id,
            su1.`name` as approverName,
            cear.approval_date
        FROM
            com_elder_auth_records cear
                LEFT JOIN com_elder_auth_elderlies ceae ON cear.elderlies_id = ceae.id
                LEFT JOIN sys_user su ON cear.submit_user_id = su.user_id
                LEFT JOIN sys_user su1 ON cear.approver_id = su1.user_id
        WHERE
            cear.id = #{authRecordId}
    </select>
 
    <select id="getElderAuthRecordsByIds" resultType="com.panzhihua.common.model.vos.community.ComElderAuthRecordExcleVO">
        SELECT
            su.`name` submitUserName,
            ceae.phone,
            ceae.`name`,
            ceae.id_card,
            CASE
                ceae.sex
                WHEN 1 THEN
                    '男'
                WHEN 2 THEN
                    '女'
                WHEN 3 THEN
                    '其他'
                END sex,
            ceae.birthday,
            CASE
                ceae.personnel_category
                WHEN 1 THEN
                    '80-89周岁'
                WHEN 2 THEN
                    '90-99周岁'
                WHEN 3 THEN
                    '100周岁(含)以上'
                END personnelCategory,
            cear.address,
            CASE
                ceae.is_alive
                WHEN 1 THEN
                    '是'
                WHEN 0 THEN
                    '否'
                END isAlive,
            CASE
                cear.auth_method
                WHEN 1 THEN
                '视频认证'
                WHEN 2 THEN
                '人脸认证'
                WHEN 3 THEN
                '线下认证'
                END authMethod,
            cear.auth_period,
            cear.auth_date,
            cear.mark,
            CASE
                cear.approval_status
                WHEN 1 THEN
                    '待审核'
                WHEN 2 THEN
                    '驳回'
                WHEN 3 THEN
                    '通过'
                END approvalStatus
        FROM
            com_elder_auth_records cear
                LEFT JOIN com_elder_auth_elderlies ceae ON cear.elderlies_id = ceae.id
                LEFT JOIN sys_user su ON cear.submit_user_id = su.user_id
            <where>
                <if test="ids != null and ids.size > 0">
                    and cear.id in
                    <foreach collection="ids" item="id" open="(" separator="," close=")" >
                        #{id}
                    </foreach>
                </if>
            </where>
 
        order by cear.create_at desc
    </select>
 
    <update id="updateAll" parameterType="java.util.List">
        <foreach collection="comElderAuthRecordsDOS" item="item" index="index" separator=";">
            update com_elder_auth_records
            <set>
                <if test="item.elderliesId != null">
                    `elderlies_id` = #{item.elderliesId},
                </if>
                <if test="item.authMethod != null and item.authMethod != 0">
                    `auth_method` = #{item.authMethod},
                </if>
                <if test="item.authPeriod != null and item.authPeriod != ''">
                    `auth_period` = #{item.authPeriod},
                </if>
                <if test="item.submitUserId != null">
                    `submit_user_id` = #{item.submitUserId},
                </if>
                <if test="item.authVideo != null and item.authVideo != ''">
                    `auth_video` = #{item.authVideo},
                </if>
                <if test="item.address != null and item.address != ''">
                    `address` = #{item.address},
                </if>
                <if test="item.approverId != null">
                    `approver_id` = #{item.approverId},
                </if>
                <if test="item.approvalStatus != null">
                    `approval_status` = #{item.approvalStatus},
                </if>
                <if test="item.approvalDate != null">
                    `approval_date` = #{item.approvalDate},
                </if>
                <if test="item.mark != null and item.mark != ''">
                    `mark` = #{item.mark},
                </if>
                <if test="item.rejectReason != null and item.rejectReason != ''">
                    `reject_reason` = #{item.rejectReason},
                </if>
                <if test="item.authStatus != null">
                    `auth_status` = #{item.authStatus},
                </if>
                <if test="item.authDate != null">
                    `auth_date` = #{item.authDate},
                </if>
                `update_at` = NOW()
            </set>
            WHERE `id` = #{item.id}
        </foreach>
        ;
    </update>
 
    <select id="exportElderAuthRecordsStatistic" resultType="com.panzhihua.common.model.vos.community.ComElderAuthRecordStatisticExcleVO">
        SELECT
        su.`name` submitUserName,
        ceae.phone,
        ceae.`name`,
        ceae.id_card,
        CASE
        ceae.sex
        WHEN 1 THEN
        '男'
        WHEN 2 THEN
        '女'
        WHEN 3 THEN
        '其他'
        END sex,
        ceae.birthday,
        CASE
        ceae.personnel_category
        WHEN 1 THEN
        '80-89周岁'
        WHEN 2 THEN
        '90-99周岁'
        WHEN 3 THEN
        '100周岁(含)以上'
        END personnelCategory,
        cear.address,
        CASE
        ceae.is_alive
        WHEN 1 THEN
        '是'
        WHEN 0 THEN
        '否'
        END is_alive,
        ceahr.auth_period,
        ceahr.auth_date,
        CASE
        ceahr.auth_method
        WHEN 1 THEN
        '视频认证'
        WHEN 2 THEN
        '人脸认证'
        WHEN 3 THEN
        '线下认证'
        END authMethod,
        ceahr.mark,
        CASE
        ceahr.is_auth
        WHEN 1 THEN
        '已认证'
        WHEN 2 THEN
        '未认证'
        END authStatus
        FROM
        com_elders_auth_history_record ceahr
        LEFT JOIN com_elder_auth_elderlies ceae ON ceahr.elderlies_id = ceae.id
        LEFT JOIN sys_user su ON ceahr.submit_user_id = su.user_id
        LEFT JOIN com_elder_auth_records as cear on cear.id = ceahr.auth_id
        WHERE
        ceahr.community_id = ${pageElderAuthRecordsDTO.communityId}
        <if test="pageElderAuthRecordsDTO.authPeriod != null and pageElderAuthRecordsDTO.authPeriod !=''">
            and ceahr.auth_period = #{pageElderAuthRecordsDTO.authPeriod}
        </if>
        <if test="pageElderAuthRecordsDTO.authStatus != null and pageElderAuthRecordsDTO.authStatus != 0">
            and ceahr.is_auth = #{pageElderAuthRecordsDTO.authStatus}
        </if>
        <if test="pageElderAuthRecordsDTO.personnelCategory != null and pageElderAuthRecordsDTO.personnelCategory != 0">
            and ceae.personnel_category = #{pageElderAuthRecordsDTO.personnelCategory}
        </if>
        <if test="pageElderAuthRecordsDTO.isAlive != null and pageElderAuthRecordsDTO.isAlive != 0">
            and ceae.is_alive = #{pageElderAuthRecordsDTO.isAlive}
        </if>
        <if test="pageElderAuthRecordsDTO.keyWord != null and pageElderAuthRecordsDTO.keyWord != ''">
            and (ceae.`name` like concat ('%', #{pageElderAuthRecordsDTO.keyWord}, '%')
            or  ceahr.mark like concat ('%', #{pageElderAuthRecordsDTO.keyWord}, '%'))
        </if>
        order by ceahr.create_at desc
    </select>
 
    <select id="getNextIds" resultType="String">
        select id from com_elder_auth_records where approval_status = 1 and community_id = ${communityId}
    </select>
 
    <select id="queryRecordWithPage" resultType="com.panzhihua.common.model.vos.community.IdentityAuthRecordDetailVO">
        SELECT
            cear.id,
            cear.auth_period,
            cear.auth_date,
            cear.auth_status,
            cear.reject_reason,
            cear.approval_status,
            ceae.name,
            ceae.id_card
        FROM `com_elder_auth_records` cear
        LEFT JOIN `com_elder_auth_elderlies` ceae ON cear.elderlies_id = ceae.id
        WHERE cear.submit_user_id = #{pageIdentityAuthRecordDTO.submitUserId}
        ORDER BY cear.id DESC
    </select>
    <select id="findById" resultType="com.panzhihua.common.model.vos.community.IdentityAuthRecordDetailVO">
        SELECT
            ceae.name,
            ceae.id_card,
            ca.name AS communityName,
            cear.address,
            cear.auth_period,
            cear.auth_date,
            cear.auth_video,
            cear.reject_reason,
            cear.approval_status
        FROM `com_elder_auth_records` cear
        LEFT JOIN `com_elder_auth_elderlies` ceae ON cear.elderlies_id = ceae.id
        LEFT JOIN `com_act` ca ON ceae.community_id = ca.community_id
        WHERE cear.id = #{identityAuthId}
    </select>
</mapper>