DistributionStatsMinidaoDao_ProjDistributionStatsData.sql 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. SELECT in_postid postid ,uo.org_id deptId,dept.pjtid,count(*) peoplenum
  2. from t_bus_user_personnel bup
  3. LEFT JOIN t_bus_post bp
  4. ON bup.in_postid = bp.id
  5. LEFT JOIN t_s_user_org uo
  6. ON bup.userid = uo.user_id and uo.`status`=0 and uo.ifpluralism = 0
  7. LEFT JOIN t_s_depart d
  8. ON d.ID = uo.org_id
  9. LEFT JOIN
  10. (
  11. SELECT userid,MAX(create_date) leave_date from t_bus_leave
  12. WHERE delete_flag = 0
  13. GROUP BY userid
  14. ) l
  15. ON bup.userid = l.userid
  16. LEFT JOIN t_s_base_user u
  17. ON bup.userid = u.ID
  18. LEFT JOIN
  19. (
  20. SELECT uw.belong_unitid deptId, uw.pjt_id pjtid
  21. from t_bus_user_personnel bup
  22. LEFT JOIN t_bus_user_wage uw
  23. ON bup.userid = uw.userid and uw.monthly =:param.yearmonth
  24. LEFT JOIN t_s_depart d
  25. ON uw.pjt_id = d.ID and (d.org_type = 3 or d.org_type = 5)
  26. WHERE uw.belong_unitid != '' and uw.pjt_id !=''
  27. GROUP BY uw.pjt_id,uw.belong_unitid
  28. ) dept ON dept.deptId = uo.org_id
  29. WHERE (bup.position_status = 1 or bup.position_status = 2 or bup.position_status = 3) and bup.contract_stime <= :param.endmonth and uo.org_id != ''
  30. and (l.leave_date is NULL or l.leave_date >= :param.earlymonth ) and bup.in_postid !='' and u.delete_flag =0
  31. GROUP BY dept.pjtid,uo.org_id,in_postid