SELECT 
	uad.id AS id, 
	uad.calendarid AS calendarid, 
	uad.shiftid AS shiftid, 
	uad.projarrange_detailid AS projarrangeDetailid, 
	uad.create_name AS createName, 
	uad.create_by AS createBy, 
	uad.create_date AS createDate, 
	uad.update_name AS updateName, 
	uad.update_by AS updateBy, 
	uad.update_date AS updateDate, 
	uad.sys_org_code AS sysOrgCode, 
	uad.sys_company_code AS sysCompanyCode 
FROM 
	t_bus_user_arrange_detail uad 
LEFT JOIN t_bus_calendar tbc ON uad.calendarid = tbc.id 
WHERE 
	1 = 1  
	<#if (userArrangeCalendarDto.projarrangeDetailid )?? && userArrangeCalendarDto.projarrangeDetailid ?length gt 0>
		and uad.projarrange_detailid =:userArrangeCalendarDto.projarrangeDetailid
	<#else >
		and uad.projarrange_detailid is null
	</#if>
	
	<#if ( userArrangeCalendarDto.calendaridList )?? && userArrangeCalendarDto.calendaridList ?size gt 0>
		and uad.calendarid in(
			<#list userArrangeCalendarDto.calendaridList as item>        
			   '${item}'
			 <#if item_has_next>,</#if>
			 </#list>
		)
	<#else >
		and uad.calendarid is null
	</#if>
	
	
