You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
3.4 KiB
79 lines
3.4 KiB
<?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.epmet.dao.BizPointTotalDetailDao">
|
|
|
|
<resultMap type="com.epmet.entity.BizPointTotalDetailEntity" id="bizPointTotalDetailMap">
|
|
<result property="id" column="ID"/>
|
|
<result property="customerId" column="CUSTOMER_ID"/>
|
|
<result property="agencyId" column="AGENCY_ID"/>
|
|
<result property="gridId" column="GRID_ID"/>
|
|
<result property="bizType" column="BIZ_TYPE"/>
|
|
<result property="objectId" column="OBJECT_ID"/>
|
|
<result property="totalPoint" column="TOTAL_POINT"/>
|
|
<result property="delFlag" column="DEL_FLAG"/>
|
|
<result property="revision" column="REVISION"/>
|
|
<result property="createdBy" column="CREATED_BY"/>
|
|
<result property="createdTime" column="CREATED_TIME"/>
|
|
<result property="updatedBy" column="UPDATED_BY"/>
|
|
<result property="updatedTime" column="UPDATED_TIME"/>
|
|
</resultMap>
|
|
<select id="selectDataByObject" resultType="com.epmet.dto.BizPointTotalDetailDTO">
|
|
select ID,
|
|
CUSTOMER_ID,
|
|
AGENCY_ID,
|
|
GRID_ID,
|
|
TOTAL_POINT
|
|
from biz_point_total_detail
|
|
where BIZ_TYPE = #{type}
|
|
and OBJECT_ID = #{objectId}
|
|
</select>
|
|
|
|
<!--查询object在指定范围内的排名-->
|
|
<select id="getRanking" resultType="java.lang.Integer">
|
|
select count(distinct p_2.TOTAL_POINT) + 1 as ranking
|
|
from biz_point_total_detail point
|
|
inner join biz_point_total_detail p_2
|
|
on (point.BIZ_TYPE = p_2.BIZ_TYPE and p_2.DEL_FLAG = 0 and
|
|
point.TOTAL_POINT < p_2.TOTAL_POINT
|
|
<if test="scope == 'grid'">
|
|
and point.GRID_ID = p_2.GRID_ID
|
|
</if>
|
|
<if test="scope == 'customer'">
|
|
and point.CUSTOMER_ID = p_2.CUSTOMER_ID
|
|
</if>
|
|
)
|
|
where
|
|
point.OBJECT_ID = #{groupId}
|
|
and point.BIZ_TYPE = #{bizType}
|
|
and point.DEL_FLAG = 0
|
|
</select>
|
|
|
|
<!--获取指定范围内最低排名。子查询是取最低分的那个对象出来-->
|
|
<select id="getMinRanking" resultType="java.lang.Integer">
|
|
select count(distinct p.TOTAL_POINT) + 1 as ranking
|
|
from biz_point_total_detail p
|
|
inner join
|
|
(select point.OBJECT_ID, point.BIZ_TYPE, point.GRID_ID, point.CUSTOMER_ID, point.TOTAL_POINT
|
|
from biz_point_total_detail point
|
|
|
|
where point.BIZ_TYPE = #{bizType}
|
|
and point.DEL_FLAG = 0
|
|
<if test="searchScope == 'grid'">
|
|
and point.GRID_ID = #{searchScopeId}
|
|
</if>
|
|
<if test="searchScope == 'customer'">
|
|
and point.CUSTOMER_ID = #{searchScopeId}
|
|
</if>
|
|
order by point.TOTAL_POINT asc limit 1) t
|
|
on (p.BIZ_TYPE = t.BIZ_TYPE
|
|
and p.TOTAL_POINT > t.TOTAL_POINT
|
|
<if test="searchScope == 'grid'">
|
|
and p.GRID_ID = t.GRID_ID
|
|
</if>
|
|
<if test="searchScope == 'customer'">
|
|
and p.CUSTOMER_ID = t.CUSTOMER_ID
|
|
</if>
|
|
)
|
|
</select>
|
|
</mapper>
|