<?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.yfd.platform.modules.basedata.mapper.SubstationComponentMapper">
    <!--algorithmId,
                    stationCode, areaId, bayId, mainDeviceId,
                    componentName-->
    <select id="getComponentByBayPage" resultType="java.util.Map">
        SELECT
        t.*
        FROM
        iis_substation_component t  -- 明确主表别名
        LEFT JOIN iis_algorithm_class_component aac
        ON t.component_id = aac.component_id
        AND aac.algorithm_id = #{algorithmId}  -- 提前过滤子查询
        WHERE
        1 = 1
        <if test="stationCode != null and stationCode != ''">
            AND t.station_code = #{stationCode}
        </if>
        <if test="areaId != null and areaId != ''">
            AND t.area_id = #{areaId}
        </if>
        <if test="bayId != null and bayId != ''">
            AND t.bay_id = #{bayId}
        </if>
        <if test="mainDeviceId != null and mainDeviceId != ''">
            AND t.main_device_id = #{mainDeviceId}
        </if>
        <if test="componentName != null and componentName != ''">
            AND t.component_name LIKE CONCAT('%',#{componentName}, '%')
        </if>
        AND aac.component_id IS NULL

    </select>
</mapper>
