<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: syj  
    $Date: 2015年7月16日10:47:10
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT 
                       p.chance_number,
                       p.project_name,
				       p.business_type_n,
				       p.project_type,
				       p.project_type_n,
				       p.chance_source_n,
				       (SELECT c.description
				          FROM hls_stat_class c
				         WHERE c.class_id = m.industry_big) industry_big_n,
				       (SELECT c.description
				          FROM hls_stat_class c
				         WHERE c.class_id = m.industry_medium) industry_medium_n,
				       (SELECT c.description
				          FROM hls_stat_class c
				         WHERE c.class_id = m.industry_small) industry_small_n,
				       p.lease_organization_n,
				       p.employee_id_n,
				       m.legal_person,
				       m.actual_controller,
				       m.business_license_num,
				       m.organization_code,
				       m.registered_capital,
				       m.paid_up_capital,
				       extract(year from m.founded_date)||'年'||extract(month from m.founded_date)||'月'||extract(day from m.founded_date)||'日' founded_date,
				       (SELECT v.code_value_name
				          FROM sys_code_values_v v
				         WHERE v.code = 'PRJ_NATURE_OF_BUSINESS'
				           AND v.code_enabled_flag = 'Y'
				           AND v.code_value_enabled_flag = 'Y'
				           AND v.code_value = m.company_nature) company_nature_n,
				       m.workers_number,
				       p.regular_customer,
				       decode(p.regular_customer,'N','否','Y','是') regular_customer_n,
				       TO_CHAR(ROUND(NVL(m.technical_person_rate, 0) * 100.0, 2)) technical_person_rate,
				       m.bussiness_scope,
				       m.primary_business,
				       (SELECT A.CITY_ID_N || A.DISTRICT_ID_N || A.ADDRESS
					  		FROM HLS_BP_MASTER_ADDRESS_LV A
					   WHERE A.ADDRESS_TYPE = 'COMPANY_ADDRESS'
					   and a.bp_id = m.bp_id
					   and rownum =1)registered_place,
				       m.bp_id,
				       p.chance_id,
				       p.tenant_industy_desc,
				       p.bp_tenant_desc,
				       p.build_info_desc,
				       p.payment_source,
				       p.risk_response_plan,
				       p.lease_programme_description
				       
				  FROM prj_chance_v p, hls_bp_master m
				 WHERE p.bp_id = m.bp_id(+)
                    ) t 
                    #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="chance_id" queryExpression="t.chance_id=${@chance_id}"/>
    </bm:query-fields>
</bm:model>
