<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace='com.njcn.mapper.advanced.GetBalanceMapper'>
	<select id="getSarfiValue" resultType="java.lang.Float">
		select avg(eventvalue)
		from
		pqs_eventdetail where eventvalue &lt;= #{fvalue} and lineid
		= #{id}
		and
		timeid between #{start} and #{end}
	</select>

	<select id="getSarfiCount" resultType="java.lang.Integer">
		select count(*)
		from
		pqs_eventdetail where eventvalue &lt;= #{fvalue} and lineid
		= #{id}
		and
		timeid between #{start} and #{end} and persisttime &lt; 60000
	</select>

	<select id="getSarifiList" resultType="com.njcn.utils.GetBalance$Sarifi">
		select
		a.pt1 pt1,
		a.pt2 pt2,
		b.eventvalue
		sarifiValue,b.persisttime time from pq_line a,
		pqs_eventdetail b where
		b.lineid
		= #{id} and a.line_index = b.lineid
		and
		b.eventvalue &lt;= #{fvalue} and
		b.timeid between #{start} and #{end}
		and persisttime &lt; 60000
	</select>
</mapper>