<?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.zcloud.mapper.datasource.positAlarm.PositAlarmMapper">

	<update id="editDisposePerson">
		update
		integrated_link.reg_alarm_${CORPINFO_ID}
		set
		dispose_by = #{NAME}
		where
		id in
		<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
			#{item}
		</foreach>
	</update>
	<select id="findPositAlarmList" resultType="com.zcloud.entity.PageData">
		select id from integrated_link.reg_alarm_${CORPINFO_ID} where status = 0
	</select>

	<select id="findPositAlarmListByCorpIdlistPage" parameterType="page" resultType="pd">
		select f.id,
			   f.ele_id,
			   f.psn_id,
			   f.ele_type,
			   f.alarm_time,
			   f.lon,
			   f.lat,
			   f.alt,
			   f.dispose_by,
			   f.dispose_time,
			   f.dispose_str,
			   f.status,
			   f.remark,
			   f.layer_group,
			   f.psn_ids,
			   f.is_push,
			   f.gather_count,
			   f.level,
			   f.uuid,
			   u.NAME
		from integrated_link.reg_alarm_${pd.CORP_ID} f
		LEFT JOIN integrated_whb.sys_user u on u.PLS_ID = f.psn_id and u.CORPINFO_ID = #{pd.CORP_ID}
		WHERE 1=1
		<if test="pd.eleType != null and pd.eleType != ''"><!-- 告警类型 -->
			and f.ele_type = #{pd.eleType}
		</if>
		<if test="pd.status != null and pd.status != ''"><!-- 处理状态 -->
			and f.status = #{pd.status}
		</if>
		<if test="pd.str != null and pd.str != ''"><!-- 处理方式 -->
			and f.dispose_str LIKE CONCAT(CONCAT('%', #{pd.str}),'%')
		</if>
		<if test="pd.name != null and pd.name != ''"><!-- 触发人员 -->
			and u.NAME LIKE CONCAT(CONCAT('%', #{pd.name}),'%')
		</if>
		<if test="pd.layer_group != null and pd.layer_group != ''"><!-- 触发地点 -->
			and f.layer_group LIKE CONCAT(CONCAT('%', #{pd.layer_group}),'%')
		</if>
		<if test="pd.dispose_by != null and pd.dispose_by != ''"><!-- 处理人 -->
			and f.dispose_by LIKE CONCAT(CONCAT('%', #{pd.dispose_by}),'%')
		</if>
		order by f.alarm_time desc
	</select>
</mapper>
