<?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 in
|
<foreach collection="neighborCircleAppDTO.communityIds" item="item" index="index" open="(" separator="," close=")">
|
${item}
|
</foreach>
|
<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>
|
<if test="neighborCircleAppDTO.solveStatus !=null">
|
<if test="neighborCircleAppDTO.solveStatus ==1">
|
and canc.solve_status in (0,1)
|
</if>
|
<if test="neighborCircleAppDTO.solveStatus ==2">
|
and canc.solve_status =2
|
</if>
|
<if test="neighborCircleAppDTO.solveStatus ==3">
|
and canc.solve_status in(3,4)
|
</if>
|
</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 in
|
<foreach collection="neighborCircleAdminDTO.communityIds" item="item" index="index" open="(" separator="," close=")">
|
${item}
|
</foreach>
|
and is_del = 2
|
<if test='neighborCircleAdminDTO.releaseContent != null and neighborCircleAdminDTO.releaseContent != ""'>
|
and nc.release_content like concat('%',#{neighborCircleAdminDTO.releaseContent},'%')
|
</if>
|
<if test='neighborCircleAdminDTO.topicId != null '>
|
and canc.topic_id = #{neighborCircleAdminDTO.topicId}
|
</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>
|
<if test="neighborCircleAdminDTO.solveStatus !=null">
|
<if test="neighborCircleAdminDTO.solveStatus ==1">
|
and nc.solve_status in (0,1)
|
</if>
|
<if test="neighborCircleAdminDTO.solveStatus ==2">
|
and nc.solve_status =2
|
</if>
|
<if test="neighborCircleAdminDTO.solveStatus ==3">
|
and nc.solve_status in(3,4)
|
</if>
|
</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-->
|
<!-- 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 id="neighborDetailByApp" resultType="com.panzhihua.common.model.vos.neighbor.ComActNeighborCircleDetailAppVO">
|
|
SELECT
|
canc.*,
|
su.nick_name as name,
|
su.community_id as communityId,
|
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,COALESCE(sum(t1.hours),0) as hours from
|
((select real_service_time as hours,solve_unit_id as checkId from com_act_neighbor_circle where order_type = 1 AND is_del = 2 and solve_status = 4 and solve_unit_id = #{checkUnitId} and order_time 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 `status` = 5 and publish_at between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59'))
|
union all
|
(SELECT a.duration AS hours,s.check_unit_id AS checkId FROM com_act_activity a LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
WHERE s.end_time IS NOT NULL AND s.check_unit_id = #{checkUnitId} AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' ) AND concat( #{date}, '-12-31 23:59:59' ) GROUP BY a.id)
|
) 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="selectServiceDetailList" resultType="com.panzhihua.common.model.vos.neighbor.ServiceDetailStaticsVO">
|
<if test="serviceType == null">
|
SELECT * FROM (
|
SELECT
|
id AS serviceId,
|
order_time AS serviceAt,
|
real_service_time AS serviceTime,
|
1 AS serviceType
|
FROM
|
com_act_neighbor_circle
|
WHERE
|
order_type = 1
|
AND is_del = 2
|
AND solve_status = 4
|
AND solve_unit_id = #{checkUnitId}
|
AND order_time BETWEEN concat(#{date}, '-01-01 00:00:00')
|
AND concat(#{date}, '-12-31 23:59:59')
|
UNION ALL
|
SELECT
|
a.id AS serviceId,
|
a.publish_at AS serviceAt,
|
a.duration AS serviceTime,
|
2 AS serviceType
|
FROM
|
com_act_activity a
|
LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
WHERE
|
s.end_time IS NOT NULL
|
AND s.check_unit_id = #{checkUnitId}
|
AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
GROUP BY
|
a.id
|
UNION ALL
|
SELECT
|
id AS serviceId,
|
publish_at AS serviceAt,
|
duration AS serviceTime,
|
3 AS serviceType
|
FROM
|
com_act_activity
|
WHERE
|
check_unit_id = #{checkUnitId}
|
AND `status` = 5
|
AND publish_at BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
) temp ORDER BY serviceAt
|
</if>
|
<if test="serviceType == 1">
|
SELECT
|
id AS serviceId,
|
order_time AS serviceAt,
|
real_service_time AS serviceTime,
|
1 AS serviceType
|
FROM
|
com_act_neighbor_circle
|
WHERE
|
order_type = 1
|
AND is_del = 2
|
AND solve_status = 4
|
AND solve_unit_id = #{checkUnitId}
|
AND order_time BETWEEN concat(#{date}, '-01-01 00:00:00')
|
AND concat(#{date}, '-12-31 23:59:59')
|
ORDER BY serviceAt
|
</if>
|
<if test="serviceType == 2">
|
SELECT
|
a.id AS serviceId,
|
a.publish_at AS serviceAt,
|
a.duration AS serviceTime,
|
2 AS serviceType
|
FROM
|
com_act_activity a
|
LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
WHERE
|
s.end_time IS NOT NULL
|
AND s.check_unit_id = #{checkUnitId}
|
AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
GROUP BY a.id
|
ORDER BY serviceAt
|
</if>
|
<if test="serviceType == 3">
|
SELECT
|
id AS serviceId,
|
publish_at AS serviceAt,
|
duration AS serviceTime,
|
3 AS serviceType
|
FROM
|
com_act_activity
|
WHERE
|
check_unit_id = #{checkUnitId}
|
AND `status` = 5
|
AND publish_at BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
ORDER BY serviceAt
|
</if>
|
</select>
|
|
<select id="selectServiceDetailListForPersonal" resultType="com.panzhihua.common.model.vos.neighbor.ServiceDetailStaticsVO">
|
<if test="serviceType == null">
|
SELECT * FROM (
|
SELECT
|
canc.id AS serviceId,
|
canc.order_time AS serviceAt,
|
canc.real_service_time AS serviceTime,
|
1 AS serviceType
|
FROM
|
com_act_neighbor_circle AS canc
|
LEFT JOIN sys_user su1 ON su1.user_id = canc.solve_id
|
WHERE
|
canc.order_type = 2
|
AND canc.is_del = 2
|
AND canc.solve_status = 4
|
AND su1.phone = #{phone}
|
AND canc.order_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
<if test="checkUnitId != null and checkUnitId != '' ">
|
UNION ALL
|
SELECT
|
a.id AS serviceId,
|
a.publish_at AS serviceAt,
|
ROUND((TIMESTAMPDIFF(SECOND, s.start_time, s.end_time) / 3600), 2) as serviceTime,
|
2 AS serviceType
|
FROM
|
com_act_activity a
|
LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
LEFT JOIN sys_user su ON su.user_id = s.user_id
|
WHERE
|
s.end_time IS NOT NULL
|
AND s.check_unit_id = #{checkUnitId}
|
AND su.phone = #{phone}
|
AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
and s.start_time IS NOT NULL
|
and s.end_time IS NOT NULL
|
GROUP BY
|
a.id
|
</if>
|
UNION ALL
|
SELECT
|
a.id AS serviceId,
|
a.publish_at AS serviceAt,
|
ROUND((TIMESTAMPDIFF(SECOND, s.start_time, s.end_time) / 3600), 2) AS serviceTime,
|
3 AS serviceType
|
FROM
|
com_act_activity a
|
LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
LEFT JOIN sys_user su ON su.user_id = s.user_id
|
WHERE
|
s.end_time IS NOT NULL
|
AND a.check_unit_id IS NOT NULL
|
AND su.phone = #{phone}
|
AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
GROUP BY
|
a.id
|
UNION ALL
|
SELECT
|
a.id AS serviceId,
|
a.publish_at AS serviceAt,
|
ROUND((TIMESTAMPDIFF(SECOND, s.start_time, s.end_time) / 3600), 2) AS serviceTime,
|
4 AS serviceType
|
FROM
|
com_act_activity a
|
LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
LEFT JOIN sys_user su ON su.user_id = s.user_id
|
WHERE
|
s.end_time IS NOT NULL
|
AND s.check_unit_id IS NULL
|
AND s.sign_identity = 2
|
AND su.phone = #{phone}
|
AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
GROUP BY
|
a.id
|
) temp ORDER BY serviceAt
|
</if>
|
<if test="serviceType == 1">
|
SELECT
|
canc.id AS serviceId,
|
canc.order_time AS serviceAt,
|
canc.real_service_time AS serviceTime,
|
1 AS serviceType
|
FROM
|
com_act_neighbor_circle AS canc
|
LEFT JOIN sys_user su1 ON su1.user_id = canc.solve_id
|
WHERE
|
canc.order_type = 2
|
AND canc.is_del = 2
|
AND canc.solve_status = 4
|
AND su1.phone = #{phone}
|
AND canc.order_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
ORDER BY serviceAt
|
</if>
|
<if test="serviceType == 2 and checkUnitId != null">
|
SELECT
|
a.id AS serviceId,
|
a.publish_at AS serviceAt,
|
ROUND((TIMESTAMPDIFF(SECOND, s.start_time, s.end_time) / 3600), 2) AS serviceTime,
|
2 AS serviceType
|
FROM
|
com_act_activity a
|
LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
LEFT JOIN sys_user su ON su.user_id = s.user_id
|
WHERE
|
s.end_time IS NOT NULL
|
AND s.check_unit_id = #{checkUnitId}
|
AND su.phone = #{phone}
|
AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
GROUP BY a.id
|
ORDER BY serviceAt
|
</if>
|
<if test="serviceType == 3">
|
SELECT
|
a.id AS serviceId,
|
a.publish_at AS serviceAt,
|
ROUND((TIMESTAMPDIFF(SECOND, s.start_time, s.end_time) / 3600), 2) AS serviceTime,
|
3 AS serviceType
|
FROM
|
com_act_activity a
|
LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
LEFT JOIN sys_user su ON su.user_id = s.user_id
|
WHERE
|
s.end_time IS NOT NULL
|
AND a.check_unit_id IS NOT NULL
|
AND su.phone = #{phone}
|
AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
GROUP BY a.id
|
ORDER BY serviceAt
|
</if>
|
<if test="serviceType == 4">
|
SELECT
|
a.id AS serviceId,
|
a.publish_at AS serviceAt,
|
ROUND((TIMESTAMPDIFF(SECOND, s.start_time, s.end_time) / 3600), 2) AS serviceTime,
|
4 AS serviceType
|
FROM
|
com_act_activity a
|
LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
LEFT JOIN sys_user su ON su.user_id = s.user_id
|
WHERE
|
s.end_time IS NOT NULL
|
AND a.check_unit_id IS NULL
|
AND s.sign_identity = 2
|
AND su.phone = #{phone}
|
AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
GROUP BY a.id
|
ORDER BY serviceAt
|
</if>
|
</select>
|
|
|
<select id="getNewServiceNum" resultType="com.panzhihua.service_community.entity.NewFightNeedProblemClaim">
|
SELECT
|
id,
|
user_id,
|
update_time,
|
unit_id,
|
task_id,
|
service_time,
|
punch_start_time,
|
punch_end_time,
|
creation_time
|
FROM new_fight_need_problem_claim
|
<where>
|
service_time is not null
|
<if test=" phone != null and phone != '' ">
|
and user_id =(SELECT user_id FROM sys_user WHERE phone=#{phone}
|
and app_id="wx118de8a734d269f0" and type=1)
|
</if>
|
<if test=" unitId != null and unitId != '' ">
|
and unit_id =#{unitId}
|
</if>
|
</where>
|
|
</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 canc.is_del = 2 and solve_status = 4
|
and su.phone = #{phone} and canc.order_time between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59'))
|
union all
|
(select ROUND((TIMESTAMPDIFF(SECOND, caas.start_time, caas.end_time) / 3600), 2) 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 caas.sign_identity = 2
|
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')
|
and caas.start_time IS NOT NULL
|
and caas.end_time IS NOT NULL
|
and caas.check_unit_id IS NULL
|
group by caa.id)
|
|
<if test="checkUnitId != null and checkUnitId!='' ">
|
UNION ALL
|
(SELECT
|
ROUND((TIMESTAMPDIFF(SECOND, s.start_time, s.end_time) / 3600), 2) as hours,
|
a.id AS checkId
|
FROM
|
com_act_activity a
|
LEFT JOIN com_act_act_regist s ON a.id = s.activity_id
|
LEFT JOIN sys_user su ON su.user_id = s.user_id
|
WHERE
|
s.end_time IS NOT NULL
|
AND s.check_unit_id = #{checkUnitId}
|
AND su.phone = #{phone}
|
AND s.start_time BETWEEN concat( #{date}, '-01-01 00:00:00' )
|
AND concat( #{date}, '-12-31 23:59:59' )
|
and s.start_time IS NOT NULL
|
and s.end_time IS NOT NULL
|
GROUP BY
|
a.id)
|
</if>
|
) 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 as belongTo,cpcu.org_name as orgName
|
from com_act_neighbor_circle as canc
|
left join com_pb_check_unit as cpcu on canc.solve_unit_id=cpcu.id
|
where
|
canc.order_type = 1
|
AND is_del = 2
|
AND solve_status = 4
|
AND canc.solve_unit_id<>''
|
<if test="beginTime != null">
|
and canc.order_time 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>
|
<if test="unitId != null and unitId != ''">
|
and canc.solve_unit_id = #{unitId}
|
</if>
|
group by(canc.solve_unit_id)
|
having serviceTimes<>'' and serviceTime<>''
|
order by serviceTime desc
|
</select>
|
|
<select id="getNewTaskList" resultType="com.panzhihua.common.model.vos.neighbor.UnitActivityAnalysisVO">
|
SELECT
|
nfnpc.unit_id,
|
sum(nfnpc.service_time) as serviceTime,
|
count(nfnpc.service_time) as serviceTimes,
|
cpcu.belong_to as belongTo,
|
cpcu.org_name as orgName,
|
cpcu.community_id,
|
sum(nfnpi.award) as awardSum
|
FROM new_fight_need_problem_claim as nfnpc
|
left join com_pb_check_unit as cpcu on nfnpc.unit_id=cpcu.id
|
LEFT JOIN new_fight_need_problem_inventory as nfnpi on nfnpc.task_id=nfnpi.id
|
WHERE nfnpc.service_time iS NOT NULL AND nfnpc.unit_id IS NOT NULL
|
<if test="beginTime != null">
|
and nfnpc.creation_time between #{beginTime} and #{endTime}
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
and cpcu.belong_to=#{belongTo}
|
</if>
|
<if test="communityId != null">
|
and cpcu.community_id=#{communityId}
|
</if>
|
group by nfnpc.unit_id
|
having serviceTimes<>'' and serviceTime<>''
|
order by serviceTime desc
|
</select>
|
|
|
|
|
<select id="institutionalUnitActivityAnalysis"
|
resultType="com.panzhihua.common.model.vos.neighbor.UnitActivityAnalysisVO">
|
SELECT sum(serviceTimes) AS serviceTimes, sum(serviceTime) as serviceTime, unitId, communityId, belong_to, sum(award) as awardSum
|
FROM (
|
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,caa.pb_reward_integral as award
|
FROM com_act_activity as caa
|
left join com_pb_check_unit as cpcu on caa.check_unit_id=cpcu.id
|
where caa.`status` = 5 AND caa.check_unit_id<>''
|
and caa.type=5
|
<if test="beginTime != null">
|
and caa.publish_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>
|
<if test="unitId != null and unitId != ''">
|
and caa.check_unit_id = #{unitId}
|
</if>
|
GROUP BY (caa.check_unit_id)
|
UNION ALL
|
SELECT count(id) as serviceTimes, sum(duration) as serviceTime, check_unit_id as unitId, community_id as
|
communityId, belong_to,award
|
FROM(
|
SELECT caa.id, caa.duration, s.check_unit_id , cpcu.community_id , cpcu.belong_to,caa.pb_reward_integral as award
|
FROM com_act_activity caa
|
LEFT JOIN com_act_act_regist s ON caa.id = s.activity_id
|
left join com_pb_check_unit as cpcu on s.check_unit_id = cpcu.id
|
WHERE s.end_time IS NOT NULL AND s.check_unit_id IS NOT NULL
|
<if test="beginTime != null">
|
AND s.start_time 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>
|
<if test="unitId != null and unitId != ''">
|
and caa.check_unit_id = #{unitId}
|
</if>
|
GROUP BY caa.id,s.check_unit_id
|
) temp
|
GROUP BY check_unit_id
|
) temp2 GROUP BY unitId
|
having serviceTimes<>'' and serviceTime<>''
|
order by serviceTime desc
|
</select>
|
|
|
<select id="getNewPartyMemberTaskList" resultType="com.panzhihua.common.model.vos.neighbor.PartyMemberAnalysisVO">
|
SELECT
|
nfnpc.unit_id,
|
sum(nfnpc.service_time) as serviceTime,
|
count(nfnpc.service_time) as serviceTimes,
|
cpcu.belong_to as belongTo,
|
cpcu.org_name as orgName,
|
nfnpi.community_id,
|
sum(nfnpi.award) as partyCount,
|
cpcu.name as unitName,
|
cpcu.org_name as orgName,
|
nfnpc.user_id as memberId,
|
su.name as memberName,
|
cpcu.name as belongUnit,
|
ca.name as belongCommunity
|
FROM new_fight_need_problem_claim as nfnpc
|
left join sys_user as su on nfnpc.user_id=su.user_id
|
left join com_pb_check_unit as cpcu on nfnpc.unit_id=cpcu.id
|
LEFT JOIN new_fight_need_problem_inventory as nfnpi on nfnpc.task_id=nfnpi.id
|
left join com_act as ca on nfnpi.community_id=ca.community_id
|
WHERE nfnpc.service_time iS NOT NULL
|
<if test="beginTime != null">
|
and nfnpc.creation_time between #{beginTime} and #{endTime}
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
and cpcu.belong_to=#{belongTo}
|
</if>
|
<if test="communityId != null">
|
and nfnpi.community_id=#{communityId}
|
</if>
|
<if test="unitId != null">
|
and cpcu.id=#{unitId}
|
</if>
|
<if test="searchContent != null and searchContent != ''">
|
and (su.name like concat('%',#{searchContent},'%')
|
or su.phone like concat('%',#{searchContent},'%')
|
or ca.name like concat('%',#{searchContent},'%')
|
or cpcu.name like concat('%',#{searchContent},'%'))
|
</if>
|
group by nfnpc.user_id
|
having serviceTimes<>'' and serviceTime<>''
|
order by serviceTime desc
|
</select>
|
|
|
|
<select id="institutionalPartyMemberServiceAnalysis"
|
resultType="com.panzhihua.common.model.vos.neighbor.PartyMemberAnalysisVO">
|
SELECT count(id) as serviceTimes, sum(duration) as serviceTime, unitId,unitName,orgName,
|
communityId, memberId, memberName, belongUnit, belongCommunity, belongTo,sum(award) as partyCount
|
FROM (
|
SELECT caa.id, ROUND((TIMESTAMPDIFF(SECOND, caar.start_time, caar.end_time) / 3600), 2) as duration, cpcu.id as unitId,cpcu.name as unitName,cpcu.org_name as orgName, cpcu.community_id as communityId, su.user_id as
|
memberId, su.name as memberName, cpcu.name as belongUnit, ca.name as belongCommunity, cpcu.belong_to belongTo,caa.pb_reward_integral as award
|
FROM `com_act_activity` as caa
|
left join com_act_act_regist as caar on caa.id=caar.activity_id
|
left join sys_user as su on caar.user_id=su.user_id
|
left join com_pb_member as cpm on su.phone=cpm.phone
|
left join com_pb_check_unit as cpcu on cpm.check_unit_id=cpcu.id
|
left join com_act as ca on cpcu.community_id=ca.community_id
|
where caar.sign_identity = 2
|
AND cpcu.id IS NOT NULL
|
and caar.start_time IS NOT NULL
|
and caar.end_time IS NOT NULL
|
<if test="beginTime != null">
|
and caar.start_time between #{beginTime} and #{endTime}
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
and cpcu.belong_to=#{belongTo}
|
</if>
|
<if test="communityId != null">
|
and cpcu.community_id=#{communityId}
|
</if>
|
<if test="unitId != null">
|
and cpcu.id=#{unitId}
|
</if>
|
<if test="searchContent != null and searchContent != ''">
|
and (su.name like concat('%',#{searchContent},'%')
|
or su.phone like concat('%',#{searchContent},'%')
|
or ca.name like concat('%',#{searchContent},'%')
|
or cpcu.name like concat('%',#{searchContent},'%'))
|
</if>
|
GROUP BY caa.id,caar.user_id
|
) temp GROUP BY memberId
|
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
|
,cpcu.community_id as communityId,canc.solve_id as memberId,su.name as memberName,cpcu.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_pb_member as cpm on su.phone=cpm.phone
|
left join com_pb_check_unit as cpcu on cpm.check_unit_id=cpcu.id
|
left join com_act as ca on cpcu.community_id=ca.community_id
|
where cpcu.id IS NOT NULL
|
<if test="beginTime != null">
|
and canc.order_time between #{beginTime} and #{endTime}
|
</if>
|
<if test="belongTo != null and belongTo != ''">
|
and cpcu.belong_to=#{belongTo}
|
</if>
|
<if test="communityId != null">
|
and cpcu.community_id=#{communityId}
|
</if>
|
<if test="unitId != null">
|
and cpcu.id=#{unitId}
|
</if>
|
<if test="searchContent != null and searchContent != ''">
|
and (su.name like concat('%',#{searchContent},'%')
|
or su.phone like concat('%',#{searchContent},'%')
|
or ca.name like concat('%',#{searchContent},'%')
|
or cpcu.name like concat('%',#{searchContent},'%'))
|
</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>
|
<select id="selectCount" resultType="Integer">
|
select count(id) from com_act_neighbor_circle
|
<where>
|
<if test="type!=null">
|
and belong_type = #{type}
|
</if>
|
<if test="phone!=null and phone !=''">
|
and (help_member_content like concat('%',#{phone},'%') or help_org_content like concat('%',#{phone},'%') )
|
</if>
|
<if test="communityId!=null">
|
and community_id = #{communityId}
|
</if>
|
</where>
|
</select>
|
<select id="pageRelationList"
|
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 com_act_activity t ON canc.id = t.relation_id
|
where is_del = 2 and canc.status = 2 AND canc.order_type = 1 and canc.solve_status in (2,3,4) and canc.community_id = ${neighborCircleAppDTO.communityId} AND t.id IS NULL
|
<if test='neighborCircleAppDTO.topicId != null '>
|
and canc.topic_id = #{neighborCircleAppDTO.topicId}
|
</if>
|
<if test='neighborCircleAppDTO.checkUnitId != null '>
|
and canc.solve_unit_id = #{neighborCircleAppDTO.checkUnitId}
|
</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>
|
|
<select id="pageNeighborByBigScreen" 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.belong_type in (2,3) and is_del = 2
|
|
<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.status != null '>
|
and nc.status = #{neighborCircleAdminDTO.status}
|
</if>
|
<!-- <if test='neighborCircleAdminDTO.belongType != null '>-->
|
<!-- and nc.belong_type = #{neighborCircleAdminDTO.belongType}-->
|
<!-- </if>-->
|
<if test="neighborCircleAdminDTO.solveStatus !=null">
|
<if test="neighborCircleAdminDTO.solveStatus ==1">
|
and nc.solve_status in (0,1)
|
</if>
|
<if test="neighborCircleAdminDTO.solveStatus ==2">
|
and nc.solve_status =2
|
</if>
|
<if test="neighborCircleAdminDTO.solveStatus ==3">
|
and nc.solve_status in(3,4)
|
</if>
|
</if>
|
</where>
|
order by nc.create_at desc
|
</select>
|
</mapper>
|