<?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="cn.cecep.talroad.mapper.PcStationBuildingMapper">

    <resultMap type="cn.cecep.talroad.domain.PcStationBuilding" id="PcStationBuildingResult">
        <result property="id"    column="id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="stationBuildingCode"    column="station_building_code"    />
        <result property="stationBuildingName"    column="station_building_name"    />
        <result property="equipmentBrandCems"    column="equipment_brand_cems"    />
        <result property="stationId"    column="station_id"    />
        <result property="stationName"    column="station_name"    />
        <result property="outletId"    column="outlet_id"    />
        <result property="outletName"    column="outlet_name"    />
    </resultMap>


    <sql id="selectPcStationBuildingVo">
        select id, factory_id, station_building_code, station_building_name, equipment_brand_cems, station_id, station_name, outlet_id, outlet_name from pc_station_building
    </sql>

    <select id="selectPcStationBuildingList" parameterType="cn.cecep.talroad.domain.PcStationBuilding" resultMap="PcStationBuildingResult">
        <include refid="selectPcStationBuildingVo"/>
        <where>
            <if test="factoryId != null  and factoryId != ''">
                and factory_id = #{factoryId}
            </if>
            <if test="stationBuildingCode != null  and stationBuildingCode != ''">
                and station_building_code = #{stationBuildingCode}
            </if>
            <if test="stationBuildingName != null  and stationBuildingName != ''">
                and station_building_name like concat('%', #{stationBuildingName}, '%')
            </if>
            <if test="equipmentBrandCems != null  and equipmentBrandCems != ''">
                and equipment_brand_cems = #{equipmentBrandCems}
            </if>
            <if test="stationId != null  and stationId != ''">
                and station_id = #{stationId}
            </if>
            <if test="stationName != null  and stationName != ''">
                and station_name like concat('%', #{stationName}, '%')
            </if>
            <if test="outletId != null  and outletId != ''">
                and outlet_id = #{outletId}
            </if>
            <if test="outletName != null  and outletName != ''">
                and outlet_name like concat('%', #{outletName}, '%')
            </if>
        </where>
    </select>

    <select id="selectByStationBuildingIds" resultMap="PcStationBuildingResult">
        <include refid="selectPcStationBuildingVo"/>
        where station_building_code in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item}
        </foreach>
    </select>
</mapper>
