<?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.huatek.busi.mapper.BusiOtherSubTreeMapper">

  	<select id="findByEquipmentIdAndType" resultType="com.huatek.busi.entity.BusiOtherSubTree">
		SELECT
			t.id AS id ,
			t.parent_id AS parentId ,
			t.name AS name ,
			t.status AS status ,
			t.equipment_id AS equipmentId ,
			t.equipment_type AS equipmentType ,
			t.system_code AS systemCode ,
			t.site_id AS siteId ,
			t.create_time AS createTime
		FROM
			`busi_other_sub_tree` t
		WHERE
			t.equipment_id = #{equipmentId}
		AND t.equipment_type = #{equipmentType};

	</select>

	<select id="findByEquipmentId" parameterType="java.lang.String" resultType="com.huatek.busi.entity.BusiOtherSubTree">
		SELECT
			t.id AS id ,
			t.parent_id AS parentId ,
			t.name AS name ,
			t.status AS status ,
			t.equipment_id AS equipmentId ,
			t.equipment_type AS equipmentType ,
			t.system_code AS systemCode ,
			t.site_id AS siteId ,
			t.create_time AS createTime
		FROM
			`busi_other_sub_tree` t
		WHERE
			t.equipment_id = #{equipmentId};

	</select>

	<select id="findOtherlist" resultType="com.huatek.busi.vo.BusiHomePageVo">
		SELECT
		  t.id AS subTreeId,
		  tree.id AS mainTreeId,
		  ex.id AS subEquipmentId,
		  tree.`name` AS mainTreeName,
		  t.`name` AS subTreeName,
		  t.equipment_type AS equipmentType,
		  eva.type AS type,
		  sensor.sensor_code AS sensorCode,
		  sensor.sensor_name AS sensorName,
		  sensor.id AS sensorId
		FROM busi_other_sub_tree t,
		     busi_external_equipment ex,
		     busi_site_tree tree,
		     busi_other_sensor sensor,
		     busi_eva_monitor_config eva
		WHERE t.id = ex.equipment_id
		AND t.equipment_id = tree.id
		AND sensor.id = eva.sensor_id
		AND eva.equipment_type = t.equipment_type
		AND sensor.equipment_id = t.id
		AND eva.type = '4'
		AND t.status = '1'
		AND tree.status = '1'
		AND sensor.status = '1'
		AND eva.status = '1'
		AND t.equipment_type = #{equipmentType}
	</select>

	<select id="getOtherSubTreeByType" resultType="com.huatek.busi.entity.BusiOtherSubTree">
		SELECT
			t.id AS id ,
			t.parent_id AS parentId ,
			t.name AS name ,
			t.status AS status ,
			t.equipment_id AS equipmentId ,
			t.equipment_type AS equipmentType ,
			t.system_code AS systemCode ,
			t.site_id AS siteId ,
			t.create_time AS createTime
		FROM
			busi_other_sub_tree t
		 WHERE t.status='1' AND t.equipment_type=#{equipmentType}
	</select>

</mapper>
