<?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 distinct t1.* from 
(SELECT su.user_id value, su.user_name,su.description name
                   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=sdic_workflow_assign_pkg.get_assign_para(${@node_id},'position_code')
                    and sdic_workflow_assign_pkg.get_assign_para(${@node_id},'position_flag')='Y'
     union
SELECT su.user_id value, su.user_name,su.description name
                   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=sdic_workflow_assign_pkg.get_assign_para(${@node_id},'unit_code')
                    and sdic_workflow_assign_pkg.get_assign_para(${@node_id},'unit_flag')='Y'
         union
                select su.user_id, su.user_name, su.description
				  from hn_group_org_ln tt, sys_user su
				 where tt.org_user_id = su.user_id
				   and tt.org_user_type <> 'TYPE01'
           and nvl (su.frozen_flag ,'N' )<>'Y'
           and sdic_workflow_assign_pkg.get_assign_para(${@node_id},'group_flag')='Y'
				   and tt.org_hd_id in
				       (select distinct hgl.org_hd_id
				          from hn_group_org_ln hgl
				         where hgl.org_user_type = 'TYPE02'
				           and hgl.org_user_id = 
				           (select zj_wfl_core_pkg.get_parameter_value(p_instance_id => ${@instance_id},p_parameter_name => 
	                       (select tzw.parameter_desc from zj_wfl_workflow_type_parameter tzw where tzw.workflow_type_para_id =
	                       sdic_workflow_assign_pkg.get_assign_para(${@node_id},'submitted_by')))
	                        from dual))
				           and exists (select 1
				                  from hn_group_org_hd hgh
				                 where tt.org_hd_id = hgh.org_hd_id
				                   and hgh.enable_flag = 'Y'
				                   and hgh.assign_type = 'ORG')
                    ) t1
                   
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
