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
<?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.ComActMicroWishDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActMicroWishDO">
        <id column="id" property="id" />
        <result column="sponsor_id" property="sponsorId" />
        <result column="sponsor_phone" property="sponsorPhone" />
        <result column="wish_name" property="wishName" />
        <result column="status" property="status" />
        <result column="form" property="form" />
        <result column="responsible_id" property="responsibleId" />
        <result column="create_at" property="createAt" />
        <result column="examine_at" property="examineAt" />
        <result column="distribution_at" property="distributionAt" />
        <result column="feedback_at" property="feedbackAt" />
        <result column="evaluate_at" property="evaluateAt" />
        <result column="score" property="score" />
        <result column="detail" property="detail" />
        <result column="photo_path_list" property="photoPathList" />
        <result column="community_id" property="communityId" />
        <result column="evaluate" property="evaluate" />
        <result column="finish_at" property="finishAt" />
        <result column="finish_photo_path_list" property="finishPhotoPathList" />
        <result column="finish" property="finish" />
        <result column="reject_reason" property="rejectReason" />
        <result column="feedback" property="feedback" />
        <result column="feedback_photo_path_list" property="feedbackPhotoPathList" />
        <result column="aim_num" property="aimNum" />
        <result column="img_width" property="imgWidth" />
        <result column="img_height" property="imgHeight" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, sponsor_id, sponsor_phone, wish_name, status, form, responsible_id, create_at, examine_at, distribution_at, feedback_at, evaluate_at, score, detail, photo_path_list, community_id, evaluate, finish_at, finish_photo_path_list, finish, reject_reason, feedback, feedback_photo_path_list, aim_num, img_width, img_height
    </sql>
 
    <select id="pageMicroWishApplets" parameterType="com.panzhihua.common.model.vos.community.ComActMicroWishVO"
            resultType="com.panzhihua.common.model.vos.community.ComActMicroWishVO">
        SELECT
        w.id,
        u.name sponsor_name,
        u.nick_name userNickName,
        u.image_url ,
        w.sponsor_phone,
        w.wish_name,
        w.`status`,
        w.`feedback_at`,
        w.`examine_at`,
        w.`distribution_at`,
        w.`evaluate_at`,
        w.`photo_path_list`,
        count(wu.id)star_num,
        w.`detail`,
        w.form,
        w.reject_reason,
        su.`name` responsible_name,
        w.score,
        w.img_width,
        w.finish_at,
        w.aim_num,
        w.img_height,
        w.create_at
        FROM
        com_act_micro_wish w
        left join com_act_micro_wish_user wu on w.id=wu.micro_wish_id
        left JOIN sys_user u ON w.sponsor_id = u.user_id
        left JOIN com_pb_service_team su ON w.responsible_id = su.id
        <where>
            <if test='comActMicroWishVO.communityId != null and comActMicroWishVO.communityId != 0'>
                and w.community_id = ${comActMicroWishVO.communityId}
            </if>
            <if test='comActMicroWishVO.status == 3  and comActMicroWishVO.isApplets != null and comActMicroWishVO.isApplets != 0'>
                AND w.`status` in (3)
            </if>
            <if test='comActMicroWishVO.status == 6  and comActMicroWishVO.isApplets != null and comActMicroWishVO.isApplets != 0'>
                AND w.`status` in (5,6)
            </if>
            <if test='comActMicroWishVO.status == 7  and comActMicroWishVO.isApplets != null and comActMicroWishVO.isApplets != 0'>
                AND w.`status`  in (2,7)
            </if>
            <if test='comActMicroWishVO.isApplets != null and comActMicroWishVO.isApplets != 0 and comActMicroWishVO.status != null and comActMicroWishVO.status != 7 and comActMicroWishVO.status != 6 and comActMicroWishVO.status != 3'>
                AND w.status  in (3, 5, 6)
            </if>
            <if test='comActMicroWishVO.userId != null and comActMicroWishVO.userId != 0'>
                AND w.sponsor_id  =#{comActMicroWishVO.userId}
            </if>
            <if test='comActMicroWishVO.sponsorId != null and comActMicroWishVO.sponsorId != 0'>
                AND w.sponsor_id  =#{comActMicroWishVO.sponsorId}
            </if>
            <if test='comActMicroWishVO.handleId != null and comActMicroWishVO.handleId != 0'>
                AND FIND_IN_SET(#{comActMicroWishVO.handleId},w.handle_id) &gt; 0
            </if>
        </where>
        group by w.id
        ORDER BY  w.create_at desc
    </select>
 
    <select id="getWishHandleListAdmin" resultType="com.panzhihua.common.model.vos.user.SysUserVO">
        <if test="type != null and type == 1">
            select user_id,`name` as `name` from sys_user where `type` = 3 and community_id = ${communityId} and status = 1
        </if>
        <if test="type != null and type == 2">
            select user_id,IFNULL(`name`,nick_name) as `name` from sys_user where `type` = 1 and user_id IN (select user_id from com_pb_member where community_id = ${communityId} AND audit_result = 1) and status = 1 and is_partymember = 1
        </if>
        <if test="type != null and type == 3">
            select user_id,IFNULL(`name`,nick_name) as `name` from sys_user where `type` = 1 and user_id IN (select user_id from com_mng_volunteer_mng where community_id = ${communityId} AND state = 2) and status = 1 and is_volunteer = 1
        </if>
        <if test="type != null and type == 4">
            select user_id,IFNULL(`name`,nick_name) as `name` from sys_user where `type` = 1 AND phone in (select DISTINCT(telephone) from com_act_social_worker where community_id = ${communityId}) and status = 1
        </if>
        <if test="type != null and type == 5">
            select user_id,IFNULL(`name`,nick_name) as `name` from sys_user where `type` = 1 AND id_card in (select id_card from com_act_four_member where community_id = ${communityId}) and status = 1
        </if>
    </select>
 
    <select id="getUserByUserId" resultType="com.panzhihua.common.model.vos.user.SysUserVO">
        select user_id,IFNULL(`name`,nick_name) as `name`,`type`,is_volunteer,is_partymember from sys_user where user_id = #{userId}
    </select>
 
    <select id="pageMicroWishAdmin" resultType="com.panzhihua.common.model.vos.community.ComActMicroWishVO">
        SELECT
        w.id,
        u.`name` sponsor_name,
        u.nick_name userNickName,
        u.image_url ,
        w.sponsor_phone,
        w.wish_name,
        w.`status`,
        w.`feedback_at`,
        w.`examine_at`,
        w.`distribution_at`,
        w.`evaluate_at`,
        w.`photo_path_list`,
        count(wu.id)star_num,
        w.`detail`,
        w.form,
        w.reject_reason,
        w.score,
        w.img_width,
        w.finish_at,
        w.aim_num,
        w.img_height,
        w.handle_id,
        w.create_at
        FROM
        com_act_micro_wish w
        left join com_act_micro_wish_user wu on w.id=wu.micro_wish_id
        left JOIN sys_user u ON w.sponsor_id = u.user_id
        LEFT JOIN (SELECT * FROM com_act_easy_photo_handler WHERE service_type = 2) ch ON w.id = ch.service_id
        LEFT JOIN sys_user u2 ON ch.user_id = u2.user_id
        <where>
            <if test='comActMicroWishVO.communityId != null and comActMicroWishVO.communityId != 0'>
                and w.community_id = ${comActMicroWishVO.communityId}
            </if>
            <if test='comActMicroWishVO.createBegin != null '>
                AND w.create_at BETWEEN #{comActMicroWishVO.createBegin}
                AND #{comActMicroWishVO.createEnd}
            </if>
            <if test='comActMicroWishVO.sponsorPhone != null and comActMicroWishVO.sponsorPhone != &quot;&quot;'>
                AND u.`phone` like concat(#{comActMicroWishVO.sponsorPhone},'%')
            </if>
            <if test='comActMicroWishVO.sponsorName != null and comActMicroWishVO.sponsorName != &quot;&quot;'>
                AND u.`name` like concat(#{comActMicroWishVO.sponsorName},'%')
            </if>
            <if test='comActMicroWishVO.responsibleName != null and comActMicroWishVO.responsibleName != &quot;&quot;'>
                AND u2.`name` like concat(#{comActMicroWishVO.responsibleName},'%')
            </if>
            <if test='comActMicroWishVO.status != null'>
                AND w.`status` = #{comActMicroWishVO.status}
            </if>
        </where>
        group by w.id
 
        ORDER BY  w.create_at desc
    </select>
 
 
    <select id="detailMicroWish" resultType="com.panzhihua.common.model.vos.community.ComActMicroWishVO">
       SELECT
            w.id,
            u.name sponsor_name,
            u.nick_name userNickName,
            w.create_at,
            w.aim_num,
            u.image_url,
            w.sponsor_phone,
            w.`status`,
            w.`sponsor_id`,
            w.wish_name,
            count(wu.id)starNum,
            w.detail,
            w.photo_path_list,
            su.`name` responsible_name,
            w.form,
            w.reject_reason,
            w.community_id,
            w.examine_at,
            w.finish,
            w.finish_photo_path_list,
            w.finish_at,
            w.score,
            w.feedback,
            w.feedback_at,
            w.feedback_photo_path_list,
            w.distribution_at,
            w.evaluate_at,
            w.img_width,
            w.img_height,
            w.handle_id,
            w.evaluate
            FROM
            com_act_micro_wish w
            LEFT JOIN sys_user u ON w.sponsor_id = u.user_id
            LEFT JOIN com_pb_service_team su ON w.responsible_id = su.id
            LEFT JOIN com_act_micro_wish_user wu ON w.id = wu.micro_wish_id
            LEFT JOIN (SELECT * FROM com_act_easy_photo_handler WHERE service_type = 2) ch ON w.id = ch.service_id
            LEFT JOIN sys_user u2 ON ch.user_id = u2.user_id
            WHERE
            w.id =#{id}
    </select>
 
 
 
 
<!--    <select id="selectRealizePercent" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">-->
<!--        SELECT t1.filed, t1.num, ROUND( t1.num / t2.sum * 100, 2 ) AS percent-->
<!--        FROM-->
<!--        (SELECT IF(`status` = 6,'已实现','待实现') AS filed, COUNT(`status`) AS num FROM com_act_micro_wish-->
<!--        WHERE community_id = ${communityId} AND `status` NOT IN(1,4) GROUP BY filed) t1,-->
<!--        (SELECT COUNT(id) AS sum FROM com_act_micro_wish WHERE community_id = ${communityId} AND  `status` NOT IN(1,4)) t2-->
<!--    </select>-->
 
    <select id="selectRealizePercent" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT t1.filed, t1.num, ROUND( t1.num / t2.sum * 100, 2 ) AS percent
        FROM
        (SELECT IF(`state` = 2,'已实现','待实现') AS filed, COUNT(`state`) AS num FROM jinhui_micro_volunteering
         GROUP BY filed) t1,
        (SELECT COUNT(id) AS sum FROM jinhui_micro_volunteering) t2
    </select>
<!--    <select id="getPassedAllImages" resultType="java.lang.String">-->
<!--        SELECT photo_path_list FROM com_act_micro_wish-->
<!--        WHERE community_id = ${communityId} AND (`status` =2 OR `status` = 3 OR `status` = 5 OR `status` = 6 OR `status` = 7)-->
<!--        AND photo_path_list IS NOT NULL AND photo_path_list != ''-->
<!--        ORDER BY create_at DESC limit #{pageSize}-->
<!--    </select>-->
 
    <select id="getPassedAllImages" resultType="java.lang.String">
        SELECT img_url as photoPathList FROM jinhui_micro_volunteering
        WHERE img_url IS NOT NULL AND img_url != ''
        ORDER BY creation_time DESC limit #{pageSize}
    </select>
 
    <select id="selectIndexMicroWishBaseData"
            resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenMicroWishStatisticsInfo">
        SELECT
        (SELECT COUNT(id) FROM com_act_micro_wish WHERE community_id = ${communityId} AND `status` NOT IN(1,4)) AS microWishTotal,
        (SELECT COUNT(id) FROM com_act_micro_wish WHERE community_id = ${communityId} AND `status` = 6) AS microWishRealized,
        (SELECT COUNT(id) FROM com_act_micro_wish WHERE community_id = ${communityId} AND `status` NOT IN(1,4,6)) AS microWishUnrealized
    </select>
    <select id="getMicroWishAddPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT filed, SUM(num) AS num FROM (
            SELECT DATE_FORMAT( create_at, '%Y-%m' ) AS filed, COUNT(id) AS num FROM com_act_micro_wish
            WHERE community_id = ${communityId} AND `status` NOT IN(1,4) AND DATE_FORMAT( create_at, '%Y-%m' ) &gt; DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
            UNION ALL SELECT * FROM
            (
                SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
                SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
            ) temT
        ) temp GROUP BY filed ORDER BY filed ASC
    </select>
    <select id="getMicroWishTotalPolylineDate"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT COUNT(id) AS num FROM com_act_micro_wish
        WHERE community_id = ${communityId} AND `status` NOT IN(1,4) AND DATE_FORMAT( create_at, '%Y-%m' ) &lt;= #{date}
    </select>
    <select id="selectScreenDisplayList"
            resultType="com.panzhihua.common.model.vos.community.ComActMicroWishVO">
        SELECT id, `status`, detail, photo_path_list
        FROM com_act_micro_wish
        WHERE community_id = ${pageBaseDTO.communityId} AND `status` NOT IN(1,4) ORDER BY create_at DESC
    </select>
    <select id="pagePartyBuildIngMicroWish"
            resultType="com.panzhihua.common.model.vos.community.ComActMicroWishVO">
        SELECT t2.id, t2.photo_path_list
        FROM com_act_easy_photo_handler t1
        INNER JOIN com_act_micro_wish t2 ON t1.service_id = t2.id
        WHERE t1.community_id = #{pageBaseDTO.communityId} AND t1.`type` = 2 AND t1.service_type = 2 AND t2.`status` = 6 AND t2.photo_path_list IS NOT NULL
    </select>
    <select id="pageFourMemberResolve" resultType="com.panzhihua.common.model.vos.community.ComActMicroWishVO">
        SELECT * FROM(
            SELECT t2.id, t2.photo_path_list
            FROM com_act_easy_photo_handler t1
            INNER JOIN com_act_micro_wish t2 ON t1.service_id = t2.id
            WHERE t1.community_id = #{pageBaseDTO.communityId} AND t1.`type` = 5 AND t1.service_type = 2 AND t2.`status` = 6 AND t2.photo_path_list IS NOT NULL
            UNION ALL
            SELECT t2.id, t2.photo_path_list
            FROM com_act_easy_photo_handler t1
            INNER JOIN com_act_easy_photo t2 ON t1.service_id = t2.id
            WHERE t1.community_id = #{pageBaseDTO.communityId} AND t1.`type` = 5 AND t1.service_type = 1 AND t2.`status` = 5 AND t2.photo_path_list IS NOT NULL
        ) temp
    </select>
 
</mapper>