<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: shenhaozhe  
    $Date: 2017-9-29 上午10:59:00  
    $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
                        v.UNIT_ID,
                        v.UNIT_CODE,
                        v.DESCRIPTION unit_name
                    FROM
                        exp_org_unit_vl v
                    WHERE
                        v.UNIT_CODE not IN ('10','130') AND
                        v.COMPANY_ID=${/session/@company_id} and
                        EXISTS
                        (SELECT
                            1
                        FROM
                            hn_wfl_unit_assigned hw
                        WHERE
                            hw.instance_id = ${@instance_id}
                        )
                    ) t1
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                begin
                hn_csh_payment_req_pkg.hn_wfl_unit_assined(p_instance_id =>${@instance_id},
                                p_unit_id     =>${@unit_id},
                                p_user_id     =>${/session/@user_id});
                end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
                delete from hn_wfl_unit_assigned t where t.instance_id = ${/parameter/@instance_id}
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                begin
                sdic_workflow_assign_pkg.submit_button_action(p_instance_id   =>${/parameter/@instance_id},
                                 p_user_id       =>${/session/@user_id},
                                 p_return_number =>${return_number});
                end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="unit_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="UNIT_ID"/>
        <bm:field name="unit_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="UNIT_CODE"/>
        <bm:field name="unit_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="UNIT_NAME"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="unit_code" queryExpression="T1.unit_code LIKE ${@unit_code}"/>
        <bm:query-field name="unit_name" queryExpression="T1.unit_name LIKE ${@unit_name}"/>
    </bm:query-fields>
</bm:model>
