<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: shenyamin
    $Date: 2018-11_03 上午11:00:06  
    $Revision: 3.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                 SELECT COUNT(1) v_count
      FROM (SELECT p.project_id
              FROM prj_project p, prj_project_lease_item v
             WHERE p.project_id = v.project_id
               AND (v.machine_number_70 = ${@machine_number} or v.machine_number = ${@machine_number})
               AND p.project_status <> 'CLOSED'
               AND nvl(p.secondary_lease, 'NO') = 'NO'
               and p.project_id <> nvl(${@project_id},1)
            UNION
            SELECT c.project_id
              FROM con_contract c, con_contract_lease_item h
             WHERE c.contract_id = h.contract_id
               AND (h.machine_number_70 = ${@machine_number} or h.machine_number = ${@machine_number})
               AND c.contract_status <> 'CANCEL'
               AND nvl(c.secondary_lease, 'NO') = 'NO'
               AND c.data_class = 'NORMAL'
               and c.project_id != nvl(${@project_id},1))
                ]]>
            </bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                begin
                    prj_project_pkg.project_submit(
                    p_project_id =>${@project_id}, 
                    p_user_id => ${/session/@user_id}
                    );
                end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                begin
                    prj_project_check_pkg.check_prj_lease_item(
                    p_project_id      =>${@project_id},
                    p_machine_number =>${@machine_number},
                    p_user_id => ${/session/@user_id}

                    );
                end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="v_count" databaseType="NUMBER" datatype="java.lang.Long" physicalName="v_count"/>
    </bm:fields>
</bm:model>
