<?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.bs_level">
    <bm:operations>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                begin
  -- Call the procedure
  ds_report_common_pkg.init_bs_score_report(p_base_date_from => to_date(${@base_internal_period_num},'yyyymm'),
                                            p_base_date_to => last_day(to_date(${@base_internal_period_num},'yyyymm')),
                                            p_base_area => ${@base_area},
                                            p_base_agent_id => ${@base_agent_id},
                                            p_base_model => ${@base_model},
                                            p_report_date_from => to_date(${@report_internal_period_num},'yyyymm'),
                                            p_report_date_to => last_day(to_date(${@report_internal_period_num},'yyyymm')),
                                            p_report_area => ${@report_area},
                                            p_report_agent_id => ${@report_agent_id},
                                            p_report_model => ${@report_model},
                                            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 decode(t1.bs_level,9999,'合计',t1.bs_level) bs_level,
	    	  base_level_count,
	    	  report_level_count,
	    	  base_level_rate,
	    	  report_level_rate,
	    	  psi
  from con_bs_score_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>
