<?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.mapper.configuration.EventPushLogsDetailMapper'>
    <select id="getEventPushLogsDetail" resultType="EventPushLogsDetail">
        SELECT
            eventDetail.TIMEID timeId,
            eventlog.EVENTDETAIL_INDEX eventDetaileIndex,
            eventlog.line_index lineId,
            gd.name gdName,
            sub.name subName,
            line.name lineName,
            eventDetail.EVENTVALUE*100 eventValue,
            eventDetail.PERSISTTIME/1000 persistTime,
            eventlog.CREAT_TIME creatTime,
            eventlog.UPDATE_TIME updateTime,
            eventlog.USER_UPDATETIME userUpdateTime,
            eventlog.PUSHFAILED pushfailed,
            eventlog.RESULT result
        FROM
            PQS_EVENTPUSHLOGS eventlog,
            pq_line line,
            PQS_EVENTDETAIL eventDetail,
            PQ_SUBSTATION sub,
            PQ_GDINFORMATION gd
        WHERE
            eventlog.EVENTDETAIL_INDEX = eventDetail.EVENTDETAIL_INDEX
          AND eventlog.LINE_INDEX = line.LINE_INDEX
          AND line.GD_INDEX = gd.GD_INDEX
          AND line.SUB_INDEX = sub.SUB_INDEX
          AND eventlog.RESULT = #{result}
          and eventDetail.TIMEID between  #{startTime} and #{endTime}
    </select>

    <select id="getEventPushLogsDetails" resultType="EventPushLogsDetail">
        SELECT
            eventDetail.TIMEID timeId,
            eventlog.EVENTDETAIL_INDEX eventDetaileIndex,
            eventlog.line_index lineId,
            gd.name gdName,
            sub.name subName,
            line.name lineName,
            eventDetail.EVENTVALUE*100 eventValue,
            eventDetail.PERSISTTIME/1000 persistTime,
            eventlog.CREAT_TIME creatTime,
            eventlog.UPDATE_TIME updateTime,
            eventlog.USER_UPDATETIME userUpdateTime,
            eventlog.PUSHFAILED pushfailed,
            eventlog.RESULT result
        FROM
            PQS_EVENTPUSHLOGS eventlog,
            pq_line line,
            PQS_EVENTDETAIL eventDetail,
            PQ_SUBSTATION sub,
            PQ_GDINFORMATION gd
        WHERE
            eventlog.EVENTDETAIL_INDEX = eventDetail.EVENTDETAIL_INDEX
          AND eventlog.LINE_INDEX = line.LINE_INDEX
          AND line.GD_INDEX = gd.GD_INDEX
          AND line.SUB_INDEX = sub.SUB_INDEX
          and eventDetail.TIMEID between  #{startTime} and #{endTime}
    </select>

    <update id="updatEventPushLog">
        update PQS_EVENTPUSHLOGS set result=1,USER_UPDATETIME=#{userUpdateTime}
        where EVENTDETAIL_INDEX = #{eventDetailIndex} and line_index = #{lineId}
    </update>
</mapper>
