<?xml version="1.0" encoding="UTF-8"?>
<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
                        cc.contract_number,
                        cc.contract_name,
                        pp.project_number,
                        ppb.bp_name,
                        ppb.bp_id,
                        ppb.bp_category,
                        ppb.bp_category_n,
                        ppb.id_card_no,
                        ppli.license_number,
                        DECODE(pp.division, '00', ppli.vin_number, '01', ppli.item_frame_number) item_num
                    FROM
                        con_contract cc,
                        prj_project pp,
                        prj_project_bp_lv ppb,
                        prj_project_lease_item ppli
                    WHERE
                        cc.project_id       = pp.project_id AND
                        pp.project_id       = ppb.project_id AND
                        cc.data_class       = 'NORMAL' AND
                        cc.contract_status IN ('SIGN','INCEPT') AND
                        pp.project_id       = ppli.project_id AND
                        ppb.bp_category     = 'TENANT'
                    ) v #WHERE_CLAUSE#
                ORDER BY
                    v.contract_number DESC
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="bp_name" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="200" forDisplay="true" forQuery="true" physicalName="bp_name" prompt="承租人名称"/>
        <bm:field name="project_number" databaseType="VARCHAR" datatype="java.lang.String" displayWidth="200" forDisplay="true" forQuery="true" physicalName="project_number" prompt="申请编号"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="bp_name" queryExpression="v.bp_name like ${@bp_name}"/>
        <bm:query-field name="project_number" queryExpression="v.project_number like ${@project_number}"/>
    </bm:query-fields>
</bm:model>
