<#-- 班次设定主页显示-->

select 
ad.id,
ad.duty_name AS dutyName,
ad.pid AS pid,
ad.duty_type AS dutyType,
ad.normalwork_stime AS normalworkStime,
ad.normalwork_etime AS normalworkEtime,
ad.spunch_minute AS spunchMinute,
ad.epunch_minute AS epunchMinute,
ad.datum_workhours AS datumWorkhours,
ad.shift_workhours AS shiftWorkhours,
ad.onduty_stime AS ondutyStime,
ad.onduty_etime AS ondutyEtime,
ad.onduty_workhours AS ondutyWorkhours,
ad.timeout_overtime_stime AS timeOutOvertimeStime,
ad.timeout_overtime_etime AS timeOutOvertimeEtime,
ad.timeout_overtime_hours AS timeOutOvertimeHours,
ad.duty_mealid AS dutyMealid,
ad.remark AS remark,
ad.create_name AS createName,
ad.create_by AS createBy,
ad.create_date AS createDate,
ad.update_name AS updateName,
ad.update_by AS updateBy,
ad.update_date AS updateDate,
ad.sys_org_code AS sysOrgCode,
ad.sys_company_code AS sysCompanyCode,
ad.status AS status,
ad.delete_flag AS deleteFlag
 from t_bus_arrange_duty ad where 1 = 1
		
<#if ( arrangeDutyDto.pidList )?? && arrangeDutyDto.pidList ?size gt 0>
 and ad.pid in(
<#list arrangeDutyDto.pidList as item>        
   '${item}'
	 <#if item_has_next>,</#if>
	 </#list>
	) 
<#else >
	and ad.id=null
</#if>	
		
		
		<#if (arrangeDutyDto.dutyName )?? && arrangeDutyDto.dutyName ?length gt 0>
		    /* 班次名称 */
			and ad.duty_name like CONCAT('%', :arrangeDutyDto.dutyName ,'%') 
		</#if>
		<#if ( arrangeDutyDto.dutyType )?? && arrangeDutyDto.dutyType ?length gt 0>
		    /* 班次类型*/
			and ad.duty_type = :arrangeDutyDto.dutyType
		</#if>
		<#if ( arrangeDutyDto.status )?? && arrangeDutyDto.status ?length gt 0>
		    /* 班次类型*/
			and ad.status = :arrangeDutyDto.status
		</#if>
		and ad.delete_flag = 0
		
		ORDER BY
			ad.create_date DESC