SELECT o.pjt_id pid,d.description pName,u.realname pidName,o.yearmonth,
<#if (overtimeEntity.attType)?? && overtimeEntity.attType != 0>
	convert(sum(o.overtime_duration)/60,decimal(10,2)) overtimeDuration, 
	CONCAT(floor(sum(o.overtime_duration)/60),'小时',floor(sum(o.overtime_duration) - floor(sum(o.overtime_duration)/60)*60),'分钟') overtimeDurationStr,
	sum(o.overtime_fee) overtimeFee,round(avg(o.unit_people_total)) unitPeopleTotal
</#if>
<#if (overtimeEntity.attType)?? && overtimeEntity.attType == 0>
	convert(o.overtime_duration/60,decimal(10,2)) overtimeDuration ,
	CONCAT(floor(o.overtime_duration/60),'小时',floor(o.overtime_duration - floor(o.overtime_duration/60)*60),'分钟') overtimeDurationStr,
	 o.overtime_fee overtimeFee,o.unit_people_total unitPeopleTotal
</#if>
from t_bus_proj_overtime_statistics o
LEFT JOIN t_s_depart d
ON o.pjt_id = d.ID
LEFT JOIN t_s_base_user u
ON o.pm_id = u.ID
where 1=1
<#if (overtimeEntity.attType)?? && overtimeEntity.attType == 2>
	 and o.yearmonth like CONCAT('%', :overtimeEntity.attYear ,'%') 
</#if>
<#if (overtimeEntity.attType)?? && overtimeEntity.attType != 2>
	<#if ( overtimeEntity.yearMonthList )?? && overtimeEntity.yearMonthList ?size gt 0>
			and o.yearmonth in(
			<#list overtimeEntity.yearMonthList as item>        
			   '${item}'
			 <#if item_has_next>,</#if>
			 </#list>
			)
	</#if>
</#if>

<#if (overtimeEntity.attType)?? && overtimeEntity.attType != 0>
		   GROUP BY o.pjt_id
</#if>
 order by overtimeDuration desc

