<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: chenlingfeng  
    $Date: 2017-12-7 16:01:32
    $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 
            to_char(hda.last_update_date,'yyyy') current_year,
 translate(to_char(hda.last_update_date,'yyyy"年'),'0123456789','〇一二三四五六七八九')approval_year ,
change_number_to_cn(number_in => to_char(hda.last_update_date,'mm'))||'月' approval_month,
change_number_to_cn(number_in => to_char(hda.last_update_date,'dd'))||'日' approval_day,
to_char(hda.last_update_date,'YYYY"年"MM"月"DD"日"') approval_date,
hda.approval_id,
       hda.document_id,
       hda.document_type,
       hda.document_desc,
       hda.meeting_time,
       ppm.meeting_name,
       ppm.meeting_id,
       ppm.meeting_location,
       ppm.meeting_date,
       v.instance_id,
       v.workflow_desc,
       v.workflow_code,
       hn_doc_meeting_pkg.get_approver_name(p_approver_id   => hda.approval_id,
                                            p_approval_type => null) approver_name,
       (select count(1)
          from hn_doc_approver a
         where a.approval_id = hda.approval_id) approver_count,
       (select count(1)
          from hn_doc_approver a
         where a.approval_id = hda.approval_id
           and nvl(a.approve_status, 'leave') <> 'leave') no_leave_approver_count,
       (select count(1)
          from hn_doc_approver a
         where a.approval_id = hda.approval_id
           and nvl(a.approve_status, 'leave') = 'agree') agree_approver_count,
       (select count(1)
          from hn_doc_approver a
         where a.approval_id = hda.approval_id
           and nvl(a.approve_status, 'leave') = 'discuss') discuss_approver_count,
       (select count(1)
          from hn_doc_approver a
         where a.approval_id = hda.approval_id
           and nvl(a.approve_status, 'leave') = 'refuse') refuse_approver_count
           
  from hn_doc_approval            hda,
       prj_project_meeting        ppm,
       zj_wfl_workflow_instance_v v
 where hda.meeting_id = ppm.meeting_id(+)
   and v.instance_id =
       hn_doc_meeting_pkg.get_instance_id(p_document_id   => hda.document_id,
                                          p_document_type => hda.document_type)

and hda.document_type=${/parameter/@document_type}
 and hda.document_id=${/parameter/@document_id}
 and rownum=1]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
