<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-6-23 下午02:54:49  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="CON_CONTRACT_CONTENT_FILE">
    <bm:fields>
        <bm:field name="content_file_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTENT_FILE_ID" prompt="CON_CONTRACT_CONTENT_FILE.CONTENT_FILE_ID"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON_CONTRACT_CONTENT_FILE.CONTRACT_ID"/>
        <bm:field name="content_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTENT_NUMBER" prompt="CON_CONTRACT_CONTENT_FILE.CONTENT_NUMBER"/>
        <bm:field name="clause_usage" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CLAUSE_USAGE" prompt="CON_CONTRACT_CONTENT_FILE.CLAUSE_USAGE"/>
        <bm:field name="templet_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TEMPLET_ID" prompt="CON_CONTRACT_CONTENT_FILE.TEMPLET_ID"/>
        <bm:field name="con_contract_bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CON_CONTRACT_BP_ID" prompt="CON_CONTRACT_CONTENT_FILE.CON_CONTRACT_BP_ID"/>
        <bm:field name="mortgage_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="MORTGAGE_ID" prompt="CON_CONTRACT_CONTENT_FILE.MORTGAGE_ID"/>
        <bm:field name="content_print_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTENT_PRINT_FLAG" prompt="CON_CONTRACT_CONTENT_FILE.CONTENT_PRINT_FLAG"/>
        <bm:field name="available_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="AVAILABLE_FLAG" prompt="CON_CONTRACT_CONTENT_FILE.AVAILABLE_FLAG"/>
        <bm:field name="file_date" databaseType="DATE" datatype="java.util.Date" physicalName="FILE_DATE" prompt="CON_CONTRACT_CONTENT_FILE.FILE_DATE"/>
        <bm:field name="file_place" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_PLACE" prompt="CON_CONTRACT_CONTENT_FILE.FILE_PLACE"/>
        <bm:field name="file_person" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_PERSON" prompt="CON_CONTRACT_CONTENT_FILE.FILE_PERSON"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="CON_CONTRACT_CONTENT_FILE.DESCRIPTION"/>
        <bm:field name="ref_v01" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V01" prompt="CON_CONTRACT_CONTENT_FILE.REF_V01"/>
        <bm:field name="ref_v02" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V02" prompt="CON_CONTRACT_CONTENT_FILE.REF_V02"/>
        <bm:field name="ref_v03" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V03" prompt="CON_CONTRACT_CONTENT_FILE.REF_V03"/>
        <bm:field name="ref_v04" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V04" prompt="CON_CONTRACT_CONTENT_FILE.REF_V04"/>
        <bm:field name="ref_v05" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V05" prompt="CON_CONTRACT_CONTENT_FILE.REF_V05"/>
        <bm:field name="ref_n01" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N01" prompt="CON_CONTRACT_CONTENT_FILE.REF_N01"/>
        <bm:field name="ref_n02" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N02" prompt="CON_CONTRACT_CONTENT_FILE.REF_N02"/>
        <bm:field name="ref_n03" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N03" prompt="CON_CONTRACT_CONTENT_FILE.REF_N03"/>
        <bm:field name="ref_n04" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N04" prompt="CON_CONTRACT_CONTENT_FILE.REF_N04"/>
        <bm:field name="ref_n05" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N05" prompt="CON_CONTRACT_CONTENT_FILE.REF_N05"/>
        <bm:field name="ref_d01" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D01" prompt="CON_CONTRACT_CONTENT_FILE.REF_D01"/>
        <bm:field name="ref_d02" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D02" prompt="CON_CONTRACT_CONTENT_FILE.REF_D02"/>
        <bm:field name="ref_d03" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D03" prompt="CON_CONTRACT_CONTENT_FILE.REF_D03"/>
        <bm:field name="ref_d04" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D04" prompt="CON_CONTRACT_CONTENT_FILE.REF_D04"/>
        <bm:field name="ref_d05" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D05" prompt="CON_CONTRACT_CONTENT_FILE.REF_D05"/>
        <bm:field name="bp_category" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="bp_category_desc" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="bp_class" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="bp_class_desc" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" forInsert="false" forUpdate="false"/>
        <bm:field name="couple_guarantee_flag" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="templet_code" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="templet_name" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="templet_usage" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="clause_usage_name" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="attach_count" databaseType="NUMBER" datatype="java.lang.Long" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			select t1.content_file_id,
				       t2.contract_id,
				       t1.con_contract_bp_id,
				       t1.mortgage_id,
				       t1.content_number,
				       t1.content_print_flag,
				       t1.available_flag,
				       t1.file_date,
				       t1.file_place,
				       t1.file_person,
				       t1.creation_date,
				       t1.created_by,
				       t1.last_update_date,
				       t1.last_updated_by,
				       t1.description,
				       t1.ref_v01,
				       t1.ref_v02,
				       t1.ref_v03,
				       t1.ref_v04,
				       t1.ref_v05,
				       t1.ref_n01,
				       t1.ref_n02,
				       t1.ref_n03,
				       t1.ref_n04,
				       t1.ref_n05,
				       t1.ref_d01,
				       t1.ref_d02,
				       t1.ref_d03,
				       t1.ref_d04,
				       t1.ref_d05,
				       t2.bp_category,
				       (select d.description
				          from hls_bp_category d
				         where d.bp_category = t2.bp_category) bp_category_desc,
				       d.bp_class,
				       d.bp_class_desc,
				       t2.bp_id,
				       (select ach.ref_v01
				          from prj_project_act_ctrler_hd ach
				         where ach.project_id = cc.project_id
				           and ach.bp_id = t2.bp_id
				           and ach.bp_category = t2.bp_category) couple_guarantee_flag,
				       d.bp_name,
				       t1.templet_id,
				       (select ct.templet_code
				          from con_clause_templet ct
				         where ct.templet_id = t1.templet_id) templet_code,
				       (select ct.description
				          from con_clause_templet ct
				         where ct.templet_id = t1.templet_id) templet_name,
				       (select ct.templet_usage
				          from con_clause_templet ct
				         where ct.templet_id = t1.templet_id) templet_usage,
				       sc.code_value clause_usage,
				       sc.code_value_name clause_usage_name,
				       (select count(1) from fnd_atm_attachment_multi m where m.table_name='CON_CONTRACT_CONTENT_FILE' and m.table_pk_value=to_char(t1.content_file_id))attach_count
				  from con_contract_content_file     t1,
				       con_contract_bp          t2,
				       hls_bp_master_all_data_v d,
				       sys_code_values_v        sc,
				       con_contract             cc
				 where t1.con_contract_bp_id = t2.record_id
				   and t2.bp_id = d.bp_id
				   and sc.code = 'CON_TMPLET_USAGE'
				   and sc.code_value = t1.clause_usage
				   and t2.contract_id = cc.contract_id
				   and t1.contract_id=${@contract_id}
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <o:sequence-pk/>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="content_file_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="contract_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
