<?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.ComActNeighborCircleDAO">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActNeighborCircleDO">
|
<id column="id" property="id"/>
|
<result column="release_id" property="releaseId"/>
|
<result column="release_phone" property="releasePhone"/>
|
<result column="community_id" property="communityId"/>
|
<result column="release_content" property="releaseContent"/>
|
<result column="release_images" property="releaseImages"/>
|
<result column="status" property="status"/>
|
<result column="refuse_reason" property="refuseReason"/>
|
<result column="comment_num" property="commentNum"/>
|
<result column="fabulous_num" property="fabulousNum"/>
|
<result column="forward_num" property="forwardNum"/>
|
<result column="views_num" property="viewsNum"/>
|
<result column="is_boutique" property="isBoutique"/>
|
<result column="create_at" property="createAt"/>
|
<result column="reply_at" property="replyAt"/>
|
<result column="last_comment_num" property="lastCommentNum"/>
|
<result column="last_fabulous_num" property="lastFabulousNum"/>
|
<result column="last_views_num" property="lastViewsNum"/>
|
<result column="type" property="type"/>
|
<result column="topic_id" property="topicId"/>
|
<result column="hot_num" property="hotNum"/>
|
<result column="is_del" property="isDel"/>
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, release_id, release_phone, community_id, release_content, release_images, status, refuse_reason, comment_num, fabulous_num, forward_num, views_num, is_boutique, create_at, reply_at, last_comment_num, last_fabulous_num, last_views_num, type, topic_id, hot_num, is_del
|
</sql>
|
|
<select id="pageNeighborByApp" parameterType="com.panzhihua.common.model.dtos.neighbor.ComActNeighborCircleAppDTO"
|
resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAppVO">
|
SELECT
|
canc.*,
|
su.nick_name as name,
|
su.community_id,
|
ca.`name` as communityName,
|
canct.name as topicName,
|
su.image_url as headUrl
|
FROM
|
com_act_neighbor_circle AS canc
|
left join sys_user as su on su.user_id = canc.release_id
|
left join com_act_neighbor_circle_topic as canct on canct.id = canc.topic_id
|
left join com_act as ca on ca.community_id = canc.community_id
|
where is_del = 2 and canc.status = 2 and canc.community_id = ${neighborCircleAppDTO.communityId}
|
<if test='neighborCircleAppDTO.topicId != null '>
|
and canc.topic_id = #{neighborCircleAppDTO.topicId}
|
</if>
|
<if test='neighborCircleAppDTO.belongType != null '>
|
and canc.belong_type = #{neighborCircleAppDTO.belongType}
|
</if>
|
<if test='neighborCircleAppDTO.keyWord != null and neighborCircleAppDTO.keyWord != ""'>
|
and (canct.`name` like concat ('%',#{neighborCircleAppDTO.keyWord},'%') or
|
su.nick_name like concat ('%',#{neighborCircleAppDTO.keyWord},'%') or
|
canc.release_content like concat ('%',#{neighborCircleAppDTO.keyWord},'%'))
|
</if>
|
<if test="neighborCircleAppDTO.isHelp ==1">
|
and (canc.help_member_content like concat ('%',#{neighborCircleAppDTO.phone},'%') or canc.help_org_content like concat ('%',#{neighborCircleAppDTO.phone},'%') )
|
</if>
|
order by canc.create_at desc
|
</select>
|
|
<update id="addHotNum">
|
update com_act_neighbor_circle set hot_num = hot_num + #{hotNum} where id = #{circleId}
|
</update>
|
|
<update id="addTopicHotNum">
|
update com_act_neighbor_circle_topic set hot_num = hot_num + 1 where id = (select topic_id from com_act_neighbor_circle where id = #{circleId})
|
</update>
|
|
<select id="pageNeighborByAdmin" parameterType="com.panzhihua.common.model.dtos.neighbor.ComActNeighborCircleAdminDTO"
|
resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAdminVO">
|
SELECT
|
nc.*,
|
u.`nick_name` AS releaseName,u.image_url,canct.`name` as topicName ,u.`type` as userType
|
,u.name as communityName,nc.solve_status
|
FROM
|
com_act_neighbor_circle nc
|
LEFT JOIN sys_user u ON nc.release_id = u.user_id
|
LEFT JOIN com_act_neighbor_circle_topic as canct ON canct.id = nc.topic_id
|
<where>
|
nc.community_id = ${neighborCircleAdminDTO.communityId} and is_del = 2
|
<if test='neighborCircleAdminDTO.releaseContent != null and neighborCircleAdminDTO.releaseContent != ""'>
|
and nc.release_content like concat('%',#{neighborCircleAdminDTO.releaseContent},'%')
|
</if>
|
<if test='neighborCircleAdminDTO.topicName != null and neighborCircleAdminDTO.topicName != ""'>
|
and canct.`name` = #{neighborCircleAdminDTO.topicName}
|
</if>
|
<if test='neighborCircleAdminDTO.keyWord != null and neighborCircleAdminDTO.keyWord != ""'>
|
and (canct.`name` like concat(#{neighborCircleAdminDTO.keyWord},'%') or
|
u.`nick_name` like concat(#{neighborCircleAdminDTO.keyWord},'%') or
|
nc.`release_content` like concat(#{neighborCircleAdminDTO.keyWord},'%') )
|
</if>
|
<if test='neighborCircleAdminDTO.startAt != null and neighborCircleAdminDTO.endAt !=null '>
|
and nc.create_at between #{neighborCircleAdminDTO.startAt} and #{neighborCircleAdminDTO.endAt}
|
</if>
|
<if test='neighborCircleAdminDTO.status != null '>
|
and nc.status = #{neighborCircleAdminDTO.status}
|
</if>
|
<if test='neighborCircleAdminDTO.belongType != null '>
|
and nc.belong_type = #{neighborCircleAdminDTO.belongType}
|
</if>
|
</where>
|
order by
|
case when nc.`status`=1 then 0 else 1 end,
|
nc.`status` asc,nc.create_at desc
|
</select>
|
<select id="getAllImages" resultType="java.lang.String">
|
SELECT release_images FROM com_act_neighbor_circle
|
WHERE community_id = ${communityId} AND `status` = 2 and belong_type = 1 AND release_images IS NOT NULL AND release_images != ''
|
ORDER BY create_at DESC limit #{pageSize}
|
</select>
|
<select id="getContents" resultType="java.lang.String">
|
SELECT release_content FROM com_act_neighbor_circle
|
WHERE community_id = ${communityId} AND `status` = 2 and belong_type = 1 AND release_content IS NOT NULL AND release_content != ''
|
ORDER BY create_at DESC limit #{pageSize}
|
</select>
|
<select id="getIndexNeighborBaseData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, num, ROUND(num/total,2) AS percent FROM
|
(SELECT IF(t2.`name` IS NULL,'无话题',t2.`name`) AS filed, COUNT(1) AS num FROM com_act_neighbor_circle t1
|
LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
|
WHERE t1.community_id = ${communityId} AND t1.`status` IN (2,3) AND t1.is_del = 2 AND (t2.`status` = 1 OR t2.id IS NULL) GROUP BY filed) temp1,
|
(SELECT COUNT(t1.id) AS total FROM com_act_neighbor_circle t1
|
LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
|
WHERE t1.community_id = ${communityId} AND t1.`status` IN (2,3) AND t1.is_del = 2 AND (t2.`status` = 1 OR t2.id IS NULL)) temp2
|
</select>
|
<select id="getNeighborAddPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT DATE_FORMAT( t1.create_at, '%Y-%m' ) AS filed, COUNT(t1.id) AS num
|
FROM com_act_neighbor_circle t1
|
LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
|
WHERE t1.community_id = ${communityId} AND t1.`status` IN (2,3) AND t1.is_del = 2 AND (t2.`status` = 1 OR t2.id IS NULL)
|
AND DATE_FORMAT( t1.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="getNeighborTotalPolylineDate"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT COUNT(t1.id) AS num FROM com_act_neighbor_circle t1
|
LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
|
WHERE t1.community_id = ${communityId} AND t1.`status` IN (2,3) AND t1.is_del = 2 AND (t2.`status` = 1 OR t2.id IS NULL) AND DATE_FORMAT( t1.create_at, '%Y-%m' ) <= #{date}
|
</select>
|
<select id="indexNeighborList"
|
resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAdminVO">
|
SELECT t1.id, t1.release_content, t1.release_images, t1.comment_num, t1.fabulous_num, t2.`name` AS topicName
|
FROM com_act_neighbor_circle t1
|
LEFT JOIN com_act_neighbor_circle_topic t2 ON t1.topic_id = t2.id
|
WHERE 1=1
|
<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` IN (2,3) AND t1.is_del = 2 AND (t2.`status` = 1 OR t2.id IS NULL)
|
<if test="pageBaseDTO.paramId != null">
|
AND t1.topic_id = #{pageBaseDTO.paramId}
|
</if>
|
ORDER BY t1.id DESC
|
</select>
|
|
<select id="selectSolve" resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAppVO">
|
select canc.id,canc.release_content,canc.release_images,canc.status,canc.create_at,canct.name as topicName
|
,canc.comment_num,canc.fabulous_num,canc.forward_num,canc.views_num,canc.refuse_reason,su.nick_name as name,su.image_url as headUrl,canc.solve_status,canc.community_id
|
from com_act_neighbor_circle as canc left join sys_user as su on su.user_id = canc.release_id
|
left join com_act_neighbor_circle_topic as canct on canct.id = canc.topic_id
|
<where>
|
<if test="neighborCircleAppDTO.solveId !=null">
|
and canc.solve_id =#{neighborCircleAppDTO.solveId}
|
</if>
|
<if test="neighborCircleAppDTO.solveStatus !=null">
|
and canc.solve_status =#{neighborCircleAppDTO.solveStatus}
|
</if>
|
<if test="neighborCircleAppDTO.belongType !=null">
|
and canc.belong_type =#{neighborCircleAppDTO.belongType}
|
</if>
|
<if test="neighborCircleAppDTO.orderType !=null">
|
and canc.order_type =#{neighborCircleAppDTO.orderType}
|
</if>
|
</where> order by create_at desc
|
</select>
|
|
<select id="neighborDetailByApp" resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleDetailAppVO">
|
SELECT
|
canc.*,
|
su.nick_name as name,
|
su.community_id,
|
ca.`name` as communityName,
|
canct.name as topicName,
|
su.image_url as headUrl
|
FROM
|
com_act_neighbor_circle AS canc
|
left join sys_user as su on su.user_id = canc.release_id
|
left join com_act_neighbor_circle_topic as canct on canct.id = canc.topic_id
|
left join com_act as ca on ca.community_id = canc.community_id
|
where canc.id =#{circleId}
|
</select>
|
|
<select id="selectStatsCheckUnit" resultType="com.panzhihua.common.model.vos.neighbor.ServiceStaticsVO">
|
select count(t1.checkId) as times,sum(t1.hours) as hours from
|
((select real_service_time as hours,solve_unit_id as checkId from com_act_neighbor_circle where order_type = 1 and solve_status = 4 and solve_unit_id = #{checkUnitId} and create_at between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59'))
|
union all
|
(select duration as hours,check_unit_id as checkId from com_act_activity where check_unit_id = #{checkUnitId} and publish_at between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59'))) t1
|
</select>
|
<select id="selectListByCheckUnitId" resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAppVO">
|
SELECT
|
canc.*,
|
su.nick_name as name,
|
su.community_id,
|
ca.`name` as communityName,
|
canct.name as topicName,
|
su.image_url as headUrl
|
FROM
|
com_act_neighbor_circle AS canc
|
left join sys_user as su on su.user_id = canc.release_id
|
left join com_act_neighbor_circle_topic as canct on canct.id = canc.topic_id
|
left join com_act as ca on ca.community_id = canc.community_id
|
where is_del = 2 and canc.solve_status=4 and canc.solve_unit_id = #{checkUnitId} and canc.create_at between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59')
|
</select>
|
|
<select id="selectStatsUser" resultType="com.panzhihua.common.model.vos.neighbor.ServiceStaticsVO">
|
select count(t1.checkId) as times,sum(t1.hours) as hours from ((select real_service_time as hours,solve_id as checkId from com_act_neighbor_circle canc left join sys_user su on canc.solve_id = su.user_id where order_type = 2 and solve_status = 4 and su.phone = #{phone} and canc.create_at between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59')) union all
|
(select duration as hours,caas.user_id as checkId from com_act_activity caa LEFT JOIN com_act_act_regist caas on caa.id = caas.activity_id left join sys_user su on caas.user_id = su.user_id where caa.type !=5 and caas.end_time is not null and su.phone =#{phone} and publish_at between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59') group by caa.id)) t1
|
</select>
|
|
<select id="selectListByPhone" resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleAppVO">
|
SELECT
|
canc.*,
|
su.nick_name as name,
|
su.community_id,
|
ca.`name` as communityName,
|
canct.name as topicName,
|
su.image_url as headUrl
|
FROM
|
com_act_neighbor_circle AS canc
|
left join sys_user as su on su.user_id = canc.release_id
|
left join com_act_neighbor_circle_topic as canct on canct.id = canc.topic_id
|
left join com_act as ca on ca.community_id = canc.community_id
|
left join sys_user su1 on su1.user_id = canc.solve_id
|
where is_del = 2 and canc.solve_status=4 and su1.phone = #{phone} and canc.create_at between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59')
|
</select>
|
<select id="institutionalUnitServiceAnalysis"
|
resultType="com.panzhihua.common.model.vos.neighbor.UnitActivityAnalysisVO">
|
select canc.solve_unit_id as unitId,sum(canc.real_service_time) as serviceTime,count(canc.real_service_time) as serviceTimes,canc.community_id as communityId,cpcu.belong_to
|
from com_act_neighbor_circle as canc
|
left join com_pb_check_unit as cpcu on canc.solve_unit_id=cpcu.id
|
where canc.solve_unit_id<>''
|
<if test="beginTime != null">
|
and canc.create_at between #{beginTime} and #{endTime}
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
and belong_to=#{belongTo}
|
</if>
|
<if test="communityId != null">
|
and canc.community_id=#{communityId}
|
</if>
|
group by(canc.solve_unit_id)
|
having serviceTimes<>'' and serviceTime<>''
|
order by serviceTime desc
|
</select>
|
<select id="institutionalUnitActivityAnalysis"
|
resultType="com.panzhihua.common.model.vos.neighbor.UnitActivityAnalysisVO">
|
SELECT count(caa.check_unit_id) as serviceTimes,sum(caa.duration) as serviceTime,caa.check_unit_id as unitId,caa.community_id as communityId,cpcu.belong_to
|
FROM com_act_activity as caa
|
left join com_pb_check_unit as cpcu on caa.check_unit_id=cpcu.id
|
where caa.check_unit_id<>''
|
and caa.type=5
|
<if test="beginTime != null">
|
and caa.create_at between #{beginTime} and #{endTime}
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
and belong_to=#{belongTo}
|
</if>
|
<if test="communityId != null">
|
and caa.community_id=#{communityId}
|
</if>
|
GROUP BY (caa.check_unit_id)
|
having serviceTimes<>'' and serviceTime<>''
|
order by serviceTime desc
|
</select>
|
<select id="institutionalPartyMemberServiceAnalysis"
|
resultType="com.panzhihua.common.model.vos.neighbor.PartyMemberAnalysisVO">
|
SELECT count(caa.sponsor_id) as serviceTimes,sum(caa.duration) as serviceTime,caa.check_unit_id as unitId
|
,caa.community_id as communityId,caa.sponsor_id as memberId,su.name as memberName,su.relation_name as belongUnit,ca.name as belongCommunity,cpcu.belong_to
|
FROM `com_act_activity` as caa
|
left join com_act_act_sign as caas on caa.id=caas.activity_id
|
left join sys_user as su on caa.sponsor_id=su.user_id
|
left join com_act as ca on su.community_id=ca.community_id
|
left join com_pb_check_unit as cpcu on ca.community_id=cpcu.community_id
|
where caa.sponsor_id<>''
|
and caa.type=3
|
<if test="beginTime != null">
|
and caa.create_at between #{beginTime} and #{endTime}
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
and belong_to=#{belongTo}
|
</if>
|
<if test="communityId != null">
|
and su.community_id=#{communityId}
|
</if>
|
<if test="unitId != null">
|
and caa.check_unit_id=#{unitId}
|
</if>
|
GROUP BY (caa.sponsor_id)
|
having serviceTimes<>'' and serviceTime<>'' and memberName<>''
|
order by serviceTime desc
|
</select>
|
<select id="institutionalPartyMemberActAnalysis"
|
resultType="com.panzhihua.common.model.vos.neighbor.PartyMemberAnalysisVO">
|
SELECT count(canc.solve_id) as serviceTimes,sum(canc.real_service_time) as serviceTime
|
,canc.community_id as communityId,canc.solve_id as memberId,su.name as memberName,su.relation_name as belongUnit,ca.name as belongCommunity,cpcu.belong_to
|
FROM `com_act_neighbor_circle` as canc
|
left join sys_user as su on canc.solve_id=su.user_id
|
left join com_act as ca on su.community_id=ca.community_id
|
left join com_pb_check_unit as cpcu on ca.community_id=cpcu.community_id
|
where canc.solve_id<>''
|
<if test="beginTime != null">
|
and canc.create_at between #{beginTime} and #{endTime}
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
and belong_to=#{belongTo}
|
</if>
|
<if test="communityId != null">
|
and su.community_id=#{communityId}
|
</if>
|
<if test="unitId != null">
|
and cpcu.id=#{unitId}
|
</if>
|
GROUP BY (canc.solve_id)
|
having serviceTimes<>'' and serviceTime<>'' and memberName<>''
|
order by serviceTime desc
|
</select>
|
<select id="institutionalPartyMemberServiceAnalysisByServicesTimes"
|
resultType="com.panzhihua.common.model.vos.neighbor.PartyMemberAnalysisVO">
|
SELECT count(caa.check_unit_id) as serviceTimes,sum(caa.duration) as serviceTime,caa.check_unit_id as unitId,caa.community_id as communityId,cpcu.belong_to
|
FROM com_act_activity as caa
|
left join com_pb_check_unit as cpcu on caa.check_unit_id=cpcu.id
|
where caa.check_unit_id<>''
|
and caa.type=5
|
<if test="beginTime != null">
|
and caa.create_at between #{beginTime} and #{endTime}
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
and belong_to=#{belongTo}
|
</if>
|
GROUP BY (caa.check_unit_id)
|
having serviceTimes<>'' and serviceTime<>''
|
order by serviceTimes desc
|
</select>
|
</mapper>
|