select count(baseuu.realname) as total, 

count(uu3.id)as maleCount, 
count(uu4.id)as femaleCount, 
:inDto.inMonth as inMonth,
dp.glcname as departname
from t_bus_user_personnel pers
LEFT JOIN t_s_base_user baseuu on baseuu.id = pers.userid
left join t_s_user_org uorg on uorg.user_id = pers.userid and uorg.ifpluralism = '0'
left join t_s_user uu on baseuu.id = uu.id
left join t_s_depart dp on dp.ID = uorg.org_id
left join t_s_user uu3 on baseuu.id = uu3.id and uu3.gender = '0'
left join t_s_user uu4 on baseuu.id = uu4.id and uu4.gender = '1'
where  (pers.leave_date is null 
<#if inDto.inMonth ?exists && inDto.inMonth ?length gt 0>
	OR pers.leave_date > :inDto.inMonth 
</#if>
) 
<#if inDto.inMonth ?exists && inDto.inMonth ?length gt 0>
	AND pers.contract_stime <= :inDto.inMonth 
</#if>
and baseuu.delete_flag = '0' and dp.glcname is not null 
GROUP BY dp.glcname