<?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.IntegrityMapper">


    <select id="getIntegrityData" resultType="IntegrityVO">
        SELECT
            line.Id,
            line.Pid,
            line.Pids,
            line.`Name` NAME,
            line.Sort,
            line.LEVEL,
            scale.`Name` voltageLevel,
            factory.`Name` factoryName,
            pqdevice.IP networkParam,
            pqdevice.Update_Time time,
            pqdevice.Com_Flag state,
            device.`Name` deviceName,
            loadtype.`Name` loadType
        FROM
            pq_line line,
            pq_line_detail lineDetail,
            pq_line voltage,
            pq_voltage pqvoltage,
            pq_line device,
            pq_device pqdevice,
            sys_dict_data scale,
            sys_dict_data factory,
            sys_dict_data loadtype
        WHERE
            line.pid = voltage.id
        AND line.pid = pqvoltage.id
        AND pqvoltage.Scale = scale.id
        AND voltage.pid = device.id
        AND voltage.pid = pqdevice.id
        AND pqdevice.Manufacturer = factory.id
        AND line.id = lineDetail.id
        AND lineDetail.Load_Type = loadtype.id
        AND line.Id IN
            <foreach item="item" collection="list" separator="," open="(" close=")">
                #{item}
            </foreach>
    </select>

    <select id="getLineInfoByList" resultType="IntegrityVO">
        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="IntegrityVO">
        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="getProviceInfoByList" resultType="IntegrityVO">
        SELECT
        A.id,
        A.Pid,
        A.Pids,
        A.Sort,
        A.Level level,
        B.`Name` name
        FROM
        pq_line A,
        sys_area B
        WHERE
        A.Id IN
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
        AND A.name = B.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>
