<?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
                        cc.contract_id,
                        cc.contract_number,
                        cc.contract_name,
                        cc.quotation_id,
                        cc.contract_status,
                        (SELECT
                            v.code_value_name
                        FROM
                            sys_code_values_v v
                        WHERE
                            v.code       = 'CON500_CONTRACT_STATUS' AND
                            v.code_value = cc.contract_status
                        ) contract_status_desc,
                        hbm.bp_name
                        ||
                        (SELECT
                            '、'
                            || ccb.bp_name
                        FROM
                            con_contract_bp ccb
                        WHERE
                            ccb.contract_id = cc.contract_id AND
                            ccb.bp_type     = 'TENANT_SEC'
                        ) bp_name
                    FROM
                        con_contract cc,
                        hls_bp_master hbm
                    WHERE
                        cc.bp_id_tenant = hbm.bp_id AND
                        cc.data_class   = 'NORMAL'
                    ) t1 #WHERE_CLAUSE#
                    order by t1.contract_id desc
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="contract_number" queryExpression="t1.contract_number=${@contract_number}"/>
        <bm:query-field name="contract_name" queryExpression="t1.contract_name like &apos;%&apos;||${@contract_name}||&apos;%&apos;"/>
        <bm:query-field name="bp_name" queryExpression="t1.bp_name like &apos;%&apos;||${@bp_name}||&apos;%&apos;"/>
        <bm:query-field name="contract_status" queryExpression="t1.contract_status=${@contract_status}"/>
    </bm:query-fields>
</bm:model>
