<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Administrator  
    $Date: 2015-5-28 下午2:19:08  
    $Revision: 1.0  
    $Purpose: 
-->
<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
                        (wwn.node_desc
                        || ':') AS node,
                        NVL(war.comment_text,
                        (SELECT
                            v.action_type_desc
                        FROM
                            zj_wfl_workflow_node_action_v v
                        WHERE
                            v.node_action_id = war.action_taken
                        )) comment_text,
                        c.contract_id,
                        (SELECT
                            s.description
                        FROM
                            zj_wfl_instance_node_rcpt_ht j,
                            sys_user s
                        WHERE
                            j.record_id = war.rcpt_record_id AND
                            j.user_id   = s.user_id
                        ) approver
                    FROM
                        zj_wfl_workflow zww,
                        zj_wfl_workflow_type wwt,
                        zj_wfl_workflow_type_parameter wtp,
                        zj_wfl_workflow_instance wwi,
                        zj_wfl_workflow_instance_para wip,
                        zj_wfl_approve_record war,
                        zj_wfl_workflow_node wwn,
                        con_contract c
                    WHERE
                        zww.workflow_code         = 'CONTRACT_TEXT_WORK_FLOW' AND
                        zww.workflow_type_id      = wwt.workflow_type_id AND
                        wwt.workflow_type_id      = wtp.workflow_type_id AND
                        wtp.parameter_code        = 'CONTRACT_ID' AND
                        wip.workflow_type_para_id = wtp.workflow_type_para_id AND
                        wwi.instance_id           = wip.instance_id AND
                        wwi.status                = 10 --结束，审批通过
                        AND
                        war.instance_id   = wwi.instance_id AND
                        war.node_id       = wwn.node_id AND
                        wwn.sequence_num not in ('5','90')
                    ORDER BY
                        wwn.sequence_num
                    ) t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="contract_id" queryExpression="t1.contract_id=${@contract_id}"/>
    </bm:query-fields>
</bm:model>
