101captain
2022-07-20 d50ef0ec94f90ddf92bcd42671aa62ae38df81b9
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
<?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"/>
    </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.communityId !=0 and commonPage.communityId !=null">
                    and (t.community_id =#{commonPage.communityId} or t.responsibility_id =#{commonPage.communityId})
                </if>
                <if test="commonPage.streetId !=0 and commonPage.streetId !=null">
                    and t.street_id =#{commonPage.streetId}
                </if>
            </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>
</mapper>