XcglRptDao_activitiOvertimeSumDetail.sql 2.7 KB

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