|
|
|
|
<?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.IssueVoteDetailDao">
|
|
|
|
|
|
|
|
|
|
<resultMap type="com.epmet.entity.IssueVoteDetailEntity" id="issueVoteDetailMap">
|
|
|
|
|
<result property="id" column="ID"/>
|
|
|
|
|
<result property="issueId" column="ISSUE_ID"/>
|
|
|
|
|
<result property="attitude" column="ATTITUDE"/>
|
|
|
|
|
<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="checkoutVote" parameterType="com.epmet.dto.form.VoteFormDTO" resultType="integer">
|
|
|
|
|
SELECT
|
|
|
|
|
COUNT(*)
|
|
|
|
|
FROM
|
|
|
|
|
issue_vote_detail
|
|
|
|
|
WHERE
|
|
|
|
|
del_flag = 0
|
|
|
|
|
AND issue_id = #{issueId}
|
|
|
|
|
AND created_by = #{createdBy}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 动态获取表决中状态 -->
|
|
|
|
|
<select id="getAttitudes" resultType="string">
|
|
|
|
|
SELECT
|
|
|
|
|
DISTINCT
|
|
|
|
|
ATTITUDE
|
|
|
|
|
FROM
|
|
|
|
|
ISSUE_VOTE_DETAIL
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 得到某个议题某个态度的表决数 -->
|
|
|
|
|
<select id="getVotingCount" resultType="int">
|
|
|
|
|
SELECT COUNT(ATTITUDE) AS count
|
|
|
|
|
FROM ISSUE_VOTE_DETAIL
|
|
|
|
|
WHERE
|
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
|
AND ISSUE_ID = #{issueId}
|
|
|
|
|
AND ATTITUDE = #{attitude}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 批量查找议题某个态度的表决数 -->
|
|
|
|
|
<select id="getVotingCountList" resultType="com.epmet.dto.result.IssueAttitudeCountResultDTO">
|
|
|
|
|
SELECT ISSUE_ID,COUNT(ATTITUDE) AS count
|
|
|
|
|
FROM ISSUE_VOTE_DETAIL
|
|
|
|
|
WHERE
|
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
|
AND ATTITUDE = #{attitude}
|
|
|
|
|
<foreach collection="issueId" item="ids" open="AND (" separator="OR" close=")">
|
|
|
|
|
ISSUE_ID = #{issueId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getVotingSummaryList" resultType="com.epmet.dto.result.IssueAttitudeCountResultDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
issue_id,
|
|
|
|
|
attitude,
|
|
|
|
|
count( attitude ) as count
|
|
|
|
|
FROM
|
|
|
|
|
ISSUE_VOTE_DETAIL
|
|
|
|
|
WHERE
|
|
|
|
|
del_flag = '0'
|
|
|
|
|
<foreach collection="ids" item="issueId" open="AND (" separator=" or " close=" )">
|
|
|
|
|
issue_id = #{issueId}
|
|
|
|
|
</foreach>
|
|
|
|
|
GROUP BY
|
|
|
|
|
issue_id,
|
|
|
|
|
attitude
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 个人中心-我参与的议题列表 -->
|
|
|
|
|
<select id="myPartIssues" resultType="com.epmet.dto.result.MyPartIssuesResultDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
vd.ISSUE_ID,
|
|
|
|
|
i.SUGGESTION,
|
|
|
|
|
i.ISSUE_TITLE,
|
|
|
|
|
i.GRID_ID AS gridId,
|
|
|
|
|
UNIX_TIMESTAMP(i.CREATED_TIME) AS shiftIssueTime
|
|
|
|
|
FROM issue_vote_detail vd
|
|
|
|
|
LEFT JOIN issue i ON i.ID = vd.ISSUE_ID
|
|
|
|
|
WHERE i.DEL_FLAG = '0'
|
|
|
|
|
AND vd.DEL_FLAG = '0'
|
|
|
|
|
AND vd.CREATED_BY = #{userId}
|
|
|
|
|
<if test='null!=topicIds and topicIds.size()>0'>
|
|
|
|
|
<foreach collection="topicIds" item="topicId" open="AND (" separator="AND" close=")">
|
|
|
|
|
i.SOURCE_ID != #{topicId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
ORDER BY i.CREATED_TIME DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="myPartIssuesByTopicId" resultType="com.epmet.dto.result.MyPartIssuesResultDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
i.ID AS issueId,
|
|
|
|
|
i.SUGGESTION,
|
|
|
|
|
i.ISSUE_TITLE,
|
|
|
|
|
i.GRID_ID AS gridId,
|
|
|
|
|
UNIX_TIMESTAMP(i.CREATED_TIME) AS shiftIssueTime
|
|
|
|
|
FROM issue i
|
|
|
|
|
WHERE i.DEL_FLAG = '0'
|
|
|
|
|
<foreach collection="topicIds" item="topicId" open="AND (" separator="OR" close=")">
|
|
|
|
|
i.SOURCE_ID = #{topicId}
|
|
|
|
|
</foreach>
|
|
|
|
|
ORDER BY i.CREATED_TIME DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 查询用户对某个议题的表决信息 -->
|
|
|
|
|
<select id="selectUserIssueDet" parameterType="map" resultType="com.epmet.dto.IssueVoteDetailDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
*
|
|
|
|
|
FROM
|
|
|
|
|
issue_vote_detail ivd
|
|
|
|
|
WHERE
|
|
|
|
|
ivd.DEL_FLAG = '0'
|
|
|
|
|
AND ivd.ISSUE_ID =#{issueId}
|
|
|
|
|
AND ivd.CREATED_BY =#{userId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectInfo4Cache" resultType="com.epmet.dto.form.VoteRedisFormDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
issue_id,
|
|
|
|
|
count( ATTITUDE = 'opposition' OR NULL ) AS oppositionAmount,
|
|
|
|
|
count( ATTITUDE = 'support' OR NULL ) AS supportAmount,
|
|
|
|
|
0 as shouldVoteCount
|
|
|
|
|
|
|
|
|
|
FROM
|
|
|
|
|
`issue_vote_detail`
|
|
|
|
|
WHERE
|
|
|
|
|
del_flag = '0' and
|
|
|
|
|
issue_id = #{issueId}
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectBatchVoteCount" resultType="com.epmet.dto.form.VoteRedisFormDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
issue_id,
|
|
|
|
|
count( ATTITUDE = 'opposition' OR NULL ) AS oppositionAmount,
|
|
|
|
|
count( ATTITUDE = 'support' OR NULL ) AS supportAmount,
|
|
|
|
|
0 as shouldVoteCount
|
|
|
|
|
|
|
|
|
|
FROM
|
|
|
|
|
`issue_vote_detail`
|
|
|
|
|
WHERE
|
|
|
|
|
del_flag = '0'
|
|
|
|
|
<foreach collection="issueIds" item="issueId" open="AND (" separator=" or " close=" )">
|
|
|
|
|
issue_id = #{issueId}
|
|
|
|
|
</foreach>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectIssueVoteCount" resultType="java.lang.String">
|
|
|
|
|
SELECT
|
|
|
|
|
CREATED_BY
|
|
|
|
|
FROM
|
|
|
|
|
issue_vote_detail
|
|
|
|
|
WHERE
|
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
|
AND ISSUE_ID = #{issueId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 查询议题表决数【批量】 -->
|
|
|
|
|
<select id="selectIssueVoteCountBatch" resultType="com.epmet.dto.result.IssueVoteResultDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
CREATED_BY AS userId,
|
|
|
|
|
ISSUE_ID
|
|
|
|
|
FROM
|
|
|
|
|
issue_vote_detail
|
|
|
|
|
WHERE
|
|
|
|
|
DEL_FLAG = '0'
|
|
|
|
|
AND (
|
|
|
|
|
<foreach collection="issueIds" item="issueId" separator=" OR ">
|
|
|
|
|
ISSUE_ID = #{issueId}
|
|
|
|
|
</foreach>
|
|
|
|
|
)
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 查询客户下的议题表决日增 -->
|
|
|
|
|
<select id="statisticVote" resultType="com.epmet.dto.result.DailyStatisticalVoteJobResultDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
vs.votable_count,
|
|
|
|
|
<if test="status == false">
|
|
|
|
|
(t.oppositionCount + t.supportCount) AS totalCount,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="status == true">
|
|
|
|
|
(t.oppositionIncrement + t.supportIncrement) AS todayIncrement,
|
|
|
|
|
</if>
|
|
|
|
|
t.* FROM
|
|
|
|
|
(SELECT
|
|
|
|
|
vd.ISSUE_ID,
|
|
|
|
|
vd.CUSTOMER_ID AS customerId,
|
|
|
|
|
COUNT(CASE WHEN vd.ATTITUDE = 'opposition' THEN 1 END) AS oppositionCount,
|
|
|
|
|
COUNT(CASE WHEN vd.ATTITUDE = 'opposition' THEN 1 END) AS oppositionIncrement,
|
|
|
|
|
COUNT(CASE WHEN vd.ATTITUDE = 'support' THEN 1 END) AS supportCount,
|
|
|
|
|
COUNT(CASE WHEN vd.ATTITUDE = 'support' THEN 1 END) AS supportIncrement,
|
|
|
|
|
str_to_date(#{dateId},'%Y-%m-%d') AS statisticalDate
|
|
|
|
|
FROM issue_vote_detail vd
|
|
|
|
|
WHERE vd.DEL_FLAG = '0'
|
|
|
|
|
AND vd.CUSTOMER_ID = #{customerId}
|
|
|
|
|
<if test="status == true">
|
|
|
|
|
AND DATE_FORMAT(vd.CREATED_TIME,'%Y-%m-%d') = #{dateId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="status == false">
|
|
|
|
|
AND DATE_FORMAT(vd.CREATED_TIME,'%Y-%m-%d') <![CDATA[ <= ]]> #{dateId}
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY vd.ISSUE_ID)t
|
|
|
|
|
INNER JOIN issue_vote_statistical vs ON (vs.ISSUE_ID = t.ISSUE_ID AND vs.DEL_FLAG = '0')
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 根据议题ID查询折线图一天的数据 -->
|
|
|
|
|
<select id="polyLineData" resultType="com.epmet.dto.PolyLineDTO">
|
|
|
|
|
SELECT
|
|
|
|
|
COUNT(CASE WHEN vd.ATTITUDE = 'opposition' THEN 1 END) AS oppositionIncrement,
|
|
|
|
|
COUNT(CASE WHEN vd.ATTITUDE = 'support' THEN 1 END) AS supportIncrement
|
|
|
|
|
FROM issue_vote_detail vd
|
|
|
|
|
WHERE vd.DEL_FLAG = '0'
|
|
|
|
|
AND DATE_FORMAT(vd.CREATED_TIME,'%Y-%m-%d') = #{dateId}
|
|
|
|
|
AND ISSUE_ID = #{issueId}
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|