<?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.yeejoin.equipmanage.mapper.RiskSourceSceneMapper">
    <resultMap id="riskSourceMap" type="com.yeejoin.equipmanage.common.entity.vo.RiskSourceTreeVO">
        <result property="id" column="id"/>
        <result property="parentId" column="parent_id"/>
        <result property="code" column="code"/>
        <result property="name" column="name"/>
        <result property="level" column="level"/>
        <result property="riskLevelId" column="risk_level_id"/>
        <result property="rpn" column="rpn"/>
        <result property="rpni" column="rpni"/>
        <result property="isRegion" column="is_region"/>
        <result property="isIndoor" column="is_indoor"/>
        <result property="status" column="status"/>
        <result property="count" column="ccount"/>
        <result property="qualified" column="qualified"/>
        <result property="unqualified" column="unqualified"/>
        <result property="omission" column="omission"/>
        <result property="unplan" column="unplan"/>
        <result property="position3d" column="position3d"/>
        <result property="tube" column="tube"/>
        <result property="port" column="port"/>
        <result property="password" column="password"/>
        <result property="account" column="account"/>
        <result property="ip" column="ip"/>
        <result property="rtspAddress" column="rtsp_address"/>
        <result property="url" column="url"/>
        <result property="carmeraType" column="carmera_type"/>
        <result property="token" column="token"/>
        <result property="riskSourceType" column="riskSourceType"/>
		<result property="sceneId" column="sceneId"/>
	</resultMap>
    <select id="getRiskSources" resultMap="riskSourceMap">
			SELECT
				id,
				`code`,
				parent_id,
				`name`,
				risk_level_id,
				rpn,
				rpni,
				is_region,
				position3d,
				floor3d,
				status,
				is_indoor,
				'menu' riskSourceType
			FROM
				`f_risk_source`
			where org_code = #{compCode} and is_region='TRUE'
			ORDER BY sort_num,id  ASC
	</select>

	<select id="getVideo" resultMap="riskSourceMap">
		select
		wlv.name,
		wlvs.id,
		wlv.token,
		wlv.carmera_type,
		wlv.url,
		wlv.rtsp_address,
		wlv.ip,
		wlv.account,
		wlv.password,
		wlv.port,
		wlv.position3d,
		wlv.tube,
		'video' riskSourceType,
		wlvs.source_id as sceneId
		from wl_video wlv
		left join wl_video_source wlvs on wlv.id = wlvs.video_id
		where wlvs.source_id=#{sourceId}
	</select>
	<select id="getImportantEquip" resultMap="riskSourceMap">
		select id,name,'false' is_region from f_equipment where risk_source_id=#{sourceId}
	</select>

	<select id="getAllImportantEquip" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo">
			 select
				 feq.id  as sequenceNbr,
				 feq.name as displayName ,
				 feq.risk_source_id as parentId,
				 'equip' as template
				 from f_equipment  as feq
	</select>
</mapper>
