<?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.csdevice.mapper.NodeMapper">

    <select id="nodeDeviceList" resultType="com.njcn.csdevice.pojo.vo.DeviceInfo">
        SELECT
        pq_device.Id id,
        pq_device.IP ip,
        s1.Name devType,
        pq_device.Port port,
        pq_line.Name name,
        sub.Name subName,
        pq_device.Update_Time updateTime,
        s2.Name manufacturer,
        pq_device.Com_Flag status,
        pq_device.Series series,
        pq_device_process.process_no processNo,
        pq_device.Dev_Key devKey,
        pq_node.max_Process_Num maxProcessNum
        FROM
        pq_device
        LEFT JOIN pq_node ON pq_node.Id = pq_device.Node_Id
        LEFT JOIN pq_line on pq_device.id = pq_line.id
        LEFT JOIN pq_line sub on pq_line.pid = sub.id
        LEFT JOIN pq_device_process on pq_device_process.id = pq_device.id
        LEFT JOIN pq_dev_type s1 ON pq_device.Dev_Type = s1.id
        LEFT JOIN sys_dict_data s2 ON pq_device.Manufacturer = s2.id
        <where>
            <if test="nodeDeviceParam.ip!=null  and nodeDeviceParam.ip != ''">
                pq_node.ip=#{nodeDeviceParam.ip}
            </if>
            <if test="nodeDeviceParam.devId!=null  and nodeDeviceParam.devId != ''">
                pq_device.id=#{nodeDeviceParam.devId}
            </if>
            <if test="nodeDeviceParam.runFlag!=null and nodeDeviceParam.runFlag.size()!=0">
                AND pq_device.Run_Flag in
                <foreach collection="nodeDeviceParam.runFlag" open="(" close=")" item="item" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
</mapper>
