123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.fs.qw.mapper.QwWatchLogMapper">
- <resultMap type="QwWatchLog" id="QwWatchLogResult">
- <result property="id" column="id" />
- <result property="extId" column="ext_id" />
- <result property="qwUserId" column="qw_user_id" />
- <result property="status" column="status" />
- <result property="day" column="day" />
- <result property="project" column="project" />
- <result property="createTime" column="create_time" />
- <result property="lineTime" column="line_time" />
- </resultMap>
- <sql id="selectQwWatchLogVo">
- select id, ext_id, qw_user_id,line_time, status, day, project, create_time from qw_watch_log
- </sql>
- <select id="selectQwWatchLogList" parameterType="QwWatchLog" resultMap="QwWatchLogResult">
- <include refid="selectQwWatchLogVo"/>
- <where>
- <if test="extId != null "> and ext_id = #{extId}</if>
- <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
- <if test="status != null "> and status = #{status}</if>
- <if test="day != null "> and day = #{day}</if>
- <if test="project != null "> and project = #{project}</if>
- </where>
- </select>
- <select id="selectQwWatchLogById" parameterType="Long" resultMap="QwWatchLogResult">
- <include refid="selectQwWatchLogVo"/>
- where id = #{id}
- </select>
- <select id="selectQwWatchLogAllStatisticsListVONew"
- resultType="com.fs.qw.vo.QwWatchLogAllStatisticsListVO">
- select
- any_value(company_id) as company_id,
- company_user_id,MIN(line_time) as create_time,
- COUNT(CASE WHEN day = 0 and status in (1,2) THEN 1 END) AS firstOnline,
- COUNT(CASE WHEN day = 0 and status=2 THEN 1 END) AS firstOver,
- COUNT(CASE WHEN day = 1 and status in (1,2) THEN 1 END) AS d1Online,
- COUNT(CASE WHEN day = 1 and status=2 THEN 1 END) AS d1Over,
- COUNT(CASE WHEN day = 2 and status in (1,2) THEN 1 END) AS d2Online,
- COUNT(CASE WHEN day = 2 and status=2 THEN 1 END) AS d2Over,
- COUNT(CASE WHEN day = 3 and status in (1,2) THEN 1 END) AS d3Online,
- COUNT(CASE WHEN day = 3 and status=2 THEN 1 END) AS d3Over,
- COUNT(CASE WHEN day = 4 and status in (1,2) THEN 1 END) AS d4Online,
- COUNT(CASE WHEN day = 4 and status=2 THEN 1 END) AS d4Over,
- COUNT(CASE WHEN day = 5 and status in (1,2) THEN 1 END) AS d5Online,
- COUNT(CASE WHEN day = 5 and status=2 THEN 1 END) AS d5Over,
- COUNT(CASE WHEN day = 6 and status in (1,2) THEN 1 END) AS d6Online,
- COUNT(CASE WHEN day = 6 and status=2 THEN 1 END) AS d6Over,
- COUNT(CASE WHEN day = 7 and status in (1,2) THEN 1 END) AS d7Online,
- COUNT(CASE WHEN day = 7 and status=2 THEN 1 END) AS d7Over,
- COUNT(CASE WHEN day = 8 and status in (1,2) THEN 1 END) AS d8Online,
- COUNT(CASE WHEN day = 8 and status=2 THEN 1 END) AS d8Over,
- COUNT(CASE WHEN day = 9 and status in (1,2) THEN 1 END) AS d9Online,
- COUNT(CASE WHEN day = 9 and status=2 THEN 1 END) AS d9Over,
- COUNT(CASE WHEN day = 10 and status in (1,2) THEN 1 END) AS d10Online,
- COUNT(CASE WHEN day = 10 and status=2 THEN 1 END) AS d10Over,
- COUNT(CASE WHEN day = 11 and status in (1,2) THEN 1 END) AS d11Online,
- COUNT(CASE WHEN day = 11 and status=2 THEN 1 END) AS d11Over,
- COUNT(CASE WHEN day = 12 and status in (1,2) THEN 1 END) AS d12Online,
- COUNT(CASE WHEN day = 12 and status=2 THEN 1 END) AS d12Over,
- COUNT(CASE WHEN day = 13 and status in (1,2) THEN 1 END) AS d13Online,
- COUNT(CASE WHEN day = 13 and status=2 THEN 1 END) AS d13Over,
- COUNT(CASE WHEN day = 14 and status in (1,2) THEN 1 END) AS d14Online,
- COUNT(CASE WHEN day = 14 and status=2 THEN 1 END) AS d14Over,
- COUNT(CASE WHEN day = 15 and status in (1,2) THEN 1 END) AS d15Online,
- COUNT(CASE WHEN day = 15 and status=2 THEN 1 END) AS d15Over,
- COUNT(CASE WHEN day = 16 and status in (1,2) THEN 1 END) AS d16Online,
- COUNT(CASE WHEN day = 16 and status=2 THEN 1 END) AS d16Over,
- COUNT(CASE WHEN day = 17 and status in (1,2) THEN 1 END) AS d17Online,
- COUNT(CASE WHEN day = 17 and status=2 THEN 1 END) AS d17Over,
- COUNT(CASE WHEN day = 18 and status in (1,2) THEN 1 END) AS d18Online,
- COUNT(CASE WHEN day = 18 and status=2 THEN 1 END) AS d18Over,
- COUNT(CASE WHEN day = 19 and status in (1,2) THEN 1 END) AS d19Online,
- COUNT(CASE WHEN day = 19 and status=2 THEN 1 END) AS d19Over,
- COUNT(CASE WHEN day = 20 and status in (1,2) THEN 1 END) AS d20Online,
- COUNT(CASE WHEN day = 20 and status=2 THEN 1 END) AS d20Over,
- COUNT(CASE WHEN day = 21 and status in (1,2) THEN 1 END) AS d21Online,
- COUNT(CASE WHEN day = 21 and status=2 THEN 1 END) AS d21Over,
- COUNT(CASE WHEN day = 22 and status in (1,2) THEN 1 END) AS d22Online,
- COUNT(CASE WHEN day = 22 and status=2 THEN 1 END) AS d22Over,
- COUNT(CASE WHEN day = 23 and status in (1,2) THEN 1 END) AS d23Online,
- COUNT(CASE WHEN day = 23 and status=2 THEN 1 END) AS d23Over,
- COUNT(CASE WHEN day = 24 and status in (1,2) THEN 1 END) AS d24Online,
- COUNT(CASE WHEN day = 24 and status=2 THEN 1 END) AS d24Over,
- COUNT(CASE WHEN day = 25 and status in (1,2) THEN 1 END) AS d25Online,
- COUNT(CASE WHEN day = 25 and status=2 THEN 1 END) AS d25Over,
- COUNT(CASE WHEN day = 26 and status in (1,2) THEN 1 END) AS d26Online,
- COUNT(CASE WHEN day = 26 and status=2 THEN 1 END) AS d26Over,
- COUNT(CASE WHEN day = 27 and status in (1,2) THEN 1 END) AS d27Online,
- COUNT(CASE WHEN day = 27 and status=2 THEN 1 END) AS d27Over,
- COUNT(CASE WHEN day = 28 and status in (1,2) THEN 1 END) AS d28Online,
- COUNT(CASE WHEN day = 28 and status=2 THEN 1 END) AS d28Over,
- COUNT(CASE WHEN day = 29 and status in (1,2) THEN 1 END) AS d29Online,
- COUNT(CASE WHEN day = 29 and status=2 THEN 1 END) AS d29Over,
- COUNT(CASE WHEN day = 30 and status in (1,2) THEN 1 END) AS d30Online,
- COUNT(CASE WHEN day = 30 and status=2 THEN 1 END) AS d30Over,
- COUNT(1) AS line,project,course_id,video_id
- from hy_watch_log
- <where>
- <if test="companyUserIds != null and companyUserIds.size() != 0">
- and company_user_id in
- <foreach collection="companyUserIds" item="item" open="(" close=")" separator=",">
- ${item}
- </foreach>
- </if>
- <if test="project != null">
- and project = #{project}
- </if>
- <if test="courseId != null">
- and course_id = #{courseId}
- </if>
- <if test="videoId != null">
- and video_id =#{videoId}
- </if>
- and DATE(line_time) between #{sDate} AND #{eDate} group by project,course_id,video_id,company_user_id
- </where>
- </select>
- <select id="selectQwWatchLogAllStatisticsListVONewCount" resultType="java.lang.Long">
- select count(*) from(
- select
- 1
- from hy_watch_log
- <where>
- <if test="companyUserIds != null">
- and company_user_id in
- <foreach collection="companyUserIds" item="item" open="(" close=")" separator=",">
- ${item}
- </foreach>
- </if>
- <if test="project != null">
- and project = #{project}
- </if>
- <if test="courseId != null">
- and course_id = #{courseId}
- </if>
- <if test="videoId != null">
- and video_id =#{videoId}
- </if>
- and DATE(line_time) between #{sDate} AND #{eDate} group by project,course_id,video_id
- </where>
- )t
- </select>
- <select id="selectQwWatchLogByCompanyUserId" resultType="com.fs.qw.vo.QwWatchLogStatisticsListVO">
- select
- COUNT(CASE WHEN day = 0 and status in (1,2) THEN 1 END) AS firstOnline,
- COUNT(CASE WHEN day = 0 and status=2 THEN 1 END) AS firstOver,
- COUNT(CASE WHEN day = 1 and status in (1,2) THEN 1 END) AS d1Online,
- COUNT(CASE WHEN day = 1 and status=2 THEN 1 END) AS d1Over,
- COUNT(1) AS line,project,course_id,video_id,company_id,company_user_id
- from hy_watch_log
- <where>
- <if test="companyUserIds != null and companyUserIds.size() != 0">
- and company_user_id in
- <foreach collection="companyUserIds" item="item" open="(" close=")" separator=",">
- ${item}
- </foreach>
- </if>
- <if test="project != null">
- and project=#{project}
- </if>
- <if test="courseId != null">
- and course_id=#{courseId}
- </if>
- <if test="videoId != null">
- and video_id=#{videoId}
- </if>
- and DATE(line_time) between #{sTime} and #{dTime}
- </where>
- group by project,course_id,video_id
- limit ${(pageNum-1)*pageSize},${pageSize}
- </select>
- <select id="selectQwWatchLogByCompanyUserIdCount" resultType="java.lang.Long">
- SELECT COUNT(*)
- FROM (
- SELECT 1
- FROM hy_watch_log
- <where>
- <if test="companyUserIds != null and companyUserIds.size() != 0">
- and company_user_id in
- <foreach collection="companyUserIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="project != null">
- and project=#{project}
- </if>
- <if test="courseId != null">
- and course_id=#{courseId}
- </if>
- <if test="videoId != null">
- and video_id=#{videoId}
- </if>
- and DATE(line_time) between #{sTime} and #{dTime}
- </where>
- GROUP BY project, course_id, video_id,company_user_id
- ) AS count_temp_table
- </select>
- <select id="selectQwExtCountByDayAndCount" resultType="java.lang.Long">
- SELECT COUNT(*) AS total_count
- FROM (
- SELECT 1
- FROM
- qw_external_contact qec
- JOIN
- qw_user qu ON qec.qw_user_id = qu.id
- WHERE
- DATE(qec.create_time) >= DATE(#{sTime})
- AND DATE(qec.create_time) <= DATE(#{eTime})
- AND qec.company_id = #{companyId}
- <if test='nickName != null and nickName != ""'>
- AND qu.qw_user_name LIKE CONCAT(#{nickName}, '%')
- </if>
- <if test='idsList != null and !idsList.isEmpty()'>
- AND qec.qw_user_id IN
- <foreach item="item" index="index" collection="idsList" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY
- qec.qw_user_id, DATE(qec.create_time)
- ) AS grouped_data
- </select>
- <insert id="insertQwWatchLog" parameterType="QwWatchLog" useGeneratedKeys="true" keyProperty="id">
- insert into qw_watch_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="extId != null">ext_id,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="status != null">status,</if>
- <if test="day != null">day,</if>
- <if test="project != null">project,</if>
- <if test="createTime != null">create_time,</if>
- <if test="lineTime != null">line_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="extId != null">#{extId},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="status != null">#{status},</if>
- <if test="day != null">#{day},</if>
- <if test="project != null">#{project},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="lineTime != null">#{lineTime},</if>
- </trim>
- </insert>
- <insert id="insertQwWatchLogBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO qw_watch_log (
- ext_id,
- qw_user_id,
- status,
- day,
- project,
- create_time,
- line_time
- )
- VALUES
- <foreach collection="watchLogs" item="log" separator=",">
- (
- #{log.extId},
- #{log.qwUserId},
- #{log.status},
- #{log.day},
- #{log.project},
- #{log.createTime},
- #{log.lineTime}
- )
- </foreach>
- </insert>
- <update id="updateQwWatchLog" parameterType="QwWatchLog">
- update qw_watch_log
- <trim prefix="SET" suffixOverrides=",">
- <if test="extId != null">ext_id = #{extId},</if>
- <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
- <if test="status != null">status = #{status},</if>
- <if test="day != null">day = #{day},</if>
- <if test="project != null">project = #{project},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="lineTime != null">line_time = #{lineTime},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteQwWatchLogById" parameterType="Long">
- delete from qw_watch_log where id = #{id}
- </delete>
- <delete id="deleteQwWatchLogByIds" parameterType="String">
- delete from qw_watch_log where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|