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

    <select id="getDeviceLogData" resultType="DeviceLogVO">
        SELECT
        T.`Logs_Index` id,
        L.`Name` name,
        D.`Name` type,
        T.`Terminal_Describe` remark,
        T.`Update_Time` updateTime,
        T.`Update_By` updateBy
        FROM
        pqs_terminallogs T,
        pq_line L,
        sys_dict_data D
        WHERE
        T.State = 1
        AND T.Obj_Index = L.Id
        AND T.Terminal_Type = D.Id
        <if test="deviceLogParam.type!=null">
            AND T.Terminal_Type = '${deviceLogParam.type}'
        </if>
        <if test="deviceLogParam.searchBeginTime!=null">
            AND T.Update_Time >= '${deviceLogParam.searchBeginTime}'
        </if>
        <if test="deviceLogParam.searchEndTime!=null">
            AND '${deviceLogParam.searchEndTime}' >= T.Update_Time
        </if>
    </select>

    <select id="getEventLogData" resultType="EventLogVO">
        SELECT
        A.`Name` line,
        A3.`Name` substation,
        A4.`Name` powerCompany
        FROM
        pq_line A,
        pq_line A1,
        pq_line A2,
        pq_line A3,
        pq_line A4
        WHERE
        A.Id = #{lineId}
        AND A.Pid = A1.Id
        AND A1.Pid = A2.Id
        AND A2.Pid = A3.Id
        AND A3.Pid = A4.Id
    </select>


</mapper>