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
<?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.ComActReserveRecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActReserveRecordDO">
        <id column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="reserve_id" property="reserveId"/>
        <result column="community_id" property="communityId"/>
        <result column="type" property="type"/>
        <result column="name" property="name"/>
        <result column="phone" property="phone"/>
        <result column="status" property="status"/>
        <result column="content" property="content"/>
        <result column="remark" property="remark"/>
        <result column="act_remark" property="actRemark"/>
        <result column="reserve_time" property="reserveTime"/>
        <result column="json_object" property="jsonObject"/>
        <result column="create_at" property="createAt"/>
        <result column="create_by" property="createBy"/>
        <result column="update_at" property="updateAt"/>
        <result column="update_by" property="updateBy"/>
        <result column="handle_id" property="handleId"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, user_id, reserve_id, community_id, type, name, phone, status, content, remark, act_remark, reserve_time, json_object, create_at, create_by, update_at, update_by, handle_id
    </sql>
 
    <select id="pageReserveList" resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveAppletsVO">
        select t.*,t1.title from com_act_reserve_record t left join com_act_reserve t1 on t.reserve_id = t1.id
        <where>
            1=1
            <if test="pageUserReserveDTO.type !=null">
                and t.type =#{pageUserReserveDTO.type}
            </if>
            <if test="pageUserReserveDTO.status !=null">
                and t.status =#{pageUserReserveDTO.status}
            </if>
            <if test="pageUserReserveDTO.userId !=null">
                and t.user_id =#{pageUserReserveDTO.userId}
            </if>
        </where>
        order by t.create_at desc
    </select>
 
    <select id="pageMakeAdmin" parameterType="com.panzhihua.common.model.dtos.community.reserve.PageReserveMakeAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveMakeListAdminVO">
        SELECT
            carr.id,
            su.nick_name,
            su1.`name` as handleName,
            carr.`name`,
            carr.phone,
            carr.reserve_time,
            carr.`content`,
            carr.remark,
            carr.act_remark,
            carr.create_at
        FROM
            com_act_reserve_record AS carr
            LEFT JOIN sys_user AS su ON su.user_id = carr.user_id
            LEFT JOIN sys_user AS su1 ON su1.user_id = carr.handle_id
            where carr.status = 2 and carr.`type` = 1 and carr.reserve_id = #{pageMakeDTO.reserveId}
            <if test="pageMakeDTO.startTime != null and pageMakeDTO.startTime != &quot;&quot;">
                AND carr.reserve_time <![CDATA[ >= ]]> #{pageMakeDTO.startTime}
            </if>
            <if test="pageMakeDTO.endTime != null and pageMakeDTO.endTime != &quot;&quot;">
                AND carr.reserve_time <![CDATA[ <= ]]> #{pageMakeDTO.endTime}
            </if>
            order by carr.create_at desc
    </select>
 
    <select id="getMakeDetailAdmin" resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveMakeDetailAdminVO">
        SELECT
            carr.id,
            su.nick_name,
            su1.`name` as handleName,
            carr.`name`,
            carr.phone,
            carr.reserve_time,
            carr.`content`,
            carr.remark,
            carr.act_remark,
            carr.create_at
        FROM
            com_act_reserve_record AS carr
            LEFT JOIN sys_user AS su ON su.user_id = carr.user_id
            LEFT JOIN sys_user AS su1 ON su1.user_id = carr.handle_id
            where carr.id = #{reserveRecordId}
    </select>
 
    <select id="getReserveStatusById" resultType="integer">
        select count(id) from com_act_reserve_record where `status` in (3,4) and id in
        <foreach collection='ids' item='id' index='index' open='(' close=')' separator=',' >
            #{id}
        </foreach>
    </select>
 
    <update id="editReserveStatusById">
        update com_act_reserve_record set `status` = 4 where id in
        <foreach collection='ids' item='id' index='index' open='(' close=')' separator=',' >
            #{id}
        </foreach>
    </update>
 
    <select id="exportMakeAdmin" parameterType="com.panzhihua.common.model.dtos.community.reserve.PageReserveMakeAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveMakeListAdminVO">
        SELECT
        carr.id,
        su.nick_name,
        su.`name` as handleName,
        carr.`name`,
        carr.phone,
        carr.reserve_time,
        carr.`content`,
        carr.remark,
        carr.act_remark,
        carr.create_at
        FROM
        com_act_reserve_record AS carr
        LEFT JOIN sys_user AS su ON su.user_id = carr.user_id
        LEFT JOIN sys_user AS su1 ON su1.user_id = carr.handle_id
        where carr.status = 2 and carr.`type` = 1 and carr.reserve_id = #{pageMakeDTO.reserveId}
        <if test="pageMakeDTO.startTime != null and pageMakeDTO.startTime != &quot;&quot;">
            AND carr.reserve_time <![CDATA[ >= ]]> #{pageMakeDTO.startTime}
        </if>
        <if test="pageMakeDTO.endTime != null and pageMakeDTO.endTime != &quot;&quot;">
            AND carr.reserve_time <![CDATA[ <= ]]> #{pageMakeDTO.endTime}
        </if>
        <if test="pageMakeDTO.ids != null and pageMakeDTO.ids.size > 0">
            AND carr.id in
            <foreach collection='pageMakeDTO.ids' item='id' index='index' open='(' close=')' separator=',' >
                #{id}
            </foreach>
        </if>
        order by carr.create_at desc
    </select>
 
    <select id="registerStatisticsAdmin" parameterType="com.panzhihua.common.model.dtos.community.reserve.ComActReserveRegisterStatisticsDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveRegisterStatisticsAdminVO">
        SELECT
            car.title,
            count( carr.id ) AS count,
            ( SELECT count( id ) FROM com_act_reserve_record WHERE `type` = 2 AND community_id = ${registerStatisticsDTO.communityId} AND `status` = 2 ) AS allCount
        FROM
            com_act_reserve_record AS carr
            LEFT JOIN com_act_reserve AS car ON car.id = carr.reserve_id
        WHERE
            carr.type = 2
            AND carr.community_id = ${registerStatisticsDTO.communityId}
            AND carr.`status` = 2
            <if test="registerStatisticsDTO.startTime != null and registerStatisticsDTO.startTime != &quot;&quot;">
                AND DATE_FORMAT(carr.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{registerStatisticsDTO.startTime}
            </if>
            <if test="registerStatisticsDTO.endTime != null and registerStatisticsDTO.endTime != &quot;&quot;">
                AND DATE_FORMAT(carr.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{registerStatisticsDTO.endTime}
            </if>
        GROUP BY
            car.id
    </select>
 
    <select id="registerStatisticsExportAdmin" parameterType="com.panzhihua.common.model.dtos.community.reserve.ComActReserveRegisterStatisticsDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveRegisterStatisticsAdminVO">
        SELECT
        car.title,
        count( carr.id ) AS count,
        ( SELECT count( id ) FROM com_act_reserve_record WHERE `type` = 2 AND community_id = ${registerStatisticsDTO.communityId} AND `status` = 2 ) AS allCount
        FROM
        com_act_reserve_record AS carr
        LEFT JOIN com_act_reserve AS car ON car.id = carr.reserve_id
        WHERE
        carr.type = 2
        AND carr.community_id = ${registerStatisticsDTO.communityId}
        AND carr.`status` = 2
        <if test="registerStatisticsDTO.startTime != null and registerStatisticsDTO.startTime != &quot;&quot;">
            AND DATE_FORMAT(carr.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{registerStatisticsDTO.startTime}
        </if>
        <if test="registerStatisticsDTO.endTime != null and registerStatisticsDTO.endTime != &quot;&quot;">
            AND DATE_FORMAT(carr.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{registerStatisticsDTO.endTime}
        </if>
        GROUP BY
        car.id
    </select>
 
    <select id="pageMakeHandleAdmin" parameterType="com.panzhihua.common.model.dtos.community.reserve.PageReserveMakeHandleAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveMakeHandleListAdminVO">
        SELECT
            carr.id,
            su.nick_name,
            carr.`name`,
            carr.phone,
            carr.reserve_time,
            carr.`content`,
            su1.`name` as remark,
            carr.act_remark,
            carr.`status`,
            car.`title`,
            carr.create_at
        FROM
            com_act_reserve_record AS carr
            LEFT JOIN sys_user AS su ON su.user_id = carr.user_id
            LEFT JOIN sys_user AS su1 ON su1.user_id = carr.handle_id
            LEFT JOIN com_act_reserve AS car ON car.id = carr.reserve_id
        WHERE
            carr.`type` = 1
            <if test="pageMakeHandleDTO.keyWord != null and pageMakeHandleDTO.keyWord != &quot;&quot;">
                and (car.`title` like concat (#{pageMakeHandleDTO.keyWord},'%')
                or carr.`name` like concat (#{pageMakeHandleDTO.keyWord},'%')
                or su.nick_name like concat (#{pageMakeHandleDTO.keyWord},'%'))
            </if>
            <if test="pageMakeHandleDTO.status != null and pageMakeHandleDTO.status.size > 0">
                and carr.`status` in
                <foreach collection='pageMakeHandleDTO.status' item='id' index='index' open='(' close=')' separator=',' >
                    #{id}
                </foreach>
            </if>
            <if test="pageMakeHandleDTO.reserveId != null ">
                and carr.reserve_id = #{pageMakeHandleDTO.reserveId}
            </if>
            <if test="pageMakeHandleDTO.communityId != null ">
                and carr.community_id = ${pageMakeHandleDTO.communityId}
            </if>
            <if test="pageMakeHandleDTO.startTime != null and pageMakeHandleDTO.startTime != &quot;&quot;">
                AND DATE_FORMAT(carr.reserve_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{pageMakeHandleDTO.startTime}
            </if>
            <if test="pageMakeHandleDTO.endTime != null and pageMakeHandleDTO.endTime != &quot;&quot;">
                AND DATE_FORMAT(carr.reserve_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{pageMakeHandleDTO.endTime}
            </if>
        order by carr.create_at desc
    </select>
 
    <select id="getReserveListCountByIds" resultType="integer">
        select count(id) from com_act_reserve_record where `status` != 1 and `type` = 1 and id in
        <foreach collection='ids' item='id' index='index' open='(' close=')' separator=',' >
            #{id}
        </foreach>
    </select>
 
    <select id="exportMakeHandleAdmin" parameterType="com.panzhihua.common.model.dtos.community.reserve.PageReserveMakeHandleAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveMakeHandleListAdminVO">
        SELECT
        carr.id,
        su.nick_name,
        su1.`name` as handleName,
        carr.`name`,
        carr.phone,
        carr.reserve_time,
        carr.`content`,
        carr.remark,
        carr.act_remark,
        carr.`status`,
        car.`title`,
        carr.create_at
        FROM
        com_act_reserve_record AS carr
        LEFT JOIN sys_user AS su ON su.user_id = carr.user_id
        LEFT JOIN sys_user AS su1 ON su1.user_id = carr.handle_id
        LEFT JOIN com_act_reserve AS car ON car.id = carr.reserve_id
        WHERE
        carr.`type` = 1
        <if test="pageMakeHandleDTO.keyWord != null and pageMakeHandleDTO.keyWord != &quot;&quot;">
            and (car.`title` like concat (#{pageMakeHandleDTO.keyWord},'%')
            or carr.`name` like concat (#{pageMakeHandleDTO.keyWord},'%')
            or su.nick_name like concat (#{pageMakeHandleDTO.keyWord},'%'))
        </if>
        <if test="pageMakeHandleDTO.status != null and pageMakeHandleDTO.status.size > 0">
            and carr.`status` in
            <foreach collection='pageMakeHandleDTO.status' item='id' index='index' open='(' close=')' separator=',' >
                #{id}
            </foreach>
        </if>
        <if test="pageMakeHandleDTO.reserveId != null ">
            and carr.reserve_id = #{pageMakeHandleDTO.reserveId}
        </if>
        <if test="pageMakeHandleDTO.communityId != null ">
            and carr.community_id = ${pageMakeHandleDTO.communityId}
        </if>
        <if test="pageMakeHandleDTO.startTime != null and pageMakeHandleDTO.startTime != &quot;&quot;">
            AND DATE_FORMAT(carr.reserve_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{pageMakeHandleDTO.startTime}
        </if>
        <if test="pageMakeHandleDTO.endTime != null and pageMakeHandleDTO.endTime != &quot;&quot;">
            AND DATE_FORMAT(carr.reserve_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{pageMakeHandleDTO.endTime}
        </if>
        <if test="pageMakeHandleDTO.ids != null and pageMakeHandleDTO.ids.size > 0">
            and carr.id in
            <foreach collection='pageMakeHandleDTO.ids' item='id' index='index' open='(' close=')' separator=',' >
                #{id}
            </foreach>
        </if>
        order by carr.create_at desc
    </select>
 
    <select id="getRegisterDetailedByRecordId" resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveRegisterDetailedVO">
        SELECT
            carr.create_at,
            carr.id,
            su.nick_name,
            su.is_partymember,
            su.is_volunteer
        FROM
            com_act_reserve_record AS carr
            LEFT JOIN sys_user AS su ON su.user_id = carr.user_id
            where carr.id = #{reserveRecordId}
    </select>
 
    <select id="queryAll" resultType="com.panzhihua.common.model.vos.community.reserve.ComOperationListVO" parameterType="com.panzhihua.common.model.dtos.community.OperationDetailDTO">
        select * from com_act_reserve_operation_record
        <where>
            <if test="reserveRecordId!=null">
                and reserve_record_id =#{reserveRecordId}
            </if>
            <if test="type!=null">
                and type =#{type}
            </if>
        </where>
        order by create_at desc
    </select>
 
    <select id="biggestScreen" resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenStaticsReserve">
        select   (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%居家%' or t1.title like '%返攀%' or t1.title like '%来攀%' or t1.title like '%燃气%' or t1.title like '%防火%') and t1.community_id = ${communityId}) count,
                    (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%居家%' or t1.title like '%返攀%' or t1.title like '%来攀%' ) and t1.community_id = ${communityId}) epidemicCount,
                    (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%燃气%' ) and t1.community_id = ${communityId}) gasCount,
                    (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%防火%' ) and t1.community_id = ${communityId}) fireCount,
                    (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%居家%' ) and t1.community_id = ${communityId}) homeCount,
                    (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%返攀%' or t1.title like '%来攀%' ) and t1.community_id = ${communityId}) reserveCount
    </select>
 
    <select id="biggestScreenMonth" resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenStaticsReserveMonth">
        select   (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%居家%' or t1.title like '%返攀%' or t1.title like '%来攀%' or t1.title like '%燃气%' or t1.title like '%防火%') and t1.community_id = ${communityId} and t.create_at >= DATE_FORMAT(  CONCAT(#{year},'-',#{date},'-00'), '%Y-%m-00 00:00:00') and  DATE_FORMAT( LAST_DAY(CONCAT(#{year},'-',#{date},'-00')), '%Y-%m-%d 23:59:59') >=t.create_at ) count,
                 (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%燃气%' ) and t1.community_id = ${communityId} and t.create_at >= DATE_FORMAT(  CONCAT(#{year},'-',#{date},'-00'), '%Y-%m-00 00:00:00') and  DATE_FORMAT( LAST_DAY(CONCAT(#{year},'-',#{date},'-00')), '%Y-%m-%d 23:59:59') >=t.create_at) gasCount,
            (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%防火%' ) and t1.community_id = ${communityId} and t.create_at >= DATE_FORMAT(  CONCAT(#{year},'-',#{date},'-00'), '%Y-%m-00 00:00:00') and  DATE_FORMAT( LAST_DAY(CONCAT(#{year},'-',#{date},'-00')), '%Y-%m-%d 23:59:59') >=t.create_at) fireCount,
            (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%居家%' ) and t1.community_id = ${communityId} and t.create_at >= DATE_FORMAT(  CONCAT(#{year},'-',#{date},'-00'), '%Y-%m-00 00:00:00') and  DATE_FORMAT( LAST_DAY(CONCAT(#{year},'-',#{date},'-00')), '%Y-%m-%d 23:59:59') >=t.create_at) homeCount,
            (select count(*)  from com_act_reserve_record t LEFT JOIN com_act_reserve t1 on t.reserve_id = t1.id where (t1.title like '%返攀%' or t1.title like '%来攀%' ) and t1.community_id = ${communityId} and t.create_at >= DATE_FORMAT(  CONCAT(#{year},'-',#{date},'-00'), '%Y-%m-00 00:00:00') and  DATE_FORMAT( LAST_DAY(CONCAT(#{year},'-',#{date},'-00')), '%Y-%m-%d 23:59:59') >=t.create_at) reserveCount
    </select>
</mapper>