<?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.kafka.event.mapper.PqLineMapper">






    <select id="getBaseLedger" resultType="com.njcn.kafka.event.pojo.dto.LedgerBaseInfoDTO">
        select
        PQ_GDINFORMATION.name gdName,
        pq_line.GD_INDEX gdIndex,
        pq_line.line_index lineId,
        pq_line.name lineName,
        PQ_SUBVOLTAGE.SUBV_INDEX busBarId,
        PQ_SUBVOLTAGE.name busBarName,
        PQ_SUBVOLTAGE.SCALE,
        pq_device.dev_index devId,
        pq_device.name devName,
        pq_device.ip ip,
        pq_line.pt1/pq_line.pt2 pt,
        pq_line.ct1/pq_line.ct2 ct,
        pq_device.Status runFlag,
        PQ_SUBSTATION.sub_index stationId,
        PQ_SUBSTATION.name stationName
        from
        pq_line inner JOIN PQ_SUBVOLTAGE on pq_line.SUBV_INDEX = PQ_SUBVOLTAGE.SUBV_INDEX
        inner JOIN pq_device on PQ_SUBVOLTAGE.DEV_INDEX = pq_device.DEV_INDEX
        inner JOIN PQ_SUBSTATION on pq_device.SUB_INDEX = PQ_SUBSTATION.SUB_INDEX
        inner JOIN PQ_GDINFORMATION on pq_line.GD_INDEX =PQ_GDINFORMATION.GD_INDEX
        <where>
        and pq_line.line_index in
        <foreach collection="ids" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
            <if test="searchValue!=null and searchValue!=''">
                and (
                PQ_GDINFORMATION.name  LIKE '%' || #{searchValue} || '%'
                or PQ_SUBSTATION.name  LIKE '%' || #{searchValue} || '%'
                or pq_line.name  LIKE '%' || #{searchValue} || '%'
                )
            </if>
        </where>
    </select>




</mapper>
