<?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.harmonic.mapper.HarmonicMapper">

    <select id="getIntegrityData" resultType="HarmonicDeptVO">
        SELECT
            A.Id,
            A.Pid,
            A.Pids,
            A.`Name` name,
            A.State,
            A.Sort,
            A.Level,
            D.`Name` voltageLevel,
            D1.`Name` factoryName,
            C.IP networkParam,
            C.Update_Time time,
            A2.`Name` deviceName,
            D2.`Name` loadType
        FROM
            pq_line A,
            pq_voltage B,
            pq_line A1,
            pq_device C,
            pq_line A2,
            sys_dict_data D,
            sys_dict_data D1,
            pq_line_detail E,
            sys_dict_data D2
        WHERE
            A.Id IN
            <foreach item="item" collection="list" separator="," open="(" close=")">
                #{item}
            </foreach>
        AND A.Pid = B.Id
        AND B.Id = A1.Id
        AND B.Scale = D.Id
            <if test="voltageList != null and voltageList.size()>0">
            AND B.Scale IN
                <foreach item="item1" collection="voltageList" separator="," open="(" close=")">
                    #{item1}
                </foreach>
            </if>
        AND A1.Pid = C.Id
        AND C.Dev_Data_Type IN (1,2)
        AND C.Run_Flag = 0
        AND C.Dev_Model = 1
        AND C.Id = A2.Id
            <if test="deviceList != null and deviceList.size()>0">
            AND C.Manufacturer IN
                <foreach item="item2" collection="deviceList" separator="," open="(" close=")">
                    #{item2}
                </foreach>
            </if>
        AND C.Manufacturer = D1.Id
        AND A.Id = E.Id
        AND E.Load_Type = D2.Id
            <if test="interferenceList != null and interferenceList.size()>0">
                AND E.Load_Type IN
                <foreach item="item3" collection="interferenceList" separator="," open="(" close=")">
                    #{item3}
                </foreach>
            </if>
    </select>

    <select id="getLineInfoByList" resultType="HarmonicDeptVO">
        SELECT
            A.id,
            A.Pid,
            A.Pids,
            A.`Name`,
            A.Sort,
            A.Level level
        FROM
            pq_line A
        WHERE
            A.Id IN
            <foreach item="item" collection="list" separator="," open="(" close=")">
                #{item}
            </foreach>
    </select>

    <select id="getSubstationInfoByList" resultType="HarmonicDeptVO">

        SELECT
            A.id,
            A.Pid,
            A.Pids,
            A.`Name`,
            A.Sort,
            A.Level level,
            C.`Name` voltageLevel
        FROM
            pq_line A,
            pq_substation B,
            sys_dict_data C
        WHERE
            A.Id IN
            <foreach item="item" collection="list" separator="," open="(" close=")">
                #{item}
            </foreach>
            AND A.Id = B.Id AND B.Scale = C.Id
    </select>

    <select id="getReportMonitor" resultType="string">
        SELECT
            Id
        FROM
            pq_line_detail
        WHERE
            Monitor_Id IS NOT NULL
        AND
            Id IN
            <foreach item="item" collection="list" separator="," open="(" close=")">
                #{item}
            </foreach>
    </select>

</mapper>
