<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1"
          baseTable="CON_CONTRACT_ARCHIVE_TEMP">
    <bm:fields>
        <bm:field name="record_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RECORD_ID"
                  prompt="CON_CONTRACT_ARCHIVE_TEMP.RECORD_ID"/>

        <bm:field name="doc_warehouse" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOC_WAREHOUSE"
                  prompt="CON_CONTRACT_ARCHIVE_TEMP.DOC_WAREHOUSE"/>
        <bm:field name="doc_cabinet" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOC_CABINET"
                  prompt="CON_CONTRACT_ARCHIVE_TEMP.DOC_CABINET"/>
        <bm:field name="doc_layers" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOC_LAYERS"
                  prompt="CON_CONTRACT_ARCHIVE_TEMP.DOC_LAYERS"/>
        <bm:field name="doc_order" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DOC_ORDER"
                  prompt="CON_CONTRACT_ARCHIVE_TEMP.DOC_ORDER"/>
        <bm:field name="res_doc_cabinet" databaseType="VARCHAR2" datatype="java.lang.String"
                  physicalName="RES_DOC_CABINET" prompt="CON_CONTRACT_ARCHIVE_TEMP.RES_DOC_CABINET"/>
        <bm:field name="res_doc_layers" databaseType="VARCHAR2" datatype="java.lang.String"
                  physicalName="RES_DOC_LAYERS" prompt="CON_CONTRACT_ARCHIVE_TEMP.RES_DOC_LAYERS"/>
        <bm:field name="res_doc_order" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RES_DOC_ORDER"
                  prompt="CON_CONTRACT_ARCHIVE_TEMP.RES_DOC_ORDER"/>
        <bm:field name="note" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NOTE"
                  prompt="CON_CONTRACT_ARCHIVE_TEMP.NOTE"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String"
                  physicalName="CONTRACT_NUMBER" prompt="CON_CONTRACT_ARCHIVE_TEMP.CONTRACT_NUMBER"/>
        <bm:field name="batch_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BATCH_ID"
                  prompt="CON_CONTRACT_ARCHIVE_TEMP.BATCH_ID"/>
        <bm:field name="err_message"/>
        <bm:field name="archive_flag"/>
        <bm:field name="complete_flag"/>
        <bm:field name="archive_date"/>
        <bm:field name="cert_receive_flag"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="record_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field name="batch_id" queryExpression="t1.batch_id=${@batch_id}"/>
    </bm:query-fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
               Select t1.record_id,
               decode(t1.cert_receive_flag,'Y','是'，'N','否') cert_receive_flag,
               t1.doc_warehouse,
               t1.doc_cabinet,
               t1.doc_layers,
               t1.doc_order,
               t1.res_doc_cabinet,
               t1.res_doc_layers,
               T1.res_doc_order,
               t1.note,
               t1.contract_number,
               t1.batch_id,
               t1.err_message,
               decode(t1.archive_flag,'Y','是'，'N','否') archive_flag,
               decode(t1.complete_flag,'Y','是'，'N','否') complete_flag,
               to_char(t1.archive_date,'yyyy-mm-dd') archive_date
          From con_contract_archive_temp t1
          Where t1.batch_id =${@batch_id}
         Order By decode(t1.err_message, Null, 2, 1)
         ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            begin
             con_contract_archive_pkg.save_data
                    (
                        p_batch_id=>${@batch_id},
                        p_user_id=>${/session/@user_id},
                        p_company_id =>${/session/@company_id}
                    );
             end;
         ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
