<?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>
|