<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: weiwuzhen  
    $Date: 2016-5-22 下午9:52:42  
    $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(sysdate,'yyyy') current_year,
((select COUNT(1) meet_sum --会议总人数
  from prj_project_approver ppa, prj_project_approval pa, prj_project p
 where p.project_id = pa.project_id
   and pa.approval_id = ppa.approval_id
    and pa.approval_count=(
   select max(to_number(pa.approval_count)) from prj_project_approval pa, prj_project p
    where p.project_id = pa.project_id
     and p.project_id=${/parameter/@project_id}
   )
   and p.project_id=${/parameter/@project_id})-(SELECT COUNT(1) meet_leave --会议请假人数,
  FROM prj_project_approver ppa, prj_project_approval pa, prj_project p
 where p.project_id = pa.project_id
   and pa.approval_id = ppa.approval_id
   AND ppa.approve_status = 'leave'
    and pa.approval_count=(
   select max(to_number(pa.approval_count)) from prj_project_approval pa, prj_project p
    where p.project_id = pa.project_id
     and p.project_id=${/parameter/@project_id}
   )
   and p.project_id=${/parameter/@project_id}))meet_num,--会议实际人数          
(SELECT COUNT(1) meet_agree --会议同意人数
  FROM prj_project_approver ppa,
       prj_project_approval pa,
       prj_project          p
 where p.project_id = pa.project_id
   and pa.approval_id = ppa.approval_id
   AND ppa.approve_status = 'agree'
    and pa.approval_count=(
   select max(to_number(pa.approval_count)) from prj_project_approval pa, prj_project p
    where p.project_id = pa.project_id
     and p.project_id=${/parameter/@project_id}
   )
   and p.project_id=${/parameter/@project_id})meet_agree,--会议同意人数               
                 
(SELECT COUNT(1) meet_discuss --会议再议人数
  FROM prj_project_approver ppa,
       prj_project_approval pa,
       prj_project          p
 where p.project_id = pa.project_id
   and pa.approval_id = ppa.approval_id
   AND ppa.approve_status = 'discuss'
    and pa.approval_count=(
   select max(to_number(pa.approval_count)) from prj_project_approval pa, prj_project p
    where p.project_id = pa.project_id
     and p.project_id=${/parameter/@project_id}
   )
   and p.project_id=${/parameter/@project_id}) meet_discuss, --会议再议人数                                
                                     
(SELECT COUNT(1) meet_refuse --会议不同意人数,
  FROM prj_project_approver ppa,
       prj_project_approval pa,
       prj_project          p
 where p.project_id = pa.project_id
   and pa.approval_id = ppa.approval_id
   AND ppa.approve_status = 'refuse'
    and pa.approval_count=(
   select max(to_number(pa.approval_count)) from prj_project_approval pa, prj_project p
    where p.project_id = pa.project_id
     and p.project_id=${/parameter/@project_id}
   )
   and p.project_id=${/parameter/@project_id}) meet_refuse, --会议不同意人数,

  (select  SDIC_INDIVIDUAL_PKG.string_combination('select sv.description from prj_project_approver ppa, prj_project_approval pa, prj_project p1,sys_user_v sv
 where p1.project_id = pa.project_id
   and pa.approval_id = ppa.approval_id
    and pa.approval_count=(
   select max(to_number(pa.approval_count)) from prj_project_approval pa, prj_project p2
    where p2.project_id = pa.project_id
     and p2.project_id=p1.project_id)
     and ppa.approver_user_id = sv.user_id
     and ppa.approve_status != ''leave''
     and p1.project_id=', P.project_id,'、') from prj_project p
     where p.project_id=${/parameter/@project_id}
    ) name 
    from dual
 ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
