<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: mumu  
    $Date: 2014-7-19 下午11:30:38  
    $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 t.*,decode(t.packet_number,1,'主车','挂车') car_type,
            t.contract_lease_item_id,
            t.engine,-- 发动机
            t.ref_v03,--车架号
            (SELECT h.bp_name FROM hls_bp_master h WHERE h.bp_id = main_ins_company) main_ins_company_n,
            (SELECT h.bp_name FROM hls_bp_master h WHERE h.bp_id = slave_ins_company) slave_ins_company_n,
            to_char(t.insurance_start_date,'yyyy-mm-dd') insurance_start_date_n FROM con_contract_lease_item t
				where t.contract_id = ${@contract_id} and t.packet_number = ${@packet_number}]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter name="contract_id"/>
                <bm:parameter name="packet_number"/>
            </bm:parameters>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        		begin
				  -- Call the procedure
				  con_contract_lease_item_pkg.cfl_update_item(p_contract_lease_item_id => ${@contract_lease_item_id},
				                                              p_engine => ${@engine},
				                                              p_ref_v03 => ${@ref_v03},
				                                              p_user_id => ${/session/@user_id});
				end;
        	]]></bm:update-sql>
            <!-- <bm:parameters>
                <bm:parameter name="contract_lease_item_id"/>
            </bm:parameters> -->
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_id"/>
        <bm:field name="contract_lease_item_id"/>
        <bm:field name="packet_number"/>
        <bm:field name="car_type"/>
        <bm:field name="policy_number"/>
        <bm:field name="main_ins_company_n"/>
        <bm:field name="slave_ins_company_n"/>
        <bm:field name="insurance_payment_status"/>
        <bm:field name="insurance_start_date_n"/>
        <bm:field name="engine"/>
        <bm:field name="ref_v03"/>
    </bm:fields>
</bm:model>
