<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Feng  
    $Date: 2014-1-1 下午4:05:13  
    $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
                    cc.contract_id,
                    cc.contract_number,
                    to_char(cc.archive_date,'yyyy-mm-dd') archive_date,
                    cc.archive_flag,
                    cc.bp_id_tenant,
                    cc.contract_file_date,
                    cc.project_number,
                    cc.bp_name,
                    cc.business_type_desc,
                    cc.division_desc,
                    cc.bp_class_desc,
                    cc.invoice_agent_desc,
                    cc.project_id,
                    cc.express_number,
                    cc.express_province,
                    cc.express_province_n,
                    cc.express_city,
                    cc.express_city_n,
                   	to_char( cc.express_date,'yyyy-mm-dd') express_date,
                    cc.archive_status,
                    cc.archive_status_n,
                    cc.reg_status,
                    cc.reg_status_n,
                    cc.doc_type1,
                    cc.doc_type2,
                    to_char(cc.full_write_off_date,'yyyy-mm-dd') full_write_off_date,
                    cc.express_person,
                    cc.express_tel,
                    cc.express_note,
                    cc.express_address,
                    cc.lease_term,
                    cc.region,
                    cc.region_n,
                    cc.hd_user_col_v02,
                    to_char(cc.inception_of_lease,'yyyy-mm-dd') inception_of_lease
                FROM
                    con_contract_storage_v cc
                WHERE
                    cc.contract_id = ${/parameter/@contract_id}
            ]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter inputPath="/parameter/@contract_id"/>
            </bm:parameters>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        	begin
        		con_contract_pkg.contract_archive_save(p_contract_id => ${@contract_id},
        											   p_archive_date => ${@archive_date},
        											   p_archive_flag => ${@archive_flag},
        											   p_user_id => ${/session/@user_id});
        	end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:parameters>
                <bm:parameter name="doc_number" datatype="java.lang.Long" input="false" output="true" outputpath="/parameter/@doc_number"/>
                <!--    <bm:parameter name="location_number2" datatype="java.lang.Long" input="false" output="true" outputpath="/parameter/@location_number2"/> -->
            </bm:parameters>
            <!--  <bm:update-sql><![CDATA[
                BEGIN
                    IF ${@doc_type}='10' THEN
                        contract_archive_workflow_pkg.get_location_number_s1(location_number => ${@location_number});
                    ELSE
                        contract_archive_workflow_pkg.get_location_number_s2(location_number =>${@location_number2});
                    END IF;
                END;
            ]]></bm:update-sql> -->
            <bm:update-sql><![CDATA[
        
                BEGIN
                    SELECT
                        MAX( ccll.doc_number)
                    INTO
                        ${@doc_number}
                    FROM
                        CON_CONTRACT_LOCATION_LN ccll
                    WHERE
                        ccll.location_id=${@location_id};
                END;
               ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
