<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129
    $Date: 2013-10-16 上午11:24:23 
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HLS_MORTGAGE" defaultOrderBy="t1.mortgage_code desc">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    SELECT t1.MORTGAGE_ID,
       t1.MORTGAGE_CODE,
       t1.MORTGAGE_NAME,   
       t1.MORTGAGE_TYPE,
       (select v3.code_value_name
          from sys_code_values_v v3
         where v3.code = 'HLS209_MORTGAGE_TYPE'
           and v3.code_value = t1.Mortgage_Type) MORTGAGE_TYPE_DESC, 
        t1.MORTGAGE_AST_CLASSFICATION,
       (select v2.code_value_name
          from sys_code_values_v v2
         where (v2.code = 'HLS209_ASSET_MORTGAGE' or
               v2.code = 'HLS209_ASSET_PLEDGE')
           and v2.code_value = t1.MORTGAGE_AST_CLASSFICATION) MORTGAGE_AST_CLASS_DESC,   
        t1.MORTGAGE_ASSET_DETAIL,
       (select v.code_value_name
          from sys_code_values_v v
         where (v.code = 'HLS209_ASSET_DETAIL_RIGHT_P' or
               v.code = 'HLS209_ASSET_DETAIL_MOVABLE_PROPERTY_M' or
               v.code = 'HLS209_ASSET_DETAIL_IMMOVABLE_PROPERTY_M')
           and v.code_value = t1.MORTGAGE_ASSET_DETAIL) MORTGAGE_ASSET_DETAIL_DESC,
       
       t1.MORTGAGE_CONTRACT_NO,
       t1.PROJECT_ID,
       t1.MORTGAGE_REGISTER_NO,
       t1.MORTGAGE_REGISTED_DEPT,
       t1.BP_ID_MORTGAGOR,
       t1.MORTGAGOR_NAME,
       (select m.bp_name from hls_bp_master m where m.bp_id=t1.bp_id_mortgagor)bp_id_mortgagor_n,
       t1.VALUE,
       t1.CURRENCY,
       t1.UOM,
       t1.QUANTITY,
       t1.MORTGAGE_STATUS,
       (select v.code_value_name from sys_code_values_v v where v.code='HLS209_MORTGAGE_STATUS' and v.code_value=t1.mortgage_status)mortgage_status_desc,
       t1.START_DATE,
       t1.END_DATE,
       t1.BP_ID_EVALUATOR,
       t1.EVALUATOR_NAME,
       t1.OWNERSHIP,
       t1.OCCUPIED,
       t1.LOCATION,
       t1.ESTATE_LICENSE_CODE,
       t1.HOUSING_AREA,
       t1.USE,
       t1.CONSTRUCTION_DATE,
       t1.BUILDING_STRUCTURE,
       t1.LAND_CERTIFICATE_CODE,
       t1.LAND_AREA,
       t1.LAND_USE_RIGHTS_TYPE,
       t1.LAND_USE_RIGHTS_START_DATE,
       t1.USABLE_PERIOD,
       t1.CONSTRUCTION_AREA,
       t1.STATUS_OF_LAND_USE,
       t1.COMPANY_NAME_STOCK,
       t1.STOCK_NAME,
       t1.STOCK_CODE,
       t1.STOCK_AMOUNT,
       t1.STOCK_RATIO,
       t1.FAIR_VALUE,
       t1.APPRAISE_DATE,
       t1.TOTAL_VALUE,
       t1.BVPS,
       t1.EQUIPMENT_TYPE,
       t1.PATTERN,
       t1.SPECIFICATION,
       t1.ENABLED_FLAG,
       t1.NOTE,
       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.PROJECT_NUMBER,
       t2.PROJECT_NAME
  FROM HLS_MORTGAGE t1
  LEFT OUTER JOIN PRJ_PROJECT t2 ON t1.PROJECT_ID = t2.PROJECT_ID
  #WHERE_CLAUSE#
 order by t1.mortgage_code desc
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <s:bm-script><![CDATA[
            var cx = Packages.leaf.javascript.Context.getCurrentContext();
            Packages.leaf.plugin.script.engine.ScriptImportor.defineExternScript(cx, this, $ctx.getData(), "aut_authority_bm_validate.js");
        ]]></s:bm-script>
    </bm:features>
    <bm:fields>
        <bm:field name="mortgage_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="MORTGAGE_ID" prompt="HLS_MORTGAGE.MORTGAGE_ID"/>
        <bm:field name="mortgage_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGE_CODE" prompt="HLS_MORTGAGE.MORTGAGE_CODE"/>
        <bm:field name="mortgage_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGE_NAME" prompt="HLS_MORTGAGE.MORTGAGE_NAME"/>
        <bm:field name="mortgage_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGE_TYPE" prompt="HLS_MORTGAGE.MORTGAGE_TYPE"/>
        <bm:field name="mortgage_ast_classfication" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGE_AST_CLASSFICATION" prompt="HLS_MORTGAGE.MORTGAGE_AST_CLASSFICATION"/>
        <bm:field name="mortgage_asset_detail" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGE_ASSET_DETAIL" prompt="HLS_MORTGAGE.MORTGAGE_ASSET_DETAIL"/>
        <bm:field name="mortgage_contract_no" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGE_CONTRACT_NO" prompt="HLS_MORTGAGE.MORTGAGE_CONTRACT_NO"/>
        <bm:field name="mortgage_type_desc"/>
        <bm:field name="mortgage_ast_class_desc"/>
        <bm:field name="mortgage_asset_detail_desc"/>
        <bm:field name="project_name"/>
        <bm:field name="project_number"/>
        <bm:field name="mortgage_status_desc"/>
        <bm:field name="bp_id_mortgagor_n"/>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID" prompt="HLS_MORTGAGE.PROJECT_ID"/>
        <bm:field name="mortgage_register_no" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGE_REGISTER_NO" prompt="HLS_MORTGAGE.MORTGAGE_REGISTER_NO"/>
        <bm:field name="mortgage_registed_dept" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGE_REGISTED_DEPT" prompt="HLS_MORTGAGE.MORTGAGE_REGISTED_DEPT"/>
        <bm:field name="bp_id_mortgagor" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_MORTGAGOR" prompt="HLS_MORTGAGE.BP_ID_MORTGAGOR"/>
        <bm:field name="mortgagor_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGOR_NAME" prompt="HLS_MORTGAGE.MORTGAGOR_NAME"/>
        <bm:field name="value" databaseType="NUMBER" datatype="java.lang.Long" physicalName="VALUE" prompt="HLS_MORTGAGE.VALUE"/>
        <bm:field name="currency" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY" prompt="HLS_MORTGAGE.CURRENCY"/>
        <bm:field name="uom" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="UOM" prompt="HLS_MORTGAGE.UOM"/>
        <bm:field name="quantity" databaseType="NUMBER" datatype="java.lang.Long" physicalName="QUANTITY" prompt="HLS_MORTGAGE.QUANTITY"/>
        <bm:field name="mortgage_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MORTGAGE_STATUS" prompt="HLS_MORTGAGE.MORTGAGE_STATUS"/>
        <bm:field name="start_date" databaseType="DATE" datatype="java.util.Date" physicalName="START_DATE" prompt="HLS_MORTGAGE.START_DATE"/>
        <bm:field name="end_date" databaseType="DATE" datatype="java.util.Date" physicalName="END_DATE" prompt="HLS_MORTGAGE.END_DATE"/>
        <bm:field name="bp_id_evaluator" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_EVALUATOR" prompt="HLS_MORTGAGE.BP_ID_EVALUATOR"/>
        <bm:field name="evaluator_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EVALUATOR_NAME" prompt="HLS_MORTGAGE.EVALUATOR_NAME"/>
        <bm:field name="ownership" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OWNERSHIP" prompt="HLS_MORTGAGE.OWNERSHIP"/>
        <bm:field name="occupied" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OCCUPIED" prompt="HLS_MORTGAGE.OCCUPIED"/>
        <bm:field name="location" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOCATION" prompt="HLS_MORTGAGE.LOCATION"/>
        <bm:field name="estate_license_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ESTATE_LICENSE_CODE" prompt="HLS_MORTGAGE.ESTATE_LICENSE_CODE"/>
        <bm:field name="housing_area" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HOUSING_AREA" prompt="HLS_MORTGAGE.HOUSING_AREA"/>
        <bm:field name="use" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="USE" prompt="HLS_MORTGAGE.USE"/>
        <bm:field name="construction_date" databaseType="DATE" datatype="java.util.Date" physicalName="CONSTRUCTION_DATE" prompt="HLS_MORTGAGE.CONSTRUCTION_DATE"/>
        <bm:field name="building_structure" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUILDING_STRUCTURE" prompt="HLS_MORTGAGE.BUILDING_STRUCTURE"/>
        <bm:field name="land_certificate_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LAND_CERTIFICATE_CODE" prompt="HLS_MORTGAGE.LAND_CERTIFICATE_CODE"/>
        <bm:field name="land_area" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LAND_AREA" prompt="HLS_MORTGAGE.LAND_AREA"/>
        <bm:field name="land_use_rights_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LAND_USE_RIGHTS_TYPE" prompt="HLS_MORTGAGE.LAND_USE_RIGHTS_TYPE"/>
        <bm:field name="land_use_rights_start_date" databaseType="DATE" datatype="java.util.Date" physicalName="LAND_USE_RIGHTS_START_DATE" prompt="HLS_MORTGAGE.LAND_USE_RIGHTS_START_DATE"/>
        <bm:field name="usable_period" databaseType="NUMBER" datatype="java.lang.Long" physicalName="USABLE_PERIOD" prompt="HLS_MORTGAGE.USABLE_PERIOD"/>
        <bm:field name="construction_area" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONSTRUCTION_AREA" prompt="HLS_MORTGAGE.CONSTRUCTION_AREA"/>
        <bm:field name="status_of_land_use" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STATUS_OF_LAND_USE" prompt="HLS_MORTGAGE.STATUS_OF_LAND_USE"/>
        <bm:field name="company_name_stock" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_NAME_STOCK" prompt="HLS_MORTGAGE.COMPANY_NAME_STOCK"/>
        <bm:field name="stock_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STOCK_NAME" prompt="HLS_MORTGAGE.STOCK_NAME"/>
        <bm:field name="stock_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STOCK_CODE" prompt="HLS_MORTGAGE.STOCK_CODE"/>
        <bm:field name="stock_amount" databaseType="NUMBER" datatype="java.lang.Long" physicalName="STOCK_AMOUNT" prompt="HLS_MORTGAGE.STOCK_AMOUNT"/>
        <bm:field name="stock_ratio" databaseType="NUMBER" datatype="java.lang.Long" physicalName="STOCK_RATIO" prompt="HLS_MORTGAGE.STOCK_RATIO"/>
        <bm:field name="fair_value" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FAIR_VALUE" prompt="HLS_MORTGAGE.FAIR_VALUE"/>
        <bm:field name="appraise_date" databaseType="DATE" datatype="java.util.Date" physicalName="APPRAISE_DATE" prompt="HLS_MORTGAGE.APPRAISE_DATE"/>
        <bm:field name="total_value" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TOTAL_VALUE" prompt="HLS_MORTGAGE.TOTAL_VALUE"/>
        <bm:field name="bvps" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BVPS" prompt="HLS_MORTGAGE.BVPS"/>
        <bm:field name="equipment_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EQUIPMENT_TYPE" prompt="HLS_MORTGAGE.EQUIPMENT_TYPE"/>
        <bm:field name="pattern" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PATTERN" prompt="HLS_MORTGAGE.PATTERN"/>
        <bm:field name="specification" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SPECIFICATION" prompt="HLS_MORTGAGE.SPECIFICATION"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HLS_MORTGAGE.ENABLED_FLAG"/>
        <bm:field name="note" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NOTE" prompt="HLS_MORTGAGE.NOTE"/>
        <bm:field name="ref_v01" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V01" prompt="HLS_MORTGAGE.REF_V01"/>
        <bm:field name="ref_v02" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V02" prompt="HLS_MORTGAGE.REF_V02"/>
        <bm:field name="ref_v03" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V03" prompt="HLS_MORTGAGE.REF_V03"/>
        <bm:field name="ref_v04" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V04" prompt="HLS_MORTGAGE.REF_V04"/>
        <bm:field name="ref_v05" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V05" prompt="HLS_MORTGAGE.REF_V05"/>
        <bm:field name="ref_n01" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N01" prompt="HLS_MORTGAGE.REF_N01"/>
        <bm:field name="ref_n02" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N02" prompt="HLS_MORTGAGE.REF_N02"/>
        <bm:field name="ref_n03" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N03" prompt="HLS_MORTGAGE.REF_N03"/>
        <bm:field name="ref_n04" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N04" prompt="HLS_MORTGAGE.REF_N04"/>
        <bm:field name="ref_n05" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N05" prompt="HLS_MORTGAGE.REF_N05"/>
        <bm:field name="ref_d01" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D01" prompt="HLS_MORTGAGE.REF_D01"/>
        <bm:field name="ref_d02" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D02" prompt="HLS_MORTGAGE.REF_D02"/>
        <bm:field name="ref_d03" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D03" prompt="HLS_MORTGAGE.REF_D03"/>
        <bm:field name="ref_d04" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D04" prompt="HLS_MORTGAGE.REF_D04"/>
        <bm:field name="ref_d05" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D05" prompt="HLS_MORTGAGE.REF_D05"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="mortgage_id" queryExpression="t1.mortgage_id=${@mortgage_id}"/>
        <bm:query-field name="mortgage_code" queryExpression="t1.mortgage_code like ${@mortgage_code}"/>
        <bm:query-field name="mortgage_name" queryExpression="t1.mortgage_name like ${@mortgage_name}"/>
        <bm:query-field name="mortgage_type" queryExpression="t1.mortgage_type=${@mortgage_type}"/>
        <bm:query-field name="mortgage_ast_classfication" queryExpression="t1.mortgage_ast_classfication=${@mortgage_ast_classfication}"/>
        <bm:query-field name="mortgage_asset_detail" queryExpression="t1.mortgage_asset_detail=${@mortgage_asset_detail}"/>
        <bm:query-field name="mortgage_contract_no" queryExpression="t1.mortgage_contract_no like ${@mortgage_contract_no}"/>
        <bm:query-field name="project_id" queryExpression="t1.project_id = ${@project_id}"/>
        <bm:query-field name="project_name" queryExpression="t2.project_name like ${@project_name}"/>
        <bm:query-field name="mortgage_register_no" queryExpression="t1.mortgage_register_no like ${@mortgage_register_no}"/>
        <bm:query-field name="bp_id_mortgagor" queryExpression="t1.bp_id_mortgagor =${@bp_id_mortgagor}"/>
        <bm:query-field name="bp_id_mortgagor_n" queryExpression="exists (select 1 from hls_bp_master m where m.bp_name like ${@bp_id_mortgagor_n} and m.bp_id=bp_id_mortgagor)"/>
        <bm:query-field name="mortgage_status" queryExpression="t1.mortgage_status = ${@mortgage_status}"/>
        <bm:query-field name="bp_id_evaluator" queryExpression="t1.bp_id_evaluator=${@bp_id_evaluator}"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.enabled_flag = &apos;Y&apos;"/>
    </bm:data-filters>
</bm:model>