FsCourseWatchLogMapper.xml 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.course.mapper.FsCourseWatchLogMapper">
  6. <resultMap type="FsCourseWatchLog" id="FsCourseWatchLogResult">
  7. <result property="logId" column="log_id" />
  8. <result property="userId" column="user_id" />
  9. <result property="videoId" column="video_id" />
  10. <result property="logType" column="log_type" />
  11. <result property="createTime" column="create_time" />
  12. <result property="updateTime" column="update_time" />
  13. <result property="qwExternalContactId" column="qw_external_contact_id" />
  14. <result property="duration" column="duration" />
  15. <result property="qwUserId" column="qw_user_id" />
  16. <result property="companyUserId" column="company_user_id" />
  17. <result property="companyId" column="company_id" />
  18. <result property="courseId" column="course_id" />
  19. <result property="sendType" column="send_type" />
  20. <result property="rewardType" column="reward_type" />
  21. <result property="sopId" column="sop_id" />
  22. <result property="finishTime" column="finish_time" />
  23. <result property="sendFinishMsg" column="send_finish_msg" />
  24. <result property="campPeriodTime" column="camp_period_time" />
  25. <result property="lastHeartbeatTime" column="last_heartbeat_time" />
  26. <result property="project" column="project" />
  27. </resultMap>
  28. <sql id="selectFsCourseWatchLogVo">
  29. select log_id, user_id,finish_time,send_finish_msg,sop_id,video_id,reward_type, log_type, create_time, update_time, qw_external_contact_id, duration, qw_user_id, company_user_id, company_id, course_id,camp_period_time,project from fs_course_watch_log
  30. </sql>
  31. <select id="selectFsCourseWatchLogList" parameterType="FsCourseWatchLog" resultMap="FsCourseWatchLogResult">
  32. <include refid="selectFsCourseWatchLogVo"/>
  33. <where>
  34. <if test="userId != null "> and user_id = #{userId}</if>
  35. <if test="videoId != null "> and video_id = #{videoId}</if>
  36. <if test="logType != null "> and log_type = #{logType}</if>
  37. <if test="qwExternalContactId != null "> and qw_external_contact_id = #{qwExternalContactId}</if>
  38. <if test="duration != null "> and duration = #{duration}</if>
  39. <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
  40. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  41. <if test="companyId != null "> and company_id = #{companyId}</if>
  42. <if test="courseId != null "> and course_id = #{courseId}</if>
  43. <if test="sendType != null "> and send_type = #{sendType}</if>
  44. <if test="campPeriodTime != null "> and camp_period_time = #{campPeriodTime}</if>
  45. <if test="project != null "> and project = #{project}</if>
  46. </where>
  47. </select>
  48. <select id="selectFsCourseWatchLogByLogId" parameterType="Long" resultMap="FsCourseWatchLogResult">
  49. <include refid="selectFsCourseWatchLogVo"/>
  50. where log_id = #{logId}
  51. </select>
  52. <select id="selectFsCourseWatchLogListVO" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
  53. select l.log_id,l.user_id,uc.course_name,v.title as video_name,qec.avatar as external_user_avatar,
  54. l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,
  55. cu.nick_name as company_user_name ,l.send_type,l.create_time,l.update_time,l.last_heartbeat_time,
  56. qu.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,
  57. u.is_vip isVip
  58. from fs_course_watch_log l
  59. left join fs_user_course_video v on v.video_id = l.video_id
  60. left join fs_user_course uc on uc.course_id = l.course_id
  61. left join fs_user u on u.user_id = l.user_id
  62. left join company_user cu on cu.user_id = l.company_user_id
  63. left join company c on c.company_id = l.company_id
  64. LEFT JOIN qw_user qu on qu.id= l.qw_user_id
  65. LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
  66. <where>
  67. <if test ='maps.isVip !=null'>
  68. and l.user_id != 0 and u.is_vip = #{maps.isVip}
  69. </if>
  70. <if test ='maps.sendType !=null'>
  71. and l.send_type = #{maps.sendType}
  72. </if>
  73. <if test ='maps.userId !=null'>
  74. and l.user_id = #{maps.userId}
  75. </if>
  76. <if test ='maps.qwExternalContactId !=null'>
  77. and l.qw_external_contact_id = #{maps.qwExternalContactId}
  78. </if>
  79. <if test ='maps.qwUserId !=null'>
  80. and l.qw_user_id = #{maps.qwUserId}
  81. </if>
  82. <if test ='maps.courseId !=null'>
  83. and l.course_id = #{maps.courseId}
  84. </if>
  85. <if test ='maps.videoId !=null'>
  86. and l.video_id = #{maps.videoId}
  87. </if>
  88. <if test ='maps.logType !=null'>
  89. and l.log_type = #{maps.logType}
  90. </if>
  91. <if test ='maps.companyId !=null'>
  92. and l.company_id = #{maps.companyId}
  93. </if>
  94. <if test ='maps.companyUserId !=null'>
  95. and l.company_user_id = #{maps.companyUserId}
  96. </if>
  97. <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
  98. and cu.nick_name like concat('%', #{maps.companyUserName}, '%')
  99. </if>
  100. <if test ='maps.nickName !=null and maps.nickName!=""'>
  101. and u.nick_name like concat('%', #{maps.nickName}, '%')
  102. </if>
  103. <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
  104. and qec.name like concat('%', #{maps.externalUserName}, '%')
  105. </if>
  106. <if test= 'maps.qecSTime != null '>
  107. and DATE(qec.create_time) &gt;= DATE(#{maps.qecSTime})
  108. </if>
  109. <if test='maps.qecETime != null '>
  110. and DATE(qec.create_time) &lt;= DATE(#{maps.qecETime})
  111. </if>
  112. <if test= 'maps.sTime != null '>
  113. and DATE(l.create_time) &gt;= DATE(#{maps.sTime})
  114. </if>
  115. <if test='maps.eTime != null '>
  116. and DATE(l.create_time) &lt;= DATE(#{maps.eTime})
  117. </if>
  118. <if test= 'maps.scheduleStartTime != null '>
  119. and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
  120. </if>
  121. <if test='maps.scheduleEndTime != null '>
  122. and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
  123. </if>
  124. <if test= 'maps.upSTime != null '>
  125. and DATE(l.update_time) &gt;= DATE(#{maps.upSTime})
  126. </if>
  127. <if test='maps.upETime != null '>
  128. and DATE(l.update_time) &lt;= DATE(#{maps.upETime})
  129. </if>
  130. <if test="maps.sopIds != null and maps.sopIds.size() > 0">
  131. and l.sop_id in
  132. <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
  133. #{sopId}
  134. </foreach>
  135. </if>
  136. </where>
  137. order by l.finish_time desc,l.update_time desc,l.create_time desc
  138. </select>
  139. <select id="selectFsCourseWatchLogListByParam" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
  140. select l.log_id,l.user_id,uc.course_name,v.title as video_name,u.nick_name as fsNickName, u.avatar as fsAvatar,
  141. l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,
  142. cu.nick_name as company_user_name ,l.send_type,l.create_time, qu.qw_user_name,qec.name as external_user_name
  143. from fs_course_watch_log l
  144. left join fs_user_course_video v on v.video_id = l.video_id
  145. left join fs_user_course uc on uc.course_id = l.course_id
  146. left join fs_user u on u.user_id = l.user_id
  147. left join company_user cu on cu.user_id = l.company_user_id
  148. left join company c on c.company_id = l.company_id
  149. LEFT JOIN qw_user qu on qu.id= l.qw_user_id
  150. LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
  151. <where>
  152. <if test ='userId !=null'>
  153. and l.user_id = #{userId}
  154. </if>
  155. <if test ='qwUserId !=null'>
  156. and l.qw_user_id = #{qwUserId}
  157. </if>
  158. <if test ='courseId !=null'>
  159. and l.course_id = #{courseId}
  160. </if>
  161. <if test ='videoId !=null'>
  162. and l.video_id = #{videoId}
  163. </if>
  164. <if test ='logType !=null'>
  165. and l.log_type = #{logType}
  166. </if>
  167. <if test ='companyId !=null'>
  168. and l.company_id = #{companyId}
  169. </if>
  170. <if test ='companyUserId !=null'>
  171. and l.company_user_id = #{companyUserId}
  172. </if>
  173. <if test ='companyUserName !=null and maps.companyUserName!=""'>
  174. and cu.nick_name like concat('%', #{companyUserName}, '%')
  175. </if>
  176. <if test ='nickName !=null and maps.nickName!=""'>
  177. and u.nick_name like concat('%', #{nickName}, '%')
  178. </if>
  179. <if test= 'sTime != null '>
  180. and DATE(l.create_time) &gt;= DATE(#{sTime})
  181. </if>
  182. <if test='eTime != null '>
  183. and DATE(l.create_time) &lt;= DATE(#{eTime})
  184. </if>
  185. <if test= 'maps.scheduleStartTime != null '>
  186. and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
  187. </if>
  188. <if test='maps.scheduleEndTime != null '>
  189. and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
  190. </if>
  191. <if test="sopIds != null and sopIds.size() > 0">
  192. and l.sop_id in
  193. <foreach item="sopId" index="index" collection="sopIds" open="(" separator="," close=")">
  194. #{sopId}
  195. </foreach>
  196. </if>
  197. </where>
  198. order by l.log_id desc
  199. </select>
  200. <insert id="insertFsCourseWatchLog" parameterType="FsCourseWatchLog" useGeneratedKeys="true" keyProperty="logId">
  201. insert into fs_course_watch_log
  202. <trim prefix="(" suffix=")" suffixOverrides=",">
  203. <if test="userId != null">user_id,</if>
  204. <if test="videoId != null">video_id,</if>
  205. <if test="logType != null">log_type,</if>
  206. <if test="createTime != null">create_time,</if>
  207. <if test="updateTime != null">update_time,</if>
  208. <if test="qwExternalContactId != null">qw_external_contact_id,</if>
  209. <if test="duration != null">duration,</if>
  210. <if test="qwUserId != null">qw_user_id,</if>
  211. <if test="companyUserId != null">company_user_id,</if>
  212. <if test="companyId != null">company_id,</if>
  213. <if test="courseId != null">course_id,</if>
  214. <if test="sendType != null">send_type,</if>
  215. <if test="rewardType != null">reward_type,</if>
  216. <if test="sopId != null">sop_id,</if>
  217. <if test="finishTime != null">finish_time,</if>
  218. <if test="sendFinishMsg != null">send_finish_msg,</if>
  219. <if test="campPeriodTime != null">camp_period_time,</if>
  220. <if test="periodId != null">period_id,</if>
  221. <if test="project != null">project,</if>
  222. </trim>
  223. <trim prefix="values (" suffix=")" suffixOverrides=",">
  224. <if test="userId != null">#{userId},</if>
  225. <if test="videoId != null">#{videoId},</if>
  226. <if test="logType != null">#{logType},</if>
  227. <if test="createTime != null">#{createTime},</if>
  228. <if test="updateTime != null">#{updateTime},</if>
  229. <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
  230. <if test="duration != null">#{duration},</if>
  231. <if test="qwUserId != null">#{qwUserId},</if>
  232. <if test="companyUserId != null">#{companyUserId},</if>
  233. <if test="companyId != null">#{companyId},</if>
  234. <if test="courseId != null">#{courseId},</if>
  235. <if test="sendType != null">#{sendType},</if>
  236. <if test="rewardType != null">#{rewardType},</if>
  237. <if test="sopId != null">#{sopId},</if>
  238. <if test="finishTime != null">#{finishTime},</if>
  239. <if test="sendFinishMsg != null">#{sendFinishMsg},</if>
  240. <if test="campPeriodTime != null">#{campPeriodTime},</if>
  241. <if test="periodId != null">#{periodId},</if>
  242. <if test="project != null">#{project},</if>
  243. </trim>
  244. </insert>
  245. <insert id="insertOrUpdateFsCourseWatchLog" parameterType="FsCourseWatchLog">
  246. insert into fs_course_watch_log
  247. <trim prefix="(" suffix=")" suffixOverrides=",">
  248. <if test="userId != null">user_id,</if>
  249. <if test="videoId != null">video_id,</if>
  250. <if test="logType != null">log_type,</if>
  251. <if test="createTime != null">create_time,</if>
  252. <if test="updateTime != null">update_time,</if>
  253. <if test="qwExternalContactId != null">qw_external_contact_id,</if>
  254. <if test="duration != null">duration,</if>
  255. <if test="qwUserId != null">qw_user_id,</if>
  256. <if test="companyUserId != null">company_user_id,</if>
  257. <if test="companyId != null">company_id,</if>
  258. <if test="courseId != null">course_id,</if>
  259. <if test="sendType != null">send_type,</if>
  260. <if test="rewardType != null">reward_type,</if>
  261. <if test="sopId != null">sop_id,</if>
  262. <if test="finishTime != null">finish_time,</if>
  263. <if test="sendFinishMsg != null">send_finish_msg,</if>
  264. <if test="campPeriodTime != null">camp_period_time,</if>
  265. <if test="project != null">project,</if>
  266. </trim>
  267. <trim prefix="values (" suffix=")" suffixOverrides=",">
  268. <if test="userId != null">#{userId},</if>
  269. <if test="videoId != null">#{videoId},</if>
  270. <if test="logType != null">#{logType},</if>
  271. <if test="createTime != null">#{createTime},</if>
  272. <if test="updateTime != null">#{updateTime},</if>
  273. <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
  274. <if test="duration != null">#{duration},</if>
  275. <if test="qwUserId != null">#{qwUserId},</if>
  276. <if test="companyUserId != null">#{companyUserId},</if>
  277. <if test="companyId != null">#{companyId},</if>
  278. <if test="courseId != null">#{courseId},</if>
  279. <if test="sendType != null">#{sendType},</if>
  280. <if test="rewardType != null">#{rewardType},</if>
  281. <if test="sopId != null">#{sopId},</if>
  282. <if test="finishTime != null">#{finishTime},</if>
  283. <if test="sendFinishMsg != null">#{sendFinishMsg},</if>
  284. <if test="campPeriodTime != null">#{campPeriodTime},</if>
  285. <if test="project != null">#{project},</if>
  286. </trim>
  287. on duplicate key update
  288. <trim suffixOverrides=",">
  289. <if test="updateTime != null">update_time = #{updateTime},</if>
  290. </trim>
  291. </insert>
  292. <insert id="insertFsCourseWatchLogBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="logId">
  293. INSERT INTO fs_course_watch_log (
  294. user_id,
  295. video_id,
  296. log_type,
  297. create_time,
  298. update_time,
  299. qw_external_contact_id,
  300. duration,
  301. qw_user_id,
  302. company_user_id,
  303. company_id,
  304. course_id,
  305. send_type,
  306. reward_type,
  307. sop_id,
  308. camp_period_time,
  309. project
  310. )
  311. VALUES
  312. <foreach collection="watchLogs" item="log" separator=",">
  313. (
  314. #{log.userId},
  315. #{log.videoId},
  316. #{log.logType},
  317. #{log.createTime},
  318. #{log.updateTime},
  319. #{log.qwExternalContactId},
  320. #{log.duration},
  321. #{log.qwUserId},
  322. #{log.companyUserId},
  323. #{log.companyId},
  324. #{log.courseId},
  325. #{log.sendType},
  326. #{log.rewardType},
  327. #{log.sopId},
  328. #{log.campPeriodTime},
  329. #{log.project}
  330. )
  331. </foreach>
  332. ON DUPLICATE KEY UPDATE
  333. update_time = VALUES(update_time)
  334. </insert>
  335. <update id="updateFsCourseWatchLog" parameterType="FsCourseWatchLog">
  336. update fs_course_watch_log
  337. <trim prefix="SET" suffixOverrides=",">
  338. <if test="userId != null">user_id = #{userId},</if>
  339. <if test="videoId != null">video_id = #{videoId},</if>
  340. <if test="logType != null">log_type = #{logType},</if>
  341. <if test="createTime != null">create_time = #{createTime},</if>
  342. <if test="updateTime != null">update_time = #{updateTime},</if>
  343. <if test="qwExternalContactId != null">qw_external_contact_id = #{qwExternalContactId},</if>
  344. <if test="duration != null">duration = #{duration},</if>
  345. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  346. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  347. <if test="companyId != null">company_id = #{companyId},</if>
  348. <if test="courseId != null">course_id = #{courseId},</if>
  349. <if test="sendType != null">send_type = #{sendType},</if>
  350. <if test="rewardType != null">reward_type = #{rewardType},</if>
  351. <if test="sopId != null">sop_id = #{sopId},</if>
  352. <if test="finishTime != null">finish_time = #{finishTime},</if>
  353. <if test="sendFinishMsg != null">send_finish_msg = #{sendFinishMsg},</if>
  354. <if test="lastHeartbeatTime != null">last_heartbeat_time = #{lastHeartbeatTime},</if>
  355. <if test="periodId != null">period_id = #{periodId},</if>
  356. <if test="project != null">project = #{project},</if>
  357. </trim>
  358. where log_id = #{logId}
  359. </update>
  360. <delete id="deleteFsCourseWatchLogByLogId" parameterType="Long">
  361. delete from fs_course_watch_log where log_id = #{logId}
  362. </delete>
  363. <delete id="deleteFsCourseWatchLogByLogIds" parameterType="String">
  364. delete from fs_course_watch_log where log_id in
  365. <foreach item="logId" collection="array" open="(" separator="," close=")">
  366. #{logId}
  367. </foreach>
  368. </delete>
  369. <select id="selectFsCourseWatchLogByFinishTime" resultType="com.fs.course.param.FsCourseWatchLogByFinishTimeParam">
  370. <![CDATA[
  371. SELECT
  372. fcwl.log_id,
  373. fcwl.create_time,
  374. fcwl.qw_external_contact_id,
  375. fcwl.qw_user_id,
  376. fcwl.user_id,
  377. fcwl.company_user_id,
  378. fcwl.company_id,
  379. fcwl.sop_id,
  380. fcwl.finish_time,
  381. fcwl.camp_period_time,
  382. qec.corp_id,
  383. qec.external_user_id,
  384. qec.tag_ids,
  385. qec.user_id AS qw_user,
  386. qec.name AS external_contact_name
  387. FROM
  388. fs_course_watch_log fcwl
  389. LEFT JOIN qw_external_contact qec ON fcwl.qw_external_contact_id = qec.id
  390. WHERE
  391. DATE(fcwl.finish_time)= '2025-02-09'
  392. and fcwl.camp_period_time is not NULL
  393. ]]>
  394. </select>
  395. <select id="getWatchLogByFsUser" resultType="com.fs.course.domain.FsCourseWatchLog">
  396. SELECT
  397. log_id,
  398. user_id,
  399. video_id,
  400. log_type,
  401. create_time,
  402. update_time,
  403. duration,
  404. company_user_id,
  405. company_id,
  406. course_id,
  407. send_type,
  408. reward_type,
  409. last_heartbeat_time,
  410. sop_id,
  411. finish_time,
  412. send_finish_msg,
  413. camp_period_time
  414. FROM
  415. fs_course_watch_log
  416. WHERE
  417. send_type = 1
  418. AND video_id = #{videoId}
  419. AND user_id = #{fsUserId}
  420. AND company_user_id = #{companyUserId} order by log_id desc limit 1
  421. </select>
  422. <select id="selectFsCourseWatchLogStatisticsListVONew"
  423. resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListVO">
  424. SELECT
  425. o.company_user_id,o.user_id,DATE(o.create_time) create_time,
  426. SUM(CASE WHEN o.log_type = '1' THEN 1 ELSE 0 END) AS type1,
  427. SUM(CASE WHEN o.log_type = '2' THEN 1 ELSE 0 END) AS type2,
  428. SUM(CASE WHEN o.log_type = '3' THEN 1 ELSE 0 END) AS type3,
  429. SUM(CASE WHEN o.log_type = '4' THEN 1 ELSE 0 END) AS type4,
  430. o.project as project,
  431. o.course_id as course_id,
  432. o.video_id as video_id
  433. FROM fs_course_watch_log o
  434. <where>
  435. send_type=1
  436. <if test="companyId != null">
  437. and o.company_id=#{companyId}
  438. </if>
  439. <if test= 'sTime != null '>
  440. and o.create_time &gt;= #{sTime}
  441. </if>
  442. <if test='eTime != null '>
  443. and o.create_time &lt;= #{eTime}
  444. </if>
  445. <if test ='courseId !=null'>
  446. and o.course_id = #{courseId}
  447. </if>
  448. <if test ='videoId !=null'>
  449. and o.video_id = #{videoId}
  450. </if>
  451. <if test="companyUserId != null">
  452. and o.company_user_id = #{companyUserId}
  453. </if>
  454. <if test="project != null">
  455. and o.project = #{project}
  456. </if>
  457. <if test="userId != null">
  458. and o.user_id = #{userId}
  459. </if>
  460. </where>
  461. GROUP BY o.video_id,o.user_id,DATE(o.create_time),o.project,o.course_id
  462. ORDER BY o.video_id ,DATE(o.create_time)
  463. limit ${(pageNum-1)*pageSize},${pageSize}
  464. </select>
  465. <select id="selectFsCourseWatchLogStatisticsListVONewCount" resultType="java.lang.Long">
  466. SELECT COUNT(*)
  467. FROM (
  468. SELECT 1
  469. FROM fs_course_watch_log o
  470. <where>
  471. send_type=2
  472. <if test="companyId != null">
  473. and o.company_id=#{companyId}
  474. </if>
  475. <if test= 'sTime != null '>
  476. and o.create_time &gt;= #{startDate}
  477. </if>
  478. <if test='eTime != null '>
  479. and o.create_time &lt;= #{endDate}
  480. </if>
  481. <if test ='courseId !=null'>
  482. and o.course_id = #{courseId}
  483. </if>
  484. <if test ='videoId !=null'>
  485. and o.video_id = #{videoId}
  486. </if>
  487. <if test="companyUserId != null">
  488. and o.company_user_id = #{companyUserId}
  489. </if>
  490. <if test="project != null">
  491. and o.project = #{project}
  492. </if>
  493. <if test="userId != null">
  494. and o.user_id = #{userId}
  495. </if>
  496. </where>
  497. GROUP BY o.video_id, o.user_id, DATE(o.create_time), o.project, o.course_id
  498. ) AS grouped_results_count
  499. </select>
  500. <!-- 根据条件查询条数 -->
  501. <select id="countByMap" resultType="java.lang.Integer">
  502. select count(fcwl.log_id) from fs_course_watch_log fcwl
  503. <where>
  504. <if test="params.logTypes != null and params.logTypes.size() > 0">
  505. and fcwl.log_type in
  506. <foreach collection="params.logTypes" open="(" close=")" separator="," item="logType">
  507. #{logType}
  508. </foreach>
  509. </if>
  510. <if test="params.companyUserId != null">
  511. and fcwl.company_user_id = #{params.companyUserId}
  512. </if>
  513. <if test="params.date != null">
  514. and date(fcwl.create_time) = #{params.date}
  515. </if>
  516. </where>
  517. </select>
  518. <update id="batchUpdateWatchLog" parameterType="java.util.List">
  519. UPDATE fs_course_watch_log
  520. SET
  521. duration = CASE
  522. <foreach collection="list" item="item" index="index">
  523. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  524. CASE
  525. <!-- 仅当传入的duration > 当前值时才更新 -->
  526. WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
  527. ELSE duration <!-- 如果 duration 为 null,保持原值 -->
  528. END
  529. </foreach>
  530. END,
  531. last_heartbeat_time = CASE
  532. <foreach collection="list" item="item" index="index">
  533. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  534. CASE
  535. WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
  536. ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
  537. END
  538. </foreach>
  539. END,
  540. finish_time = CASE
  541. <foreach collection="list" item="item" index="index">
  542. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  543. CASE
  544. WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
  545. ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
  546. END
  547. </foreach>
  548. END,
  549. log_type = CASE
  550. <foreach collection="list" item="item" index="index">
  551. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  552. CASE
  553. WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
  554. WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
  555. ELSE log_type <!-- 其他情况保持原值 -->
  556. END
  557. </foreach>
  558. END
  559. WHERE
  560. (video_id, qw_external_contact_id, qw_user_id) IN
  561. <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
  562. (#{item.videoId}, #{item.qwExternalContactId}, #{item.qwUserId})
  563. </foreach>
  564. </update>
  565. <update id="batchUpdateWatchLogSendMsg" parameterType="java.util.List">
  566. UPDATE fs_course_watch_log
  567. SET send_finish_msg = CASE
  568. <foreach collection="list" item="item">
  569. WHEN log_id = #{item.logId} THEN #{item.sendFinishMsg}
  570. </foreach>
  571. ELSE send_finish_msg
  572. END
  573. WHERE log_id IN
  574. <foreach collection="list" item="item" open="(" separator="," close=")">
  575. #{item.logId}
  576. </foreach>
  577. </update>
  578. <update id="batchUpdateFsUserWatchLog" parameterType="java.util.List">
  579. UPDATE fs_course_watch_log
  580. SET
  581. duration = CASE
  582. <foreach collection="list" item="item" index="index">
  583. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
  584. CASE
  585. <!-- 仅当传入的duration > 当前值时才更新 -->
  586. WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
  587. ELSE duration <!-- 如果 duration 为 null,保持原值 -->
  588. END
  589. </foreach>
  590. END,
  591. last_heartbeat_time = CASE
  592. <foreach collection="list" item="item" index="index">
  593. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
  594. CASE
  595. WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
  596. ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
  597. END
  598. </foreach>
  599. END,
  600. finish_time = CASE
  601. <foreach collection="list" item="item" index="index">
  602. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
  603. CASE
  604. WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
  605. ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
  606. END
  607. </foreach>
  608. END,
  609. log_type = CASE
  610. <foreach collection="list" item="item" index="index">
  611. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
  612. CASE
  613. WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
  614. WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
  615. ELSE log_type <!-- 其他情况保持原值 -->
  616. END
  617. </foreach>
  618. END
  619. WHERE
  620. (video_id, user_id, company_user_id) IN
  621. <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
  622. (#{item.videoId}, #{item.userId}, #{item.companyUserId})
  623. </foreach>
  624. </update>
  625. <update id="batchUpdateWatchLogIsOpen">
  626. UPDATE fs_course_watch_log
  627. SET
  628. duration = CASE
  629. <foreach collection="list" item="item" index="index">
  630. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
  631. CASE
  632. <!-- 仅当传入的duration > 当前值时才更新 -->
  633. WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
  634. ELSE duration <!-- 如果 duration 为 null,保持原值 -->
  635. END
  636. </foreach>
  637. END,
  638. last_heartbeat_time = CASE
  639. <foreach collection="list" item="item" index="index">
  640. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
  641. CASE
  642. WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
  643. ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
  644. END
  645. </foreach>
  646. END,
  647. finish_time = CASE
  648. <foreach collection="list" item="item" index="index">
  649. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
  650. CASE
  651. WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
  652. ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
  653. END
  654. </foreach>
  655. END,
  656. log_type = CASE
  657. <foreach collection="list" item="item" index="index">
  658. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
  659. CASE
  660. WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
  661. WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
  662. ELSE log_type <!-- 其他情况保持原值 -->
  663. END
  664. </foreach>
  665. END
  666. WHERE
  667. (video_id, user_id) IN
  668. <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
  669. (#{item.videoId}, #{item.userId})
  670. </foreach>
  671. </update>
  672. <select id="selectListBytrainingCampId" resultType="com.fs.course.vo.FsCourseWatchLogVO">
  673. select
  674. uc.course_name,v.title as video_name,
  675. watch.log_id,
  676. watch.user_id,
  677. watch.finish_time,
  678. watch.send_finish_msg,
  679. watch.sop_id,
  680. watch.video_id,
  681. watch.reward_type,
  682. watch.log_type,
  683. watch.create_time,
  684. watch.update_time,
  685. watch.qw_external_contact_id,
  686. watch.duration,
  687. watch.qw_user_id,
  688. watch.company_user_id,
  689. watch.company_id,
  690. watch.course_id,
  691. watch.camp_period_time
  692. from
  693. fs_user_course_training_camp camp
  694. left join fs_user_course_period period on
  695. camp.training_camp_id = period.training_camp_id
  696. left join fs_course_watch_log watch on
  697. period.period_id = watch.period_id
  698. left join fs_user_course uc on uc.course_id = watch.course_id
  699. left join fs_user_course_video v on v.video_id = watch.video_id
  700. <where>
  701. `period`.del_flag = '0' and watch.log_type &lt;&gt; 3
  702. <if test="trainingCampId != null">and camp.training_camp_id = #{trainingCampId}</if>
  703. <if test="userId != null">and watch.user_id = #{userId}</if>
  704. <if test="periodId != null">and `period`.period_id = #{periodId}</if>
  705. </where>
  706. </select>
  707. <select id="selectFsCourseWatchLogListVOexport" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
  708. SELECT
  709. l.log_id,
  710. l.project AS project,
  711. l.user_id,
  712. l.log_type,
  713. SEC_TO_TIME(l.duration) AS duration,
  714. l.camp_period_time,
  715. l.finish_time,
  716. l.send_type,
  717. l.create_time,
  718. l.update_time,
  719. l.last_heartbeat_time,
  720. l.company_id,
  721. l.company_user_id,
  722. l.course_id,
  723. l.video_id,
  724. l.qw_user_id,
  725. l.qw_external_contact_id,
  726. qec.create_time as qec_create_time
  727. FROM
  728. fs_course_watch_log l LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
  729. left join fs_user u on u.user_id = l.user_id
  730. left join company_user cu on cu.user_id = l.company_user_id
  731. <where>
  732. <if test ='maps.sendType !=null'>
  733. and l.send_type = #{maps.sendType}
  734. </if>
  735. <if test ='maps.userId !=null'>
  736. and l.user_id = #{maps.userId}
  737. </if>
  738. <if test ='maps.qwExternalContactId !=null'>
  739. and l.qw_external_contact_id = #{maps.qwExternalContactId}
  740. </if>
  741. <if test ='maps.qwUserId !=null'>
  742. and l.qw_user_id = #{maps.qwUserId}
  743. </if>
  744. <if test ='maps.courseId !=null'>
  745. and l.course_id = #{maps.courseId}
  746. </if>
  747. <if test ='maps.videoId !=null'>
  748. and l.video_id = #{maps.videoId}
  749. </if>
  750. <if test ='maps.logType !=null'>
  751. and l.log_type = #{maps.logType}
  752. </if>
  753. <if test ='maps.companyId !=null'>
  754. and l.company_id = #{maps.companyId}
  755. </if>
  756. <if test ='maps.companyUserId !=null'>
  757. and l.company_user_id = #{maps.companyUserId}
  758. </if>
  759. <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
  760. and cu.nick_name like concat('%', #{maps.companyUserName}, '%')
  761. </if>
  762. <if test ='maps.nickName !=null and maps.nickName!=""'>
  763. and u.nick_name like concat('%', #{maps.nickName}, '%')
  764. </if>
  765. <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
  766. and qec.name like concat('%', #{maps.externalUserName}, '%')
  767. </if>
  768. <if test= 'maps.qecSTime != null '>
  769. and DATE(qec.create_time) &gt;= DATE(#{maps.qecSTime})
  770. </if>
  771. <if test='maps.qecETime != null '>
  772. and DATE(qec.create_time) &lt;= DATE(#{maps.qecETime})
  773. </if>
  774. <if test= 'maps.sTime != null '>
  775. and DATE(l.create_time) &gt;= DATE(#{maps.sTime})
  776. </if>
  777. <if test='maps.eTime != null '>
  778. and DATE(l.create_time) &lt;= DATE(#{maps.eTime})
  779. </if>
  780. <if test= 'maps.scheduleStartTime != null '>
  781. and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
  782. </if>
  783. <if test='maps.scheduleEndTime != null '>
  784. and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
  785. </if>
  786. <if test= 'maps.upSTime != null '>
  787. and DATE(l.update_time) &gt;= DATE(#{maps.upSTime})
  788. </if>
  789. <if test='maps.upETime != null '>
  790. and DATE(l.update_time) &lt;= DATE(#{maps.upETime})
  791. </if>
  792. <if test="maps.sopIds != null and maps.sopIds.size() > 0">
  793. and l.sop_id in
  794. <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
  795. #{sopId}
  796. </foreach>
  797. </if>
  798. </where>
  799. order by l.finish_time desc,l.update_time desc,l.create_time desc
  800. </select>
  801. </mapper>