<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: mumu  
    $Date: 2013-10-31 下午03:32:46  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[select * from 
(select r.rp_agreement_id,r.rp_agreement_number,c.contract_number,c.contract_status,c.contract_id,
v1.code_value_name as contract_status_desc,r.status as rp_agreement_status, v2.code_value_name as rp_agreement_status_desc,
r.created_by,u.description as created_name,to_char(r.creation_date,'yyyy-mm-dd') creation_date,to_char(r.repurchase_date,'yyyy-mm-dd') repurchase_date,
c.bp_id_tenant,m.bp_code,m.bp_name as bp_tenant_name,
c.bp_id_agent_level1,
(select bp_name from hls_bp_master where bp_id = c.bp_id_agent_level1) bp_id_agent_desc
from con_contract_rp_hd r,con_contract c,hls_bp_master m,
sys_code_values_v v1,sys_code_values_v v2,sys_user u
where r.contract_id = c.contract_id(+)
  and c.bp_id_tenant = m.bp_id(+)
  and r.created_by = u.user_id(+)
  and c.contract_status = v1.code_value(+)
  and r.status = v2.code_value(+)
  and v1.code = 'CON500_CONTRACT_STATUS'
  and v2.code = 'CON_RP_STATUS' order by r.rp_agreement_id desc) v #WHERE_CLAUSE# #ORDER_BY_CLAUSE#]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="bp_code" dataType="java.lang.String" queryExpression="v.bp_code = ${@bp_code}"/>
        <bm:query-field name="creation_date_from" dataType="java.lang.String" queryExpression="v.creation_date &gt;= ${@creation_date_from}"/>
        <bm:query-field name="creation_date_to" dataType="java.lang.String" queryExpression="v.creation_date &lt;= ${@creation_date_to}"/>
        <bm:query-field name="contract_number" dataType="java.lang.String" queryExpression="v.contract_number = ${@contract_number}"/>
        <bm:query-field name="repurchase_date" dataType="java.lang.String" queryExpression="v.repurchase_date = ${@repurchase_date}"/>
        <bm:query-field name="contract_status" dataType="java.lang.String" queryExpression="v.contract_status = ${@contract_status}"/>
        <bm:query-field name="rp_agreement_number" dataType="java.lang.String" queryExpression="v.rp_agreement_number=${@rp_agreement_number}"/>
        <bm:query-field name="rp_agreement_status" dataType="java.lang.String" queryExpression="v.rp_agreement_status=${@rp_agreement_status}"/>
    </bm:query-fields>
</bm:model>
