<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            SELECT * FROM(
            select hvc.power_station_seq,
			       (select pp.virtual_con_number from prj_project pp where pp.project_id = hvcrh.project_id)||'-'||hvc.power_station_seq station_number,
			       hvc.power_station_name,       --电站名称
			       (select pp.virtual_con_number from prj_project pp where pp.project_id = hvcrh.project_id) virtual_con_number,
			       (select pp.virtual_con_name from prj_project pp where pp.project_id = hvcrh.project_id) virtual_con_name,
			       (SELECT nvl(sum(NVL(ccc.due_amount, 0)), 0)
						          FROM con_contract_cashflow    ccc,
						               con_contract             cc
						         WHERE cc.contract_id = ccc.contract_id
						           AND hvcrh.project_id = cc.project_id
						           AND ccc.times = 0
						           AND cc.data_class = 'NORMAL'
						           AND ccc.cf_item = 0) principal_amount, --本金总额
			       (select pp.hn_industry_classification from prj_project pp where pp.project_id = hvcrh.project_id) hn_industry_classification,
			       (SELECT scvv.code_value_name
			          FROM sys_code_values_v scvv
			         WHERE scvv.code IN ('WITHIN_GROUP', 'MARKETIZATION')
			           AND scvv.code_value = (select pp.binary_classification 
			                                    from prj_project pp where pp.project_id = hvcrh.project_id)) binary_classification_n, --行业细分
			       hvc.prj_scale,               --装机规模
			       hvc.source_area,             --所在资源区          HN_SOURCE_AREA
			       hvc.province_id,
			       (select r1.description
			          from fnd_province r1
			         where r1.province_id = hvc.province_id) as province_id_n,
			       hvc.city_id,
			       (select r2.description from fnd_city r2 where r2.city_id = hvc.city_id) as city_id_n,
			       hvc.district_id,
			       (select r3.description
			          from fnd_district r3
			         where r3.district_id = hvc.district_id) as district_id_n,
			       hvc.built_flag,       
			       hvc.built_date,
			       hvc.subsidy_list_flag, --是否纳入指标
			       hvc.subsidy_list_date,
			       hvc.subsidy_seq,       --补贴批次
			       hvc.use_price,         --上网电价
			       hvc.country_subsidy_price,
			       hvc.thermal_power_price, --火电标杆
			       hvc.local_subsidy_price, -- 地方补贴
			       hvc.station_id
			  from hn_vir_con_power_station hvc, hn_virtual_con_relate_hd hvcrh
			 where hvcrh.hd_id = hvc.hd_id 
			   and hvcrh.project_id = ${@project_id}
			   ) t1 #WHERE_CLAUSE# order by t1.virtual_con_number,t1.power_station_seq
			]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter name="project_id"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
</bm:model>
