<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: chenlingfeng  
    $Date: 2017-7-14 上午10:10:50  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HN_CHANCE_BP" defaultOrderBy="creation_date desc">
    <bm:operations>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
            begin
  -- Call the procedure
  hn_chance_bp_pkg.hn_chance_bp_save(p_chance_bp_id => ${@chance_bp_id},
                                     p_chance_bp_name => ${@chance_bp_name},
                                     p_hn_industry_classification => ${@hn_industry_classification},
                                     p_binary_classification => ${@binary_classification},
                                     p_orgcrdno => ${@orgcrdno},
                                     p_unit_id => ${@unit_id},
                                     p_contact_person => ${@contact_person},
                                     p_cell_phone => ${@cell_phone},
                                     p_id_card_no => ${@id_card_no},
                                     p_bp_class => ${@bp_class},
                                     p_enabled_flag => ${@enabled_flag},
                                     p_chance_source => ${@chance_source},
                                     p_user_id => ${/session/@user_id},
                                     p_company_id => ${/session/@company_id}
                                     );
end;
    ]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="chance_bp_id" dataType="java.lang.Long" input="true" output="true" outputPath="@chance_bp_id"/>
            </bm:parameters>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
         begin
  -- Call the procedure
  hn_chance_bp_pkg.hn_chance_bp_save(p_chance_bp_id => ${@chance_bp_id},
                                     p_chance_bp_name => ${@chance_bp_name},
                                     p_hn_industry_classification => ${@hn_industry_classification},
                                     p_binary_classification => ${@binary_classification},
                                     p_orgcrdno => ${@orgcrdno},
                                     p_unit_id => ${@unit_id},
                                     p_contact_person => ${@contact_person},
                                     p_cell_phone => ${@cell_phone},
                                     p_id_card_no => ${@id_card_no},
                                     p_bp_class => ${@bp_class},
                                     p_enabled_flag => ${@enabled_flag},
                                     p_chance_source => ${@chance_source},
                                     p_user_id => ${/session/@user_id},
                                     p_company_id => ${/session/@company_id}
                                     );
end;
            ]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="chance_bp_id" dataType="java.lang.Long" input="true" output="true" outputPath="@chance_bp_id"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="chance_bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CHANCE_BP_ID" prompt="HN_CHANCE_BP.CHANCE_BP_ID"/>
        <bm:field name="chance_bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CHANCE_BP_NAME" prompt="HN_CHANCE_BP.CHANCE_BP_NAME"/>
        <bm:field name="hn_industry_classification" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="HN_INDUSTRY_CLASSIFICATION" prompt="HN_CHANCE_BP.HN_INDUSTRY_CLASSIFICATION"/>
        <bm:field name="binary_classification" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BINARY_CLASSIFICATION" prompt="HN_CHANCE_BP.BINARY_CLASSIFICATION"/>
        <bm:field name="orgcrdno" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ORGCRDNO" prompt="HN_CHANCE_BP.ORGCRDNO"/>
        <bm:field name="unit_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="UNIT_ID" prompt="HN_CHANCE_BP.UNIT_ID"/>
        <bm:field name="contact_person" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTACT_PERSON" prompt="HN_CHANCE_BP.CONTACT_PERSON"/>
        <bm:field name="cell_phone" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CELL_PHONE" prompt="HN_CHANCE_BP.CELL_PHONE"/>
        <bm:field name="owner_user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OWNER_USER_ID" prompt="HN_CHANCE_BP.OWNER_USER_ID"/>
        <bm:field name="id_card_no" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ID_CARD_NO" prompt="HN_CHANCE_BP.ID_CARD_NO"/>
        <bm:field name="bp_class" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CLASS" prompt="HN_CHANCE_BP.BP_CLASS"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HN_CHANCE_BP.ENABLED_FLAG"/>
        <bm:field name="chance_source" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="owner_user_id_n" expression="(select description from sys_user su where su.user_id = t1.owner_user_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="creation_date_desc" databaseType="DATE" datatype="java.util.Date" expression="trunc(creation_date)" forInsert="false" forUpdate="false"/>
        <bm:field name="unit_id_n" expression="(select un.unit_name from exp_org_unit_v un where un.unit_id = t1.unit_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="is_bp" expression=" nvl((select &apos;商业伙伴&apos;              from dual             where exists (select 1                      from hls_bp_master hbm                     where hbm.bp_id = t1.bp_id)),            &apos;潜在客户&apos;)" forInsert="false" forUpdate="false"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <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:primary-key>
        <bm:pk-field name="chance_bp_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field name="chance_bp_name" queryExpression="t1.chance_bp_name like &apos;%&apos;||${@chance_bp_name}||&apos;%&apos;"/>
        <bm:query-field name="bp_class" queryExpression="t1.bp_class =${@bp_class}"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter expression="t1.bp_id is null"/>
    </bm:data-filters>
</bm:model>
