<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hand  
    $Date: 2016-5-14 下午2:17:49  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="CON_SETTLE_LIST">
    <bm:fields>
        <bm:field name="con_settle_list_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CON_SETTLE_LIST_ID" prompt="CON_SETTLE_LIST.CON_SETTLE_LIST_ID"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON_SETTLE_LIST.CONTRACT_ID"/>
        <!--  <bm:field name="settle_person" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SETTLE_PERSON" prompt="CON_SETTLE_LIST.SETTLE_PERSON"/> -->
        <bm:field name="settle_time" databaseType="DATE" datatype="java.util.Date" physicalName="SETTLE_TIME" prompt="CON_SETTLE_LIST.SETTLE_TIME"/>
        <bm:field name="note" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NOTE" prompt="CON_SETTLE_LIST.NOTE"/>
        <bm:field name="list1" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LIST1" prompt="CON_SETTLE_LIST.LIST1"/>
        <bm:field name="list2" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LIST2" prompt="CON_SETTLE_LIST.LIST2"/>
        <bm:field name="list3" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LIST3" prompt="CON_SETTLE_LIST.LIST3"/>
        <bm:field name="list4" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LIST4" prompt="CON_SETTLE_LIST.LIST4"/>
        <bm:field name="list5" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LIST5" prompt="CON_SETTLE_LIST.LIST5"/>
        <bm:field name="list6" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LIST6" prompt="CON_SETTLE_LIST.LIST6"/>
        <bm:field name="other1" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OTHER1" prompt="CON_SETTLE_LIST.OTHER1"/>
        <bm:field name="other2" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OTHER2" prompt="CON_SETTLE_LIST.OTHER2"/>
        <bm:field name="other3" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OTHER3" prompt="CON_SETTLE_LIST.OTHER3"/>
        <bm:field name="other4" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OTHER4" prompt="CON_SETTLE_LIST.OTHER4"/>
        <bm:field name="other5" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OTHER5" prompt="CON_SETTLE_LIST.OTHER5"/>
        <bm:field name="other6" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OTHER6" prompt="CON_SETTLE_LIST.OTHER6"/>
        <!--         <bm:field name="v_exists" databaseType="NUMBER" datatype="java.lang.Long"  forInsert="false"  forUpdate="false"  forSelect="false" />
 -->
        <bm:field name="settle_person" databaseType="VARCHAR2" datatype="java.lang.String" expression="(select user_name from sys_user s where s.user_id=t1.created_by)" forInsert="false"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="con_settle_list_id"/>
    </bm:primary-key>
    <bm:data-filters>
        <bm:data-filter name="contract_id" expression="t1.contract_id=${@contract_id}"/>
    </bm:data-filters>
    <bm:operations>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    IF ${@settle}='Y' THEN
                        UPDATE
                            con_contract c
                        SET
                            c.reg_status='50'
                        WHERE
                            c.contract_id=${@contract_id};
                    ELSE
                        UPDATE
                            CON_SETTLE_LIST t1
                        SET
                            t1.CONTRACT_ID     =${@contract_id},
                            t1.SETTLE_TIME     =to_date(${@settle_time},'yyyy-mm-dd'),
                            t1.NOTE            =${@note},
                            t1.LIST1           =${@list1},
                            t1.LIST2           =${@list2},
                            t1.LIST3           =${@list3},
                            t1.LIST4           =${@list4},
                            t1.LIST5           =${@list5},
                            t1.LIST6           =${@list6},
                            t1.OTHER1          =${@other1},
                            t1.OTHER2          =${@other2},
                            t1.OTHER3          =${@other3},
                            t1.OTHER4          =${@other4},
                            t1.OTHER5          =${@other5},
                            t1.OTHER6          =${@other6},
                            t1.LAST_UPDATED_BY =${/session/@user_id},
                            t1.LAST_UPDATE_DATE=sysdate
                        WHERE
                            t1.CON_SETTLE_LIST_ID = ${@con_settle_list_id} AND
                            t1.contract_id        =${@contract_id};
                    END IF;
                END;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                BEGIN
               
                    SELECT
                       count(*)
                    INTO
                       ${@v_exists}
                    FROM
                        hls_doc_file_content t
                    WHERE
                        t.document_id    = ${@document_id} AND
                        t.document_table = ${@document_table} AND
                        rownum           = 1;
                END;
            ]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="v_exists" dataType="java.lang.Long" input="true" output="true" outputpath="/parameter/@v_exists"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
</bm:model>
