<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qm  
    $Date: 2014-4-21 上午10:02:36  
    $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="AST_CAR_TRAILER">
    <bm:fields>
        <bm:field name="ast_car_trailer_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="AST_CAR_TRAILER_ID" prompt="AST_CAR_TRAILER.AST_CAR_TRAILER_ID"/>
        <bm:field name="item_detail_id" databaseType="NUMBER" datatype="java.lang.Long" insertExpression="${/parameter/@item_detail_id}" physicalName="ITEM_DETAIL_ID" prompt="AST_CAR_TRAILER.ITEM_DETAIL_ID"/>
        <bm:field name="trailer_date" databaseType="DATE" datatype="java.util.Date" physicalName="TRAILER_DATE" prompt="AST_CAR_TRAILER.TRAILER_DATE"/>
        <bm:field name="trailer_place" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TRAILER_PLACE" prompt="AST_CAR_TRAILER.TRAILER_PLACE"/>
        <bm:field name="trailer_partner" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TRAILER_PARTNER" prompt="AST_CAR_TRAILER.TRAILER_PARTNER"/>
        <bm:field name="trailer_fee" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TRAILER_FEE" prompt="AST_CAR_TRAILER.TRAILER_FEE"/>
        <bm:field name="trailer_result" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TRAILER_RESULT" prompt="AST_CAR_TRAILER.TRAILER_RESULT"/>
        <bm:field name="disposal_scheme" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DISPOSAL_SCHEME" prompt="AST_CAR_TRAILER.DISPOSAL_SCHEME"/>
        <bm:field name="trailer_reason" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TRAILER_REASON" prompt="AST_CAR_TRAILER.TRAILER_REASON"/>
        <bm:field name="trail_wfl_status" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="trail_fee_status" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="estimate_amount" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="trail_wfl_status_desc" expression="(select v.code_value_name           from sys_code_values_v v          where v.code = &apos;AST_CAR_TRAILER_STATUS&apos; and v.code_value = t1.trail_wfl_status)"/>
        <bm:field name="trail_fee_status_desc" expression="(select v.code_value_name           from sys_code_values_v v          where v.code = &apos;AST_CAR_TRAILER_STATUS&apos;            and v.code_value = t1.trail_fee_status)"/>
        <bm:field name="trail_other_fee" databaseType="NUMBER" datatype="java.lang.Double"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk sequenceName="AST_CAR_TRAILER_S"/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="ast_car_trailer_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
                begin
        ast_car_pkg.ast_trail_car_req_create(p_item_detail_id  =>${@item_detail_id},
                                     p_trailer_date     =>to_date(${@trailer_date},'yyyy-mm-dd'),
                                     p_trailer_place    =>${@trailer_place},
                                     p_trailer_partner  =>${@trailer_partner},
                                     p_trailer_fee      =>${@trailer_fee},
                                     p_trailer_result   =>${@trailer_result},
                                     p_disposal_scheme  =>${@disposal_scheme},
                                     p_trailer_reason   =>${@trailer_reason},
                                     p_estimate_amount  =>${@estimate_amount},
                                     p_user_id          =>${/session/@user_id},
                                     p_trail_other_fee   =>${@trail_other_fee});
                end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
   begin
         
            UPDATE
    AST_CAR_TRAILER t1
SET
    t1.ITEM_DETAIL_ID  =${@item_detail_id},
    t1.TRAILER_DATE    =to_date(${@trailer_date},'yyyy-mm-dd'),
    t1.TRAILER_PLACE   =${@trailer_place},
    t1.TRAILER_PARTNER =${@trailer_partner},
    t1.TRAILER_FEE     =${@trailer_fee},
    t1.TRAILER_RESULT  =${@trailer_result},
    t1.DISPOSAL_SCHEME =${@disposal_scheme},
    t1.TRAILER_REASON  =${@trailer_reason},
    t1.trail_wfl_status=${@trail_wfl_status},
    t1.trail_fee_status=${@trail_fee_status},
    t1.estimate_amount=${@estimate_amount},
    t1.trail_other_fee=${@trail_other_fee},
    t1.LAST_UPDATED_BY =${/session/@user_id},
    t1.LAST_UPDATE_DATE=sysdate
WHERE
    t1.AST_CAR_TRAILER_ID = ${@ast_car_trailer_id};
  
    end;
      ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="item_detail_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
