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
<?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.ComActSocialProjectDao">
 
    <resultMap type="com.panzhihua.service_community.entity.ComActSocialProject" id="ComActSocialProjectBaseResultMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="type" column="type"/>
        <result property="status" column="status"/>
        <result property="createTime" column="create_time"/>
        <result property="communityId" column="community_id"/>
        <result property="streetId" column="street_id"/>
        <result property="responsibility" column="responsibility"/>
        <result property="parentId" column="parent_id"/>
        <result property="url" column="url"/>
        <result property="image" column="image"/>
        <result property="content" column="content"/>
        <result property="phone" column="phone"/>
    </resultMap>
 
    <select id="pageList" resultType="com.panzhihua.common.model.vos.community.social.SocialProjectVO">
        select t.*,t1.name as columnName,t2.name as secondColumnName from com_act_social_project t
        left join com_act_column t1 on t.column_id = t1.id
        left join com_act_column t2 on t.second_column_id = t2.id
        <where>
            1=1
            <if test="commonPage.paramId2==null">
                <if test="commonPage.orgId != null">
                    AND t.responsibility_type = 3 AND t.responsibility_id = #{commonPage.orgId}
                </if>
                <if test="commonPage.orgId == null">
                    <if test="commonPage.communityId !=0 and commonPage.communityId !=null">
                        and t.responsibility_type = 2 AND t.responsibility_id =#{commonPage.communityId}
                    </if>
                    <if test="commonPage.streetId !=0 and commonPage.streetId !=null">
                        and (t.street_id =#{commonPage.streetId} OR (t.responsibility_type = 1 AND t.responsibility_id =#{commonPage.streetId}))
                    </if>
                </if>
            </if>
            <if test="commonPage.isPublicity == 1">
                and t.is_publicity = 1
            </if>
            <if test="commonPage.paramId2!=null">
                and (t.street_id = #{commonPage.streetId} or t.community_id =#{commonPage.communityId})
            </if>
            <if test="commonPage.status !=null">
                and t.status =#{commonPage.status}
            </if>
            <if test="commonPage.type !=null">
                and t.type =#{commonPage.type}
            </if>
            <if test="commonPage.keyword !=null and commonPage.keyword !=''">
                and (t.name like concat('%',#{commonPage.keyword},'%') or responsibility like
                concat('%',#{commonPage.keyword},'%') )
            </if>
            <if test="commonPage.beginTime !=null">
                and t.create_time >= #{commonPage.beginTime}
            </if>
            <if test="commonPage.endTime !=null">
                and #{commonPage.endTime} >= t.create_time
            </if>
            <if test="commonPage.paramId!=null and commonPage.paramId !=0">
                and t.parent_id = #{commonPage.paramId}
            </if>
            <if test="commonPage.paramId ==0 and commonPage.streetId!=null">
                and t.parent_id = #{commonPage.paramId}
            </if>
            <if test="commonPage.columnId !=null">
                and t.column_id = #{commonPage.columnId}
            </if>
            <if test="commonPage.columnId !=null">
                and t.column_id = #{commonPage.columnId}
            </if>
            <if test="commonPage.secondColumnId !=null">
                and t.second_column_id = #{commonPage.secondColumnId}
            </if>
        </where>
        order by t.create_time desc
    </select>
 
    <select id="getByApplet" resultType="com.panzhihua.common.model.vos.community.social.SocialProjectVO">
        select t.*, t1.phone as streetPhone, t2.name as columnName, t3.name as secondColumnName,t1.name as streetName,t4.name as communityName,t4.contacts_phone as communityPhone
        from com_act_social_project t
                 LEFT JOIN com_street t1 on t.street_id = t1.street_id
                 LEFT JOIN com_act_column t2 on t.column_id = t2.id
                 LEFT JOIN com_act_column t3 on t.second_column_id = t3.id
                 LEFT JOIN com_act  t4 on t.community_id = t4.community_id
        where t.id = #{id}
    </select>
 
    <select id="selectBaseInfo" resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkProjectInfo">
        select (select count(*) from com_act_social_project where street_id =15 <if test="communityId!=null">and
        community_id = #{communityId}</if>) count,
        (select count(*) from com_act_social_project where street_id =15 and status >=2 <if test="communityId!=null">and
        community_id = #{communityId}</if>) assigned,
        (select count(*) from com_act_social_project where street_id =15 and 1 >=status <if test="communityId!=null">and
        community_id = #{communityId}</if>) assign
    </select>
 
    <select id="selectType" resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkProjectTypeInfo">
        select count(id) as count,type as name from com_act_social_project where street_id = 15
        <if test="orgName !=null and orgName!=''">
            and responsibility=#{orgName}
        </if>
        <if test="communityId !=null">
            and community_id=#{communityId}
        </if>
        GROUP BY type
    </select>
 
    <select id="selectActivity" resultType="integer">
        select count(*) from com_act_activity
        <where>
            is_project = 1
            <if test="type =1">
                and volunteer_max > 0
            </if>
            <if test="type =2">
                and volunteer_max = 0
            </if>
            <if test="communityId !=null">
                and community_id = #{communityId}
            </if>
        </where>
    </select>
 
    <select id="selectIndexBaseInfo"
            resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkBaseInfo">
        select (select count(*) from com_act_social_project where street_id = 15) projectCount,
               (select count(*) from com_act_activity where is_project = 1)       activityCount,
               (select count(*) from com_act_social_worker where street_id = 15)  socialWorkerCount,
               (select count(*) from com_mng_population where street_id = 15)     userCount,
               (select count(*) from com_act_social_org where street_id = 15)     socialOrgCount,
               (select count(*) from com_act_social_worker_service)               serviceCount
    </select>
 
    <select id="selectActivityCountMonth"
            resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenActivityLine">
        select (select count(id) from com_act_activity where status!=6 and is_project = 1 and publish_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') >=publish_at) y,
            (
        select count(id)
        from com_act_activity
        where status!=6
          and is_project = 1
          and DATE_FORMAT( LAST_DAY(CONCAT(#{year}
            , '-'
            , #{date}
            , '-00'))
            , '%Y-%m-%d 23:59:59') >=publish_at) countY
    </select>
 
    <select id="selectByLevel" resultType="com.panzhihua.common.model.vos.community.social.SocialProjectVO">
        select t.*, t1.name as columnName, t2.name as secondColumnName
        from com_act_social_project t
                 left join com_act_column t1 on t.column_id = t1.id
                 left join com_act_column t2 on t.second_column_id = t2.id
        where t.id = #{id}
    </select>
    <select id="pageProjectSignList" resultType="com.panzhihua.common.model.vos.community.ComActSocialOrgVO">
        SELECT t1.id, t1.`name`, t1.corporation_name, t1.contact_phone, t1.company_type, t1.attach_url, t3.`name` AS serviceName
        FROM com_act_social_org t1
                 LEFT JOIN com_act_social_project_sign t2 ON t1.id = t2.org_id
                 LEFT JOIN com_act_column t3 ON t1.service_type = t3.id
        WHERE t2.project_id = #{pageProjectSignListDTO.projectId}
        ORDER BY t2.created_at DESC
    </select>
    <select id="pageProjectWhichIsSignedByUser"
            resultType="com.panzhihua.common.model.vos.community.social.SocialProjectVO">
        SELECT t.*, t2.name AS columnName, t3.name AS secondColumnName
        FROM com_act_social_project t
                 INNER JOIN com_act_social_project_sign t1 ON t.id = t1.project_id
                 LEFT JOIN com_act_column t2 ON t.column_id = t2.id
                 LEFT JOIN com_act_column t3 ON t.second_column_id = t3.id
        WHERE t1.user_id = #{pageProjectDTO.userId}
        ORDER BY t1.created_at DESC
    </select>
 
    <select id="pageSocialProjectList"
            resultType="com.panzhihua.common.model.vos.community.social.SocialProjectVO">
        SELECT id, `name`, image
        FROM com_act_social_project
        WHERE street_id = #{streetId}
    </select>
    <select id="getFiveAssociationsBaseData"
            resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenFiveAssociationsStatisticsInfo">
        SELECT
                (SELECT COUNT(community_id) FROM com_act WHERE street_id = #{streetId}) AS communityNum,
                (SELECT COUNT(id) FROM (SELECT id FROM com_act_social_org t
                                                           LEFT JOIN com_act t1 ON t.affiliated_unit = t1.community_id
                                        WHERE t.is_society = 1 AND t.affiliated_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
                                        UNION ALL
                                        SELECT id FROM com_act_social_org
                                        WHERE is_society = 1 AND affiliated_unit_type = 1 AND `status` = 1 AND affiliated_unit = #{streetId}) temp) AS socialOrgNum,
                (SELECT COUNT(id) FROM com_act_enterprise WHERE street_id = #{streetId}) AS enterpriseNum,
                (SELECT COUNT(id) FROM com_act_social_worker WHERE community_id = ${communityId} OR street_id = #{streetId}) AS socialWorkerNum,
                (SELECT COUNT(id) FROM com_act_social_project WHERE responsibility_type = 3 AND responsibility_id IN (SELECT id FROM com_act_social_org WHERE community_id = ${communityId} AND is_society = 1)) AS acceptProjectTotal,
                (SELECT COUNT(id) FROM com_mng_volunteer_mng WHERE community_id = ${communityId} AND state = 2) AS volunteerNum
    </select>
</mapper>