<?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.shining.cloud.mapper.information.MonFlowMapper">
    <resultMap type="com.shining.cloud.pojo.information.MonFlow" id="MonFlowMap" autoMapping="true"></resultMap>
    <select id="getMonFlow" resultMap="MonFlowMap">
SELECT #{endTime} timeId,
	round(sum(actflow.ACTUALFLOW/(( dev.DATAPLAN + dev.NEWTRAFFIC ) * 1024 * 1024 ))*100,2) monFlow
FROM
	PQS_ACTUALFLOW actflow,
	PQ_DEVICEDETAIL dev
WHERE
	dev.DEV_INDEX = actflow.DEV_INDEX
	AND actflow.DEV_INDEX = #{devIndex}
	AND to_char( actflow.TIMEID, 'yyyy-MM-DD hh24:mi:ss' ) BETWEEN #{statTime} and #{endTime}
    </select>

    <select id="getMonFlows" resultType="Float">
SELECT
	nvl(round(sum(actflow.ACTUALFLOW/(( dev.DATAPLAN + dev.NEWTRAFFIC ) * 1024 * 1024 ))*100,2),0) monFlow
FROM
	PQS_ACTUALFLOW actflow,
	PQ_DEVICEDETAIL dev
WHERE
	dev.DEV_INDEX = actflow.DEV_INDEX
	AND actflow.DEV_INDEX = #{devIndex}
	AND to_char( actflow.TIMEID, 'yyyy-MM-DD hh24:mi:ss' ) BETWEEN #{statTime} and #{endTime}
    </select>

	<select id="getMonFlowByTop" resultType="com.shining.cloud.pojo.information.TopException">
		select * from pqs_topmsg where dev_index = #{devIndex} and timeid = #{startTime}
	</select>

	<select id="getAlarmByDev" resultType="com.shining.cloud.pojo.information.AlarmInfo">
		select
        min(occurredtime) occurredTime,
        descrpiption
        from pqs_alarminfo
        where type_index = #{devIndex}
        and devline_type = 1
        and occurredtime BETWEEN #{startTime} and #{endTime}
        group by
        type,
        type_index,
        devline_type,
        descrpiption
        order by occurredtime desc
	</select>
</mapper>
