select 
	buser.realname as realname,
	temp.time as lastdingtime,
	warntext,
	dept.glcdesc as projectname,
	dept.parentdepartid as projectid,
	user.mobilePhone as tel
from (
	select
		user_id,
		time ,
		'超过10天未考勤' as warntext
	from (
		select 
			user_id ,
			max(attendance_time) as time 
		from t_bus_ding_attendanceinfo 
		group by user_id
		) ding 
	where 
	DATE_FORMAT(time,'%Y-%m-%d') < :dingdate
	) temp 
left join t_s_base_user buser on buser.id = temp.user_id
left join t_s_user_org uo on uo.user_id = temp.user_id
left join t_s_user user on user.id = temp.user_id
left join t_s_depart dept on uo.org_id = dept.id
left join t_bus_user_personnel per on per.userid = uo.user_id
 and not exists(select * from t_bus_special_attend special where special.userid =temp.user_id)
where per.leave_date is null and per.manager_type = '2'
order by projectname


