|
|
@@ -27,6 +27,9 @@
|
|
|
LEFT JOIN company_dept AS cd ON ci.company_id = cd.company_id AND cd.STATUS = 0
|
|
|
LEFT JOIN company_user AS cu ON cu.dept_id = cd.dept_id AND cu.del_flag = 0
|
|
|
WHERE ci.is_del = 0 AND cd.del_flag = 0
|
|
|
+ <if test="companyId != null">
|
|
|
+ and ci.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
</select>
|
|
|
|
|
|
<select id="getStatisticNum" resultType="com.fs.company.dto.CompanyDeptUserInfoDTO">
|
|
|
@@ -61,5 +64,183 @@
|
|
|
select t2.lineNum, t3.activeNum, t4.completeNum, t5.answerNum, t6.redPacketNum from t2, t3, t4, t5, t6
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getStatisticNumByPersonal">
|
|
|
+ WITH RECURSIVE date_range AS (
|
|
|
+ SELECT #{startTime} AS dt
|
|
|
+ UNION ALL
|
|
|
+ SELECT DATE_ADD(dt, INTERVAL 1 DAY)
|
|
|
+ FROM date_range
|
|
|
+ WHERE dt < #{endTime}
|
|
|
+ ),
|
|
|
+ t1 AS (
|
|
|
+ SELECT
|
|
|
+ COUNT(qec.id) AS t1_count,
|
|
|
+ d.dt AS create_time
|
|
|
+ FROM date_range d
|
|
|
+ LEFT JOIN qw_external_contact qec
|
|
|
+ ON DATE(qec.create_time) = d.dt
|
|
|
+ <if test="userIds != null">
|
|
|
+ <if test="dimension == 1">
|
|
|
+ <choose>
|
|
|
+ <when test="userIds.length > 1 ">
|
|
|
+ AND qec.company_user_id IN (
|
|
|
+ <foreach collection="userIds" item="i" separator=",">
|
|
|
+ #{i}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ AND qec.company_user_id = #{userIds[0]}
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ <if test="dimension == 2">
|
|
|
+ AND qec.company_id = #{userIds[0]}
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ GROUP BY d.dt
|
|
|
+ ),
|
|
|
+ t2 AS (
|
|
|
+ SELECT
|
|
|
+ COUNT(qec.id) AS t2_count,
|
|
|
+ d.dt AS create_time
|
|
|
+ FROM date_range d
|
|
|
+ LEFT JOIN qw_external_contact qec
|
|
|
+ ON DATE(qec.create_time) = d.dt
|
|
|
+ <if test="userIds != null">
|
|
|
+ <if test="dimension == 1">
|
|
|
+ <choose>
|
|
|
+ <when test="userIds.length > 1 ">
|
|
|
+ AND qec.company_user_id IN (
|
|
|
+ <foreach collection="userIds" item="i" separator=",">
|
|
|
+ #{i}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ AND qec.company_user_id = #{userIds[0]}
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ <if test="dimension == 2">
|
|
|
+ AND qec.company_id = #{userIds[0]}
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ AND qec.fs_user_id IS NOT NULL
|
|
|
+ GROUP BY d.dt
|
|
|
+ ),
|
|
|
+ t4 AS (
|
|
|
+ SELECT
|
|
|
+ d.dt AS create_time,
|
|
|
+ COUNT(fcwl.qw_external_contact_id) AS completeNum
|
|
|
+ FROM
|
|
|
+ date_range d
|
|
|
+ LEFT JOIN fs_course_watch_log AS fcwl
|
|
|
+ ON DATE(fcwl.create_time) = d.dt
|
|
|
+ AND fcwl.log_type = 2
|
|
|
+ <if test="userIds != null">
|
|
|
+ <if test="dimension == 1">
|
|
|
+ <choose>
|
|
|
+ <when test="userIds.length > 1 ">
|
|
|
+ AND fcwl.company_user_id IN (
|
|
|
+ <foreach collection="userIds" item="i" separator=",">
|
|
|
+ #{i}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ AND fcwl.company_user_id = #{userIds[0]}
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ <if test="dimension == 2">
|
|
|
+ AND fcwl.company_id = #{userIds[0]}
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ GROUP BY d.dt
|
|
|
+ ),
|
|
|
+ t5 AS (
|
|
|
+ SELECT
|
|
|
+ d.dt AS create_time,
|
|
|
+ COUNT(fcal.log_id) AS answerNum
|
|
|
+ FROM
|
|
|
+ date_range d
|
|
|
+ LEFT JOIN fs_course_answer_logs AS fcal
|
|
|
+ ON DATE(fcal.create_time) = d.dt
|
|
|
+ <if test="userIds != null">
|
|
|
+ <if test="dimension == 1">
|
|
|
+ <choose>
|
|
|
+ <when test="userIds.length > 1 ">
|
|
|
+ AND fcal.company_user_id IN (
|
|
|
+ <foreach collection="userIds" item="i" separator=",">
|
|
|
+ #{i}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ AND fcal.company_user_id = #{userIds[0]}
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ <if test="dimension == 2">
|
|
|
+ AND fcal.company_id = #{userIds[0]}
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ GROUP BY d.dt
|
|
|
+ ),
|
|
|
+ t6 AS (
|
|
|
+ SELECT
|
|
|
+ d.dt AS create_time,
|
|
|
+ COUNT(fcrpl.log_id) AS redPacketNum
|
|
|
+ FROM
|
|
|
+ date_range d
|
|
|
+ LEFT JOIN fs_course_red_packet_log AS fcrpl
|
|
|
+ ON DATE(fcrpl.create_time) = d.dt
|
|
|
+ <if test="userIds != null">
|
|
|
+ <if test="dimension == 1">
|
|
|
+ <choose>
|
|
|
+ <when test="userIds.length > 1 ">
|
|
|
+ AND fcrpl.company_user_id IN (
|
|
|
+ <foreach collection="userIds" item="i" separator=",">
|
|
|
+ #{i}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ AND fcrpl.company_user_id = #{userIds[0]}
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ <if test="dimension == 2">
|
|
|
+ AND fcrpl.company_id = #{userIds[0]}
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ GROUP BY d.dt
|
|
|
+ )
|
|
|
+ SELECT
|
|
|
+ t1.create_time,
|
|
|
+ t1.t1_count as lineNum,
|
|
|
+ t2.t2_count as activeNum,
|
|
|
+ t4.completeNum,
|
|
|
+ t5.answerNum,
|
|
|
+ t6.redPacketNum
|
|
|
+ FROM t1
|
|
|
+ INNER JOIN t2 ON t1.create_time = t2.create_time
|
|
|
+ INNER JOIN t4 ON t1.create_time = t4.create_time
|
|
|
+ INNER JOIN t5 ON t1.create_time = t5.create_time
|
|
|
+ INNER JOIN t6 ON t1.create_time = t6.create_time
|
|
|
+ ORDER BY t1.create_time
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getCompanyInfo" resultType="com.fs.company.domain.CompanyDeptUserInfo">
|
|
|
+ SELECT
|
|
|
+ ci.company_id,
|
|
|
+ ci.company_name
|
|
|
+ FROM
|
|
|
+ company AS ci
|
|
|
+ WHERE
|
|
|
+ ci.is_del = 0
|
|
|
+ </select>
|
|
|
+
|
|
|
|
|
|
</mapper>
|