<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei  
    $Date: 2015-11-10 上午10:50:45  
    $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 distinct t1.* from 
(SELECT su.user_id, su.user_name,su.description
                   FROM sys_user             su ,
                        exp_employee_assigns eea ,
                        exp_employees ex ,
                        exp_org_position_vl  eo
                  WHERE su.employee_id = eea.employee_id
                    AND eea.position_id = eo.position_id
                    and ex.employee_id =su.employee_id
                    and nvl (su.frozen_flag ,'N' )<>'Y'
                    and eea.enabled_flag ='Y'
                    and ex.enabled_flag ='Y'
                    and eo.ENABLED_FLAG='Y'
                    and sysdate between su.start_date and
                    nvl(su.end_date ,to_date ('3000-01-01' ,'yyyy-mm-dd' ))
                    and eo.POSITION_CODE=${@position_code}
                    and ${@position_flag}='Y'
                    
     union
SELECT su.user_id, su.user_name,su.description
                   FROM sys_user             su ,
                        exp_employee_assigns eea ,
                        exp_employees ex ,
                        exp_org_position_vl  eo,
                        exp_org_unit    eou
                  WHERE su.employee_id = eea.employee_id
                    AND eea.position_id = eo.position_id
                    and ex.employee_id =su.employee_id
                    and nvl (su.frozen_flag ,'N' )<>'Y'
                    and eea.enabled_flag ='Y'
                    and ex.enabled_flag ='Y'
                    and eo.ENABLED_FLAG='Y'
                    and sysdate between su.start_date and
                    nvl(su.end_date ,to_date ('3000-01-01' ,'yyyy-mm-dd' ))
                    and eou.unit_id=eo.UNIT_ID
                    and eou.enabled_flag='Y'
                    and eou.unit_code in (${@unit_code_one},${@unit_code_two})
                    and ${@unit_flag}='Y'
                     )    t1   #WHERE_CLAUSE#  

]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="user_name" queryExpression="T1.user_name LIKE ${@user_name}"/>
        <bm:query-field name="description" queryExpression="T1.description LIKE ${@description}"/>
    </bm:query-fields>
</bm:model>
