XcglRptDao_activitiOvertimeSum.sql 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. select realName,userid,username,month,concat(month,username) as id,sum(overtimetotal) as overtimetotal
  2. from (
  3. select
  4. bu.realname as realName,bu.id as userid, hi.ASSIGNEE_ as username,
  5. left(hi.START_TIME_ + INTERVAL :tookTime day,7) as month ,count(*) as overtimetotal
  6. from
  7. ACT_HI_TASKINST hi
  8. left join act_hi_varinst hivar on hi.PROC_INST_ID_ =hivar.PROC_INST_ID_ and hivar.NAME_ ='bpm_biz_title'
  9. left join act_hi_varinst hivardept on hi.PROC_INST_ID_ =hivardept.PROC_INST_ID_ and hivardept.NAME_ ='dep_name'
  10. left join act_hi_varinst hivarcreate on hi.PROC_INST_ID_ =hivarcreate.PROC_INST_ID_ and hivarcreate.NAME_ ='create_by'
  11. left join act_hi_procinst proc on proc.PROC_INST_ID_ = hivar.PROC_INST_ID_
  12. inner join t_s_base_user bu on hi.ASSIGNEE_=bu.username
  13. left join t_s_base_user startu on startu.username = proc.start_user_id_ and startu.delete_flag = 0
  14. left join t_s_user_org uo on uo.user_id = startu.id and uo.ifpluralism = 0
  15. left join t_s_depart dept on dept.id = uo.org_id
  16. where
  17. hi.START_TIME_<now() +INTERVAL 0-2 day
  18. and hi.END_TIME_ is null
  19. and left(hi.START_TIME_ ,4) > '2019'
  20. and hivarcreate.text_ <> hi.ASSIGNEE_
  21. and left(hi.START_TIME_ + INTERVAL :tookTime day,7) = :month
  22. group by
  23. bu.realname ,bu.id ,
  24. left(hi.START_TIME_ + INTERVAL :tookTime day,7)
  25. union all
  26. select
  27. bu.realname as realName,bu.id as userid, hi.ASSIGNEE_ as username,
  28. left(hi.START_TIME_ + INTERVAL :tookTime day,7) as month ,count(*) as overtimetotal
  29. from
  30. ACT_HI_TASKINST hi
  31. left join act_hi_varinst hivar on hi.PROC_INST_ID_ =hivar.PROC_INST_ID_ and hivar.NAME_ ='bpm_biz_title'
  32. left join act_hi_varinst hivardept on hi.PROC_INST_ID_ =hivardept.PROC_INST_ID_ and hivardept.NAME_ ='dep_name'
  33. left join act_hi_varinst hivarcreate on hi.PROC_INST_ID_ =hivarcreate.PROC_INST_ID_ and hivarcreate.NAME_ ='create_by'
  34. left join act_hi_procinst proc on proc.PROC_INST_ID_ = hivar.PROC_INST_ID_
  35. inner join t_s_base_user bu on hi.ASSIGNEE_=bu.username
  36. left join t_s_base_user startu on startu.username = proc.start_user_id_ and startu.delete_flag = 0
  37. left join t_s_user_org uo on uo.user_id = startu.id and uo.ifpluralism = 0
  38. left join t_s_depart dept on dept.id = uo.org_id
  39. where
  40. hi.START_TIME_< hi.END_TIME_ +INTERVAL 0-:tookTime day
  41. and left(hi.START_TIME_ ,4) > '2019'
  42. and hivarcreate.text_ <> hi.ASSIGNEE_
  43. and left(hi.START_TIME_ + INTERVAL :tookTime day,7) = :month
  44. group by
  45. bu.realname ,bu.id ,
  46. left(hi.START_TIME_ + INTERVAL :tookTime day,7)
  47. ) temptable
  48. group by realName,userid,username,month
  49. order by overtimetotal desc