<?xml version="1.0" encoding="UTF-8"?>
<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,
                        decode(v.unit_code,'40','业务部',v.DESCRIPTION) unit_name
                    FROM
                        exp_org_unit_vl v
                    WHERE
                        v.UNIT_CODE IN ('30', '40', '50') 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>
