|
|
@@ -139,17 +139,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
|
|
|
and qec.name like concat('%', #{maps.externalUserName}, '%')
|
|
|
</if>
|
|
|
+ <!-- 时间已在 Service 归一化为 yyyy-MM-dd HH:mm:ss,直接闭区间,避免 DATE_ADD 多算一天 -->
|
|
|
<if test= 'maps.qecSTime != null '>
|
|
|
- and DATE(qec.create_time) >= DATE(#{maps.qecSTime})
|
|
|
+ and qec.create_time >= #{maps.qecSTime}
|
|
|
</if>
|
|
|
<if test='maps.qecETime != null '>
|
|
|
- and DATE(qec.create_time) <= DATE(#{maps.qecETime})
|
|
|
+ and qec.create_time <= #{maps.qecETime}
|
|
|
</if>
|
|
|
<if test= 'maps.sTime != null '>
|
|
|
- and l.create_time >= CONCAT(#{maps.sTime}," 00:00:00")
|
|
|
+ and l.create_time >= #{maps.sTime}
|
|
|
</if>
|
|
|
<if test='maps.eTime != null '>
|
|
|
- and l.create_time < CONCAT(#{maps.eTime}, ' 00:00:00')
|
|
|
+ and l.create_time <= #{maps.eTime}
|
|
|
</if>
|
|
|
<if test= 'maps.scheduleStartTime != null '>
|
|
|
and l.camp_period_time >= #{maps.scheduleStartTime}
|
|
|
@@ -158,10 +159,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
and l.camp_period_time <= #{maps.scheduleEndTime}
|
|
|
</if>
|
|
|
<if test= 'maps.upSTime != null '>
|
|
|
- and DATE(l.update_time) >= DATE(#{maps.upSTime})
|
|
|
+ and l.update_time >= #{maps.upSTime}
|
|
|
</if>
|
|
|
<if test='maps.upETime != null '>
|
|
|
- and l.update_time < date_add(#{maps.upETime}, interval 1 day)
|
|
|
+ and l.update_time <= #{maps.upETime}
|
|
|
</if>
|
|
|
<if test="maps.sopIds != null and maps.sopIds.size() > 0">
|
|
|
and l.sop_id in
|
|
|
@@ -924,29 +925,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
|
|
|
and qec.name like concat('%', #{maps.externalUserName}, '%')
|
|
|
</if>
|
|
|
+ <!-- 与列表同一口径:Service 归一化后闭区间比较(对齐导出,不再用 DATE()) -->
|
|
|
<if test= 'maps.qecSTime != null '>
|
|
|
- and DATE(qec.create_time) >= DATE(#{maps.qecSTime})
|
|
|
+ and qec.create_time >= #{maps.qecSTime}
|
|
|
</if>
|
|
|
<if test='maps.qecETime != null '>
|
|
|
- and DATE(qec.create_time) <= DATE(#{maps.qecETime})
|
|
|
+ and qec.create_time <= #{maps.qecETime}
|
|
|
</if>
|
|
|
<if test= 'maps.sTime != null '>
|
|
|
- and DATE(l.create_time) >= DATE(#{maps.sTime})
|
|
|
+ and l.create_time >= #{maps.sTime}
|
|
|
</if>
|
|
|
<if test='maps.eTime != null '>
|
|
|
- and DATE(l.create_time) <= DATE(#{maps.eTime})
|
|
|
+ and l.create_time <= #{maps.eTime}
|
|
|
</if>
|
|
|
<if test= 'maps.scheduleStartTime != null '>
|
|
|
- and DATE(l.camp_period_time) >= DATE(#{maps.scheduleStartTime})
|
|
|
+ and l.camp_period_time >= #{maps.scheduleStartTime}
|
|
|
</if>
|
|
|
<if test='maps.scheduleEndTime != null '>
|
|
|
- and DATE(l.camp_period_time) <= DATE(#{maps.scheduleEndTime})
|
|
|
+ and l.camp_period_time <= #{maps.scheduleEndTime}
|
|
|
</if>
|
|
|
<if test= 'maps.upSTime != null '>
|
|
|
- and DATE(l.update_time) >= DATE(#{maps.upSTime})
|
|
|
+ and l.update_time >= #{maps.upSTime}
|
|
|
</if>
|
|
|
<if test='maps.upETime != null '>
|
|
|
- and DATE(l.update_time) <= DATE(#{maps.upETime})
|
|
|
+ and l.update_time <= #{maps.upETime}
|
|
|
</if>
|
|
|
<if test="maps.sopIds != null and maps.sopIds.size() > 0">
|
|
|
and l.sop_id in
|
|
|
@@ -1171,12 +1173,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
FROM fs_course_watch_log
|
|
|
WHERE create_time >= #{createTime}
|
|
|
AND create_time < DATE_ADD(DATE(#{createTime}), INTERVAL 1 DAY)
|
|
|
- <if test="project != null">
|
|
|
- AND project = #{project}
|
|
|
- </if>
|
|
|
+ <!-- 已选课程时只用 course_id:企微完播 project 常为 NULL,再按 project 过滤会漏数 -->
|
|
|
<if test="courseId != null">
|
|
|
AND course_id = #{courseId}
|
|
|
</if>
|
|
|
+ <if test="courseId == null and project != null">
|
|
|
+ AND project = #{project}
|
|
|
+ </if>
|
|
|
<if test="videoIds != null and videoIds.size() > 0">
|
|
|
AND video_id IN
|
|
|
<foreach collection="videoIds" open="(" close=")" separator="," item="vid">
|
|
|
@@ -1190,6 +1193,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
</select>
|
|
|
|
|
|
+ <!-- 完播统计全量合计:对各公司已聚合人数再 SUM(与列表口径一致,不受分页影响) -->
|
|
|
+ <select id="selectUserIdListSummary" resultType="com.fs.course.vo.FsCoureseWatchLogVO"
|
|
|
+ parameterType="com.fs.course.param.FsCourseWatchLogParam">
|
|
|
+ SELECT
|
|
|
+ '合计' AS companyName,
|
|
|
+ COALESCE(SUM(l.typeOneAll), 0) AS typeOneAll,
|
|
|
+ COALESCE(SUM(l.typeTwoAll), 0) AS typeTwoAll,
|
|
|
+ COALESCE(SUM(l.typeAll), 0) AS typeAll,
|
|
|
+ COALESCE(SUM(l.allUserId), 0) AS allUserId
|
|
|
+ FROM (
|
|
|
+ SELECT
|
|
|
+ company_id,
|
|
|
+ COUNT(DISTINCT CASE WHEN log_type = 2 AND send_type = 1 THEN user_id END) AS typeOneAll,
|
|
|
+ COUNT(DISTINCT CASE WHEN log_type = 2 AND send_type = 2 THEN user_id END) AS typeTwoAll,
|
|
|
+ COUNT(DISTINCT CASE WHEN log_type = 2 THEN user_id END) AS typeAll,
|
|
|
+ COUNT(DISTINCT CASE WHEN log_type != 3 THEN user_id END) AS allUserId
|
|
|
+ FROM fs_course_watch_log
|
|
|
+ WHERE create_time >= #{createTime}
|
|
|
+ AND create_time < DATE_ADD(DATE(#{createTime}), INTERVAL 1 DAY)
|
|
|
+ <if test="courseId != null">
|
|
|
+ AND course_id = #{courseId}
|
|
|
+ </if>
|
|
|
+ <if test="courseId == null and project != null">
|
|
|
+ AND project = #{project}
|
|
|
+ </if>
|
|
|
+ <if test="videoIds != null and videoIds.size() > 0">
|
|
|
+ AND video_id IN
|
|
|
+ <foreach collection="videoIds" open="(" close=")" separator="," item="vid">
|
|
|
+ #{vid}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY company_id
|
|
|
+ ) l
|
|
|
+ INNER JOIN company c ON c.company_id = l.company_id AND c.is_del = '0'
|
|
|
+ </select>
|
|
|
+
|
|
|
|
|
|
<select id="selectFsCourseWatchLogStatisticsListVO_COUNT"
|
|
|
resultType="java.lang.Long">
|
|
|
@@ -1363,4 +1402,190 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</choose>
|
|
|
ORDER BY accessCount desc
|
|
|
</select>
|
|
|
+
|
|
|
+ <!-- P0:分页先查主键,避免多表 JOIN 参与排序与 COUNT -->
|
|
|
+ <select id="selectFsCourseWatchLogListIds" resultType="java.lang.Long">
|
|
|
+ select l.log_id
|
|
|
+ from fs_course_watch_log l
|
|
|
+ <if test="(maps.companyUserName != null and maps.companyUserName != '') or maps.deptId != null or (maps.cuDeptIdList != null and !maps.cuDeptIdList.isEmpty() and maps.userType != '00') or (maps.userIds != null and !maps.userIds.isEmpty())">
|
|
|
+ left join company_user cu on cu.user_id = l.company_user_id
|
|
|
+ </if>
|
|
|
+ <if test="(maps.nickName != null and maps.nickName != '')">
|
|
|
+ left join fs_user u on u.user_id = l.user_id
|
|
|
+ </if>
|
|
|
+ <if test="(maps.externalUserName != null and maps.externalUserName != '') or maps.qecSTime != null or maps.qecETime != null or (maps.externalStatus != null and maps.externalStatus != '') or (maps.corpId != null and maps.corpId != '') or (maps.tagIds != null and maps.tagIds.size() > 0)">
|
|
|
+ left join qw_external_contact qec on l.qw_external_contact_id = qec.id
|
|
|
+ </if>
|
|
|
+ <if test="maps.qwUserName != null and maps.qwUserName != ''">
|
|
|
+ left join qw_user qu on qu.id = l.qw_user_id
|
|
|
+ </if>
|
|
|
+ <where>
|
|
|
+ <if test ='maps.appid != null'>
|
|
|
+ and l.app_id = #{maps.appid}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.isVip != null and maps.isVip == 0'>
|
|
|
+ and (l.user_id = 0 or l.user_id is null)
|
|
|
+ </if>
|
|
|
+ <if test ='maps.isVip != null and maps.isVip == 1'>
|
|
|
+ and l.user_id != 0 and l.user_id is not null
|
|
|
+ </if>
|
|
|
+ <if test ='maps.sendType !=null'>
|
|
|
+ and l.send_type = #{maps.sendType}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.userId !=null'>
|
|
|
+ and l.user_id = #{maps.userId}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.logId !=null'>
|
|
|
+ and l.log_id = #{maps.logId}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.qwExternalContactId !=null'>
|
|
|
+ and l.qw_external_contact_id = #{maps.qwExternalContactId}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.qwUserId !=null'>
|
|
|
+ and l.qw_user_id = #{maps.qwUserId}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.courseId !=null'>
|
|
|
+ and l.course_id = #{maps.courseId}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.videoId !=null'>
|
|
|
+ and l.video_id = #{maps.videoId}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.logType !=null'>
|
|
|
+ and l.log_type = #{maps.logType}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.companyId !=null'>
|
|
|
+ and l.company_id = #{maps.companyId}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.watchType !=null'>
|
|
|
+ and l.watch_type = #{maps.watchType}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.companyUserId !=null'>
|
|
|
+ and l.company_user_id = #{maps.companyUserId}
|
|
|
+ </if>
|
|
|
+ <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
|
|
|
+ and cu.nick_name like concat('%', #{maps.companyUserName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test ='maps.nickName !=null and maps.nickName!=""'>
|
|
|
+ and u.nick_name like concat('%', #{maps.nickName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
|
|
|
+ and qec.name like concat('%', #{maps.externalUserName}, '%')
|
|
|
+ </if>
|
|
|
+ <!-- 时间已在 Service 归一化为 yyyy-MM-dd HH:mm:ss,直接闭区间,避免 DATE_ADD 多算一天 -->
|
|
|
+ <if test= 'maps.qecSTime != null '>
|
|
|
+ and qec.create_time >= #{maps.qecSTime}
|
|
|
+ </if>
|
|
|
+ <if test='maps.qecETime != null '>
|
|
|
+ and qec.create_time <= #{maps.qecETime}
|
|
|
+ </if>
|
|
|
+ <if test= 'maps.sTime != null '>
|
|
|
+ and l.create_time >= #{maps.sTime}
|
|
|
+ </if>
|
|
|
+ <if test='maps.eTime != null '>
|
|
|
+ and l.create_time <= #{maps.eTime}
|
|
|
+ </if>
|
|
|
+ <if test= 'maps.scheduleStartTime != null '>
|
|
|
+ and l.camp_period_time >= #{maps.scheduleStartTime}
|
|
|
+ </if>
|
|
|
+ <if test='maps.scheduleEndTime != null '>
|
|
|
+ and l.camp_period_time <= #{maps.scheduleEndTime}
|
|
|
+ </if>
|
|
|
+ <if test= 'maps.upSTime != null '>
|
|
|
+ and l.update_time >= #{maps.upSTime}
|
|
|
+ </if>
|
|
|
+ <if test='maps.upETime != null '>
|
|
|
+ and l.update_time <= #{maps.upETime}
|
|
|
+ </if>
|
|
|
+ <if test="maps.sopIds != null and maps.sopIds.size() > 0">
|
|
|
+ and l.sop_id in
|
|
|
+ <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
|
|
|
+ #{sopId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="maps.sopId != null and maps.sopId != '' ">
|
|
|
+ and l.sop_id = #{maps.sopId}
|
|
|
+ </if>
|
|
|
+ <if test="maps.externalStatus != null and maps.externalStatus != '' ">
|
|
|
+ and qec.status = #{maps.externalStatus}
|
|
|
+ </if>
|
|
|
+ <if test="maps.periodId != null">
|
|
|
+ and l.period_id = #{maps.periodId}
|
|
|
+ </if>
|
|
|
+ <if test="maps.periodIds != null and maps.periodIds.size() > 0">
|
|
|
+ and l.period_id in
|
|
|
+ <foreach item="periodId" index="index" collection="maps.periodIds" open="(" separator="," close=")">
|
|
|
+ #{periodId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="maps.qwUserName != null and maps.qwUserName != '' ">
|
|
|
+ and (
|
|
|
+ qu.qw_user_name = #{maps.qwUserName}
|
|
|
+ OR (qu.qw_user_name LIKE '{%' AND JSON_UNQUOTE(JSON_EXTRACT(qu.qw_user_name, '$.name')) = #{maps.qwUserName})
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="maps.deptId != null and maps.deptId != '' ">
|
|
|
+ and cu.dept_id = #{maps.deptId}
|
|
|
+ </if>
|
|
|
+ <if test='maps.cuDeptIdList != null and !maps.cuDeptIdList.isEmpty() and maps.userType != "00" '>
|
|
|
+ AND cu.dept_id IN
|
|
|
+ <foreach collection='maps.cuDeptIdList' item='item' open='(' separator=',' close=')'>
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="maps.userIds != null and !maps.userIds.isEmpty()">
|
|
|
+ AND cu.user_id IN
|
|
|
+ <foreach collection='maps.userIds' item='item' open='(' separator=',' close=')'>
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="maps.corpId != null and maps.corpId != ''">
|
|
|
+ and qec.corp_id = #{maps.corpId}
|
|
|
+ </if>
|
|
|
+ <if test="maps.tagIds != null and maps.tagIds.size() > 0">
|
|
|
+ <choose>
|
|
|
+ <when test="maps.tagFilterType != null and maps.tagFilterType == 2">
|
|
|
+ and (
|
|
|
+ <foreach collection="maps.tagIds" item="item" index="index" separator=" or ">
|
|
|
+ <![CDATA[find_in_set(#{item}, REPLACE(REPLACE(REPLACE(REPLACE(IFNULL(qec.tag_ids,''), '"', ''), '[', ''), ']', ''), ' ', ''))]]>
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ and (
|
|
|
+ <foreach collection="maps.tagIds" item="item" index="index" separator=" and ">
|
|
|
+ <![CDATA[find_in_set(#{item}, REPLACE(REPLACE(REPLACE(REPLACE(IFNULL(qec.tag_ids,''), '"', ''), '[', ''), ']', ''), ' ', ''))]]>
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ order by l.create_time desc, l.log_id desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectFsCourseWatchLogListByLogIds" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
|
|
|
+ select l.log_id,l.project,l.period_id,l.user_id,uc.course_name,v.title as video_name,qec.avatar as external_user_avatar,qec.status as externalStatus,
|
|
|
+ l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,l.app_id,
|
|
|
+ cu.nick_name as company_user_name ,l.send_type,l.create_time,l.update_time,l.last_heartbeat_time,fcpsc.name,
|
|
|
+ CASE
|
|
|
+ WHEN qu.qw_user_name IS NOT NULL AND qu.qw_user_name LIKE '{%' THEN JSON_UNQUOTE(JSON_EXTRACT(qu.qw_user_name, '$.name'))
|
|
|
+ ELSE qu.qw_user_name
|
|
|
+ END as qw_user_name,
|
|
|
+ qec.name as external_user_name,c.company_id,u.avatar as fsAvatar,u.nick_name as fsNickName,qec.create_time as qec_create_time,
|
|
|
+ u.is_vip isVip, l.project, l.im_msg_send_detail_id,l.reward_type,cu.dept_id, l.watch_type
|
|
|
+ from fs_course_watch_log l
|
|
|
+ left join fs_user_course_video v on v.video_id = l.video_id
|
|
|
+ left join fs_user_course uc on uc.course_id = l.course_id
|
|
|
+ left join fs_user u on u.user_id = l.user_id
|
|
|
+ left join company_user cu on cu.user_id = l.company_user_id
|
|
|
+ left join company c on c.company_id = l.company_id
|
|
|
+ LEFT JOIN qw_user qu on qu.id= l.qw_user_id
|
|
|
+ LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
|
|
|
+ LEFT JOIN fs_course_play_source_config fcpsc ON fcpsc.appid = l.app_id
|
|
|
+ where l.log_id in
|
|
|
+ <foreach collection="logIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|