| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- <?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.im.mapper.FsImMsgSendLogMapper">
- <resultMap type="FsImMsgSendLog" id="FsImMsgSendLogResult">
- <result property="logId" column="log_id" />
- <result property="companyUserId" column="company_user_id" />
- <result property="companyId" column="company_id" />
- <result property="courseId" column="course_id" />
- <result property="courseName" column="course_name" />
- <result property="videoId" column="video_id" />
- <result property="videoName" column="video_name" />
- <result property="periodId" column="period_id" />
- <result property="sendTitle" column="send_title" />
- <result property="planSendTime" column="plan_send_time" />
- <result property="sendType" column="send_type" />
- <result property="sendMode" column="send_mode" />
- <result property="sendStatus" column="send_status" />
- <result property="isUrgeCourse" column="is_urge_course" />
- <result property="msgType" column="msg_type" />
- <result property="createTime" column="create_time" />
- <result property="createBy" column="create_by" />
- <result property="updateTime" column="update_time" />
- <result property="sendUnionId" column="send_union_id" />
- <result property="tagIds" column="tag_ids" />
- <result property="tagNames" column="tag_names" />
- <result property="projectId" column="project_id" />
- <result property="periodDaysId" column="period_days_id" />
- </resultMap>
- <sql id="selectFsImMsgSendLogVo">
- select log_id, company_user_id, company_id, course_id, course_name, video_id, video_name, period_id, send_title, plan_send_time, send_type, send_mode, send_status, is_urge_course, msg_type, create_time, create_by, update_time, send_union_id, tag_ids,
- tag_names, project_id, period_days_id from fs_im_msg_send_log
- </sql>
- <select id="selectFsImMsgSendLogList" parameterType="FsImMsgSendLog" resultMap="FsImMsgSendLogResult">
- <include refid="selectFsImMsgSendLogVo"/>
- <where>
- <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>
- <if test="courseName != null and courseName != ''"> and course_name like concat('%', #{courseName}, '%')</if>
- <if test="videoId != null "> and video_id = #{videoId}</if>
- <if test="videoName != null and videoName != ''"> and video_name like concat('%', #{videoName}, '%')</if>
- <if test="periodId != null "> and period_id = #{periodId}</if>
- <if test="sendTitle != null and sendTitle != ''"> and send_title = #{sendTitle}</if>
- <if test="planSendTime != null "> and plan_send_time = #{planSendTime}</if>
- <if test="sendType != null "> and send_type = #{sendType}</if>
- <if test="sendMode != null "> and send_mode = #{sendMode}</if>
- <if test="sendStatus != null "> and send_status = #{sendStatus}</if>
- <if test="isUrgeCourse != null "> and is_urge_course = #{isUrgeCourse}</if>
- <if test="msgType != null "> and msg_type = #{msgType}</if>
- <if test="sendUnionId != null and sendUnionId != ''"> and send_union_id = #{sendUnionId}</if>
- <if test="tagIds != null and tagIds != ''"> and tag_ids = #{tagIds}</if>
- <if test="tagNames != null and tagNames != ''"> and tag_names = #{tagNames}</if>
- <if test="projectId != null and projectId != ''"> and project_id = #{projectId}</if>
- <if test="periodDaysId != null and periodDaysId != ''"> and period_days_id = #{periodDaysId}</if>
- </where>
- </select>
- <select id="selectFsImMsgSendLogByLogId" parameterType="Long" resultMap="FsImMsgSendLogResult">
- <include refid="selectFsImMsgSendLogVo"/>
- where log_id = #{logId}
- </select>
- <insert id="insertFsImMsgSendLog" parameterType="FsImMsgSendLog" useGeneratedKeys="true" keyProperty="logId">
- insert into fs_im_msg_send_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="companyUserId != null">company_user_id,</if>
- <if test="companyId != null">company_id,</if>
- <if test="courseId != null">course_id,</if>
- <if test="courseName != null">course_name,</if>
- <if test="videoId != null">video_id,</if>
- <if test="videoName != null">video_name,</if>
- <if test="periodId != null">period_id,</if>
- <if test="sendTitle != null">send_title,</if>
- <if test="planSendTime != null">plan_send_time,</if>
- <if test="sendType != null">send_type,</if>
- <if test="sendMode != null">send_mode,</if>
- <if test="sendStatus != null">send_status,</if>
- <if test="isUrgeCourse != null">is_urge_course,</if>
- <if test="msgType != null">msg_type,</if>
- <if test="createTime != null">create_time,</if>
- <if test="createBy != null">create_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="sendUnionId != null">send_union_id,</if>
- <if test="tagIds != null">tag_ids,</if>
- <if test="tagNames != null">tag_names,</if>
- <if test="projectId != null">project_id,</if>
- <if test="periodDaysId != null">period_days_id,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="courseId != null">#{courseId},</if>
- <if test="courseName != null">#{courseName},</if>
- <if test="videoId != null">#{videoId},</if>
- <if test="videoName != null">#{videoName},</if>
- <if test="periodId != null">#{periodId},</if>
- <if test="sendTitle != null">#{sendTitle},</if>
- <if test="planSendTime != null">#{planSendTime},</if>
- <if test="sendType != null">#{sendType},</if>
- <if test="sendMode != null">#{sendMode},</if>
- <if test="sendStatus != null">#{sendStatus},</if>
- <if test="isUrgeCourse != null">#{isUrgeCourse},</if>
- <if test="msgType != null">#{msgType},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="sendUnionId != null">#{sendUnionId},</if>
- <if test="tagIds != null">#{tagIds},</if>
- <if test="tagNames != null">#{tagNames},</if>
- <if test="projectId != null">#{projectId},</if>
- <if test="periodDaysId != null">#{periodDaysId},</if>
- </trim>
- </insert>
- <update id="updateFsImMsgSendLog" parameterType="FsImMsgSendLog">
- update fs_im_msg_send_log
- <trim prefix="SET" suffixOverrides=",">
- <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="courseName != null">course_name = #{courseName},</if>
- <if test="videoId != null">video_id = #{videoId},</if>
- <if test="videoName != null">video_name = #{videoName},</if>
- <if test="periodId != null">period_id = #{periodId},</if>
- <if test="sendTitle != null">send_title = #{sendTitle},</if>
- <if test="planSendTime != null">plan_send_time = #{planSendTime},</if>
- <if test="sendType != null">send_type = #{sendType},</if>
- <if test="sendMode != null">send_mode = #{sendMode},</if>
- <if test="sendStatus != null">send_status = #{sendStatus},</if>
- <if test="isUrgeCourse != null">is_urge_course = #{isUrgeCourse},</if>
- <if test="msgType != null">msg_type = #{msgType},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="sendUnionId != null">send_union_id = #{sendUnionId},</if>
- <if test="tagIds != null">tag_ids = #{tagIds},</if>
- <if test="tagNames != null">tag_names = #{tagNames},</if>
- <if test="projectId != null">project_id = #{projectId},</if>
- <if test="periodDaysId != null">period_days_id = #{periodDaysId},</if>
- </trim>
- where log_id = #{logId}
- </update>
- <delete id="deleteFsImMsgSendLogByLogId" parameterType="Long">
- delete from fs_im_msg_send_log where log_id = #{logId}
- </delete>
- <delete id="deleteFsImMsgSendLogByLogIds" parameterType="String">
- delete from fs_im_msg_send_log where log_id in
- <foreach item="logId" collection="array" open="(" separator="," close=")">
- #{logId}
- </foreach>
- </delete>
- <select id="selectFsImSendLogList" resultType="com.fs.course.vo.newfs.FsImSendLogVO">
- SELECT
- log.log_id,
- log.company_user_id,
- log.company_id,
- log.course_id,
- log.course_name,
- log.video_id,
- log.video_name,
- log.send_title,
- log.plan_send_time,
- log.send_type,
- log.send_mode,
- log.send_status,
- log.is_urge_course,
- log.msg_type,
- log.create_time,
- log.send_union_id,
- log.tag_ids,
- log.tag_names,
- log2.send_title as urgeSendTitle,
- GROUP_CONCAT( DISTINCT detail.user_id ) AS userIds,
- GROUP_CONCAT( DISTINCT fs_user.nick_name ) AS nickNames
- FROM
- fs_im_msg_send_log log
- LEFT JOIN fs_im_msg_send_detail detail ON detail.log_id = log.log_id
- LEFT JOIN fs_user ON fs_user.user_id = detail.user_id
- LEFT JOIN fs_im_msg_send_log log2 on log2.send_union_id = log.send_union_id and log2.msg_type = 2
- WHERE
- log.msg_type = 1
- AND log.company_user_id = #{params.companyUserId}
- AND log.company_id = #{params.companyId}
- <if test="params.keyword != null and params.keyword !='' ">
- AND log.send_title like concat('%',#{params.keyword},'%')
- </if>
- GROUP BY
- log.log_id
- ORDER BY
- log.create_time DESC
- </select>
- <select id="selectSendLogListByDetailId" resultType="FsImMsgSendLog">
- SELECT DISTINCT log.*
- FROM
- fs_im_msg_send_log log
- LEFT JOIN fs_im_msg_send_detail detail ON detail.log_id = log.log_id
- WHERE
- detail.log_detail_id IN
- <foreach item="logDetailId" collection="params.logDetailIds" open="(" separator="," close=")">
- #{logDetailId}
- </foreach>
- </select>
- <select id="selectFsImMsgSendLogInfoList" resultType="com.fs.app.service.param.FsImMsgSendLogResponse">
- SELECT
- d.log_id AS logId,
- l.company_user_id AS companyUserId,
- l.company_id AS companyId,
- l.course_id AS courseId,
- l.course_name AS courseName,
- l.video_id AS videoId,
- l.video_name AS videoName,
- l.project_id AS projectId,
- l.send_title AS sendTitle,
- l.plan_send_time AS planSendTime,
- l.send_type AS sendType,
- l.send_mode AS sendMode,
- l.is_urge_course AS isUrgeCourse,
- l.msg_type AS msgType,
- l.send_status AS sendStatus,
- l.count AS count,
- l.create_time AS createTime,
- d.user_id AS userId,
- d.status AS status,
- d.exception_info AS exceptionInfo
- FROM fs_im_msg_send_detail d
- LEFT JOIN fs_im_msg_send_log l ON l.log_id = d.log_id
- <where>
- <if test="companyUserId != null"> AND l.company_user_id = #{companyUserId}</if>
- <if test="companyId != null"> AND l.company_id = #{companyId}</if>
- <if test="courseId != null"> AND l.course_id = #{courseId}</if>
- <if test="courseName != null and courseName != ''"> AND l.course_name like concat('%', #{courseName}, '%')</if>
- <if test="videoId != null"> AND l.video_id = #{videoId}</if>
- <if test="videoName != null and videoName != ''"> AND l.video_name like concat('%', #{videoName}, '%')</if>
- <if test="sendTitle != null and sendTitle != ''"> AND l.send_title like concat('%', #{sendTitle}, '%')</if>
- <if test="planSendStartTime != null and planSendEndTime != null">
- AND l.plan_send_time between #{planSendStartTime} and #{planSendEndTime}
- </if>
- <if test="sendType != null"> AND l.send_type = #{sendType}</if>
- <if test="sendMode != null"> AND l.send_mode = #{sendMode}</if>
- <if test="sendStatus != null"> AND l.send_status = #{sendStatus}</if>
- <if test="msgType != null"> AND l.msg_type = #{msgType}</if>
- <if test="projectId != null"> AND l.project_id = #{projectId}</if>
- <if test="createTimeStartTime != null and createTimeEndTime != null">
- AND d.create_time between #{createTimeStartTime} and #{createTimeEndTime}
- </if>
- <if test="status != null"> AND d.status = #{status}</if>
- </where>
- ORDER BY l.create_time DESC
- </select>
- <select id="getFsImMsgSendStatistics" resultType="com.fs.app.service.param.FsImMsgSendLogStatisticsResponse">
- SELECT
- count(d.log_detail_id) as total,
- sum(case when d.status = 0 then 1 else 0 end) as sent,
- sum(case when d.send_status = 2 then 1 else 0 end) as pending,
- sum(case when d.status = 1 then 1 else 0 end) as failed
- FROM fs_im_msg_send_detail d
- LEFT JOIN fs_im_msg_send_log l ON l.log_id = d.log_id
- <where>
- <if test="companyUserId != null"> AND l.company_user_id = #{companyUserId}</if>
- <if test="companyId != null"> AND l.company_id = #{companyId}</if>
- <if test="courseId != null"> AND l.course_id = #{courseId}</if>
- <if test="courseName != null and courseName != ''"> AND l.course_name like concat('%', #{courseName}, '%')</if>
- <if test="videoId != null"> AND l.video_id = #{videoId}</if>
- <if test="videoName != null and videoName != ''"> AND l.video_name like concat('%', #{videoName}, '%')</if>
- <if test="sendTitle != null and sendTitle != ''"> AND l.send_title like concat('%', #{sendTitle}, '%')</if>
- <if test="planSendStartTime != null and planSendEndTime != null">
- AND l.plan_send_time between #{planSendStartTime} and #{planSendEndTime}
- </if>
- <if test="sendType != null"> AND l.send_type = #{sendType}</if>
- <if test="sendMode != null"> AND l.send_mode = #{sendMode}</if>
- <if test="msgType != null"> AND l.msg_type = #{msgType}</if>
- <if test="projectId != null"> AND l.project_id = #{projectId}</if>
- <if test="createTimeStartTime != null and createTimeEndTime != null">
- AND d.create_time between #{createTimeStartTime} and #{createTimeEndTime}
- </if>
- </where>
- </select>
- </mapper>
|