<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: chenlingfeng
    $Date: 2018-12-31 18:17:30
    $Revision: 1.0
    $Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" defaultOrderBy="t1.ROW_LEVEL">
    <bm:operations>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                begin
  -- Call the procedure
  ds_report_common_pkg.init_bs_tm_report(p_internal_period_num => ${@base_internal_period_num} ,
                                            p_base_area => ${@base_area},
                                            p_base_agent_id => ${@base_agent_id},
                                            p_base_model => ${@base_model},
                                            p_bp_class => ${@bp_class},
                                            p_session_id => ${/session/@session_id},
                                            p_user_id => ${/session/@user_id});
end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
	    	  select

       SESSION_ID,
       UNDER_SIX_MONTH,
       ROW_LEVEL,
       decode(t1.ROW_LEVEL,0,'6个月内',9999,'合计',t1.ROW_LEVEL||'等级') bs_level_n,
       LEVEL_1,
       LEVEL_2,
       LEVEL_3,
       LEVEL_4,
       LEVEL_5,
       LEVEL_6,
       LEVEL_7,
       LEVEL_8,
       LEVEL_9,
       LEVEL_10,
       LEVEL_11,
       LEVEL_12,
       LEVEL_13,
       LEVEL_14,
       LEVEL_15,
       SUM_RESULT
  from CON_BS_TM_REPORT t1

#WHERE_CLAUSE#
#ORDER_BY_CLAUSE#

	    	]]></bm:query-sql>
        </bm:operation>
    </bm:operations>

    <bm:data-filters>
        <bm:data-filter name="query" expression="t1.session_id = ${/session/@session_id}"/>
    </bm:data-filters>
</bm:model>
