<?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 hpcp.plan_number,--检查计划编号
			       hpcp.check_year, --检查年度
			       hpcp.check_times,  --检查维度
			       hpcp.project_id,
			       (select pp.project_number from prj_project pp where pp.project_id = hpcp.project_id) project_number, --项目编号
			       (select pp.project_name from prj_project pp where pp.project_id = hpcp.project_id) project_name, --项目名称
			       (select hbm.bp_name from prj_project pp,hls_bp_master hbm where pp.project_id = hpcp.project_id and pp.bp_id_tenant = hbm.bp_id) bp_id_tenant_n,--主承租人(客户名称)
			       hpcp.check_person, --计划检查人
			       hpcp.check_date,   --计划检查日期
			       hpcp.check_method, --计划检查方式
			       hpcp.check_location,  --计划检查地点
			       hpca.actual_number,   --检查实际编号
			       hpca.actual_check_date,  --实际检查时间
			       hpca.actual_check_person, --实际检查人员
			       hpca.actual_check_method,	--实际检查方式
			       hpca.actual_check_location,	-- 实际检查地点
			       (hn_report_pkg.get_prj_filr_name(p_check_id => hpca.check_id,
                                              		p_table_name => 'HN_PRJ_CHECK_ACTUAL')) file_name,  --附件名
                   (hn_report_pkg.get_prj_attachment_id(p_check_id => hpca.check_id,
                                                  p_table_name => 'HN_PRJ_CHECK_ACTUAL')) attachment_id,
			       hpcp.check_point          --检查重点
			from hn_prj_check_plan hpcp,
			     hn_prj_check_actual hpca
			where hpca.plan_id = hpcp.plan_id and hpca.check_status = 'APPROVED'
			)t1 #WHERE_CLAUSE# 
			ORDER BY t1.plan_number
			]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="plan_number" queryExpression="t1.plan_number like &apos;%&apos;||${@plan_number}||&apos;%&apos;"/>
        <bm:query-field name="project_number" queryExpression="t1.project_number like &apos;%&apos;||${@project_number}||&apos;%&apos;"/>
        <bm:query-field name="project_name" queryExpression="t1.project_name like &apos;%&apos;||${@project_name}||&apos;%&apos;"/>
        <bm:query-field name="check_date" queryExpression="t1.check_date like &apos;%&apos;||to_date(${@check_date},&apos;yyyy-mm-dd&apos;)||&apos;%&apos;"/>
        <bm:query-field name="bp_id_tenant_n" queryExpression="t1.bp_id_tenant_n like &apos;%&apos;||${@bp_id_tenant_n}||&apos;%&apos;"/>
        <bm:query-field name="check_person" queryExpression="t1.check_person like &apos;%&apos;||${@check_person}||&apos;%&apos;"/>
        <bm:query-field name="check_method_n" queryExpression="t1.check_method like &apos;%&apos;||${@check_method}||&apos;%&apos;"/>
        <bm:query-field name="check_location" queryExpression="t1.check_location like &apos;%&apos;||${@check_location}||&apos;%&apos;"/>
        <bm:query-field name="actual_number" queryExpression="t1.actual_number like &apos;%&apos;||${@actual_number}||&apos;%&apos;"/>
        <bm:query-field name="actual_check_date" queryExpression="t1.actual_check_date like &apos;%&apos;||to_date(${@actual_check_date},&apos;yyyy-mm-dd&apos;)||&apos;%&apos;"/>
    </bm:query-fields>
</bm:model>
