<#-- 轮流值班人员选择页面 -->

select 
bu.id, 
bu.id as userid,
bu.username, 
bu.realname,
up.in_postid, 
up.position_status, 
up.contract_stime
 from t_s_base_user bu 
 LEFT JOIN t_bus_user_personnel up  ON bu.ID=up.userid
 WHERE 1=1 
 
<#if ( userAndUserPersonnelDto.userIdList )?? && userAndUserPersonnelDto.userIdList ?size gt 0>
	and bu.id in(
	<#list userAndUserPersonnelDto.userIdList as item>
		'${item}'
	<#if item_has_next>,</#if>
	</#list>
	)
<#else >
	and bu.id=null
</#if>
AND bu.delete_flag = '0'

<#if (userAndUserPersonnelDto.realname )?? && userAndUserPersonnelDto.realname ?length gt 0>
	 and bu.realname like CONCAT('%', :userAndUserPersonnelDto.realname ,'%') 
</#if>

<#--在职状态 已入职1，已转正2-->
and up.position_status in ('1','2')

order by  convert(bu.realname using gbk) collate gbk_Chinese_ci asc





