<?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
                    w.workflow_desc, --工作流名称
                    nvl(
                    (SELECT
                        n.node_desc
                    FROM
                        zj_wfl_workflow_node n
                    WHERE
                        n.node_id = ${@node_id}
                    ), '流程结束') node_desc,
                    by_hls_wx_core_pkg.get_doc_name_from_instance(i.instance_id) document_name,
                    (SELECT u.description FROM sys_user U WHERE u.user_id = i.submitted_by
                    ) submitted_by,
                    
                    to_char(i.date_from,'yyyy-mm-dd')date_from,
                    
                    by_hls_wx_core_pkg.get_wx_wfl_sql_execute(p_instance_id=>${@instance_id},p_node_id=>${@node_id}) wx_wfl_sql_execute,
                    
                    (select e.unit_name from  exp_emp_assign_e_v e where e.user_id = i.submitted_by and e.primary_position_flag = 'Y')unit_name,
                    
                    decode((select count(*) from zj_wfl_instance_node_rcpt_v v where v.instance_id = ${@instance_id} and v.node_id = ${@node_id}),0,'Y','N') approved_flag, -- 是否审批通过
                      decode((select COUNT(1)
                    from sdic_workflow_assigned wa where wa.instance_id = ${@instance_id}
                    and wa.sequence_num=sdic_workflow_assign_pkg.get_assign_para(${@node_id},'sequence_num')
                    and wa.created_by=${@user_id}),0,'N','Y') selected_flag, --是否有选择
                    
                    (select wa.user_id
                    from sdic_workflow_assigned wa where wa.instance_id = ${@instance_id}
                    and wa.sequence_num=sdic_workflow_assign_pkg.get_assign_para(${@node_id},'sequence_num')
                    and wa.created_by=${@user_id}) value ,
                    (select su.description
                    from sdic_workflow_assigned wa,sys_user su where wa.instance_id = ${@instance_id}
                    and wa.sequence_num=sdic_workflow_assign_pkg.get_assign_para(${@node_id},'sequence_num')
                    and wa.created_by=${@user_id}
                    and su.user_id=wa.user_id) NAME,
                    by_hls_wx_core_pkg.get_meeting_name_from_instance(i.instance_id) meeting_name,
                    by_hls_wx_core_pkg.get_meeting_location(i.instance_id) meeting_location,
                    by_hls_wx_core_pkg.get_meeting_date_from_instance(i.instance_id) meeting_date,
                    by_hls_wx_core_pkg.get_meeting_time_from_instance(i.instance_id) meeting_time
                    
                FROM
                    zj_wfl_workflow w,
                    zj_wfl_workflow_instance i
                WHERE
                    i.instance_id = ${@instance_id} AND
                    w.workflow_id = i.workflow_id
                    
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="workflow_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="node_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="document_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="submitted_by" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="date_from" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="wx_wfl_sql_execute" databaseType="CLOB" datatype="java.sql.Clob"/>
        <bm:field name="unit_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="approved_flag" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="selected_flag" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="value" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="meeting_name"/>
        <bm:field name="meeting_location"/>
        <bm:field name="meeting_date"/>
        <bm:field name="meeting_time"/>
    </bm:fields>
</bm:model>
