<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="ZJ_WFL_BUSINESS_RULE_DETAILS">
    <bm:fields>
        <bm:field name="business_rule_detail_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BUSINESS_RULE_DETAIL_ID"/>
        <bm:field name="business_rule_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BUSINESS_RULE_ID"/>
        <bm:field name="rule_parameter_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RULE_PARAMETER_TYPE" prompt="规则参数类型"/>
        <bm:field name="rule_parameter_id" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RULE_PARAMETER_ID"/>
        <bm:field name="and_or" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="AND_OR" prompt="且_或"/>
        <bm:field name="filtrate_method" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILTRATE_METHOD" prompt="取值方式"/>
        <bm:field name="parameter_lower_limit" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARAMETER_LOWER_LIMIT" prompt="下限值"/>
        <bm:field name="parameter_upper_limit" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARAMETER_UPPER_LIMIT" prompt="上限值"/>
        <bm:field name="currency_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY_CODE" prompt="币种"/>
        <bm:field name="invalid_date" databaseType="DATE" datatype="java.util.Date" physicalName="INVALID_DATE" prompt="失效日期"/>
        <bm:field name="sql_param_1" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SQL_PARAM_1" prompt="SQL参数 1"/>
        <bm:field name="sql_param_2" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SQL_PARAM_2" prompt="SQL参数 2"/>
        <bm:field name="sql_param_3" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SQL_PARAM_3" prompt="SQL参数 3"/>
        <bm:field name="sql_param_4" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SQL_PARAM_4" prompt="SQL参数 4"/>
        <bm:field name="sql_param_5" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SQL_PARAM_5" prompt="SQL参数 5"/>
        <bm:field name="and_or_code" forInsert="false" forUpdate="false" prompt="且_或"/>
        <bm:field name="filtrate_method_code" forInsert="false" forUpdate="false" prompt="取值方式"/>
        <bm:field name="value_compare_method" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="rule_parameter_code" forInsert="false" forUpdate="false" prompt="规则参数代码"/>
        <bm:field name="rule_parameter_name" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			SELECT t1.BUSINESS_RULE_DETAIL_ID,
				       t1.BUSINESS_RULE_ID,
				       t1.RULE_PARAMETER_TYPE,
				       t1.RULE_PARAMETER_ID,
				       t1.AND_OR,
				       t1.FILTRATE_METHOD,
				       t1.PARAMETER_LOWER_LIMIT,
				       t1.PARAMETER_UPPER_LIMIT,
				       t1.CURRENCY_CODE,
				       t1.INVALID_DATE,
				       t1.SQL_PARAM_1,
				       t1.SQL_PARAM_2,
				       t1.SQL_PARAM_3,
				       t1.SQL_PARAM_4,
				       t1.SQL_PARAM_5,
				       (select c.code_value_name
				          from sys_code_values_v c
				         where c.code = 'WFL_WORKFLOW_APPROVAL_RULE'
				           and c.code_value = t1.and_or) as and_or_code,
				       (select c.code_value_name
				          from sys_code_values_v c
				         where c.code = 'WFL_WORKFLOW_FILTRATE_METHOD'
				           and c.code_value = t1.filtrate_method) as filtrate_method_code,
				       t1.value_compare_method,
				       v.parameter_code as rule_parameter_code,
				       v.parameter_desc as rule_parameter_name
				  FROM ZJ_WFL_BUSINESS_RULE_DETAILS t1,
				       (SELECT 'WORKFLOW_TYPE_PARAMETER' as rule_parameter_type,
				               tp.workflow_type_para_id AS parameter_id,
				               tp.parameter_code,
				               tp.parameter_desc
				          FROM zj_wfl_workflow_type_parameter tp, zj_wfl_workflow_type j
				         WHERE tp.workflow_type_id = j.workflow_type_id
				           and j.workflow_type_code = ${@workflow_category}
				        union all
				        SELECT 'WORKFLOW_RULE_PARAMETER' as rule_parameter_type,
				               t.parameter_id AS parameter_id,
				               t.parameter_code,
				               (SELECT description_text
				                  FROM fnd_descriptions fd
				                 WHERE fd.description_id = t.description_id
				                   AND fd.language = userenv('LANG')) AS parameter_desc
				          FROM zj_wfl_business_rule_paras t
				         WHERE t.workflow_category = ${@workflow_category}) v
				 where t1.business_rule_id = ${@business_rule_id}
				   and t1.rule_parameter_id = v.parameter_id
				   and t1.rule_parameter_type = v.rule_parameter_type
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="business_rule_detail_id"/>
    </bm:primary-key>
</bm:model>
