<?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="io.renren.modules.dataSet.mapper.SubsystemMapper">

    <select id="subsystem" resultType="io.renren.modules.dataSet.entity.Subsystem">
        SELECT id,substring(name,5)  as name  FROM subSystem
    </select>

    <select id="getEquipment" resultType="io.renren.modules.dataSet.entity.Subsystem">
        SELECT
            id,substring(name,5)  as name
        FROM
            equipment
        WHERE
                id  IN(
                SELECT
                    subSystem_equipment.equipmentId
                FROM subSystem,subSystem_equipment
                WHERE
                    subSystem.id = subSystem_equipment.subSystemId
                  AND
                    subSystem.id =#{id,jdbcType=INTEGER}
            )
    </select>

    <select id="getSubequipment" resultType="io.renren.modules.dataSet.entity.Subsystem">
        SELECT id,substring(name,5)  as name,hbaseTableName  FROM subEquipment
        WHERE id IN(
            SELECT
                equipment_subEquipment.subEquipmentNameId
            FROM
                equipment,equipment_subEquipment
            WHERE
                equipment.id = equipment_subEquipment.equipmentNameId
              AND
                equipment.id =#{id,jdbcType=INTEGER}
        )
    </select>


    <select id="getcolumns" resultType="io.renren.modules.dataSet.entity.Subsystem">
        SELECT
            id, name
        FROM
            measurePoint
        where
                measurePoint.id
                IN(
                    SELECT
                        subEquipment_measurePoint.measurePointId
                    FROM
                        subEquipment_measurePoint
                    WHERE
                            subEquipment_measurePoint.subEquipmentId = #{equpmentId,jdbcType=INTEGER}
                )
    </select>
</mapper>
