<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang 
    $Date: 2015-7-10 下午03:44:00  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        A.*,
                        ROWNUM RN
                    FROM
                        (SELECT
                            t1.record_id,
                            t1.workflow_desc,
                            t1.instance_id,
                            t1.submitted_by,
                            t1.submitted_by_name,
                            t1.node_id,
                            (select t.app_approve_flag from ZJ_WFL_WORKFLOW_NODE t where  t.node_id =  t1.node_id) app_approve_flag,
                            t1.node_desc,
                            t1.hierarchy_record_id,
                            t1.current_seq,
                            t1.user_id,
                            t1.date_limit,
                            t1.commision_by,
                            t1.commision_desc,
                            t1.last_notify_date,
                            (SELECT
                                t2.last_approve_date
                            FROM
                                zj_wfl_workflow_instance_v t2
                            WHERE
                                t2.instance_id = t1.instance_id
                            ) last_approve_date,
                            t1.workflow_id,
                            t1.workflow_code,
                            t1.workflow_desc
                            || '-'
                            || t1.node_desc AS workflow_info,
                            t1.document_info,
                            TO_CHAR(t1.creation_date, 'yyyy-mm-dd hh24:mi:ss') AS creation_date,
                            TO_CHAR(t1.creation_date,'yyyy/mm/dd') create_time,
                            TO_CHAR(t1.creation_date,'hh24:mi:ss') create_min,
                            DECODE(t1.workflow_code, 'CSH_PAYMENT_WFL', '付', 'WFL_PRJ_DEP2', '租' ,'WFL_PRJ_DEP1', '租','PRJ_PREAPPLY_WFL', '租', '') title,
                            DECODE(t1.workflow_code, 'CSH_PAYMENT_WFL', 'yellow', 'WFL_PRJ_DEP2', 'green' ,'WFL_PRJ_DEP1', 'green','PRJ_PREAPPLY_WFL', 'green', '') color,
                            t1.urgent_type,
                            'Y' expand_flag,
                            'N' receipts_flag,
                            t1.record_id rcpt_record_id,
                            wx_wfl_pkg.get_document_id(p_instance_id => t1.instance_id, p_current_seq => t1.current_seq, p_workflow_code => t1.workflow_code) document_id
                        FROM
                            zj_wfl_instance_node_rcpt_v t1 #WHERE_CLAUSE#
                        ORDER BY
                            t1.creation_date DESC
                        ) A
                    WHERE
                        ROWNUM <= NVL(${@pagesize},10) * NVL(${@offsize},1)
                    )
                WHERE
                    RN >= 1 + ((NVL(${@offsize},1)-1) * NVL(${@pagesize},10))
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="record_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RECORD_ID"/>
        <bm:field name="workflow_desc" physicalName="WORKFLOW_DESC"/>
        <bm:field name="instance_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INSTANCE_ID"/>
        <bm:field name="submitted_by" physicalName="SUBMITTED_BY"/>
        <bm:field name="submitted_by_name" physicalName="SUBMITTED_BY_NAME"/>
        <bm:field name="node_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NODE_ID"/>
        <bm:field name="node_desc" physicalName="NODE_DESC"/>
        <bm:field name="hierarchy_record_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HIERARCHY_RECORD_ID"/>
        <bm:field name="current_seq" physicalName="CURRENT_SEQ"/>
        <bm:field name="user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="USER_ID"/>
        <bm:field name="date_limit" physicalName="DATE_LIMIT"/>
        <bm:field name="commision_by" physicalName="COMMISION_BY"/>
        <bm:field name="commision_desc" physicalName="COMMISION_DESC"/>
        <bm:field name="last_notify_date" physicalName="LAST_NOTIFY_DATE"/>
        <bm:field name="last_approve_date" physicalName="LAST_APPROVE_DATE"/>
        <bm:field name="workflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="workflow_id"/>
        <bm:field name="workflow_code" physicalName="WORKFLOW_CODE"/>
        <bm:field name="workflow_info" physicalName="WORKFLOW_INFO"/>
        <bm:field name="document_info" physicalName="DOCUMENT_INFO"/>
        <bm:field name="creation_date" physicalName="CREATION_DATE"/>
        <bm:field name="create_time"/>
        <bm:field name="create_min"/>
        <bm:field name="title"/>
        <bm:field name="color"/>
        <bm:field name="app_approve_flag"/>
        <bm:field name="urgent_type" physicalName="URGENT_TYPE"/>
        <bm:field name="expand_flag" physicalName="EXPAND_FLAG"/>
        <bm:field name="receipts_flag" physicalName="RECEIPTS_FLAG"/>
        <bm:field name="rcpt_record_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RCPT_RECORD_ID"/>
        <bm:field name="document_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DOCUMENT_ID"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="date" queryExpression="t1.creation_date &gt; to_date(${@date},&apos;yyyy-MM-dd hh24:mi:ss&apos;)"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="user_id" enforceOperations="query" expression="(t1.user_id = ${@user_id})"/>
        <bm:data-filter name="workflow_code" enforceOperations="query" expression="t1.workflow_code in (&apos;CSH_PAYMENT_WFL&apos;,&apos;WFL_PRJ_DEP2&apos;,&apos;WFL_PRJ_DEP1&apos;,&apos;PRJ_PREAPPLY_WFL&apos;)"/>
    </bm:data-filters>
</bm:model>
