<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qwm  
    $Date: 2013-10-29 下午3:38:35  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="PRJ_BP_MANAGEMENT_SALES_LV">
    <!-- <bm:fields>
        <bm:field name="seq_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SEQ_ID" prompt="PRJ_BP_MANAGEMENT_SALES_LV.SEQ_ID"/>
        <bm:field name="prj_bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PRJ_BP_ID" prompt="PRJ_BP_MANAGEMENT_SALES_LV.PRJ_BP_ID"/>
        <bm:field name="product_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRODUCT_NAME" prompt="PRJ_BP_MANAGEMENT_SALES_LV.PRODUCT_NAME"/>
        <bm:field name="sales_year1" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SALES_YEAR1" prompt="PRJ_BP_MANAGEMENT_SALES_LV.SALES_YEAR1"/>
        <bm:field name="ratio_year1" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RATIO_YEAR1" prompt="PRJ_BP_MANAGEMENT_SALES_LV.RATIO_YEAR1"/>
        <bm:field name="growth_year1" databaseType="NUMBER" datatype="java.lang.Long" physicalName="GROWTH_YEAR1" prompt="PRJ_BP_MANAGEMENT_SALES_LV.GROWTH_YEAR1"/>
        <bm:field name="sales_year2" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SALES_YEAR2" prompt="PRJ_BP_MANAGEMENT_SALES_LV.SALES_YEAR2"/>
        <bm:field name="ratio_year2" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RATIO_YEAR2" prompt="PRJ_BP_MANAGEMENT_SALES_LV.RATIO_YEAR2"/>
        <bm:field name="growth_year2" databaseType="NUMBER" datatype="java.lang.Long" physicalName="GROWTH_YEAR2" prompt="PRJ_BP_MANAGEMENT_SALES_LV.GROWTH_YEAR2"/>
        <bm:field name="sales_year3" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SALES_YEAR3" prompt="PRJ_BP_MANAGEMENT_SALES_LV.SALES_YEAR3"/>
        <bm:field name="ratio_year3" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RATIO_YEAR3" prompt="PRJ_BP_MANAGEMENT_SALES_LV.RATIO_YEAR3"/>
        <bm:field name="growth_year3" databaseType="NUMBER" datatype="java.lang.Long" physicalName="GROWTH_YEAR3" prompt="PRJ_BP_MANAGEMENT_SALES_LV.GROWTH_YEAR3"/>
        <bm:field name="sales_year4" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SALES_YEAR4" prompt="PRJ_BP_MANAGEMENT_SALES_LV.SALES_YEAR4"/>
        <bm:field name="ratio_year4" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RATIO_YEAR4" prompt="PRJ_BP_MANAGEMENT_SALES_LV.RATIO_YEAR4"/>
        <bm:field name="growth_year4" databaseType="NUMBER" datatype="java.lang.Long" physicalName="GROWTH_YEAR4" prompt="PRJ_BP_MANAGEMENT_SALES_LV.GROWTH_YEAR4"/>
        <bm:field name="end_date" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="END_DATE" prompt="PRJ_BP_MANAGEMENT_SALES_LV.END_DATE"/>
        <bm:field name="ref_v01" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V01" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_V01"/>
        <bm:field name="ref_v02" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V02" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_V02"/>
        <bm:field name="ref_v03" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V03" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_V03"/>
        <bm:field name="ref_v04" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V04" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_V04"/>
        <bm:field name="ref_v05" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V05" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_V05"/>
        <bm:field name="ref_n01" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N01" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_N01"/>
        <bm:field name="ref_n02" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N02" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_N02"/>
        <bm:field name="ref_n03" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N03" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_N03"/>
        <bm:field name="ref_n04" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N04" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_N04"/>
        <bm:field name="ref_n05" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N05" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_N05"/>
        <bm:field name="ref_d01" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D01" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_D01"/>
        <bm:field name="ref_d02" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D02" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_D02"/>
        <bm:field name="ref_d03" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D03" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_D03"/>
        <bm:field name="ref_d04" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D04" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_D04"/>
        <bm:field name="ref_d05" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D05" prompt="PRJ_BP_MANAGEMENT_SALES_LV.REF_D05"/>
    </bm:fields>
    <bm:features>
        <f:standard-who xmlns:f="leaf.database.features"/>
    </bm:features>
    <bm:data-filters>
        <bm:data-filter name="prj_bp_id" enforceOperations="query" expression="exists ( select 1 from PRJ_PROJECT_BP b where b.project_id =${@project_id} and b.prj_bp_id = t1.prj_bp_id)"/>
    </bm:data-filters> -->
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                select t1.PRJ_BP_ID,
    t1.PRODUCT_NAME,
    to_char(t1.SALES_YEAR1,'FM99,999,999,990.00') SALES_YEAR1,
    t1.RATIO_YEAR1,
    t1.GROWTH_YEAR1,
    to_char(t1.SALES_YEAR2,'FM99,999,999,990.00') SALES_YEAR2,
    t1.RATIO_YEAR2,
    t1.GROWTH_YEAR2,
    to_char(t1.SALES_YEAR3,'FM99,999,999,990.00') SALES_YEAR3,
    t1.RATIO_YEAR3,
    t1.GROWTH_YEAR3,
    to_char(t1.SALES_YEAR4,'FM99,999,999,990.00') SALES_YEAR4,
    t1.RATIO_YEAR4,
    t1.GROWTH_YEAR4,
    t1.END_DATE
  from prj_bp_management_sales_lv t1
 where exists (select 1
          from PRJ_PROJECT_BP b
         where b.project_id = ${@project_id}
           and b.prj_bp_id = t1.prj_bp_id)
union all
select t1.PRJ_BP_ID,
     '总计' PRODUCT_NAME,
    to_char(sum(t1.SALES_YEAR1),'FM99,999,999,990.00'),
    sum(t1.RATIO_YEAR1),
    sum(t1.GROWTH_YEAR1),
    to_char(sum(t1.SALES_YEAR2),'FM99,999,999,990.00'),
    sum(t1.RATIO_YEAR2),
    sum(t1.GROWTH_YEAR2),
    to_char(sum(t1.SALES_YEAR3),'FM99,999,999,990.00'),
    sum(t1.RATIO_YEAR3),
    sum(t1.GROWTH_YEAR3),
    to_char(sum(t1.SALES_YEAR4),'FM99,999,999,990.00'),
    sum(t1.RATIO_YEAR4),
    sum(t1.GROWTH_YEAR4),
    null END_DATE
  from prj_bp_management_sales_lv t1
 where exists (select 1
          from PRJ_PROJECT_BP b
         where b.project_id = ${@project_id}
           and b.prj_bp_id = t1.prj_bp_id)
 group by t1.prj_bp_id

            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
