<?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.gather.monitor.mapper.PqMonitorMapper">

    <select id="selectMonitorInfo"
            resultType="com.njcn.gather.device.pojo.vo.PreDetection$MonitorListDTO">
        SELECT CONCAT(pq_dev.IP, '_', Num) as lineId,
               Num                      as line,
               pt                       as ptStr,
               ct                       as ctStr,
               Stat_Interval,
               sys_dict_data.Code       as `Connection`
        FROM pq_monitor
                 inner join sys_dict_data on pq_monitor.Connection = sys_dict_data.id
                 inner join pq_dev on pq_monitor.Dev_Id = pq_dev.Id
        WHERE Dev_Id = #{devId}
    </select>

    <select id="getByDevIdAndNum" resultType="com.njcn.gather.monitor.pojo.po.PqMonitor">
        select pq_monitor.Id,
               pq_monitor.Dev_Id,
               pq_monitor.Name,
               pq_monitor.Busbar,
               pq_monitor.Num,
               pq_monitor.Pt,
               pq_monitor.Ct,
               pq_monitor.Stat_Interval,
               pq_monitor.Harm_Sys_Id,
               sys_dict_data.Code as `Connection`
        from pq_monitor
                 inner join sys_dict_data on pq_monitor.Connection = sys_dict_data.id
        where Dev_Id = #{devId}
          and Num = #{num}
    </select>
    <select id="listByDevIds" resultType="com.njcn.gather.monitor.pojo.po.PqMonitor">
        select *
        from pq_monitor
        where Dev_Id in
        <foreach collection="devIds" item="devId" open="(" separator="," close=")">
            #{devId}
        </foreach>
        order by Num
    </select>
</mapper>

