101captain
2021-12-23 5a8a90c095280fbd2106869ecd2bad10e01a57a6
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
<?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 (2,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` = 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>
        </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 community_id = #{communityId} 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 community_id = #{communityId} and status = 1 and is_volunteer = 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,
        su1.`name` responsible_name,
        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 sys_user su1 ON w.responsible_id = su1.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 su1.`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="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="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="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 DATE_FORMAT( create_at, '%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' ) = DATE_FORMAT( CURDATE( ) , '%Y' ) GROUP BY filed
    </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>
 
</mapper>