123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <?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.course.mapper.FsCourseTrafficLogMapper">
- <resultMap type="FsCourseTrafficLog" id="FsCourseTrafficLogResult">
- <result property="logId" column="log_id" />
- <result property="userId" column="user_id" />
- <result property="videoId" column="video_id" />
- <result property="createTime" column="create_time" />
- <result property="qwExternalContactId" column="qw_external_contact_id" />
- <result property="internetTraffic" column="internet_traffic" />
- <result property="qwUserId" column="qw_user_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="companyId" column="company_id" />
- <result property="courseId" column="course_id" />
- <result property="uuId" column="uu_id" />
- <result property="periodId" column="period_id" />
- <result property="project" column="project" />
- </resultMap>
- <sql id="selectFsCourseTrafficLogVo">
- select log_id,
- user_id,
- video_id,
- create_time,
- qw_external_contact_id,
- internet_traffic,
- qw_user_id,
- company_user_id,
- company_id,
- course_id,
- uu_id,
- project,
- period_id from fs_course_traffic_log
- </sql>
- <select id="selectFsCourseTrafficLogList" parameterType="FsCourseTrafficLog" resultMap="FsCourseTrafficLogResult">
- <include refid="selectFsCourseTrafficLogVo"/>
- <where>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="videoId != null "> and video_id = #{videoId}</if>
- <if test="qwExternalContactId != null "> and qw_external_contact_id = #{qwExternalContactId}</if>
- <if test="internetTraffic != null "> and internet_traffic = #{internetTraffic}</if>
- <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="courseId != null "> and course_id = #{courseId}</if>
- </where>
- </select>
- <select id="selectFsCourseTrafficLogByLogId" parameterType="Long" resultMap="FsCourseTrafficLogResult">
- <include refid="selectFsCourseTrafficLogVo"/>
- where log_id = #{logId}
- </select>
- <select id="getTodayTrafficLogCompanyId" resultType="java.lang.Long">
- SELECT
- COALESCE(SUM(internet_traffic), 0) AS today_traffic_bytes
- FROM
- fs_course_traffic_log
- <where>
- DATE(create_time) = CURDATE()
- <if test="companyId != null">
- AND company_id = ${companyId}
- </if>
- </where>
- </select>
- <select id="getYesterdayTrafficLogCompanyId" resultType="java.lang.Long">
- SELECT
- COALESCE(SUM(internet_traffic), 0) AS yesterday_traffic_bytes
- FROM
- fs_course_traffic_log
- <where>
- DATE(create_time) = CURDATE() - INTERVAL 1 DAY
- <if test="companyId != null">
- AND company_id = ${companyId}
- </if>
- </where>
- </select>
- <select id="getMonthTrafficLogCompanyId" resultType="java.lang.Long">
- SELECT
- COALESCE(SUM(internet_traffic), 0) AS month_traffic_bytes
- FROM
- fs_course_traffic_log
- <where>
- YEAR(create_time) = YEAR(CURDATE())
- AND MONTH(create_time) = MONTH(CURDATE())
- <if test="companyId != null">
- AND company_id = ${companyId}
- </if>
- </where>
- </select>
- <select id="getTodayTrafficLog" resultType="java.lang.Long">
- SELECT
- COALESCE(SUM(internet_traffic), 0) AS today_traffic_bytes
- FROM
- fs_course_traffic_log
- WHERE
- DATE(create_time) = CURDATE()
- </select>
- <select id="getYesterdayTrafficLog" resultType="java.lang.Long">
- SELECT
- COALESCE(SUM(internet_traffic), 0) AS yesterday_traffic_bytes
- FROM
- fs_course_traffic_log
- WHERE
- DATE(create_time) = CURDATE() - INTERVAL 1 DAY
- </select>
- <select id="getMonthTrafficLog" resultType="java.lang.Long">
- SELECT
- COALESCE(SUM(internet_traffic), 0) AS month_traffic_bytes
- FROM
- fs_course_traffic_log
- WHERE
- YEAR(create_time) = YEAR(CURDATE())
- AND MONTH(create_time) = MONTH(CURDATE())
- </select>
- <insert id="insertFsCourseTrafficLog" parameterType="FsCourseTrafficLog" useGeneratedKeys="true" keyProperty="logId">
- insert into fs_course_traffic_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="userId != null">user_id,</if>
- <if test="videoId != null">video_id,</if>
- <if test="createTime != null">create_time,</if>
- <if test="qwExternalContactId != null">qw_external_contact_id,</if>
- <if test="internetTraffic != null">internet_traffic,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="companyId != null">company_id,</if>
- <if test="courseId != null">course_id,</if>
- <if test="uuId != null">uu_id,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="userId != null">#{userId},</if>
- <if test="videoId != null">#{videoId},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
- <if test="internetTraffic != null">#{internetTraffic},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="courseId != null">#{courseId},</if>
- <if test="uuId != null">#{uuId},</if>
- </trim>
- </insert>
- <insert id="insertOrUpdateTrafficLog" parameterType="FsCourseTrafficLog" useGeneratedKeys="true" keyProperty="logId">
- insert into fs_course_traffic_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="userId != null">user_id,</if>
- <if test="videoId != null">video_id,</if>
- <if test="createTime != null">create_time,</if>
- <if test="qwExternalContactId != null">qw_external_contact_id,</if>
- <if test="internetTraffic != null">internet_traffic,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="companyId != null">company_id,</if>
- <if test="courseId != null">course_id,</if>
- <if test="uuId != null">uu_id,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="userId != null">#{userId},</if>
- <if test="videoId != null">#{videoId},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
- <if test="internetTraffic != null">#{internetTraffic},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="courseId != null">#{courseId},</if>
- <if test="uuId != null">#{uuId},</if>
- </trim>
- on duplicate key update
- <trim suffixOverrides=",">
- <if test="internetTraffic != null">internet_traffic = #{internetTraffic},</if>
- </trim>
- </insert>
- <update id="updateFsCourseTrafficLog" parameterType="FsCourseTrafficLog">
- update fs_course_traffic_log
- <trim prefix="SET" suffixOverrides=",">
- <if test="userId != null">user_id = #{userId},</if>
- <if test="videoId != null">video_id = #{videoId},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="qwExternalContactId != null">qw_external_contact_id = #{qwExternalContactId},</if>
- <if test="internetTraffic != null">internet_traffic = #{internetTraffic},</if>
- <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="courseId != null">course_id = #{courseId},</if>
- <if test="uuId != null">uu_id = #{uuId},</if>
- </trim>
- where log_id = #{logId}
- </update>
- <delete id="deleteFsCourseTrafficLogByLogId" parameterType="Long">
- delete from fs_course_traffic_log where log_id = #{logId}
- </delete>
- <delete id="deleteFsCourseTrafficLogByLogIds" parameterType="String">
- delete from fs_course_traffic_log where log_id in
- <foreach item="logId" collection="array" open="(" separator="," close=")">
- #{logId}
- </foreach>
- </delete>
- <select id="selectCourseTrafficLogByTwoDaysLater" resultMap="FsCourseTrafficLogResult">
- <![CDATA[
- SELECT
- l.log_id,
- l.user_id,
- l.video_id,
- l.create_time,
- l.qw_external_contact_id,
- l.internet_traffic,
- l.qw_user_id,
- l.company_user_id,
- l.company_id,
- l.course_id,
- l.uu_id,
- l.project, l.period_id
- FROM
- fs_course_traffic_log l
- WHERE
- l.create_time < DATE_SUB( NOW( ), INTERVAL 2 DAY )
- ORDER BY l.log_id limit #{offset},#{limit} ]]>
- </select>
- <insert id="insertCourseTrafficLogByTwoDaysLaterBatch" useGeneratedKeys="false">
- insert into fs_course_traffic_log (
- log_id, user_id, video_id, create_time, qw_external_contact_id, internet_traffic, qw_user_id, company_user_id, company_id, course_id, uu_id, project, period_id ) values
- <foreach collection="list" item="item" separator=",">
- (#{item.logId},#{item.userId},#{item.videoId},#{item.createTime},#{item.qwExternalContactId},#{item.internetTraffic},#{item.qwUserId}
- ,#{item.companyUserId},#{item.companyId},#{item.courseId},#{item.uuId},#{item.project},#{item.periodId})
- </foreach>
- </insert>
- <select id="selectTrafficNew" resultType="com.fs.course.vo.FsCourseTrafficLogListVO">
- select company_id,project,course_id,SUM(internet_traffic) AS total_internet_traffic
- ,DATE_FORMAT(create_time, '%Y-%m-%d') AS `month` from fs_course_traffic_log
- <where>
- <if test="startDate != null and endDate != null">
- and DATE_FORMAT(create_time, '%Y-%m-%d') between #{startDate} AND #{endDate}
- </if>
- <if test='companyId !=null'>
- and company_id = #{companyId}
- </if>
- <if test="courseId != null">
- and course_id = ${courseId}
- </if>
- <if test="project != null">
- and project = ${project}
- </if>
- </where>
- <if test="tabType==null or tabType==''">
- group by company_id,`month`,course_id,project
- </if>
- <if test="tabType!=null and tabType=='project'">
- group by project,`month`
- </if>
- <if test="tabType!=null and tabType=='course'">
- group by course_id,`month`
- </if>
- <if test="tabType!=null and tabType=='company'">
- group by company_id,`month`
- </if>
- </select>
- </mapper>
|