<?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.pq.mapper.LineDetailMapper">

    <select id="getLineDetail" resultType="LineDetail">
        select b.* from pq_line a
        inner join pq_line_detail b on a.id=b.id
        where
            find_in_set(#{devIndex}, a.pids)
        and a.state = 1
        and b.Num in
        <foreach collection="num" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
    </select>

    <select id="getSpecifyLineDetail" resultType="LineDetail">
        SELECT
            D.*
        FROM
            pq_line A1,
            pq_line A2,
            pq_line A3,
            pq_line_detail B,
            pq_device C,
            pq_line_detail D
        WHERE
          <if test="list != null and list.size() > 0">
            A1.Id in
            <foreach collection="list" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
              AND
          </if>
          A1.`Level` = 6 AND A1.Id = B.Id AND
          A1.Pid = A2.Id AND A2.Pid = A3.Id AND A3.Id = C.Id AND
          C.Dev_Model = 1 AND C.Dev_Data_Type IN (1,2) AND C.Run_Flag = 0 AND A1.Id = D.Id
    </select>

    <select id="getLineDetailInfo" resultType="com.njcn.device.pq.pojo.vo.LineDetailDataVO">
        select
        a.name lineName,
        c.Time_Interval,
        e.name scale
        from pq_line a
        inner join pq_line b on a.pid = b.id
        inner join pq_line_detail c on a.id = c.id
        inner join pq_voltage d on b.id = d.id
        left join sys_dict_data e on d.scale = e.id
		where a.id in
		<foreach collection="lineIds" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>


    <select id="getMonitorDetail" resultType="com.njcn.device.biz.pojo.dto.LineDevGetDTO">
        select a.id pointId,a.name pointName,b.Time_Interval `interval`
        from pq_line a
        inner join pq_line_detail b on a.id=b.id
        where a.id = #{monitorId}
    </select>
</mapper>
