<#-- 考勤预警消息表--首页数据全部展示--分页-->

select 
	awm.id,
	awm.msg_type as msgType,
	awm.msg_title as msgTitle,
	awm.msg_content as msgContent,
	awm.send_status as sendStatus,
	awm.org_id as orgId,
	awm.create_date as createDate,
	awm.send_time as sendTime,
	awm.user_id as userId
 from t_bus_attendance_warn_msg awm 
 left join t_bus_attendance_warn_msg_detail awmd on awm.id=awmd.msg_id
 where 1 = 1
 
<#if (attendanceWarnMsgDto.receivedId )?? && attendanceWarnMsgDto.receivedId ?length gt 0>
	AND awmd.received_id like CONCAT('%', :attendanceWarnMsgDto.receivedId ,'%') 
<#else>
	AND awmd.received_id = null
</#if>
		
<#if (attendanceWarnMsgDto.msgType )?? && attendanceWarnMsgDto.msgType ?length gt 0>
	<#if attendanceWarnMsgDto.msgType == 'chidaozaotui'>
		and (awm.msg_type like '%chidao%' or awm.msg_type like '%zaotui%') 
	<#else>
		and awm.msg_type like CONCAT('%', :attendanceWarnMsgDto.msgType ,'%') 
	</#if>
</#if>

<#if (attendanceWarnMsgDto.createDate_begin1 )?? >
	and awm.create_date >= :attendanceWarnMsgDto.createDate_begin1
</#if>

<#if (attendanceWarnMsgDto.createDate_end2 )?? >
	and awm.create_date <= :attendanceWarnMsgDto.createDate_end2
</#if>

ORDER BY
	awm.create_date desc