StatisticManageMapper.xml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.company.mapper.StatisticManageMapper">
  6. <resultMap id="CompanyDeptUserListMap" type="com.fs.company.domain.CompanyDeptUserInfo">
  7. <id column="company_id" property="companyId" />
  8. <result column="company_name" property="companyName"/>
  9. <result column="dept_id" property="deptId"/>
  10. <result column="dept_name" property="deptName"/>
  11. <result column="user_id" property="userId"/>
  12. <result column="user_name" property="userName"/>
  13. <result column="nick_name" property="nickName"/>
  14. </resultMap>
  15. <select id="getCompanyAndDeptAndDeptUserList" resultMap="CompanyDeptUserListMap">
  16. SELECT
  17. ci.company_id,
  18. ci.company_name,
  19. cd.dept_id,
  20. cd.dept_name,
  21. cu.user_id,
  22. cu.user_name,
  23. cu.nick_name
  24. FROM company AS ci
  25. LEFT JOIN company_dept AS cd ON ci.company_id = cd.company_id AND cd.STATUS = 0
  26. LEFT JOIN company_user AS cu ON cu.dept_id = cd.dept_id AND cu.del_flag = 0
  27. WHERE ci.is_del = 0 AND cd.del_flag = 0
  28. </select>
  29. <select id="getStatisticNum" resultType="com.fs.company.dto.CompanyDeptUserInfoDTO">
  30. with t1 as (
  31. SELECT
  32. qec.id,
  33. qec.company_user_id,
  34. qec.fs_user_id,
  35. qec.qw_user_id,
  36. qec.user_id
  37. FROM
  38. qw_external_contact AS qec
  39. WHERE
  40. date_format(qec.create_time,'%y%m%d') >= date_format(now(),'%y%m%d') and
  41. qec.create_time &lt;= now()
  42. and qec.company_user_id IN (
  43. <foreach collection="userIds" item="i" separator=",">
  44. #{i}
  45. </foreach>
  46. )
  47. ),t2 as (
  48. select count(t1.id) as lineNum from t1
  49. ),t3 as (
  50. select count(t1.id) as activeNum from t1 where t1.fs_user_id is not null
  51. ),t4 as(
  52. select count(fcwl.qw_external_contact_id) as completeNum from t1 inner join fs_course_watch_log as fcwl on t1.id = fcwl.qw_external_contact_id where fcwl.log_type = 2
  53. ),t5 as (
  54. select count(fcal.log_id) as answerNum from t1 inner join fs_course_answer_logs as fcal where fcal.user_id = t1.user_id
  55. ), t6 as (
  56. select count(fcrpl.log_id) as redPacketNum from t1 inner join fs_course_red_packet_log as fcrpl where fcrpl.user_id = t1.user_id
  57. )
  58. select t2.lineNum, t3.activeNum, t4.completeNum, t5.answerNum, t6.redPacketNum from t2, t3, t4, t5, t6
  59. </select>
  60. </mapper>