<?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.ComActDynDAO">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActDynDO">
|
<id column="id" property="id" />
|
<result column="title" property="title" />
|
<result column="status" property="status" />
|
<result column="is_topping" property="isTopping" />
|
<result column="publish_at" property="publishAt" />
|
<result column="create_at" property="createAt" />
|
<result column="update_at" property="updateAt" />
|
<result column="community_id" property="communityId" />
|
<result column="content" property="content" />
|
<result column="cover" property="cover" />
|
<result column="type" property="type" />
|
<result column="cover_mode" property="coverMode" />
|
<result column="jump_url" property="jumpUrl" />
|
<result column="jump_type" property="jumpType" />
|
<result column="category" property="category" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id
|
</sql>
|
<select id="getIndexDynBaseData" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, num, ROUND(num/total,2) AS percent FROM
|
(SELECT t2.`name` AS filed, COUNT(1) AS num FROM com_act_dyn t1
|
LEFT JOIN com_act_dyn_type t2 ON t1.type = t2.id
|
WHERE t1.community_id = ${communityId} AND t1.`status` = 1 GROUP BY filed) temp1,
|
(SELECT COUNT(t1.id) AS total FROM com_act_dyn t1
|
LEFT JOIN com_act_dyn_type t2 ON t1.type = t2.id
|
WHERE t1.community_id = ${communityId} AND t1.`status` = 1) temp2
|
</select>
|
<select id="getDynAddPolylineData" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT DATE_FORMAT( create_at, '%Y-%m' ) AS filed, COUNT(id) AS num
|
FROM com_act_dyn
|
WHERE community_id = ${communityId} AND `status` = 1
|
AND DATE_FORMAT( create_at, '%Y-%m' ) > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
|
UNION ALL SELECT * FROM
|
(
|
SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
|
) temT
|
) temp GROUP BY filed ORDER BY filed ASC
|
</select>
|
<select id="getDynTotalPolylineDate"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT COUNT(id) AS num FROM com_act_dyn
|
WHERE community_id = ${communityId} AND `status` = 1 AND DATE_FORMAT( create_at, '%Y-%m' ) <= #{date}
|
</select>
|
<select id="indexDynList" resultType="com.panzhihua.common.model.vos.community.ComActDynVO">
|
SELECT t1.id, t1.title, t1.cover, t2.`name` AS typeName
|
FROM com_act_dyn t1
|
LEFT JOIN com_act_dyn_type t2 ON t1.type = t2.id
|
WHERE 1=1 and cadt.area='2'
|
<if test="pageBaseDTO.communityIds != null and pageBaseDTO.communityIds.size > 0">
|
AND t1.community_id IN
|
<foreach collection="pageBaseDTO.communityIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="pageBaseDTO.communityIds == null">
|
AND t1.community_id = ${pageBaseDTO.communityId}
|
</if>
|
AND t1.`status` = 1 AND t2.is_del = 2
|
<if test="pageBaseDTO.paramId != null">
|
AND t1.type = #{pageBaseDTO.paramId}
|
</if>
|
ORDER BY t1.id DESC
|
</select>
|
<select id="getPartyBuildIngBaseData"
|
resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenPartyBuildIngStatisticsInfo">
|
SELECT
|
(SELECT COUNT( d.id ) FROM com_pb_dyn d LEFT JOIN com_pb_dyn_user u ON d.id = u.dyn_id LEFT JOIN com_act t ON d.community_id = t.community_id WHERE d.type = 1 AND d.community_id = #{communityId}) AS djdtTotal,
|
(SELECT COUNT( a.id ) FROM com_pb_activity a LEFT JOIN sys_user u ON a.create_by = u.user_id WHERE a.community_id = #{communityId} AND a.`status` IN ( 3, 4, 5 )) AS djhdTotal,
|
(SELECT COUNT(id) FROM com_act_discuss WHERE community_id = #{communityId} AND is_del = 2) AS ystpTotal,
|
(SELECT COUNT(DISTINCT d2.user_id) FROM com_act_discuss d1 INNER JOIN com_act_discuss_comment d2 ON d1.id = d2.discuss_id WHERE d1.community_id = #{communityId} AND d1.is_del = 2) AS ystpcyTotal,
|
(SELECT COUNT(id) FROM com_act_discuss WHERE community_id = #{communityId} AND is_del = 2 AND `type` = 1) AS ysTotal,
|
(SELECT COUNT(id) FROM com_act_discuss WHERE community_id = #{communityId} AND is_del = 2 AND `type` = 2) AS tpTotal,
|
(SELECT COUNT(id) FROM com_act_discuss WHERE community_id = #{communityId} AND content_type = 2 AND is_del = 2) AS ylysTotal,
|
(SELECT COUNT(id) FROM com_act_discuss WHERE community_id = #{communityId} AND content_type = 1 AND is_del = 2) AS sqysTotal,
|
(SELECT COUNT(id) FROM com_pb_member WHERE community_id = #{communityId} AND audit_result = 1) AS dyTotal,
|
(SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId}) AS szsyTotal,
|
(SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','居民小组长','%') OR position = '全部')) AS jmxzzTotal,
|
(SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','妇女小组长','%') OR position = '全部')) AS fnxzzTotal,
|
(SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','党小组长','%') OR position = '全部')) AS dxzzTotal,
|
(SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','楼栋长','%') OR position = '全部')) AS ldzTotal,
|
(SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','调解员','%') OR position = '全部')) AS tjyTotal,
|
(SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','安全员','%') OR position = '全部')) AS aqyTotal,
|
(SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','宣传员','%') OR position = '全部')) AS xcyTotal,
|
(SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','监督员','%') OR position = '全部')) AS jdyTotal,
|
(SELECT COUNT(t1.id) FROM com_act_easy_photo_handler t1 INNER JOIN com_act_micro_wish t2 ON t1.service_id = t2.id
|
WHERE t1.community_id = #{communityId} AND t1.`type` = 2 AND t1.service_type = 2 AND t2.`status` = 6) AS zyxServiceTotal,
|
(SELECT COUNT(id) FROM com_act_dyn WHERE community_id = #{communityId} AND `status` = 1) AS jmxcTotal,
|
(SELECT COUNT(id) FROM com_sw_patrol_record WHERE community_id = #{communityId}) AS xqxcTotal,
|
(SELECT IF(AVG(t1.score) IS NULL,0,ROUND(AVG(t1.score),1)) FROM com_act_easy_photo_evaluate t1
|
INNER JOIN com_act_easy_photo t2 ON t1.service_id = t2.id WHERE t1.community_id = #{communityId} AND t1.service_type = 1 AND t2.del_tag = 0) AS qzmydStar
|
</select>
|
<select id="pagePartyBuildIngAct"
|
resultType="com.panzhihua.common.model.vos.partybuilding.PartyBuildingActivityVO">
|
SELECT
|
id,
|
activity_name AS name,
|
publish_at AS releaseTime,
|
cover
|
FROM com_act_activity
|
WHERE community_id = #{pageBaseDTO.communityId} AND `status` IN ( 3, 4, 5 ) AND `type` = 3
|
ORDER BY publish_at desc
|
</select>
|
<select id="pagePartyBuildIngDiscuss"
|
resultType="com.panzhihua.common.model.vos.community.ComActDiscussVO">
|
SELECT
|
id,
|
discuss_subject,
|
`type`,
|
photo_pah
|
FROM com_act_discuss
|
WHERE community_id = #{pageBaseDTO.communityId} AND is_del = 2
|
ORDER BY create_at DESC
|
</select>
|
<select id="getPartyBuildIngDynRecord" resultType="com.panzhihua.common.model.vos.community.ComActDynVO">
|
SELECT id,title,publish_at FROM com_act_dyn WHERE community_id = #{communityId} AND `status` = 1 LIMIT #{pageSize}
|
</select>
|
<select id="getPartyBuildIngPatrolRecord"
|
resultType="com.panzhihua.common.model.vos.community.ComSwPatrolRecordVO">
|
SELECT id,person_name,patrol_type,patrol_time FROM com_sw_patrol_record WHERE community_id = #{communityId} LIMIT #{pageSize}
|
</select>
|
<select id="pageDynamic" resultType="com.panzhihua.common.model.vos.community.ComActDynVO">
|
SELECT
|
d.id,
|
d.title,
|
IFNULL( u.readNum, 0 ) readNum,
|
d.`status`,
|
d.`cover`,
|
d.`type`,
|
d.`cover_mode`,
|
d.jump_url,
|
d.jump_type,
|
d.is_topping,
|
d.publish_at,
|
d.create_at,
|
cadt.`name` AS typeName,
|
cadt.color AS typeColor,
|
ca.NAME AS communityName,
|
d.release_time,
|
d.category
|
FROM
|
com_act_dyn d
|
LEFT JOIN ( SELECT dyn_id, count( id ) AS readNum FROM com_act_dyn_user GROUP BY dyn_id ) u ON d.id = u.dyn_id
|
LEFT JOIN com_act_dyn_type AS cadt ON cadt.id = d.type
|
LEFT JOIN com_act ca ON d.community_id = ca.community_id
|
WHERE
|
1 = 1
|
<if test='comActDynVO.choice == 0 '>
|
AND d.community_id in (${comActDynVO.communityId})
|
</if>
|
<if test="comActDynVO.category != null and comActDynVO.category != '' ">
|
AND d.category = #{comActDynVO.category}
|
</if>
|
<if test='comActDynVO.areaCode !=null and comActDynVO.category == 1 '>
|
AND ca.area_code = ${comActDynVO.areaCode}
|
</if>
|
<if test="comActDynVO.title != null and comActDynVO.title.trim() != '' ">
|
AND d.title LIKE concat(#{comActDynVO.title},'%')
|
</if>
|
<if test="comActDynVO.isTopping != null and comActDynVO.isTopping != '' ">
|
AND d.is_topping = #{comActDynVO.isTopping}
|
</if>
|
<if test="comActDynVO.status != null and comActDynVO.status != '' ">
|
AND d.`status` = #{comActDynVO.status}
|
</if>
|
<if test="comActDynVO.type != null and comActDynVO.type != '' ">
|
AND d.type in (${comActDynVO.type})
|
</if>
|
<if test="comActDynVO.publishAtBegin != null and comActDynVO.publishAtBegin != '' ">
|
AND d.publish_at BETWEEN #{comActDynVO.publishAtBegin} AND #{comActDynVO.publishAtEnd}
|
</if>
|
<if test="comActDynVO.isOrgHatch == 1">
|
AND (cadt.`name` = '社会组织培训' OR cadt.`name` = '社工培训')
|
</if>
|
ORDER BY d.is_topping DESC, d.create_at DESC
|
</select>
|
|
<!-- <select id="pageDynamicByAdmin" resultType="com.panzhihua.common.model.vos.community.ComActDynVO">-->
|
<!-- SELECT d.id, d.title,(SELECT COUNT(u.id) FROM com_act_dyn_user u WHERE d.id = u.dyn_id ) readNum,-->
|
<!-- d.`status`, d.`content`, d.`cover`, d.`type`, d.`cover_mode`,-->
|
<!-- d.is_topping, d.publish_at, d.create_at, cadt.`name` as typeName, ca.name as communityName,d.release_time-->
|
<!-- FROM com_act_dyn d-->
|
<!-- LEFT JOIN com_act_dyn_type as cadt ON cadt.id = d.type-->
|
<!-- LEFT JOIN com_act ca ON d.community_id = ca.community_id-->
|
<!-- WHERE 1=1-->
|
<!-- <if test="comActDynVO.communityId != null and comActDynVO.communityId != '' ">-->
|
<!-- and d.community_id in (${comActDynVO.communityId})-->
|
<!-- </if>-->
|
|
<!-- <if test="comActDynVO.communityId == null and comActDynVO.streetId != null" >-->
|
<!-- and d.community_id in (select community_id from com_act where street_id=#{comActDynVO.streetId})-->
|
<!-- </if>-->
|
|
<!-- <if test="comActDynVO.category != null and comActDynVO.category != '' ">-->
|
<!-- AND d.category = #{comActDynVO.category}-->
|
<!-- </if>-->
|
<!-- <if test="comActDynVO.title != null and comActDynVO.title.trim() != '' ">-->
|
<!-- AND d.title like concat(#{comActDynVO.title},'%')-->
|
<!-- </if>-->
|
<!-- <if test="comActDynVO.isTopping != null and comActDynVO.isTopping != '' ">-->
|
<!-- AND d.is_topping = #{comActDynVO.isTopping}-->
|
<!-- </if>-->
|
<!-- <if test="comActDynVO.status != null and comActDynVO.status != '' ">-->
|
<!-- AND d.`status` = #{comActDynVO.status}-->
|
<!-- </if>-->
|
|
<!-- <if test="comActDynVO.typeS == null or comActDynVO.typeS != 2 ">-->
|
<!-- <if test="comActDynVO.type != null and comActDynVO.type != '' ">-->
|
<!-- AND d.type = #{comActDynVO.type}-->
|
<!-- </if>-->
|
<!-- </if>-->
|
|
<!-- <if test="comActDynVO.typeS != null and comActDynVO.typeS == 2 ">-->
|
<!-- AND d.type in (-->
|
<!-- SELECT cadt.id FROM `com_act_dyn_type` as cadt WHERE cadt.name in-->
|
<!-- <foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">-->
|
<!-- #{id}-->
|
<!-- </foreach>-->
|
<!-- <if test="comActDynVO.communityId != null and comActDynVO.communityId != '' ">-->
|
<!-- and cadt.community_id in (${comActDynVO.communityId})-->
|
<!-- </if>-->
|
<!-- union-->
|
<!-- SELECT cadt2.id FROM `com_act_dyn_type` as cadt2 WHERE cadt2.area=1 and cadt2.name in-->
|
<!-- <foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">-->
|
<!-- #{id}-->
|
<!-- </foreach>-->
|
|
<!-- )-->
|
<!-- </if>-->
|
|
<!-- <if test="comActDynVO.publishAtBegin != null and comActDynVO.publishAtBegin != '' ">-->
|
<!-- AND (d.publish_at BETWEEN #{comActDynVO.publishAtBegin} AND #{comActDynVO.publishAtEnd})-->
|
<!-- </if>-->
|
<!-- order by d.is_topping desc, d.create_at desc-->
|
<!-- </select>-->
|
|
|
<select id="pageDynamicByAdmin" resultType="com.panzhihua.common.model.vos.community.ComActDynVO">
|
SELECT d.id, d.title,
|
d.`status`, d.`cover`, d.`type`, d.`cover_mode`,
|
d.is_topping, d.publish_at, d.create_at, cadt.`name` as typeName, ca.name as communityName,d.release_time
|
FROM com_act_dyn d
|
LEFT JOIN com_act_dyn_type as cadt ON cadt.id = d.type
|
LEFT JOIN com_act ca ON d.community_id = ca.community_id
|
WHERE 1=1
|
<if test="comActDynVO.communityId != null and comActDynVO.communityId != '' ">
|
and d.community_id in (${comActDynVO.communityId})
|
</if>
|
|
<if test="comActDynVO.communityId == null and comActDynVO.streetId != null" >
|
and d.community_id in (select community_id from com_act where street_id=#{comActDynVO.streetId})
|
</if>
|
|
<if test="comActDynVO.category != null and comActDynVO.category != '' ">
|
AND d.category = #{comActDynVO.category}
|
</if>
|
<if test="comActDynVO.title != null and comActDynVO.title.trim() != '' ">
|
AND d.title like concat(#{comActDynVO.title},'%')
|
</if>
|
<if test="comActDynVO.isTopping != null and comActDynVO.isTopping != '' ">
|
AND d.is_topping = #{comActDynVO.isTopping}
|
</if>
|
<if test="comActDynVO.status != null and comActDynVO.status != '' ">
|
AND d.`status` = #{comActDynVO.status}
|
</if>
|
|
<if test="comActDynVO.typeS == null or comActDynVO.typeS != 2 ">
|
<if test="comActDynVO.type != null and comActDynVO.type != '' ">
|
AND d.type = #{comActDynVO.type}
|
</if>
|
</if>
|
|
<if test="comActDynVO.typeS != null and comActDynVO.typeS == 2 ">
|
AND d.type in (
|
SELECT cadt.id FROM `com_act_dyn_type` as cadt WHERE cadt.name in
|
<foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
<if test="comActDynVO.communityId != null and comActDynVO.communityId != '' ">
|
and cadt.community_id in (${comActDynVO.communityId})
|
</if>
|
union
|
SELECT cadt2.id FROM `com_act_dyn_type` as cadt2 WHERE cadt2.area=1 and cadt2.name in
|
<foreach collection="comActDynVO.typeList" item="id" index="index" open="(" close=")" separator=",">
|
#{id}
|
</foreach>
|
|
)
|
</if>
|
|
<if test="comActDynVO.publishAtBegin != null ">
|
AND (d.publish_at BETWEEN #{comActDynVO.publishAtBegin} AND #{comActDynVO.publishAtEnd})
|
</if>
|
order by d.is_topping desc, d.create_at desc
|
</select>
|
|
|
<select id="getContent" resultType="String" parameterType="String">
|
SELECT content FROM `com_act_dyn` WHERE id=#{id}
|
</select>
|
|
|
<select id="getReadNum" resultType="Integer" parameterType="String">
|
SELECT COUNT(id) FROM `com_act_dyn_user` WHERE dyn_id=#{dynId}
|
</select>
|
|
|
<select id="getTypeId" resultType="String">
|
select id from com_act_dyn_type where community_id=#{communityId} and name=#{name} and area in (1,2) and is_del=2
|
</select>
|
|
|
|
|
</mapper>
|