XcglRptDao_activitiStatsOrgData.sql 728 B

1234567891011121314151617181920
  1. select
  2. dep.glcname as name
  3. ,dep.id as id
  4. ,count(*) as taskTotal
  5. ,SUM(CASE WHEN hi.END_TIME_ is not null THEN 1 ELSE 0 END) AS finishTotal
  6. ,SUM(CASE WHEN hi.END_TIME_ is null THEN 1 ELSE 0 END) AS noFinishTaskTotal
  7. ,SUM(CASE WHEN hi.START_TIME_<ifnull(hi.END_TIME_,now()) +INTERVAL 0-:tookTime day THEN 1 ELSE 0 END) AS overdueCount
  8. from
  9. ACT_HI_TASKINST hi
  10. inner join t_s_base_user bu on hi.ASSIGNEE_=bu.username
  11. inner join t_s_user_org org on org.user_id=bu.ID and ifpluralism='0' and org.status='0'
  12. inner join t_s_depart dep on org.org_id=dep.ID
  13. where 1=1
  14. <#if (entityParam.attType)??>
  15. and hi.START_TIME_ between :entityParam.attStartTime and :entityParam.attEndTime
  16. </#if>
  17. group by dep.id
  18. order by taskTotal asc