<?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.njcn.device.pms.mapper.majornetwork.TerminalMapper">

    <select id="page" resultType="com.njcn.device.pms.pojo.vo.PmsTerminalVO">
        SELECT pms_terminal.*
        FROM pms_terminal pms_terminal
        WHERE ${ew.sqlSegment}
    </select>
    <select id="selectTerminalList" resultType="com.njcn.device.pms.pojo.vo.RStatDevSignalVO">
        SELECT
            Id as terminalId,
            NAME as terminalName,
            Org_Name  as orgName,
            Org_Id as orgId,
            ip  as ip,
            PORT  as port,
            Terminal_State  as deviceStatus,
            Com_Flag  as runStatus,
            Update_Time  as updateTime
        FROM
            pms_terminal
        <where>
            <if test="ids != null and ids.size > 0">
                AND Org_Id IN
                <foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
                    #{item}
                </foreach>
            </if>
            <if test="param.deviceName != null and param.deviceName !=''">
                and pms_terminal.id like  concat('%',#{param.deviceName},'%')
            </if>
            <if test="param.deviceStatus != null and param.deviceStatus !='' ">
                and pms_terminal.Terminal_State = #{param.deviceStatus}
            </if>
            <if test="param.runStatus != null and param.runStatus !='' ">
                and pms_terminal.Com_Flag = #{param.runStatus}
            </if>
        </where>

    </select>
</mapper>
