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.
317 lines
12 KiB
317 lines
12 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.epmet.dao.topic.TopicDao">
|
|
|
|
<resultMap id="groupTopic" type="com.epmet.dto.topic.result.ResiGroupTopicResultDTO">
|
|
<id property="groupId" column="groupId" />
|
|
<result property="gridId" column="GRID_ID" />
|
|
<result property="customerId" column="CUSTOMER_ID" />
|
|
<result property="groupName" column="GROUP_NAME" />
|
|
<collection property="topics" ofType="com.epmet.dto.topic.result.ResiTopicResultDTO">
|
|
<id property="topicId" column="topicId" />
|
|
<id property="status" column="STATUS"/>
|
|
<id property="shiftIssue" column="SHIFT_ISSUE" />
|
|
<id property="incrFlag" column="incrFlag" />
|
|
</collection>
|
|
</resultMap>
|
|
<!--获取话题内容及图片信息-->
|
|
<resultMap id="topicImgResultMap" type="com.epmet.dto.topic.result.ResiTopicAndImgResultDTO">
|
|
<id property="topicId" column="ID" />
|
|
<result property="topicContent" column="TOPIC_CONTENT" />
|
|
<collection property="topicImgList" ofType="com.epmet.dto.topic.TopicAttachmentDTO">
|
|
<id property="sort" column="SORT"/>
|
|
<id property="attachmentUrl" column="ATTACHMENT_URL" />
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<!-- 将组按照网格Id排序,并取出组Id、话题Id等相关信息,incrFlag代表是否是在当日创建 -->
|
|
<select id="selectGroupOrderByGrid" resultMap="groupTopic">
|
|
SELECT
|
|
groupp.ID AS groupId,
|
|
groupp.GRID_ID,
|
|
groupp.CUSTOMER_ID ,
|
|
groupp.GROUP_NAME,
|
|
|
|
topic.ID AS topicID,
|
|
topic.STATUS,
|
|
CASE WHEN log.CREATED_TIME IS NULL THEN 0 ELSE 1 END AS 'SHIFT_ISSUE',
|
|
(CASE WHEN
|
|
topic.CREATED_TIME <![CDATA[>=]]> #{targetDate} AND topic.CREATED_TIME <![CDATA[<]]> DATE_SUB( #{targetDate}, INTERVAL - 1 DAY)
|
|
THEN '1' ELSE '0' END ) AS incrFlag
|
|
FROM
|
|
RESI_GROUP groupp
|
|
LEFT JOIN RESI_TOPIC topic ON groupp.ID = topic.GROUP_ID AND topic.DEL_FLAG = '0'
|
|
LEFT JOIN resi_topic_operation log ON log.TOPIC_ID = topic.ID AND log.DEL_FLAG = '0' AND log.OPERATION_TYPE = 'shift_issue' AND log.CREATED_TIME <![CDATA[<]]> DATE_SUB( #{targetDate}, INTERVAL - 1 DAY )
|
|
WHERE groupp.DEL_FLAG = '0'
|
|
<if test='null != customerId and "" != customerId'>
|
|
AND groupp.CUSTOMER_ID = #{customerId}
|
|
</if>
|
|
<choose>
|
|
<when test="null != targetDate">
|
|
AND topic.CREATED_TIME <![CDATA[<]]> DATE_SUB( #{targetDate}, INTERVAL - 1 DAY)
|
|
AND groupp.CREATED_TIME <![CDATA[<]]> DATE_SUB( #{targetDate}, INTERVAL - 1 DAY)
|
|
</when>
|
|
<otherwise>
|
|
AND topic.CREATED_TIME <![CDATA[<]]> CURDATE( )
|
|
AND groupp.CREATED_TIME <![CDATA[<]]> CURDATE( )
|
|
</otherwise>
|
|
</choose>
|
|
|
|
ORDER BY groupp.GRID_ID
|
|
</select>
|
|
|
|
<!-- 查询话题的操作记录,如果返回结果中没有对应Id的话题说明当日话题没有操作记录 -->
|
|
<select id="selectTopicOperationRecord" resultType="com.epmet.dto.topic.result.ResiTopicOperationResultDTO">
|
|
SELECT
|
|
TOPIC_ID ,
|
|
OPERATION_TYPE AS status,
|
|
date_format(CREATED_TIME,'%Y-%m-%d') AS createdTime
|
|
FROM RESI_TOPIC_OPERATION operation
|
|
WHERE operation.DEL_FLAG = '0'
|
|
<choose>
|
|
<when test="null != targetDate">
|
|
AND CREATED_TIME <![CDATA[>=]]> #{targetDate} AND CREATED_TIME <![CDATA[<]]> DATE_SUB( #{targetDate}, INTERVAL - 1 DAY)
|
|
</when>
|
|
<otherwise>
|
|
AND CREATED_TIME <![CDATA[<]]> CURDATE( ) AND CREATED_TIME <![CDATA[>=]]> DATE_SUB( CURDATE( ), INTERVAL 1 DAY )
|
|
</otherwise>
|
|
</choose>
|
|
|
|
order by TOPIC_ID
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 将组按照网格Id排序,并取出组Id、话题Id等相关信息,incrFlag代表是否是在当日创建 -->
|
|
<select id="selectGroupOrderByGridBetweenTimeRange" resultMap="groupTopic">
|
|
SELECT
|
|
groupp.ID AS groupId,
|
|
groupp.GRID_ID,
|
|
groupp.CUSTOMER_ID ,
|
|
groupp.GROUP_NAME,
|
|
|
|
topic.ID AS topicID,
|
|
topic.STATUS,
|
|
topic.SHIFT_ISSUE,
|
|
|
|
(CASE WHEN
|
|
topic.CREATED_TIME <![CDATA[>=]]> #{startDate} AND topic.CREATED_TIME <![CDATA[<]]> DATE_SUB( #{endDate}, INTERVAL - 1 DAY)
|
|
THEN '1'
|
|
ELSE '0' END ) AS incrFlag
|
|
|
|
FROM RESI_GROUP groupp LEFT JOIN RESI_TOPIC topic ON groupp.ID = topic.GROUP_ID AND topic.DEL_FLAG = '0'
|
|
WHERE groupp.DEL_FLAG = '0'
|
|
<if test='null != customerId and "" != customerId'>
|
|
AND groupp.CUSTOMER_ID = #{customerId}
|
|
</if>
|
|
AND topic.CREATED_TIME <![CDATA[<]]> DATE_SUB( #{endDate}, INTERVAL - 1 DAY)
|
|
AND groupp.CREATED_TIME <![CDATA[<]]> DATE_SUB( #{endDate}, INTERVAL - 1 DAY)
|
|
|
|
ORDER BY groupp.GRID_ID
|
|
</select>
|
|
|
|
<!-- 查询话题的操作记录,如果返回结果中没有对应Id的话题说明当日话题没有操作记录 -->
|
|
<select id="selectTopicOperationRecordBetweenTimeRange" resultType="com.epmet.dto.topic.result.ResiTopicOperationResultDTO">
|
|
SELECT
|
|
TOPIC_ID ,
|
|
OPERATION_TYPE AS status,
|
|
date_format(CREATED_TIME,'%Y-%m-%d') AS createdTime
|
|
FROM RESI_TOPIC_OPERATION operation
|
|
WHERE operation.DEL_FLAG = '0'
|
|
AND
|
|
CREATED_TIME <![CDATA[>=]]> #{startDate} AND CREATED_TIME <![CDATA[<]]> DATE_SUB( #{endDate}, INTERVAL - 1 DAY)
|
|
|
|
order by TOPIC_ID
|
|
</select>
|
|
<select id="selectTopicByIds" resultType="com.epmet.dto.topic.ResiTopicDTO" parameterType="java.util.List">
|
|
SELECT
|
|
rt.ID,
|
|
rg.GRID_ID,
|
|
rt.CREATED_BY
|
|
FROM resi_topic rt
|
|
LEFT JOIN resi_group rg ON rg.ID = rt.GROUP_ID
|
|
WHERE 1=1
|
|
<foreach collection="ids" item="item" open="AND( " separator=" OR " index="index" close=")">
|
|
rt.ID = #{item}
|
|
</foreach>
|
|
</select>
|
|
|
|
<!-- 查询话题创建者信息 -->
|
|
<select id="selectTopicInfo" resultType="com.epmet.dto.extract.result.TopicInfoResultDTO">
|
|
SELECT
|
|
id AS topicId,
|
|
CREATED_BY AS userId
|
|
FROM
|
|
resi_topic
|
|
WHERE
|
|
del_flag = '0'
|
|
AND
|
|
(
|
|
<foreach collection="topicIds" item="item" separator=" OR ">
|
|
id = #{item}
|
|
</foreach>
|
|
)
|
|
</select>
|
|
|
|
<!-- 根据日期查询resi_topic_operation,返回当前日期这一天内所有话题相关的操作记录 -->
|
|
<select id="selectListTopicOriginInfo" parameterType="map" resultType="com.epmet.dto.topic.TopicOriginInfoDTO">
|
|
SELECT
|
|
rto.TOPIC_ID,
|
|
rto.OPERATION_TYPE as ACTION_CODE,
|
|
rto.CREATED_BY as OPERATE_USER_ID,
|
|
DATE_FORMAT(rto.CREATED_TIME,'%Y%m%d') as DATE_ID,
|
|
DATE_FORMAT(rto.CREATED_TIME,'%Y%m') as MONTH_ID,
|
|
DATE_FORMAT(rto.CREATED_TIME,'%Y') as YEAR_ID,
|
|
rto.CREATED_TIME AS ORIGINAL_BUSINESS_TIME,
|
|
rt.GROUP_ID,
|
|
rt.STATUS as TOPIC_STATUS,
|
|
rg.GRID_ID,
|
|
RG.CUSTOMER_ID,
|
|
rt.CLOSED_STATUS
|
|
FROM
|
|
resi_topic_operation rto
|
|
LEFT JOIN resi_topic rt ON ( rto.TOPIC_ID = rt.id AND rt.DEL_FLAG = '0' )
|
|
LEFT JOIN RESI_GROUP RG ON(RT.GROUP_ID=RG.ID AND RG.DEL_FLAG='0')
|
|
WHERE
|
|
rto.DEL_FLAG = '0'
|
|
AND DATE_FORMAT(rto.CREATED_TIME,'%Y%m%d')=#{dateId}
|
|
AND RG.CUSTOMER_ID=#{customerId}
|
|
union all
|
|
SELECT
|
|
rtc.TOPIC_ID,
|
|
'comment' as ACTION_CODE,
|
|
rtc.CREATED_BY as OPERATE_USER_ID,
|
|
DATE_FORMAT(rtc.CREATED_TIME,'%Y%m%d') as DATE_ID,
|
|
DATE_FORMAT(rtc.CREATED_TIME,'%Y%m') as MONTH_ID,
|
|
DATE_FORMAT(rtc.CREATED_TIME,'%Y') as YEAR_ID,
|
|
rtc.CREATED_TIME AS ORIGINAL_BUSINESS_TIME,
|
|
rt.GROUP_ID ,
|
|
rt.STATUS as TOPIC_STATUS,
|
|
rg.GRID_ID,
|
|
rg.CUSTOMER_ID,
|
|
rt.CLOSED_STATUS
|
|
FROM
|
|
resi_topic_comment rtc
|
|
LEFT JOIN resi_topic rt ON ( rtc.TOPIC_ID = rt.id AND rt.DEL_FLAG = '0' )
|
|
LEFT JOIN resi_group rg ON ( rt.GROUP_ID = rg.id AND rg.DEL_FLAG = '0' )
|
|
WHERE
|
|
rtc.DEL_FLAG = '0'
|
|
AND DATE_FORMAT( rtc.CREATED_TIME, '%Y%m%d' )=#{dateId}
|
|
AND RG.CUSTOMER_ID =#{customerId}
|
|
</select>
|
|
|
|
<!-- 查询在这一天发生变化的话题记录 -->
|
|
<select id="queryUpdateTopicOriginInfoList" parameterType="map" resultType="com.epmet.dto.topic.TopicOriginInfoDTO">
|
|
select
|
|
rt.id as TOPIC_ID,
|
|
rt.CLOSED_STATUS,
|
|
rt.STATUS as TOPIC_STATUS
|
|
from resi_topic rt
|
|
where rt.del_flag='0'
|
|
and DATE_FORMAT( rt.UPDATED_TIME, '%Y%m%d' )=#{dateId}
|
|
</select>
|
|
|
|
<select id="selectTopicImgs" resultType="com.epmet.entity.evaluationindex.screen.ScreenDifficultyImgDataEntity">
|
|
SELECT
|
|
TOPIC_ID AS eventId,
|
|
ATTACHMENT_URL AS eventImgUrl,
|
|
SORT
|
|
FROM
|
|
resi_topic_attachment
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND ATTACHMENT_TYPE = 'image'
|
|
<foreach collection="list" item="item" open="AND (" separator=" OR " close=")">
|
|
TOPIC_ID = #{item.sourceId}
|
|
</foreach>
|
|
ORDER BY TOPIC_ID , SORT ASC
|
|
</select>
|
|
|
|
<select id="selectTopicContent" resultType="com.epmet.dto.group.result.TopicContentResultDTO">
|
|
SELECT
|
|
ID AS topicId,
|
|
TOPIC_CONTENT AS content
|
|
FROM RESI_TOPIC
|
|
WHERE DEL_FLAG = '0'
|
|
<foreach collection="list" item="item" open="AND (" separator=" OR " close=")">
|
|
ID = #{item.sourceId}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="selectScreenProjectData" resultType="com.epmet.dto.screen.ScreenProjectDataDTO">
|
|
SELECT
|
|
ID as topicId,
|
|
TOPIC_CONTENT as projectContent,
|
|
ADDRESS as projectAddress,
|
|
LONGITUDE,
|
|
DIMENSION as latitude
|
|
FROM RESI_TOPIC
|
|
WHERE DEL_FLAG = '0'
|
|
<foreach collection="list" item="project" open="AND (" separator=" OR " close=" )">
|
|
ID = #{project.topicId}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="initNewScreenProjectImgData" resultType="com.epmet.dto.screen.ScreenProjectImgDataDTO">
|
|
SELECT
|
|
#{customerId} as customerId,
|
|
ATTACHMENT_URL AS projectImgUrl,
|
|
SORT ,
|
|
TOPIC_ID
|
|
FROM
|
|
`resi_topic_attachment`
|
|
WHERE
|
|
del_flag = '0'
|
|
AND ATTACHMENT_TYPE = 'image'
|
|
<foreach collection="list" item="project" open="AND ( " separator=" OR " close=" )">
|
|
TOPIC_ID = #{project.topicId}
|
|
</foreach>
|
|
</select>
|
|
<select id="getTopicAttachment" resultType="com.epmet.dto.topic.TopicAttachmentDTO">
|
|
SELECT
|
|
ATTACHMENT_URL AS eventImgUrl,
|
|
SORT
|
|
FROM
|
|
`resi_topic_attachment`
|
|
WHERE
|
|
del_flag = '0'
|
|
<!-- AND ATTACHMENT_TYPE = #{attachmentType}-->
|
|
AND ATTACHMENT_TYPE = 'image'
|
|
and TOPIC_ID = #{topicId}
|
|
|
|
</select>
|
|
<select id="getTopicAndImgs" resultMap="topicImgResultMap">
|
|
SELECT
|
|
t.ID,
|
|
t.TOPIC_CONTENT,
|
|
a.ATTACHMENT_URL,
|
|
a.SORT
|
|
from resi_topic t
|
|
LEFT JOIN resi_topic_attachment a ON t.ID = a.TOPIC_ID AND ATTACHMENT_TYPE = 'image'
|
|
WHERE
|
|
t.del_flag = '0'
|
|
and t.ID = #{topicId}
|
|
</select>
|
|
|
|
<select id="selectTopicList" resultType="com.epmet.dto.stats.topic.result.TopicListResultDTO">
|
|
SELECT
|
|
rt.id AS topicId,
|
|
rt.group_id AS groupId,
|
|
rt.`status` AS STATUS,
|
|
rt.shift_issue AS shiftIssue,
|
|
rg.grid_id AS gridId,
|
|
rg.customer_id AS customerId
|
|
FROM
|
|
resi_topic rt
|
|
INNER JOIN resi_group rg ON rt.group_id = rg.id
|
|
WHERE
|
|
rt.del_flag = '0'
|
|
AND rg.del_flag = '0'
|
|
AND rg.customer_id = #{customerId}
|
|
AND DATE_FORMAT(rt.created_time ,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
|
|
</select>
|
|
|
|
</mapper>
|
|
|