日照智慧社区接口服务
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.
 
 
 
 
 

222 lines
8.7 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.IcEventDao">
<!-- 更新评价,默认 perfect -->
<update id="updateAutoEvaluation">
UPDATE ic_event
SET SATISFACTION = 'perfect',
COMMENT_USER_ID = 'APP_USER',
COMMENT_TIME = NOW(),
LATEST_OPERATED_TIME = NOW(),
UPDATED_TIME = NOW()
WHERE ID IN (
<foreach collection="ids" item="id" separator=",">
#{id}
</foreach>
)
</update>
<select id="getProcessStatusRatio" resultType="java.util.Map">
select STATUS status, count(1) eventCount
from ic_event e
<where>
<if test="orgType == 'agency'">
and e.GRID_PIDS like CONCAT(#{gridPids},'%')
</if>
<if test="orgType == 'grid'">
and e.GRID_ID=#{orgId}
</if>
and CUSTOMER_ID = #{customerId}
and CREATED_TIME >= #{queryStartTime}
and CREATED_TIME <![CDATA[<=]]> #{queryEndTime}
</where>
group by STATUS
</select>
<select id="listProcessAnalysisEvents" resultType="com.epmet.dto.result.IcEventResultDTO">
select e.ID eventId,
e.GRID_ID gridId,
e.EVENT_CONTENT eventContent,
e.SOURCE_TYPE sourceType,
e.REPORT_USER_ID reportUserId,
e.NAME reportUserName,
e.MOBILE mobile,
e.STATUS processStatus
from ic_event e
inner join ic_event_category c on (e.ID = c.IC_EVENT_ID)
<where>
e.CUSTOMER_ID = #{customerId}
and e.CREATED_TIME >= #{queryStartTime}
and e.CREATED_TIME <![CDATA[<=]]> #{queryEndTime}
<if test="orgType == 'agency'">
and e.GRID_PIDS like CONCAT(#{gridPids},'%')
</if>
<if test="orgType == 'grid'">
and e.GRID_ID=#{orgId}
</if>
<if test="processStatus != null and processStatus != ''">
and e.STATUS = #{processStatus}
</if>
<if test="categoryCode != null and categoryCode != ''">
and c.CATEGORY_CODE = #{categoryCode}
</if>
</where>
</select>
<select id="listMonthlyEventCount" resultType="com.epmet.dto.result.IcEventMonthlyCountResultDTO">
select t.monthName, count(1) eventCount
from (
select date_format(e.HAPPEN_TIME, '%Y-%m') monthName
from ic_event e
<where>
e.HAPPEN_TIME >= date_format(#{queryStartTime}, '%Y-%m')
and e.HAPPEN_TIME <![CDATA[ <= ]]> date_format(#{queryEndTime}, '%Y-%m')
<if test="orgType == 'grid'">
and e.GRID_ID =#{orgId}
</if>
<if test="orgType == 'agency'">
and e.GRID_PIDS like concat('',#{gridPids},'')
</if>
</where>
) t
group by t.monthName
</select>
<resultMap id="icEventMap" type="com.epmet.dto.result.IcEventListResultDTO">
<id property="icEventId" column="id"/>
<result property="gridId" column="grid_id"/>
<result property="sourceType" column="source_type" />
<result property="address" column="address" />
<result property="name" column="name" />
<result property="mobile" column="mobile" />
<result property="satisfaction" column="satisfaction" />
<result property="satisfactionName" column="satisfaction" />
<result property="createdTime" column="created_time" />
<result property="status" column="status" />
<result property="createdUserId" column="created_by" />
<result property="categoryId" column="CATEGORY_ID" />
<collection property="attachmentList" ofType="com.epmet.dto.result.IcEventListResultDTO$Attachment">
<result column="icEventAttachmentId"/><!-- 附件表ID,如果附件url和type一样会被去重 加上id就可以了 -->
<result column="url" property="url"/>
<result column="type" property="type"/>
<result column="duration" property="duration"/>
</collection>
</resultMap>
<select id="icEventList" parameterType="map" resultMap="icEventMap">
SELECT
ie.id icEventId,
ie.grid_id gridId,
ie.event_content eventContent,
ie.source_type sourceType,
ie.address address,
ie.`name` name,
ie.mobile mobile,
ie.satisfaction satisfaction,
IF(ie.satisfaction = 'bad','不满意',IF (ie.satisfaction = 'good','基本满意',IF (ie.satisfaction = 'perfect','非常满意',''))) satisfactionName,
ie.created_time createdTime,
ie.`status` status,
ie.created_by createdUserId,
rea.attachment_url as img_url,
rea.id AS iceventattachmentid,
rea.attachment_url AS url,
rea.attachment_type AS type,
rea.duration AS duration,
iec.category_id AS categoryId
FROM
ic_event ie
LEFT JOIN ic_event_attachment rea ON(ie.id = rea.ic_event_id AND rea.del_flag = '0')
LEFT JOIN ic_event_category iec ON(ie.id = iec.ic_event_id AND iec.del_flag = '0')
WHERE
ie.del_flag = '0'
<if test="icEventId != null and icEventId != '' ">
AND ie.id = #{icEventId}
</if>
<if test="gridId != null and gridId != '' ">
AND ie.grid_id = #{gridId}
</if>
<if test="sourceType != null and sourceType != '' ">
AND ie.source_type = #{sourceType}
</if>
<if test="eventContent != null and eventContent != '' ">
AND ie.event_content LIKE CONCAT('%', #{eventContent}, '%')
</if>
<if test="name != null and name != '' ">
AND ie.`name` LIKE CONCAT('%', #{name}, '%')
</if>
<if test="mobile != null and mobile != '' ">
AND ie.mobile = #{mobile}
</if>
<if test="startTime != null and startTime != '' ">
AND DATE_FORMAT(ie.created_time,"%Y-%m-%d %H:%i") <![CDATA[>=]]> #{startTime}
</if>
<if test="endTime != null and endTime != '' ">
AND DATE_FORMAT(ie.created_time,"%Y-%m-%d %H:%i") <![CDATA[<=]]> #{endTime}
</if>
<if test="status != null and status != '' ">
AND ie.`status` = #{status}
</if>
order by ie.latest_operated_time desc, rea.sort asc
</select>
<select id="selectFirstCategoryTotal" parameterType="com.epmet.dto.form.IcEventCategoryAnalysisFormDTO" resultType="com.epmet.dto.result.IcEventCategoryAnalysisResDTO">
SELECT LEFT
( c.CATEGORY_CODE, #{categoryOneLength} ) CATEGORY_CODE,
COUNT( DISTINCT c.IC_EVENT_ID ) total
FROM
ic_event_category c
LEFT JOIN ic_event e ON ( c.IC_EVENT_ID = e.ID AND e.DEL_FLAG = '0' )
WHERE
c.DEL_FLAG = '0'
AND c.CUSTOMER_ID = #{customerId}
and e.HAPPEN_TIME >= #{queryStartTime}
and e.HAPPEN_TIME <![CDATA[<=]]> #{queryEndTime}
<if test="orgType == 'agency'">
and e.GRID_PIDS like CONCAT(#{gridPids},'%')
</if>
<if test="orgType == 'grid'">
and e.GRID_ID=#{orgId}
</if>
GROUP BY
LEFT ( c.CATEGORY_CODE, #{categoryOneLength} )
ORDER BY
total DESC
</select>
<!-- 查询客户下可以自动评价事件的ID -->
<select id="getAutoEvaluationIds" resultType="java.lang.String">
SELECT ID
FROM ic_event
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND `STATUS` = 'closed_case'
AND SATISFACTION = null
AND UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(CLOSE_CASE_TIME) > 60*60*24*7
LIMIT #{no},#{size}
</select>
<select id="selectGridTotal" parameterType="java.lang.String" resultType="java.lang.Integer">
SELECT
count( ie.id ) as total
FROM
ic_event ie
WHERE
ie.DEL_FLAG = '0'
AND ie.GRID_ID =#{gridId}
</select>
<select id="selectOrgTotal" parameterType="map" resultType="java.lang.Integer">
SELECT
count( ie.id ) as total
FROM
ic_event ie
WHERE
ie.DEL_FLAG = '0'
<if test="orgType == 'agency'">
and ie.GRID_PIDS like CONCAT('%',#{orgId},'%')
</if>
<if test="orgType == 'grid'">
and ie.GRID_ID=#{orgId}
</if>
</select>
</mapper>