select 
	dept.departname AS name,
	dept.id AS id,
	count(*) as taskTotal,
	SUM(CASE WHEN task.taskstatus ='20' or task.taskstatus ='10'  THEN 1 ELSE 0 END) AS finishTotal,
	SUM(CASE WHEN task.taskstatus ='0' or task.taskstatus ='1'  THEN 1 ELSE 0 END) AS noFinishTaskTotal,
	SUM(CASE WHEN task.taskstatus ='0' or task.taskstatus ='1'  THEN 1 ELSE 0 END)/count(*) *100 AS noFinishProportion,
	SUM(CASE WHEN task.taskstatus in ('user_add','sameleveltransfer','user_leave','green')  THEN 1 ELSE 0 END) AS activityTotal
from p_projecttask task
left join t_s_depart dept on dept.id = task.projectid 
where 1=1
<#if (entityParam.attType)?? && entityParam.attType == 2>
		and left(task.planendtime,4) = :entityParam.attYear 
	</#if>
	<#if (entityParam.attType)?? && entityParam.attType != 2>
		<#if ( entityParam.yearMonthList )?? && entityParam.yearMonthList ?size gt 0>
				and  left(task.planendtime,7) in(
				<#list entityParam.yearMonthList as item>        
				   '${item}'
				 <#if item_has_next>,</#if>
				 </#list>
				)
		</#if>
	</#if>
group by task.projectid 
order by tasktotal asc