SELECT a.pjt_id pid,d.description pjName,u.realname pidName,a.yearmonth
<#if (statsDao.attType)?? && statsDao.attType != 0>
	,CONCAT(floor(sum(a.datum_work_duration)/60) ,'小时',floor(sum(a.datum_work_duration) - floor(sum(a.datum_work_duration)/60)*60),'分钟') datumWorkDuration
    ,CONCAT(floor(sum(a.attendance_duration)/60) ,'小时',floor(sum(a.attendance_duration) - floor(sum(a.attendance_duration)/60)*60),'分钟') attendanceDuration
	,convert(AVG(a.attendance_rate),decimal(10,2)) attendanceRate 
</#if>
<#if (statsDao.attType)?? && statsDao.attType == 0>
	,CONCAT(floor(a.datum_work_duration/60) ,'小时',floor(a.datum_work_duration - floor(a.datum_work_duration/60)*60),'分钟') datumWorkDuration
    ,CONCAT(floor(a.attendance_duration/60) ,'小时',floor(a.attendance_duration - floor(a.attendance_duration/60)*60),'分钟') attendanceDuration
	,convert(a.attendance_rate,decimal(10,2)) attendanceRate 
</#if>
from t_bus_proj_attendance_statistics a
LEFT JOIN t_s_depart d
ON a.pjt_id = d.ID
LEFT JOIN t_s_base_user u
ON a.pm_id = u.ID
where 1=1
<#if (statsDao.attType)?? && statsDao.attType == 2>
	and a.yearmonth like CONCAT('%', :statsDao.attYear ,'%') 
</#if>
<#if (statsDao.attType)?? && statsDao.attType != 2>
	<#if ( statsDao.yearMonthList )?? && statsDao.yearMonthList ?size gt 0>
			and a.yearmonth in(
			<#list statsDao.yearMonthList as item>        
			   '${item}'
			 <#if item_has_next>,</#if>
			 </#list>
			)
	</#if>
</#if>
<#if (statsDao.attType)?? && statsDao.attType != 0>
		   GROUP BY a.pjt_id
</#if>
order by attendanceRate asc