You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
349 lines
14 KiB
349 lines
14 KiB
<?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.elink.esua.epdc.modules.issue.dao.IssueAnalysisDao">
|
|
<!-- 最热议题列表 -->
|
|
<select id="selectListHottestIssue" resultType="com.elink.esua.epdc.dto.issue.result.IssueResultDTO">
|
|
SELECT
|
|
ei.ID,
|
|
ei.ISSUE_CONTENT,
|
|
ei.ALL_DEPT_NAMES,
|
|
ei.NICK_NAME,
|
|
ei.CREATED_TIME,
|
|
ee.APPROVE_NUM,
|
|
ee.OPPOSE_NUM,
|
|
ee.COMMENT_NUM,
|
|
ee.BROWSE_NUM,
|
|
( ee.COMMENT_NUM + ee.BROWSE_NUM + ee.APPROVE_NUM + ee.OPPOSE_NUM ) AS expressAttitudeNum
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
LEFT JOIN <include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_events ee ON ee.ID = ei.EVENT_ID
|
|
AND ee.DEL_FLAG = '0'
|
|
WHERE
|
|
ei.DEL_FLAG = '0'
|
|
AND ei.ISSUE_STATE IN ( 0, 2 )
|
|
<if test="issueContent != null and issueContent != ''">
|
|
AND ei.ISSUE_CONTENT LIKE CONCAT('%',#{issueContent},'%')
|
|
</if>
|
|
<if test="streetId != null and streetId != ''">
|
|
AND find_in_set(#{streetId},ei.ALL_DEPT_IDS)
|
|
</if>
|
|
<if test="communityId != null and communityId != ''">
|
|
AND find_in_set(#{communityId},ei.ALL_DEPT_IDS)
|
|
</if>
|
|
<if test="gridId != null and gridId != ''">
|
|
AND ei.GRID_ID = #{gridId}
|
|
</if>
|
|
<if test="startTime != null and startTime != ''">
|
|
and DATE_FORMAT( ei.CREATED_TIME, '%Y-%m-%d' ) >=#{startTime}
|
|
</if>
|
|
<if test="endTime != null and endTime != ''">
|
|
and DATE_FORMAT( ei.CREATED_TIME, '%Y-%m-%d' ) <=#{endTime}
|
|
</if>
|
|
<if test="deptIdList!=null and deptIdList.size()>0">
|
|
and ei.GRID_ID in
|
|
<foreach collection="deptIdList" index="index" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
</if>
|
|
ORDER BY
|
|
expressAttitudeNum DESC
|
|
</select>
|
|
|
|
<!-- 最新议题列表 -->
|
|
<select id="selectListLatestIssue" resultType="com.elink.esua.epdc.dto.issue.result.IssueResultDTO">
|
|
SELECT
|
|
ei.ID,
|
|
ei.ISSUE_CONTENT,
|
|
ei.ALL_DEPT_NAMES,
|
|
ei.NICK_NAME,
|
|
ei.CREATED_TIME,
|
|
ee.APPROVE_NUM,
|
|
ee.OPPOSE_NUM,
|
|
ee.COMMENT_NUM,
|
|
ee.BROWSE_NUM,
|
|
( ee.COMMENT_NUM + ee.BROWSE_NUM + ee.APPROVE_NUM + ee.OPPOSE_NUM ) AS expressAttitudeNum
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
LEFT JOIN <include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_events ee ON ee.ID = ei.EVENT_ID
|
|
AND ee.DEL_FLAG = '0'
|
|
WHERE
|
|
ei.DEL_FLAG = '0'
|
|
AND ei.ISSUE_STATE IN ( 0, 2 )
|
|
<if test="issueContent != null and issueContent != ''">
|
|
AND ei.ISSUE_CONTENT LIKE CONCAT('%',#{issueContent},'%')
|
|
</if>
|
|
<if test="streetId != null and streetId != ''">
|
|
AND find_in_set(#{streetId},ei.ALL_DEPT_IDS)
|
|
</if>
|
|
<if test="communityId != null and communityId != ''">
|
|
AND find_in_set(#{communityId},ei.ALL_DEPT_IDS)
|
|
</if>
|
|
<if test="gridId != null and gridId != ''">
|
|
AND ei.GRID_ID = #{gridId}
|
|
</if>
|
|
<if test="startTime != null and startTime != ''">
|
|
and DATE_FORMAT( ei.CREATED_TIME, '%Y-%m-%d' ) >=#{startTime}
|
|
</if>
|
|
<if test="endTime != null and endTime != ''">
|
|
and DATE_FORMAT( ei.CREATED_TIME, '%Y-%m-%d' ) <=#{endTime}
|
|
</if>
|
|
<if test="deptIdList!=null and deptIdList.size()>0">
|
|
and ei.GRID_ID in
|
|
<foreach collection="deptIdList" index="index" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
</if>
|
|
ORDER BY
|
|
expressAttitudeNum DESC,CREATED_TIME desc
|
|
</select>
|
|
|
|
<sql id="common_where_if">
|
|
<if test="deptIdList!=null and deptIdList.size()>0">
|
|
and ei.GRID_ID in
|
|
<foreach collection="deptIdList" index="index" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
</if>
|
|
<if test="streetId != null and streetId != ''">
|
|
AND find_in_set(#{streetId},ei.ALL_DEPT_IDS)
|
|
</if>
|
|
<if test="communityId != null and communityId != ''">
|
|
AND find_in_set(#{communityId},ei.ALL_DEPT_IDS)
|
|
</if>
|
|
<if test="gridId != null and gridId != ''">
|
|
AND ei.GRID_ID = #{gridId}
|
|
</if>
|
|
<if test="startTime != null and startTime != ''">
|
|
and DATE_FORMAT( ei.CREATED_TIME, '%Y-%m-%d' ) >=#{startTime}
|
|
</if>
|
|
<if test="endTime != null and endTime != ''">
|
|
and DATE_FORMAT( ei.CREATED_TIME, '%Y-%m-%d' ) <=#{endTime}
|
|
</if>
|
|
<if test="categoryName != null and categoryName != ''">
|
|
AND ei.CATEGORY_FULL_NAME LIKE CONCAT(#{categoryName},'_%')
|
|
</if>
|
|
</sql>
|
|
<sql id="common_order-if">
|
|
<if test="sort != null and sort != '' and 'desc'==sort">
|
|
ORDER BY categoryNum desc
|
|
</if>
|
|
<if test="sort != null and sort != '' and 'asc'==sort">
|
|
ORDER BY categoryNum asc
|
|
</if>
|
|
</sql>
|
|
<!-- 一级类目统计 -->
|
|
<select id="selectFirstIssueClassifiedStatistic"
|
|
resultType="com.elink.esua.epdc.dto.issue.result.IssueClassifiedStatisticDTO">
|
|
SELECT
|
|
SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 1 ) AS categoryName,
|
|
COUNT( ei.ID ) AS categoryNum,
|
|
SUM( ei.ISSUE_STATE = 0 OR ei.ISSUE_STATE = 2 ) AS issueNum,
|
|
SUM( ei.ISSUE_STATE = 4 ) AS itemNum,
|
|
'1' as categoryLevel
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
WHERE ei.DEL_FLAG = '0'
|
|
<include refid="common_where_if"/>
|
|
GROUP BY
|
|
SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 1 ),categoryLevel
|
|
<include refid="common_order-if"/>
|
|
</select>
|
|
|
|
<!-- 二级类目统计 -->
|
|
<select id="selectSecondIssueClassifiedStatistic"
|
|
resultType="com.elink.esua.epdc.dto.issue.result.IssueClassifiedStatisticDTO">
|
|
SELECT
|
|
SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 2 ) AS categoryName,
|
|
COUNT( ei.ID ) AS categoryNum,
|
|
SUM( ei.ISSUE_STATE = 0 OR ei.ISSUE_STATE = 2 ) AS issueNum,
|
|
SUM( ei.ISSUE_STATE = 4 ) AS itemNum,
|
|
'2' as categoryLevel
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
WHERE
|
|
ei.DEL_FLAG = '0'
|
|
AND ( LENGTH( ei.CATEGORY_FULL_NAME ) - LENGTH( REPLACE ( ei.CATEGORY_FULL_NAME, '-', '' ) ) ) > 0
|
|
<include refid="common_where_if"/>
|
|
GROUP BY
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 2 ), '-', - 1 ),categoryLevel
|
|
<include refid="common_order-if"/>
|
|
</select>
|
|
|
|
<!-- 三级类目统计 -->
|
|
<select id="selectThreeIssueClassifiedStatistic"
|
|
resultType="com.elink.esua.epdc.dto.issue.result.IssueClassifiedStatisticDTO">
|
|
SELECT
|
|
SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 3 ) AS categoryName,
|
|
COUNT( ei.ID ) AS categoryNum,
|
|
SUM( ei.ISSUE_STATE = 0 OR ei.ISSUE_STATE = 2 ) AS issueNum,
|
|
SUM( ei.ISSUE_STATE = 4 ) AS itemNum,
|
|
'3' as categoryLevel
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
WHERE
|
|
ei.DEL_FLAG = '0'
|
|
AND ( LENGTH( ei.CATEGORY_FULL_NAME ) - LENGTH( REPLACE ( ei.CATEGORY_FULL_NAME, '-', '' ) ) ) > 1
|
|
<include refid="common_where_if"/>
|
|
GROUP BY
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 3 ), '-', - 1 ),categoryLevel
|
|
<include refid="common_order-if"/>
|
|
</select>
|
|
|
|
<select id="selectListStatisticsByFirstCategory" resultType="com.elink.esua.epdc.dto.issue.result.IssueStatisticsInfoResultDTO">
|
|
SELECT
|
|
SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 1 ) AS cotegoryName,
|
|
COUNT( ei.ID ) AS count
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
WHERE
|
|
ei.DEL_FLAG = '0'
|
|
AND ei.GRID_ID IN
|
|
<foreach collection="deptIdList" index="index" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
<if test="timestamp != null and timestamp != ''">
|
|
<![CDATA[ AND DATE_FORMAT(ei.CREATED_TIME,'%Y-%m-%d %H:%i:%s') <= ]]> #{timestamp}
|
|
</if>
|
|
GROUP BY
|
|
SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 1 )
|
|
ORDER BY
|
|
count DESC
|
|
LIMIT #{pageIndex}, #{pageSize};
|
|
</select>
|
|
|
|
<select id="selectListStatisticsByTwoCategory" resultType="com.elink.esua.epdc.dto.issue.result.IssueStatisticsInfoResultDTO">
|
|
SELECT
|
|
SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 2 ) AS cotegoryName,
|
|
COUNT( ei.ID ) AS count
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
WHERE
|
|
ei.DEL_FLAG = '0'
|
|
AND ( LENGTH( ei.CATEGORY_FULL_NAME ) - LENGTH( REPLACE ( ei.CATEGORY_FULL_NAME, '-', '' ) ) ) > 0
|
|
AND ei.GRID_ID IN
|
|
<foreach collection="deptIdList" index="index" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
<if test="timestamp != null and timestamp != ''">
|
|
<![CDATA[ AND DATE_FORMAT(ei.CREATED_TIME,'%Y-%m-%d %H:%i:%s') <= ]]> #{timestamp}
|
|
</if>
|
|
GROUP BY
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 2 ), '-', - 1 )
|
|
ORDER BY
|
|
count DESC
|
|
LIMIT #{pageIndex}, #{pageSize};
|
|
</select>
|
|
|
|
<select id="selectListStatisticsByThreeCategory" resultType="com.elink.esua.epdc.dto.issue.result.IssueStatisticsInfoResultDTO">
|
|
SELECT
|
|
SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 3 ) AS cotegoryName,
|
|
COUNT( ei.ID ) AS count
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
WHERE
|
|
ei.DEL_FLAG = '0'
|
|
AND ( LENGTH( ei.CATEGORY_FULL_NAME ) - LENGTH( REPLACE ( ei.CATEGORY_FULL_NAME, '-', '' ) ) ) > 1
|
|
AND ei.GRID_ID IN
|
|
<foreach collection="deptIdList" index="index" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
<if test="timestamp != null and timestamp != ''">
|
|
<![CDATA[ AND DATE_FORMAT(ei.CREATED_TIME,'%Y-%m-%d %H:%i:%s') <= ]]> #{timestamp}
|
|
</if>
|
|
GROUP BY
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( ei.CATEGORY_FULL_NAME, '-', 3 ), '-', - 1 )
|
|
ORDER BY
|
|
count DESC
|
|
LIMIT #{pageIndex}, #{pageSize};
|
|
</select>
|
|
|
|
|
|
<resultMap id="newIssueListMap" type="com.elink.esua.epdc.dto.issue.result.NewIssueResultDTO">
|
|
<result property="id" column="ID"/>
|
|
<result property="content" column="content"/>
|
|
<result property="deptName" column="deptName"/>
|
|
<result property="createdTime" column="CREATED_TIME"/>
|
|
<collection property="images" ofType="java.lang.String">
|
|
<result property="image" column="IMG_URL"/>
|
|
</collection>
|
|
</resultMap>
|
|
<select id="selectNewIssueList" resultMap="newIssueListMap">
|
|
SELECT
|
|
ei.ID,
|
|
ei.ISSUE_CONTENT AS content,
|
|
eimg.IMG_URL,
|
|
ei.ALL_DEPT_NAMES AS deptName,
|
|
ei.CREATED_TIME
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
LEFT JOIN <include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_img eimg ON eimg.REFERENCE_ID = ei.EVENT_ID
|
|
AND eimg.DEL_FLAG = '0'
|
|
WHERE
|
|
ei.ID IN (
|
|
SELECT
|
|
tmp.ID
|
|
FROM
|
|
(
|
|
SELECT
|
|
t.ID
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue t
|
|
WHERE
|
|
t.DEL_FLAG = '0'
|
|
AND t.ISSUE_STATE IN (0, 2)
|
|
AND t.GRID_ID IN
|
|
<foreach collection="deptIdList" index="index" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
<if test="timestamp != null and timestamp != ''">
|
|
AND DATE_FORMAT( t.CREATED_TIME, '%Y-%m-%d %H:%i:%s' ) <= #{timestamp}
|
|
</if>
|
|
ORDER BY
|
|
t.CREATED_TIME DESC
|
|
LIMIT #{pageIndex}, #{pageSize}
|
|
) tmp
|
|
)
|
|
ORDER BY
|
|
ei.CREATED_TIME DESC,
|
|
eimg.IMG_URL
|
|
</select>
|
|
|
|
<!--最热议题APP接口-->
|
|
<select id="selectHotIssueList" resultType="com.elink.esua.epdc.dto.issue.result.HotIssueResultDTO">
|
|
SELECT
|
|
ei.ID,
|
|
ei.ISSUE_CONTENT AS content,
|
|
( ee.COMMENT_NUM + ee.BROWSE_NUM + ee.APPROVE_NUM + ee.OPPOSE_NUM ) AS statementNum
|
|
FROM
|
|
<include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_issue ei
|
|
LEFT JOIN <include refid="com.elink.esua.epdc.modules.common.dao.EpdcTableNameDao.tb_events"/>.epdc_events ee ON ee.ID = ei.EVENT_ID
|
|
AND ee.DEL_FLAG = '0'
|
|
WHERE
|
|
ei.DEL_FLAG = '0'
|
|
AND ei.ISSUE_STATE IN ( 0, 2 )
|
|
AND ei.GRID_ID IN
|
|
<foreach collection="deptIdList" index="index" item="deptId" open="(" separator="," close=")">
|
|
#{deptId}
|
|
</foreach>
|
|
<if test="timestamp != null and timestamp != ''">
|
|
AND DATE_FORMAT( ei.CREATED_TIME, '%Y-%m-%d %H:%i:%s' ) <= #{timestamp}
|
|
</if>
|
|
<if test="someMonthsType == 1">
|
|
AND DATE_SUB( CURDATE( ), INTERVAL 1 MONTH ) <= ei.CREATED_TIME
|
|
</if>
|
|
<if test="someMonthsType == 2">
|
|
AND DATE_SUB( CURDATE( ), INTERVAL 3 MONTH ) <= ei.CREATED_TIME
|
|
</if>
|
|
<if test="someMonthsType == 3">
|
|
AND DATE_SUB( CURDATE( ), INTERVAL 6 MONTH ) <= ei.CREATED_TIME
|
|
</if>
|
|
<if test="someMonthsType == 4">
|
|
AND DATE_SUB( CURDATE( ), INTERVAL 1 YEAR ) <= ei.CREATED_TIME
|
|
</if>
|
|
ORDER BY
|
|
statementNum DESC
|
|
LIMIT #{pageIndex}, #{pageSize}
|
|
</select>
|
|
|
|
</mapper>
|
|
|