<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qianming  
    $Date: 2016-3-16 下午7:58:25  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="RD_PROJECT_ANALYSE_DETAIL_V" defaultOrderBy="(case when project_id = ${/parameter/@project_id} then 1 else 2 end),project_number desc">
    <bm:fields>
        <bm:field name="target_type" databaseType="VARCHAR2" datatype="java.lang.String" prompt="RD_PROJECT_ANALYSE_DETAIL_V.TARGET_TYPE"/>
        <bm:field name="target_type_desc" expression="DECODE(target_type,&apos;ID_CARD&apos;,&apos;身份证号&apos;,&apos;PHONE&apos;,&apos;手机号&apos;,&apos;VIN&apos;,&apos;VIN码&apos;,&apos;ITEM_FRAME_NUMBER&apos;,&apos;车架号&apos;,&apos;&apos;)" prompt="维度"/>
        <bm:field name="target" databaseType="VARCHAR2" datatype="java.lang.String" prompt="RD_PROJECT_ANALYSE_DETAIL_V.TARGET"/>
        <bm:field name="bp_category" databaseType="VARCHAR2" datatype="java.lang.String" prompt="RD_PROJECT_ANALYSE_DETAIL_V.BP_CATEGORY"/>
        <bm:field name="bp_category_n" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" prompt="RD_PROJECT_ANALYSE_DETAIL_V.BP_ID"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" prompt="RD_PROJECT_ANALYSE_DETAIL_V.BP_NAME"/>
        <bm:field name="id_card_no" databaseType="VARCHAR2" datatype="java.lang.String" expression="decode(t1.bp_category_n,&apos;联系人&apos;,&apos;&apos;,t1.id_card_no)" prompt="RD_PROJECT_ANALYSE_DETAIL_V.ID_CARD_NO"/>
        <bm:field name="cell_phone" databaseType="VARCHAR2" datatype="java.lang.String" prompt="RD_PROJECT_ANALYSE_DETAIL_V.CELL_PHONE"/>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" prompt="RD_PROJECT_ANALYSE_DETAIL_V.PROJECT_ID"/>
        <bm:field name="project_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="project_status" databaseType="VARCHAR2" datatype="java.lang.String" lookupCode="PRJ501_PRJ_STATUS" lookupField="project_status_n" prompt="RD_PROJECT_ANALYSE_DETAIL_V.PROJECT_STATUS"/>
        <bm:field name="project_status_n" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="contract_status" databaseType="VARCHAR2" datatype="java.lang.String" prompt="RD_PROJECT_ANALYSE_DETAIL_V.CONTRACT_STATUS"/>
        <bm:field name="condition_code" databaseType="CHAR" datatype="java.lang.String" prompt="RD_PROJECT_ANALYSE_DETAIL_V.CONDITION_CODE"/>
        <bm:field name="bp_class" databaseType="VARCHAR2" datatype="java.lang.String" prompt="RD_PROJECT_ANALYSE_DETAIL_V.BP_CLASS"/>
        <bm:field name="current_users" expression="((SELECT c.bp_name                   FROM prj_project_bp c                  WHERE c.project_id = ${/parameter/@project_id}                    AND DECODE(t1.target_type,                               &apos;ID_CARD&apos;,                               c.id_card_no,                               &apos;PHONE&apos;,                               c.cell_phone) = t1.target) UNION                (SELECT c.bp_name_sp                   FROM prj_project_bp c                  WHERE c.project_id = ${/parameter/@project_id}                    AND DECODE(t1.target_type,                               &apos;ID_CARD&apos;,                               c.id_no_sp,                               &apos;PHONE&apos;,                               c.cell_phone_sp) = t1.target) union                (select hb.bp_name                   from prj_project b, hls_bp_master hb                  where b.project_id = ${/parameter/@project_id}                    and b.bp_id_tenant = hb.bp_id                    and decode(t1.target_type,                               &apos;ITEM_FRAME_NUMBER&apos;,                               (select g.item_frame_number                                  from prj_project_lease_item g                                 where g.project_id = b.project_id),                               &apos;&apos;) = t1.target) union                (select y.contact_person                   from prj_project_bp_contact_info y, prj_project_bp p                  where y.prj_bp_id = p.prj_bp_id and p.bp_category not in (&apos;TENANT&apos;, &apos;GUARANTOR&apos;)                  and decode(t1.target_type, &apos;PHONE&apos;, y.cell_phone,&apos;&apos;) =                        t1.target                    and p.project_id = ${/parameter/@project_id}) union                (select y.contact_person_1                   from prj_project_bp_contact_info y, prj_project_bp p                  where y.prj_bp_id = p.prj_bp_id    and p.bp_category not in (&apos;TENANT&apos;, &apos;GUARANTOR&apos;)                and decode(t1.target_type, &apos;PHONE&apos;, y.cell_phone_1,&apos;&apos;) =                        t1.target                    and p.project_id = ${/parameter/@project_id}))"/>
        <!-- <bm:field name="current_users" expression="DECODE(t1.project_id,               ${/parameter/@project_id},               (SELECT DECODE(PPB.BP_CATEGORY,                              &apos;TENANT&apos;,                              (SELECT c.bp_name                                 FROM prj_project_bp c                                WHERE c.project_id = ppb.project_id                                  AND DECODE(a.target_type,                                             &apos;ID_CARD&apos;,                                             c.id_card_no,                                             &apos;PHONE&apos;,                                             c.cell_phone,                                             &apos;VIN&apos;,                                             (select ppl.frame_for_prj from prj_project_lease_item ppl where ppl.project_id = t1.project_id),                                             &apos;ITEM_FRAME_NUMBER&apos;,                                             (SELECT m.item_frame_number                                                FROM prj_project_lease_item m                                               WHERE m.project_id = c.project_id)) =                                      a.target                               UNION                               SELECT c.bp_name_sp                                 FROM prj_project_bp c                                WHERE c.project_id = ppb.project_id                                  AND DECODE(a.target_type,                                             &apos;ID_CARD&apos;,                                             c.id_no_sp,                                             &apos;PHONE&apos;,                                             c.cell_phone_sp,                                             &apos;VIN&apos;,                                             (select ppl.frame_for_prj from prj_project_lease_item ppl where ppl.project_id = t1.project_id),                                             &apos;ITEM_FRAME_NUMBER&apos;,                                             (SELECT m.item_frame_number                                                FROM prj_project_lease_item m                                               WHERE m.project_id = c.project_id)) =                                      a.target),                              &apos;GUARANTOR&apos;,                              (SELECT h.bp_name                                 FROM prj_project_bp h                                WHERE h.project_id = ppb.project_id                                  AND DECODE(a.target_type,                                             &apos;ID_CARD&apos;,                                             h.id_card_no,                                             &apos;PHONE&apos;,                                             h.cell_phone,                                             &apos;VIN&apos;,                                             (select ppl.frame_for_prj from prj_project_lease_item ppl where ppl.project_id = t1.project_id),                                             &apos;ITEM_FRAME_NUMBER&apos;,                                             (SELECT m.item_frame_number                                                FROM prj_project_lease_item m                                               WHERE m.project_id = h.project_id)) =                                      a.target))                  FROM prj_project_bp ppb, RD_PROJECT_ANALYSE_DETAIL_V a                 WHERE ppb.project_id = t1.project_id                   AND a.project_id = t1.project_id                   AND a.target = t1.target),               t1.bp_name)"/> -->
    </bm:fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.target_type = ${@target_type}"/>
        <bm:data-filter enforceOperations="query" expression="t1.target = ${@target}"/>
        <bm:data-filter enforceOperations="query" expression="t1.condition_code = ${@condition_code}"/>
    </bm:data-filters>
</bm:model>
