|
|
|
<?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.epmet.dao.IssueVoteStatisticalDailyDao">
|
|
|
|
|
|
|
|
<resultMap type="com.epmet.entity.IssueVoteStatisticalDailyEntity" id="issueVoteStatisticalDailyMap">
|
|
|
|
<result property="id" column="ID"/>
|
|
|
|
<result property="issueId" column="ISSUE_ID"/>
|
|
|
|
<result property="statisticalDate" column="STATISTICAL_DATE"/>
|
|
|
|
<result property="supportCount" column="SUPPORT_COUNT"/>
|
|
|
|
<result property="oppositionCount" column="OPPOSITION_COUNT"/>
|
|
|
|
<result property="totalCount" column="TOTAL_COUNT"/>
|
|
|
|
<result property="todayIncrement" column="TODAY_INCREMENT"/>
|
|
|
|
<result property="supportIncrement" column="SUPPORT_INCREMENT"/>
|
|
|
|
<result property="oppositionIncrement" column="OPPOSITION_INCREMENT"/>
|
|
|
|
<result property="votableCount" column="VOTABLE_COUNT"/>
|
|
|
|
<result property="delFlag" column="DEL_FLAG"/>
|
|
|
|
<result property="revision" column="REVISION"/>
|
|
|
|
<result property="createdBy" column="CREATED_BY"/>
|
|
|
|
<result property="createdTime" column="CREATED_TIME"/>
|
|
|
|
<result property="updatedBy" column="UPDATED_BY"/>
|
|
|
|
<result property="updatedTime" column="UPDATED_TIME"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<!-- 生成昨日的话题统计信息 -->
|
|
|
|
<select id="getIssueVotingStatistical" resultType="com.epmet.dto.result.IssuesToBeCountedResultDTO">
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
issue.ID AS ISSUE_ID,
|
|
|
|
issue.ISSUE_STATUS,
|
|
|
|
vote.ATTITUDE,
|
|
|
|
IFNULL(vote.VOTE_COUNT,0)AS VOTE_COUNT,
|
|
|
|
totalvote.ATTITUDE AS ATTITUDE_UP_TO_YESTERDAY,
|
|
|
|
IFNULL(totalvote.VOTE_COUNT,0) AS VOTE_COUNT_UP_TO_YESTERDAY
|
|
|
|
FROM
|
|
|
|
ISSUE issue
|
|
|
|
|
|
|
|
LEFT JOIN (
|
|
|
|
SELECT ISSUE_ID ,
|
|
|
|
ATTITUDE,
|
|
|
|
count(ATTITUDE) AS VOTE_COUNT
|
|
|
|
FROM issue_vote_detail
|
|
|
|
WHERE DEL_FLAG = '0'
|
|
|
|
AND TO_DAYS( NOW( ) ) - TO_DAYS( CREATED_TIME ) <![CDATA[>]]> 0
|
|
|
|
GROUP BY ISSUE_ID , ATTITUDE
|
|
|
|
) totalvote ON issue.ID = totalvote.ISSUE_ID
|
|
|
|
|
|
|
|
LEFT JOIN (
|
|
|
|
SELECT ISSUE_ID ,
|
|
|
|
ATTITUDE,
|
|
|
|
count(ATTITUDE) AS VOTE_COUNT
|
|
|
|
FROM issue_vote_detail
|
|
|
|
WHERE DEL_FLAG = '0'
|
|
|
|
AND TO_DAYS( NOW( ) ) - TO_DAYS( CREATED_TIME ) <![CDATA[<=]]> 1
|
|
|
|
AND TO_DAYS( NOW( ) ) - TO_DAYS( CREATED_TIME ) <![CDATA[>]]> 0
|
|
|
|
GROUP BY ISSUE_ID , ATTITUDE
|
|
|
|
) vote ON issue.ID = vote.ISSUE_ID AND totalvote.ATTITUDE = vote.ATTITUDE
|
|
|
|
|
|
|
|
WHERE
|
|
|
|
issue.DEL_FLAG = '0'
|
|
|
|
AND (
|
|
|
|
issue.ISSUE_STATUS = 'voting'
|
|
|
|
OR (
|
|
|
|
TO_DAYS( NOW( ) ) - TO_DAYS( issue.CLOSED_TIME ) <![CDATA[<=]]> 1
|
|
|
|
AND
|
|
|
|
TO_DAYS( NOW( ) ) - TO_DAYS( issue.CLOSED_TIME ) <![CDATA[>]]> 0
|
|
|
|
)
|
|
|
|
OR (
|
|
|
|
TO_DAYS( NOW( ) ) - TO_DAYS( issue.SHIFTED_TIME ) <![CDATA[<=]]> 1
|
|
|
|
AND
|
|
|
|
TO_DAYS( NOW( ) ) - TO_DAYS( issue.SHIFTED_TIME ) > 0
|
|
|
|
)
|
|
|
|
)
|
|
|
|
ORDER BY
|
|
|
|
issue.ID
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 生成截止到昨日的话题统计信息 -->
|
|
|
|
<select id="getIssueVotingStatisticalUpToYesterday" resultType="com.epmet.dto.result.IssuesToBeCountedResultDTO">
|
|
|
|
SELECT
|
|
|
|
issue.ID AS ISSUE_ID,
|
|
|
|
issue.ISSUE_STATUS,
|
|
|
|
totalvote.ATTITUDE,
|
|
|
|
IFNULL(totalvote.VOTE_COUNT,0) AS VOTE_COUNT_UP_TO_YESTERDAY
|
|
|
|
FROM
|
|
|
|
ISSUE issue
|
|
|
|
LEFT JOIN (
|
|
|
|
SELECT ISSUE_ID , ATTITUDE,count(ATTITUDE) AS VOTE_COUNT FROM issue_vote_detail WHERE DEL_FLAG = '0'
|
|
|
|
AND TO_DAYS( NOW( ) ) - TO_DAYS( CREATED_TIME ) > 0
|
|
|
|
GROUP BY ISSUE_ID , ATTITUDE
|
|
|
|
) totalvote ON issue.ID = totalvote.ISSUE_ID
|
|
|
|
WHERE
|
|
|
|
issue.DEL_FLAG = '0'
|
|
|
|
AND (
|
|
|
|
issue.ISSUE_STATUS = 'voting'
|
|
|
|
OR (
|
|
|
|
TO_DAYS( NOW( ) ) - TO_DAYS( issue.CLOSED_TIME ) <![CDATA[<=]]> 1 AND TO_DAYS( NOW( ) ) - TO_DAYS( issue.CLOSED_TIME ) > 0
|
|
|
|
)
|
|
|
|
OR (
|
|
|
|
TO_DAYS( NOW( ) ) - TO_DAYS( issue.SHIFTED_TIME ) <![CDATA[<=]]> 1 AND TO_DAYS( NOW( ) ) - TO_DAYS( issue.SHIFTED_TIME ) > 0
|
|
|
|
)
|
|
|
|
)
|
|
|
|
ORDER BY
|
|
|
|
issue.ID
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 通过议题Id和统计日期查找日统计信息 -->
|
|
|
|
<select id="getDailyStatisticalCountByIssueIdAndStatisticalDate" parameterType="com.epmet.entity.IssueVoteStatisticalDailyEntity" resultType="com.epmet.entity.IssueVoteStatisticalDailyEntity">
|
|
|
|
SELECT
|
|
|
|
*
|
|
|
|
FROM
|
|
|
|
issue_vote_statistical_daily
|
|
|
|
WHERE
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
AND
|
|
|
|
TO_DAYS( #{statisticalDate} ) - TO_DAYS( STATISTICAL_DATE ) = 0
|
|
|
|
AND
|
|
|
|
ISSUE_ID = #{issueId}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 批量添加 -->
|
|
|
|
<insert id="insertBatch" parameterType="java.util.List">
|
|
|
|
INSERT INTO issue_vote_statistical_daily
|
|
|
|
(
|
|
|
|
id,
|
|
|
|
|
|
|
|
issue_id,
|
|
|
|
|
|
|
|
statistical_date,
|
|
|
|
|
|
|
|
support_count,
|
|
|
|
|
|
|
|
opposition_count,
|
|
|
|
|
|
|
|
total_count,
|
|
|
|
|
|
|
|
today_increment,
|
|
|
|
|
|
|
|
support_increment,
|
|
|
|
|
|
|
|
opposition_increment,
|
|
|
|
|
|
|
|
votable_count,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
created_by,
|
|
|
|
|
|
|
|
created_time,
|
|
|
|
|
|
|
|
updated_by,
|
|
|
|
|
|
|
|
updated_time
|
|
|
|
|
|
|
|
) values
|
|
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
|
|
(
|
|
|
|
(SELECT REPLACE(UUID(), '-', '') AS id),
|
|
|
|
|
|
|
|
#{item.issueId},
|
|
|
|
|
|
|
|
#{item.statisticalDate},
|
|
|
|
|
|
|
|
#{item.supportCount},
|
|
|
|
|
|
|
|
#{item.oppositionCount},
|
|
|
|
|
|
|
|
#{item.totalCount},
|
|
|
|
|
|
|
|
#{item.todayIncrement},
|
|
|
|
|
|
|
|
#{item.supportIncrement},
|
|
|
|
|
|
|
|
#{item.oppositionIncrement},
|
|
|
|
|
|
|
|
#{item.votableCount},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#{item.createdBy},
|
|
|
|
|
|
|
|
now(),
|
|
|
|
|
|
|
|
#{item.createdBy},
|
|
|
|
|
|
|
|
now()
|
|
|
|
)
|
|
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<!-- 批量更新 -->
|
|
|
|
<update id="updateBatch" >
|
|
|
|
UPDATE issue_vote_statistical_daily
|
|
|
|
<trim prefix="set" suffixOverrides=",">
|
|
|
|
|
|
|
|
<trim prefix="support_count =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.supportCount'>
|
|
|
|
when id = #{item.id} then #{item.supportCount}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="opposition_count =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.oppositionCount'>
|
|
|
|
when id = #{item.id} then #{item.oppositionCount}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="total_count =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.totalCount'>
|
|
|
|
when id = #{item.id} then #{item.totalCount}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="today_increment =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.todayIncrement'>
|
|
|
|
when id = #{item.id} then #{item.todayIncrement}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="support_increment =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.supportIncrement'>
|
|
|
|
when id = #{item.id} then #{item.supportIncrement}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="opposition_increment =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.oppositionIncrement'>
|
|
|
|
when id = #{item.id} then #{item.oppositionIncrement}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="votable_count =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.votableCount'>
|
|
|
|
when id = #{item.id} then #{item.votableCount}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="del_flag =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.delFlag'>
|
|
|
|
when id = #{item.id} then #{item.delFlag}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="updated_by =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.updatedBy'>
|
|
|
|
when id = #{item.id} then #{item.updatedBy}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
|
|
|
|
updated_time = now()
|
|
|
|
|
|
|
|
</trim>
|
|
|
|
WHERE
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
<foreach collection="list" item="item" open="AND( " separator=" OR " index="index" close=")">
|
|
|
|
id = #{item.id}
|
|
|
|
</foreach>
|
|
|
|
</update>
|
|
|
|
</mapper>
|