101captain
2022-02-22 c83cf9d2d82a0a29a15e38f4566eb470b9a3517b
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
<?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.communityId !=0 and commonPage.communityId !=null">
                and t.community_id =#{commonPage.communityId}
            </if>
            <if test="commonPage.streetId !=0 and commonPage.streetId !=null">
                and t.street_id =#{commonPage.streetId}
            </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 t.parent_id = #{commonPage.paramId}
            </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 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
        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>
</mapper>