<?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.OdsOnlineOlPortinfoAMapper">

    <resultMap type="cn.cecep.talroad.domain.OdsOnlineOlPortinfoA" id="OdsOnlineOlPortinfoAResult">
        <result property="id"    column="id"    />
        <result property="psId"    column="ps_id"    />
        <result property="portCode"    column="port_code"    />
        <result property="portNum"    column="port_num"    />
        <result property="portNameSuffix"    column="port_name_suffix"    />
        <result property="portName"    column="port_name"    />
        <result property="portTypeId"    column="port_type_id"    />
        <result property="portPosition"    column="port_position"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="monitorTypeId"    column="monitor_type_id"    />
        <result property="regionId"    column="region_id"    />
        <result property="isSintering"    column="is_sintering"    />
        <result property="enable"    column="enable"    />
        <result property="networkTime"    column="network_time"    />
        <result property="networkStatus"    column="network_status"    />
        <result property="opFlagNetworkTime"    column="op_flag_network_time"    />
        <result property="opFlagNetworkStatus"    column="op_flag_network_status"    />
        <result property="abnormalUp"    column="abnormal_up"    />
        <result property="abnormalDown"    column="abnormal_down"    />
        <result property="highChimney"    column="high_chimney"    />
        <result property="rubbish"    column="rubbish"    />
        <result property="outputRule"    column="output_rule"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="deleteTime"    column="delete_time"    />
        <result property="enableTime"    column="enable_time"    />
        <result property="portState"    column="port_state"    />
        <result property="isSync"    column="is_sync"    />
        <result property="outletId"    column="outlet_id"    />
        <result property="createdBy"    column="created_by"    />
        <result property="updatedBy"    column="updated_by"    />
        <result property="outletYq"    column="outlet_yq"    />
        <result property="pwxkBh"    column="pwxk_bh"    />
        <result property="gfPortId"    column="gf_port_id"    />
        <result property="sySky"    column="sy_sky"    />
    </resultMap>


    <sql id="selectOdsOnlineOlPortinfoAVo">
        select id, ps_id, port_code, port_num, port_name_suffix, port_name, port_type_id, port_position, longitude, latitude, monitor_type_id, region_id, is_sintering, enable, network_time, network_status, op_flag_network_time, op_flag_network_status, abnormal_up, abnormal_down, high_chimney, rubbish, output_rule, create_time, update_time, delete_time, enable_time, port_state, is_sync, outlet_id, created_by, updated_by, outlet_yq, pwxk_bh, gf_port_id, sy_sky from ods_online_ol_portinfo_a
    </sql>

    <select id="selectOdsOnlineOlPortinfoAList" parameterType="cn.cecep.talroad.domain.OdsOnlineOlPortinfoA" resultMap="OdsOnlineOlPortinfoAResult">
        <include refid="selectOdsOnlineOlPortinfoAVo"/>
        <where>
            <if test="psId != null  and psId != ''"> and ps_id = #{psId}</if>
            <if test="portCode != null  and portCode != ''"> and port_code = #{portCode}</if>
            <if test="portNum != null  and portNum != ''"> and port_num = #{portNum}</if>
            <if test="portNameSuffix != null  and portNameSuffix != ''"> and port_name_suffix = #{portNameSuffix}</if>
            <if test="portName != null  and portName != ''"> and port_name like concat('%', #{portName}, '%')</if>
            <if test="portTypeId != null  and portTypeId != ''"> and port_type_id = #{portTypeId}</if>
            <if test="portPosition != null  and portPosition != ''"> and port_position = #{portPosition}</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if>
            <if test="monitorTypeId != null  and monitorTypeId != ''"> and monitor_type_id = #{monitorTypeId}</if>
            <if test="regionId != null  and regionId != ''"> and region_id = #{regionId}</if>
            <if test="isSintering != null  and isSintering != ''"> and is_sintering = #{isSintering}</if>
            <if test="enable != null  and enable != ''"> and enable = #{enable}</if>
            <if test="networkTime != null  and networkTime != ''"> and network_time = #{networkTime}</if>
            <if test="networkStatus != null "> and network_status = #{networkStatus}</if>
            <if test="opFlagNetworkTime != null  and opFlagNetworkTime != ''"> and op_flag_network_time = #{opFlagNetworkTime}</if>
            <if test="opFlagNetworkStatus != null "> and op_flag_network_status = #{opFlagNetworkStatus}</if>
            <if test="abnormalUp != null  and abnormalUp != ''"> and abnormal_up = #{abnormalUp}</if>
            <if test="abnormalDown != null  and abnormalDown != ''"> and abnormal_down = #{abnormalDown}</if>
            <if test="highChimney != null  and highChimney != ''"> and high_chimney = #{highChimney}</if>
            <if test="rubbish != null  and rubbish != ''"> and rubbish = #{rubbish}</if>
            <if test="outputRule != null  and outputRule != ''"> and output_rule = #{outputRule}</if>
            <if test="deleteTime != null  and deleteTime != ''"> and delete_time = #{deleteTime}</if>
            <if test="enableTime != null  and enableTime != ''"> and enable_time = #{enableTime}</if>
            <if test="portState != null  and portState != ''"> and port_state = #{portState}</if>
            <if test="isSync != null  and isSync != ''"> and is_sync = #{isSync}</if>
            <if test="outletId != null  and outletId != ''"> and outlet_id = #{outletId}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and updated_by = #{updatedBy}</if>
            <if test="outletYq != null  and outletYq != ''"> and outlet_yq = #{outletYq}</if>
            <if test="pwxkBh != null  and pwxkBh != ''"> and pwxk_bh = #{pwxkBh}</if>
            <if test="gfPortId != null  and gfPortId != ''"> and gf_port_id = #{gfPortId}</if>
            <if test="sySky != null "> and sy_sky = #{sySky}</if>
        </where>
    </select>
    <select id="selectEnableStationInfo" resultMap="OdsOnlineOlPortinfoAResult">
        SELECT * FROM  ods_online_ol_portinfo_a a where a.ps_id in (
            select id from ods_online_ol_psinfo_a where "enable"='1'
        ) and a."enable"='1' and port_type_id = #{portTypeId} and monitor_type_id in ('monitor_type1','monitor_type2') and outlet_id is not null
    </select>

</mapper>
