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.
303 lines
13 KiB
303 lines
13 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.ResiEventDao">
|
|
|
|
<!-- 查询报事列表 -->
|
|
<resultMap id="eventUnDisposedListMap" type="com.epmet.dto.result.EventListResultDTO">
|
|
<id property="eventId" column="eventId"/>
|
|
<result property="eventContent" column="eventContent"/>
|
|
<result property="eventTime" column="eventTime"/>
|
|
<result property="isProject" column="isProject"/>
|
|
<result property="redDot" column="redDot"/>
|
|
<collection property="attachmentList" ofType="com.epmet.dto.result.EventListResultDTO$Attachment">
|
|
<result column="resiEventAttachmentId"/><!-- 附件表ID,如果附件url和type一样会被去重 加上id就可以了 -->
|
|
<result column="url" property="url"/>
|
|
<result column="type" property="type"/>
|
|
</collection>
|
|
</resultMap>
|
|
<select id="eventUnDisposedList" resultMap="eventUnDisposedListMap">
|
|
SELECT
|
|
rea.id AS resiEventAttachmentId,
|
|
rea.ATTACHMENT_URL AS url,
|
|
rea.ATTACHMENT_TYPE AS type,
|
|
t.*
|
|
FROM
|
|
(
|
|
SELECT
|
|
re.EVENT_CONTENT AS eventContent,
|
|
<if test='eventType == "undisposed" '>
|
|
IFNULL(DATE_FORMAT(re.CREATED_TIME,'%Y-%m-%d %H:%i'),'') AS eventTime,
|
|
</if>
|
|
<if test='eventType == "processed" '>
|
|
IFNULL(DATE_FORMAT(re.LATEST_OPERATED_TIME,'%Y-%m-%d %H:%i'),'') AS eventTime,
|
|
</if>
|
|
<if test='eventType == "transferred" '>
|
|
IFNULL(DATE_FORMAT(re.CLOSE_CASE_TIME,'%Y-%m-%d %H:%i'),'') AS eventTime,
|
|
</if>
|
|
re.ID AS eventId,
|
|
(CASE WHEN re.SHIFT_PROJECT = 1 THEN TRUE ELSE FALSE END) AS isProject,
|
|
(CASE WHEN ro.RED_DOT = 1 THEN TRUE ELSE FALSE END) AS redDot
|
|
FROM resi_event_report_org ro
|
|
INNER JOIN resi_event re ON (ro.RESI_EVENT_ID = re.ID AND re.DEL_FLAG = '0' AND re.audit_status = 'auto_passed')
|
|
AND ro.DEL_FLAG = '0'
|
|
AND ro.ORG_ID = #{orgId}
|
|
<if test='eventType == "undisposed" '>
|
|
AND ro.ORG_READ = 'un_read'
|
|
</if>
|
|
<if test='eventType == "processed" '>
|
|
AND ro.ORG_READ = 'read'
|
|
AND re.`STATUS` = 'processing'
|
|
</if>
|
|
<if test='eventType == "transferred" '>
|
|
AND ro.ORG_READ = 'read'
|
|
AND re.`STATUS` = 'closed_case'
|
|
</if>
|
|
)t
|
|
LEFT JOIN resi_event_attachment rea ON (rea.resi_event_id = t.eventId AND rea.del_flag = '0' AND rea.attachment_type = 'image')
|
|
<if test='eventType == "undisposed" '>
|
|
ORDER BY t.eventTime,rea.sort asc
|
|
</if>
|
|
<if test='eventType == "processed" '>
|
|
ORDER BY t.eventTime DESC,rea.sort asc
|
|
</if>
|
|
<if test='eventType == "transferred" '>
|
|
ORDER BY t.eventTime DESC,rea.sort asc
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<resultMap id="MyReportedResultDTOMap" type="com.epmet.dto.result.MyReportedResultDTO">
|
|
<id property="resiEventId" column="id"/>
|
|
<result property="eventContent" column="EVENT_CONTENT"/>
|
|
<result property="redDot" column="RED_DOT" />
|
|
<result property="status" column="STATUS" />
|
|
<result property="shiftProject" column="SHIFT_PROJECT" />
|
|
<result property="showTime" column="LATEST_OPERATED_TIME" />
|
|
<result property="readFlag" column="READ_FLAG" />
|
|
<collection property="imgList" ofType="java.lang.String">
|
|
<constructor>
|
|
<arg column="img_url"/>
|
|
</constructor>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<select id="queryMyReported" parameterType="map" resultMap="MyReportedResultDTOMap">
|
|
select
|
|
re.id,
|
|
re.EVENT_CONTENT,
|
|
(
|
|
case when #{statusCondition} ='un_read' then '0'
|
|
else re.RED_DOT
|
|
end
|
|
)as RED_DOT,
|
|
re.`STATUS`,
|
|
re.SHIFT_PROJECT,
|
|
re.LATEST_OPERATED_TIME,
|
|
rea.ATTACHMENT_URL as img_url,
|
|
re.READ_FLAG
|
|
from resi_event re
|
|
left join resi_event_attachment rea
|
|
on(re.id=rea.RESI_EVENT_ID
|
|
and rea.DEL_FLAG='0'
|
|
and rea.ATTACHMENT_TYPE='image')
|
|
where re.DEL_FLAG='0'
|
|
and re.RECALL_FLAG='0'
|
|
AND re.audit_status = 'auto_passed'
|
|
and re.REPORT_USER_ID=#{userId}
|
|
<if test='statusCondition == "un_read" '>
|
|
and re.READ_FLAG='0'
|
|
</if>
|
|
<if test='statusCondition != "un_read" '>
|
|
and re.READ_FLAG='1'
|
|
and re.`STATUS`=#{statusCondition}
|
|
</if>
|
|
order by re.LATEST_OPERATED_TIME desc,rea.sort asc
|
|
</select>
|
|
|
|
<!-- 报事详情 -->
|
|
<resultMap id="selectEventDetailMap" type="com.epmet.dto.result.EventDetailResultDTO">
|
|
<result property="isProject" column="isProject"/>
|
|
<result property="eventTime" column="eventTime"/>
|
|
<result property="eventContent" column="eventContent"/>
|
|
<result property="eventAddress" column="eventAddress"/>
|
|
<result property="isClosed" column="isClosed"/>
|
|
<result property="isResolve" column="isResolve"/>
|
|
<result property="isRollback" column="isRollback"/>
|
|
<result property="projectId" column="projectId"/>
|
|
<result property="gridId" column="gridId"/>
|
|
<result property="eventUserId" column="eventUserId"/>
|
|
<!--<collection property="eventImgs" ofType="java.lang.String">
|
|
<result column="eventImg"/>
|
|
</collection>-->
|
|
<collection property="attachmentList" ofType="com.epmet.dto.result.EventDetailResultDTO$Attachment">
|
|
<result column="resiEventAttachmentId"/><!-- 附件表ID,如果附件url和type一样会被去重 加上id就可以了 -->
|
|
<result column="url" property="url"/>
|
|
<result column="type" property="type"/>
|
|
<result column="duration" property="duration"/>
|
|
</collection>
|
|
<collection property="eventPerson" ofType="java.lang.String">
|
|
<result column="person"/>
|
|
</collection>
|
|
<collection property="eventPersonIds" ofType="java.lang.String">
|
|
<result column="personUserId"/>
|
|
</collection>
|
|
<collection property="orgNameList" ofType="java.lang.String">
|
|
<result column="orgId"/>
|
|
</collection>
|
|
</resultMap>
|
|
<select id="selectEventDetail" resultMap="selectEventDetailMap">
|
|
SELECT
|
|
IFNULL(DATE_FORMAT(re.CREATED_TIME,'%Y-%m-%d %H:%i:%s'),'') AS eventTime,
|
|
IFNULL(re.EVENT_CONTENT,'') AS eventContent,
|
|
IFNULL(re.ADDRESS,'') AS eventAddress,
|
|
(CASE WHEN re.`STATUS` = 'processing' THEN FALSE WHEN re.`STATUS` = 'closed_case' THEN TRUE ELSE FALSE END) AS isClosed,
|
|
(IF(IFNULL(re.RESOLVE_STATUS,TRUE) OR '' = re.RESOLVE_STATUS, TRUE, FALSE)) AS isResolve,
|
|
(CASE WHEN re.READ_FLAG = 1 THEN FALSE ELSE TRUE END) AS isRollback,
|
|
(CASE WHEN re.SHIFT_PROJECT = 1 THEN TRUE ELSE FALSE END) AS isProject,
|
|
IFNULL(re.project_id,'') AS projectId,
|
|
ea.id AS resiEventAttachmentId,
|
|
ea.ATTACHMENT_URL AS url,
|
|
ea.ATTACHMENT_TYPE AS type,
|
|
ea.duration AS duration,
|
|
IF(ISNULL(em.USER_SHOW_NAME),NULL,concat('人大代表-',em.USER_SHOW_NAME)) AS person,
|
|
em.user_id as personUserId,
|
|
re.GRID_ID AS gridId,
|
|
re.CREATED_BY AS eventUserId,
|
|
ro.ORG_ID AS orgId
|
|
FROM resi_event re
|
|
LEFT JOIN resi_event_attachment ea ON (ea.RESI_EVENT_ID = re.ID AND ea.DEL_FLAG = '0')
|
|
LEFT JOIN resi_event_mention em ON (em.RESI_EVENT_ID = re.ID AND em.DEL_FLAG = '0')
|
|
LEFT JOIN resi_event_report_org ro ON (ro.RESI_EVENT_ID = re.ID AND ro.DEL_FLAG = '0')
|
|
WHERE re.DEL_FLAG = '0'
|
|
AND re.ID = #{eventId}
|
|
order by ea.sort asc
|
|
</select>
|
|
|
|
<!-- 更新报事人红点状态 -->
|
|
<update id="updateResiEvent">
|
|
UPDATE resi_event
|
|
SET RED_DOT = 0,
|
|
UPDATED_TIME = NOW()
|
|
WHERE DEL_FLAG = '0'
|
|
AND ID = #{eventId}
|
|
AND REPORT_USER_ID = #{userId}
|
|
</update>
|
|
|
|
<!-- 更新人大代表红点状态 -->
|
|
<update id="updateEventMention">
|
|
UPDATE resi_event_mention
|
|
SET RED_DOT = 0,
|
|
UPDATED_TIME = NOW()
|
|
WHERE DEL_FLAG = '0'
|
|
AND USER_ID = #{userId}
|
|
AND RESI_EVENT_ID = #{eventId}
|
|
</update>
|
|
|
|
<resultMap id="newEventsMap" type="com.epmet.dto.result.NewEventsResultDTO">
|
|
<result property="eventContent" column="eventContent"/>
|
|
<result property="eventTime" column="eventTime"/>
|
|
<result property="eventId" column="eventId"/>
|
|
<collection property="attachmentList" ofType="com.epmet.dto.result.NewEventsResultDTO$Attachment">
|
|
<result column="resiEventAttachmentId"/><!-- 附件表ID,如果附件url和type一样会被去重 加上id就可以了 -->
|
|
<result column="url" property="url"/>
|
|
<result column="type" property="type"/>
|
|
</collection>
|
|
<!--<collection property="eventImgs" ofType="java.lang.String">
|
|
<result column="img"/>
|
|
</collection>-->
|
|
</resultMap>
|
|
<select id="newEvents" resultMap="newEventsMap">
|
|
SELECT
|
|
IFNULL(re.EVENT_CONTENT,'') AS eventContent,
|
|
DATE_FORMAT(re.CREATED_TIME,'%Y-%m-%d %H:%i') AS eventTime,
|
|
ea.id AS resiEventAttachmentId,
|
|
ea.attachment_url AS url,
|
|
ea.attachment_type AS type,
|
|
re.id as eventId
|
|
FROM resi_event_report_org ro
|
|
LEFT JOIN resi_event re ON (re.ID = ro.RESI_EVENT_ID AND re.DEL_FLAG = '0' AND re.audit_status = 'auto_passed')
|
|
LEFT JOIN resi_event_attachment ea ON (ea.RESI_EVENT_ID = ro.RESI_EVENT_ID AND ea.DEL_FLAG = '0' AND
|
|
ea.ATTACHMENT_TYPE = 'image' AND ea.SORT IN (3,1,2))
|
|
WHERE ro.DEL_FLAG = '0'
|
|
AND ro.ORG_READ = 'un_read'
|
|
AND ro.ORG_ID IN(
|
|
<foreach collection="orgIds" item="orgId" separator=",">
|
|
#{orgId}
|
|
</foreach>)
|
|
ORDER BY ro.CREATED_TIME DESC
|
|
</select>
|
|
|
|
<select id="selectUserReported" parameterType="com.epmet.dto.form.PageUserReportEventFormDTO" resultType="com.epmet.dto.result.PageUserReportEventResDTO">
|
|
SELECT
|
|
re.id AS resiEventId,
|
|
re.EVENT_CONTENT AS eventContent,
|
|
re.SHIFT_PROJECT AS shiftProject,
|
|
IFNULL(re.PROJECT_ID,'') AS projectId,
|
|
re.CREATED_TIME AS reportTime
|
|
FROM
|
|
resi_event re
|
|
WHERE
|
|
re.DEL_FLAG = '0'
|
|
<foreach item="epmetUserId" collection="epmetUserIdList" open="AND (" separator="or" close=")" index="">
|
|
re.REPORT_USER_ID = #{epmetUserId}
|
|
</foreach>
|
|
order by re.CREATED_TIME desc
|
|
</select>
|
|
|
|
<resultMap id="resiEventListResultMap" type="com.epmet.dto.result.ResiEventListResultDTO">
|
|
<id property="resiEventId" column="id"/>
|
|
<result property="eventContent" column="event_content"/>
|
|
<result property="redDot" column="red_dot" />
|
|
<result property="status" column="status" />
|
|
<result property="shiftProject" column="shift_project" />
|
|
<result property="showTime" column="latest_operated_time" />
|
|
<result property="readFlag" column="read_flag" />
|
|
<result property="longitude" column="longitude" />
|
|
<result property="latitude" column="latitude" />
|
|
<collection property="attachmentList" ofType="com.epmet.dto.result.ResiEventListResultDTO$Attachment">
|
|
<result column="resiEventAttachmentId"/><!-- 附件表ID,如果附件url和type一样会被去重 加上id就可以了 -->
|
|
<result column="url" property="url"/>
|
|
<result column="type" property="type"/>
|
|
</collection>
|
|
<!--<collection property="imgList" ofType="java.lang.String">
|
|
<constructor>
|
|
<arg column="img_url"/>
|
|
</constructor>
|
|
</collection>-->
|
|
</resultMap>
|
|
<select id="resiEventList" parameterType="map" resultMap="resiEventListResultMap">
|
|
SELECT
|
|
re.id,
|
|
re.event_content,
|
|
(case when #{statusCondition} ='un_read' then '0' else re.red_dot end)as red_dot,
|
|
re.`status`,
|
|
re.shift_project,
|
|
re.latest_operated_time,
|
|
rea.id AS resiEventAttachmentId,
|
|
rea.attachment_url AS url,
|
|
rea.attachment_type AS type,
|
|
re.read_flag,
|
|
re.longitude,
|
|
re.latitude
|
|
FROM resi_event re
|
|
LEFT JOIN resi_event_attachment rea ON (re.id = rea.resi_event_id AND rea.del_flag = '0')
|
|
WHERE re.del_flag='0'
|
|
AND re.recall_flag='0'
|
|
AND re.audit_status = 'auto_passed'
|
|
<if test="gridId != null and gridId != ''">
|
|
AND re.grid_id = #{gridId}
|
|
</if>
|
|
<if test='statusCondition == "un_read" '>
|
|
AND re.read_flag = '0'
|
|
</if>
|
|
<if test='statusCondition != "un_read" '>
|
|
AND re.read_flag = '1'
|
|
AND re.`status` = #{statusCondition}
|
|
</if>
|
|
ORDER BY
|
|
re.latest_operated_time DESC,
|
|
rea.sort ASC
|
|
</select>
|
|
|
|
</mapper>
|