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
<?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.ComEldersAuthHistoryRecordMapper">
 
     <resultMap id="baseResult" type="com.panzhihua.service_community.model.dos.ComEldersAuthHistoryRecordDO">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="name" column="name"/>
        <result property="idCard" column="id_card"/>
        <result property="brithday" column="brithday"/>
        <result property="age" column="age"/>
        <result property="domicile" column="domicile"/>
        <result property="isAuth" column="is_auth"/>
        <result property="createAt" column="create_at"/>
    </resultMap>
 
    <sql id="columns">
    <![CDATA[
        id,user_id,name,id_card,brithday,age,domicile,is_auth,create_at
    ]]>
    </sql>
 
    <!-- 分页查询 -->
    <select id="findByPage" resultType="com.panzhihua.common.model.vos.community.ComEldersAuthHistoryRecordVO"
        parameterType="com.panzhihua.common.model.dtos.community.PageComEldersAuthHistoryRecordDTO">
        SELECT <include refid="columns" />
        FROM com_elders_auth_history_record
        <where>
           <if test="pageComEldersAuthHistoryRecordDTO.id!=null">
                AND id = #{pageComEldersAuthHistoryRecordDTO.id}
            </if>
           <if test="pageComEldersAuthHistoryRecordDTO.userId!=null">
                AND user_id = #{pageComEldersAuthHistoryRecordDTO.userId}
            </if>
           <if test="pageComEldersAuthHistoryRecordDTO.name!=null">
                AND name = #{pageComEldersAuthHistoryRecordDTO.name}
            </if>
           <if test="pageComEldersAuthHistoryRecordDTO.idCard!=null">
                AND id_card = #{pageComEldersAuthHistoryRecordDTO.idCard}
            </if>
           <if test="pageComEldersAuthHistoryRecordDTO.brithday!=null">
                AND brithday = #{pageComEldersAuthHistoryRecordDTO.brithday}
            </if>
           <if test="pageComEldersAuthHistoryRecordDTO.age!=null">
                AND age = #{pageComEldersAuthHistoryRecordDTO.age}
            </if>
           <if test="pageComEldersAuthHistoryRecordDTO.domicile!=null">
                AND domicile = #{pageComEldersAuthHistoryRecordDTO.domicile}
            </if>
           <if test="pageComEldersAuthHistoryRecordDTO.isAuth!=null">
                AND is_auth = #{pageComEldersAuthHistoryRecordDTO.isAuth}
            </if>
           <if test="pageComEldersAuthHistoryRecordDTO.createAtBegin!=null">
                AND create_at &gt;= #{pageComEldersAuthHistoryRecordDTO.createAtBegin}
           </if>
           <if test="pageComEldersAuthHistoryRecordDTO.createAtEnd!=null">
                AND create_at &lt;= #{pageComEldersAuthHistoryRecordDTO.createAtEnd}
           </if>
        </where>
        <if test="pageComEldersAuthHistoryRecordDTO.sortColumns!=null">
            ORDER BY ${pageComEldersAuthHistoryRecordDTO.sortColumns} ${pageComEldersAuthHistoryRecordDTO.sortType}
        </if>
    </select>
 
    <select id="pageAuthStatisticAdmin" parameterType="com.panzhihua.common.model.dtos.community.elder.PageElderAuthStatisticDTO"
            resultType="com.panzhihua.common.model.vos.elders.ComEldersAuthStatisticVO">
        SELECT
            ceahr.id,
            ceahr.phone,
            ceahr.`name`,
            ceahr.id_card,
            ceahr.sex,
            ceahr.age,
            ceahr.personnel_category,
            ceahr.is_alive,
            ceahr.auth_period,
            ceahr.auth_date,
            ceahr.auth_method,
            ceahr.mark,
            ceahr.is_auth,
            ceahr.submit_user_id,
            IFNULL(su.nick_name,su.`name`) as submitUserName,
            IFNULL(su1.nick_name,su1.`name`) as approvalName,
            cear.address,
            cear.auth_video,
            cear.approval_status,
            ceahr.approver_id,
            ceahr.approval_date,
            ceahr.brithday
        FROM
            com_elders_auth_history_record AS ceahr
            LEFT JOIN com_elder_auth_elderlies AS ceae ON ceae.id = ceahr.elderlies_id
            left join sys_user as su on su.user_id = ceahr.submit_user_id
            left join sys_user as su1 on su1.user_id = ceahr.approver_id
            left join com_elder_auth_records as cear on cear.id = ceahr.auth_id
        <where>
            <if test="pageElderAuthStatisticDTO.keyWord != null and pageElderAuthStatisticDTO.keyWord !=&quot;&quot;">
                and (ceahr.`name` like concat (#{pageElderAuthStatisticDTO.keyWord},'%') or
                ceahr.id_card = #{pageElderAuthStatisticDTO.keyWord} or
                ceahr.mark like concat (#{pageElderAuthStatisticDTO.keyWord},'%'))
            </if>
            <if test="pageElderAuthStatisticDTO.authPeriod != null and pageElderAuthStatisticDTO.authPeriod != &quot;&quot;">
                and ceahr.auth_period = #{pageElderAuthStatisticDTO.authPeriod}
            </if>
            <if test="pageElderAuthStatisticDTO.authStatus != null">
                and ceahr.is_auth = #{pageElderAuthStatisticDTO.authStatus}
            </if>
            <if test="pageElderAuthStatisticDTO.personnelCategory != null">
                and ceahr.personnel_category = #{pageElderAuthStatisticDTO.personnelCategory}
            </if>
            <if test="pageElderAuthStatisticDTO.isAlive != null">
                and ceahr.is_alive = #{pageElderAuthStatisticDTO.isAlive}
            </if>
            <if test="pageElderAuthStatisticDTO.communityId != null">
                and ceahr.community_id = ${pageElderAuthStatisticDTO.communityId}
            </if>
        </where>
        order by ceahr.create_at desc
    </select>
 
    <select id="getAuthHeaderStatisticAdmin" parameterType="com.panzhihua.common.model.dtos.community.elder.ElderAuthStatisticHeaderDTO"
            resultType="com.panzhihua.common.model.vos.elders.ComEldersAuthStatisticHeaderVO">
        SELECT
            count( id ) AS allCount,
            ( SELECT count( id ) FROM com_elders_auth_history_record WHERE  is_auth = 1
            <if test="statisticHeaderDTO.authPeriod != null and statisticHeaderDTO.authPeriod != &quot;&quot;">
                and auth_period = #{statisticHeaderDTO.authPeriod}
            </if>
            <if test="statisticHeaderDTO.communityId != null">
                and community_id = ${statisticHeaderDTO.communityId}
            </if>
            ) AS yesCount,
            ( SELECT count( id ) FROM com_elders_auth_history_record WHERE  is_auth = 2
            <if test="statisticHeaderDTO.authPeriod != null and statisticHeaderDTO.authPeriod != &quot;&quot;">
                and auth_period = #{statisticHeaderDTO.authPeriod}
            </if>
            <if test="statisticHeaderDTO.communityId != null">
                and community_id = ${statisticHeaderDTO.communityId}
            </if>
            ) AS noCount
        FROM
            com_elders_auth_history_record
        <where>
            <if test="statisticHeaderDTO.authPeriod != null and statisticHeaderDTO.authPeriod != &quot;&quot;">
                and auth_period = #{statisticHeaderDTO.authPeriod}
            </if>
            <if test="statisticHeaderDTO.communityId != null">
                and community_id = ${statisticHeaderDTO.communityId}
            </if>
        </where>
    </select>
 
</mapper>