select bu.id as userid,
 bu.realname as realname
 from t_s_base_user bu  
 LEFT JOIN t_s_user_org uo ON uo.user_id = bu.id
 WHERE 1=1 
 AND uo.org_id IN (
	SELECT
		tsd.id
	FROM
		t_s_depart tsd
	WHERE 1=1
		<#-- tsd.parentdepartid = '4028e4a55f6c84ec015f6caa0bf60007'-->
		<#if (userAndUserPersonnelDto.pid )?? && userAndUserPersonnelDto.pid ?length gt 0>
			and tsd.parentdepartid like CONCAT('%', :userAndUserPersonnelDto.pid ,'%') 
		<#else >
			and tsd.parentdepartid=null
		</#if>
	AND tsd. STATUS = '0'
)

 and bu.delete_flag='0' 