|
|
|
<?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.IssueVoteStatisticalDao">
|
|
|
|
|
|
|
|
<resultMap type="com.epmet.entity.IssueVoteStatisticalEntity" id="issueVoteStatisticalMap">
|
|
|
|
<result property="id" column="ID"/>
|
|
|
|
<result property="issueId" column="ISSUE_ID"/>
|
|
|
|
<result property="supportCount" column="SUPPORT_COUNT"/>
|
|
|
|
<result property="oppositionCount" column="OPPOSITION_COUNT"/>
|
|
|
|
<result property="votableCount" column="VOTABLE_COUNT"/>
|
|
|
|
<result property="revision" column="REVISION"/>
|
|
|
|
<result property="delFlag" column="DEL_FLAG"/>
|
|
|
|
<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="voteCount" parameterType="com.epmet.dto.form.IssueIdFormDTO" resultType="com.epmet.dto.result.VoteResultDTO">
|
|
|
|
SELECT
|
|
|
|
support_count AS supportCount,
|
|
|
|
opposition_count AS oppositionCount
|
|
|
|
FROM
|
|
|
|
issue_vote_statistical
|
|
|
|
WHERE
|
|
|
|
issue_id = #{issueId}
|
|
|
|
AND del_flag = 0
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 校验是否投票(表决中详情——支持、反对) -->
|
|
|
|
<select id="checkVote" resultType="java.lang.String">
|
|
|
|
SELECT
|
|
|
|
attitude AS voteType
|
|
|
|
FROM
|
|
|
|
issue_vote_detail
|
|
|
|
WHERE
|
|
|
|
del_flag = 0
|
|
|
|
AND issue_id = #{issueId}
|
|
|
|
AND created_by = #{userId}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 议题表决折线图 -->
|
|
|
|
<select id="votingTrend" resultType="com.epmet.dto.result.VotingTrendResultDTO">
|
|
|
|
SELECT
|
|
|
|
votable_count AS shouldVoteCount,
|
|
|
|
( support_count + opposition_count ) AS realityVoteCount,
|
|
|
|
support_count AS supportAmount,
|
|
|
|
opposition_count AS oppositionAmount
|
|
|
|
FROM
|
|
|
|
issue_vote_statistical
|
|
|
|
WHERE
|
|
|
|
del_flag = 0
|
|
|
|
AND issue_id = #{issueId}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 获取折线每天的支持、反对数量 (按时间正序) -->
|
|
|
|
<select id="polyLineData" parameterType="com.epmet.dto.form.IssueIdFormDTO" resultType="com.epmet.dto.PolyLineDTO">
|
|
|
|
SELECT
|
|
|
|
UNIX_TIMESTAMP(statistical_date) AS voteDate,
|
|
|
|
support_increment AS supportIncrement,
|
|
|
|
opposition_increment AS oppositionIncrement
|
|
|
|
FROM
|
|
|
|
issue_vote_statistical_daily
|
|
|
|
WHERE
|
|
|
|
issue_id = #{issueId}
|
|
|
|
AND del_flag = 0
|
|
|
|
ORDER BY statistical_date ASC
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectListByissueId" resultType="com.epmet.entity.IssueVoteStatisticalEntity">
|
|
|
|
SELECT
|
|
|
|
*
|
|
|
|
FROM
|
|
|
|
issue_vote_statistical
|
|
|
|
WHERE del_flag = '0'
|
|
|
|
<foreach item="issueId" collection="issueIdList" separator="OR" open="AND (" close=")" index="">
|
|
|
|
issue_id = #{issueId}
|
|
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 得到表决中的议题 来进行缓存与数据库的同步 -->
|
|
|
|
<select id="getVotingIssuesStatisticalForSync" resultType="com.epmet.dto.IssueVoteStatisticalDTO" >
|
|
|
|
SELECT
|
|
|
|
vote.ID,
|
|
|
|
issue.ID AS issueId,
|
|
|
|
vote.SUPPORT_COUNT,
|
|
|
|
vote.OPPOSITION_COUNT,
|
|
|
|
vote.VOTABLE_COUNT
|
|
|
|
FROM
|
|
|
|
ISSUE issue
|
|
|
|
LEFT JOIN ISSUE_VOTE_STATISTICAL vote ON issue.ID = vote.ISSUE_ID
|
|
|
|
AND vote.DEL_FLAG = '0'
|
|
|
|
WHERE
|
|
|
|
issue.DEL_FLAG = '0'
|
|
|
|
AND issue.ISSUE_STATUS = 'voting'
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 通过IssueId获取 -->
|
|
|
|
<select id="selectByIssueId" resultType="com.epmet.dto.IssueVoteStatisticalDTO">
|
|
|
|
SELECT
|
|
|
|
*
|
|
|
|
FROM
|
|
|
|
ISSUE_VOTE_STATISTICAL
|
|
|
|
WHERE
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
AND
|
|
|
|
ISSUE_ID = #{issueId}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 得到指定Id的统计数据 -->
|
|
|
|
<select id="selectListByIds" resultType="com.epmet.dto.IssueVoteStatisticalDTO">
|
|
|
|
SELECT
|
|
|
|
ID,
|
|
|
|
ISSUE_ID,
|
|
|
|
SUPPORT_COUNT,
|
|
|
|
OPPOSITION_COUNT,
|
|
|
|
VOTABLE_COUNT
|
|
|
|
FROM
|
|
|
|
ISSUE_VOTE_STATISTICAL
|
|
|
|
WHERE
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
<foreach item="issueId" collection="ids" open="AND (" separator="or" close=")" index="">
|
|
|
|
ISSUE_ID = #{issueId}
|
|
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 批量添加 -->
|
|
|
|
<insert id="insertBatch" parameterType="java.util.List">
|
|
|
|
INSERT INTO issue_vote_statistical
|
|
|
|
(
|
|
|
|
id,
|
|
|
|
|
|
|
|
issue_id,
|
|
|
|
|
|
|
|
SUPPORT_COUNT,
|
|
|
|
|
|
|
|
OPPOSITION_COUNT,
|
|
|
|
|
|
|
|
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.supportCount},
|
|
|
|
|
|
|
|
#{item.oppositionCount},
|
|
|
|
|
|
|
|
#{item.votableCount},
|
|
|
|
|
|
|
|
#{item.createdBy},
|
|
|
|
|
|
|
|
now(),
|
|
|
|
|
|
|
|
#{item.createdBy},
|
|
|
|
|
|
|
|
now()
|
|
|
|
)
|
|
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<!-- 批量更新 -->
|
|
|
|
<update id="updateBatchByIssueId" parameterType="list">
|
|
|
|
UPDATE issue_vote_statistical
|
|
|
|
<trim prefix="set" suffixOverrides=",">
|
|
|
|
|
|
|
|
<trim prefix="support_count =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.supportCount'>
|
|
|
|
when issue_id = #{item.issueId} then #{item.supportCount}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="opposition_count =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.oppositionCount'>
|
|
|
|
when issue_id = #{item.issueId} then #{item.oppositionCount}
|
|
|
|
</if>
|
|
|
|
</foreach>
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
<trim prefix="updated_by =(case" suffix="end),">
|
|
|
|
<foreach collection="list" item="item">
|
|
|
|
<if test='null != item.updatedBy'>
|
|
|
|
when issue_id = #{item.issueId} then #{item.updatedBy}
|
|
|
|
</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>
|
|
|
|
|
|
|
|
updated_time = now()
|
|
|
|
|
|
|
|
</trim>
|
|
|
|
WHERE
|
|
|
|
del_flag = '0'
|
|
|
|
<foreach collection="list" item="item" open="AND( " separator=" OR " index="index" close=")">
|
|
|
|
issue_id = #{item.issueId}
|
|
|
|
</foreach>
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 通过issueId更新 -->
|
|
|
|
<update id="updateBtIssueId" parameterType="com.epmet.dto.IssueVoteStatisticalDTO">
|
|
|
|
UPDATE
|
|
|
|
issue_vote_statistical
|
|
|
|
<set>
|
|
|
|
<if test="null != supportCount">support_count = #{supportCount}</if>
|
|
|
|
<if test="null != oppositionCount">opposition_count = #{oppositionCount}</if>
|
|
|
|
<if test="null != votableCount">votable_count = #{votableCount}</if>
|
|
|
|
<if test="null != updatedBy">updated_by = #{updatedBy}</if>
|
|
|
|
UPDATED_TIME = NOW ()
|
|
|
|
</set>
|
|
|
|
WHERE
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
AND
|
|
|
|
ISSUE_ID = #{issueId}
|
|
|
|
</update>
|
|
|
|
</mapper>
|