FsCourseWatchLogMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  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. </resultMap>
  27. <sql id="selectFsCourseWatchLogVo">
  28. 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 from fs_course_watch_log
  29. </sql>
  30. <select id="selectFsCourseWatchLogList" parameterType="FsCourseWatchLog" resultMap="FsCourseWatchLogResult">
  31. <include refid="selectFsCourseWatchLogVo"/>
  32. <where>
  33. <if test="userId != null "> and user_id = #{userId}</if>
  34. <if test="videoId != null "> and video_id = #{videoId}</if>
  35. <if test="logType != null "> and log_type = #{logType}</if>
  36. <if test="qwExternalContactId != null "> and qw_external_contact_id = #{qwExternalContactId}</if>
  37. <if test="duration != null "> and duration = #{duration}</if>
  38. <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
  39. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  40. <if test="companyId != null "> and company_id = #{companyId}</if>
  41. <if test="courseId != null "> and course_id = #{courseId}</if>
  42. <if test="sendType != null "> and send_type = #{sendType}</if>
  43. <if test="campPeriodTime != null "> and camp_period_time = #{campPeriodTime}</if>
  44. </where>
  45. </select>
  46. <select id="selectFsCourseWatchLogByLogId" parameterType="Long" resultMap="FsCourseWatchLogResult">
  47. <include refid="selectFsCourseWatchLogVo"/>
  48. where log_id = #{logId}
  49. </select>
  50. <select id="selectFsCourseWatchLogListVO" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
  51. select l.log_id,
  52. l.project as project,
  53. l.user_id,uc.course_name,v.title as video_name,u.nick_name as fsNickName, u.avatar as fsAvatar,
  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
  57. from fs_course_watch_log l
  58. left join fs_user_course_video v on v.video_id = l.video_id
  59. left join fs_user_course uc on uc.course_id = l.course_id
  60. left join fs_user u on u.user_id = l.user_id
  61. left join company_user cu on cu.user_id = l.company_user_id
  62. left join company c on c.company_id = l.company_id
  63. LEFT JOIN qw_user qu on qu.id= l.qw_user_id
  64. LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
  65. <where>
  66. <if test ='maps.userId !=null'>
  67. and l.user_id = #{maps.userId}
  68. </if>
  69. <if test ='maps.qwExternalContactId !=null'>
  70. and l.qw_external_contact_id = #{maps.qwExternalContactId}
  71. </if>
  72. <if test ='maps.qwUserId !=null'>
  73. and l.qw_user_id = #{maps.qwUserId}
  74. </if>
  75. <if test ='maps.courseId !=null'>
  76. and l.course_id = #{maps.courseId}
  77. </if>
  78. <if test ='maps.videoId !=null'>
  79. and l.video_id = #{maps.videoId}
  80. </if>
  81. <if test ='maps.logType !=null'>
  82. and l.log_type = #{maps.logType}
  83. </if>
  84. <if test ='maps.companyId !=null'>
  85. and l.company_id = #{maps.companyId}
  86. </if>
  87. <if test ='maps.companyUserId !=null'>
  88. and l.company_user_id = #{maps.companyUserId}
  89. </if>
  90. <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
  91. and cu.nick_name like concat('%', #{maps.companyUserName}, '%')
  92. </if>
  93. <if test ='maps.nickName !=null and maps.nickName!=""'>
  94. and u.nick_name like concat('%', #{maps.nickName}, '%')
  95. </if>
  96. <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
  97. and qec.name like concat('%', #{maps.externalUserName}, '%')
  98. </if>
  99. <if test= 'maps.sTime != null '>
  100. and DATE(l.create_time) &gt;= DATE(#{maps.sTime})
  101. </if>
  102. <if test='maps.eTime != null '>
  103. and DATE(l.create_time) &lt;= DATE(#{maps.eTime})
  104. </if>
  105. <if test= 'maps.scheduleStartTime != null '>
  106. and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
  107. </if>
  108. <if test='maps.scheduleEndTime != null '>
  109. and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
  110. </if>
  111. <if test= 'maps.upSTime != null '>
  112. and DATE(l.update_time) &gt;= DATE(#{maps.upSTime})
  113. </if>
  114. <if test='maps.upETime != null '>
  115. and DATE(l.update_time) &lt;= DATE(#{maps.upETime})
  116. </if>
  117. <if test="maps.sopIds != null and maps.sopIds.size() > 0">
  118. and l.sop_id in
  119. <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
  120. #{sopId}
  121. </foreach>
  122. </if>
  123. </where>
  124. order by l.log_id desc
  125. </select>
  126. <select id="selectFsCourseWatchLogListByParam" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
  127. select l.log_id,l.user_id,uc.course_name,v.title as video_name,u.nick_name as fsNickName, u.avatar as fsAvatar,
  128. l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,
  129. cu.nick_name as company_user_name ,l.send_type,l.create_time, qu.qw_user_name,qec.name as external_user_name
  130. from fs_course_watch_log l
  131. left join fs_user_course_video v on v.video_id = l.video_id
  132. left join fs_user_course uc on uc.course_id = l.course_id
  133. left join fs_user u on u.user_id = l.user_id
  134. left join company_user cu on cu.user_id = l.company_user_id
  135. left join company c on c.company_id = l.company_id
  136. LEFT JOIN qw_user qu on qu.id= l.qw_user_id
  137. LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
  138. <where>
  139. <if test ='userId !=null'>
  140. and l.user_id = #{userId}
  141. </if>
  142. <if test ='qwUserId !=null'>
  143. and l.qw_user_id = #{qwUserId}
  144. </if>
  145. <if test ='courseId !=null'>
  146. and l.course_id = #{courseId}
  147. </if>
  148. <if test ='videoId !=null'>
  149. and l.video_id = #{videoId}
  150. </if>
  151. <if test ='logType !=null'>
  152. and l.log_type = #{logType}
  153. </if>
  154. <if test ='companyId !=null'>
  155. and l.company_id = #{companyId}
  156. </if>
  157. <if test ='companyUserId !=null'>
  158. and l.company_user_id = #{companyUserId}
  159. </if>
  160. <if test ='companyUserName !=null and maps.companyUserName!=""'>
  161. and cu.nick_name like concat('%', #{companyUserName}, '%')
  162. </if>
  163. <if test ='nickName !=null and maps.nickName!=""'>
  164. and u.nick_name like concat('%', #{nickName}, '%')
  165. </if>
  166. <if test= 'sTime != null '>
  167. and DATE(l.create_time) &gt;= DATE(#{sTime})
  168. </if>
  169. <if test='eTime != null '>
  170. and DATE(l.create_time) &lt;= DATE(#{eTime})
  171. </if>
  172. <if test= 'maps.scheduleStartTime != null '>
  173. and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
  174. </if>
  175. <if test='maps.scheduleEndTime != null '>
  176. and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
  177. </if>
  178. <if test="sopIds != null and sopIds.size() > 0">
  179. and l.sop_id in
  180. <foreach item="sopId" index="index" collection="sopIds" open="(" separator="," close=")">
  181. #{sopId}
  182. </foreach>
  183. </if>
  184. </where>
  185. order by l.log_id desc
  186. </select>
  187. <insert id="insertFsCourseWatchLog" parameterType="FsCourseWatchLog" useGeneratedKeys="true" keyProperty="logId">
  188. insert into fs_course_watch_log
  189. <trim prefix="(" suffix=")" suffixOverrides=",">
  190. <if test="userId != null">user_id,</if>
  191. <if test="videoId != null">video_id,</if>
  192. <if test="logType != null">log_type,</if>
  193. <if test="createTime != null">create_time,</if>
  194. <if test="updateTime != null">update_time,</if>
  195. <if test="qwExternalContactId != null">qw_external_contact_id,</if>
  196. <if test="duration != null">duration,</if>
  197. <if test="qwUserId != null">qw_user_id,</if>
  198. <if test="companyUserId != null">company_user_id,</if>
  199. <if test="companyId != null">company_id,</if>
  200. <if test="courseId != null">course_id,</if>
  201. <if test="sendType != null">send_type,</if>
  202. <if test="rewardType != null">reward_type,</if>
  203. <if test="sopId != null">sop_id,</if>
  204. <if test="finishTime != null">finish_time,</if>
  205. <if test="sendFinishMsg != null">send_finish_msg,</if>
  206. <if test="campPeriodTime != null">camp_period_time,</if>
  207. </trim>
  208. <trim prefix="values (" suffix=")" suffixOverrides=",">
  209. <if test="userId != null">#{userId},</if>
  210. <if test="videoId != null">#{videoId},</if>
  211. <if test="logType != null">#{logType},</if>
  212. <if test="createTime != null">#{createTime},</if>
  213. <if test="updateTime != null">#{updateTime},</if>
  214. <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
  215. <if test="duration != null">#{duration},</if>
  216. <if test="qwUserId != null">#{qwUserId},</if>
  217. <if test="companyUserId != null">#{companyUserId},</if>
  218. <if test="companyId != null">#{companyId},</if>
  219. <if test="courseId != null">#{courseId},</if>
  220. <if test="sendType != null">#{sendType},</if>
  221. <if test="rewardType != null">#{rewardType},</if>
  222. <if test="sopId != null">#{sopId},</if>
  223. <if test="finishTime != null">#{finishTime},</if>
  224. <if test="sendFinishMsg != null">#{sendFinishMsg},</if>
  225. <if test="campPeriodTime != null">#{campPeriodTime},</if>
  226. </trim>
  227. </insert>
  228. <insert id="insertOrUpdateFsCourseWatchLog" parameterType="FsCourseWatchLog">
  229. insert into fs_course_watch_log
  230. <trim prefix="(" suffix=")" suffixOverrides=",">
  231. <if test="userId != null">user_id,</if>
  232. <if test="videoId != null">video_id,</if>
  233. <if test="logType != null">log_type,</if>
  234. <if test="createTime != null">create_time,</if>
  235. <if test="updateTime != null">update_time,</if>
  236. <if test="qwExternalContactId != null">qw_external_contact_id,</if>
  237. <if test="duration != null">duration,</if>
  238. <if test="qwUserId != null">qw_user_id,</if>
  239. <if test="companyUserId != null">company_user_id,</if>
  240. <if test="companyId != null">company_id,</if>
  241. <if test="courseId != null">course_id,</if>
  242. <if test="sendType != null">send_type,</if>
  243. <if test="rewardType != null">reward_type,</if>
  244. <if test="sopId != null">sop_id,</if>
  245. <if test="finishTime != null">finish_time,</if>
  246. <if test="sendFinishMsg != null">send_finish_msg,</if>
  247. <if test="campPeriodTime != null">camp_period_time,</if>
  248. </trim>
  249. <trim prefix="values (" suffix=")" suffixOverrides=",">
  250. <if test="userId != null">#{userId},</if>
  251. <if test="videoId != null">#{videoId},</if>
  252. <if test="logType != null">#{logType},</if>
  253. <if test="createTime != null">#{createTime},</if>
  254. <if test="updateTime != null">#{updateTime},</if>
  255. <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
  256. <if test="duration != null">#{duration},</if>
  257. <if test="qwUserId != null">#{qwUserId},</if>
  258. <if test="companyUserId != null">#{companyUserId},</if>
  259. <if test="companyId != null">#{companyId},</if>
  260. <if test="courseId != null">#{courseId},</if>
  261. <if test="sendType != null">#{sendType},</if>
  262. <if test="rewardType != null">#{rewardType},</if>
  263. <if test="sopId != null">#{sopId},</if>
  264. <if test="finishTime != null">#{finishTime},</if>
  265. <if test="sendFinishMsg != null">#{sendFinishMsg},</if>
  266. <if test="campPeriodTime != null">#{campPeriodTime},</if>
  267. </trim>
  268. on duplicate key update
  269. <trim suffixOverrides=",">
  270. <if test="updateTime != null">update_time = #{updateTime},</if>
  271. </trim>
  272. </insert>
  273. <insert id="insertFsCourseWatchLogBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="logId">
  274. INSERT INTO fs_course_watch_log (
  275. user_id,
  276. video_id,
  277. log_type,
  278. create_time,
  279. update_time,
  280. qw_external_contact_id,
  281. duration,
  282. qw_user_id,
  283. company_user_id,
  284. company_id,
  285. course_id,
  286. send_type,
  287. reward_type,
  288. sop_id,
  289. camp_period_time
  290. )
  291. VALUES
  292. <foreach collection="watchLogs" item="log" separator=",">
  293. (
  294. #{log.userId},
  295. #{log.videoId},
  296. #{log.logType},
  297. #{log.createTime},
  298. #{log.updateTime},
  299. #{log.qwExternalContactId},
  300. #{log.duration},
  301. #{log.qwUserId},
  302. #{log.companyUserId},
  303. #{log.companyId},
  304. #{log.courseId},
  305. #{log.sendType},
  306. #{log.rewardType},
  307. #{log.sopId},
  308. #{log.campPeriodTime}
  309. )
  310. </foreach>
  311. ON DUPLICATE KEY UPDATE
  312. update_time = VALUES(update_time)
  313. </insert>
  314. <update id="updateFsCourseWatchLog" parameterType="FsCourseWatchLog">
  315. update fs_course_watch_log
  316. <trim prefix="SET" suffixOverrides=",">
  317. <if test="userId != null">user_id = #{userId},</if>
  318. <if test="videoId != null">video_id = #{videoId},</if>
  319. <if test="logType != null">log_type = #{logType},</if>
  320. <if test="createTime != null">create_time = #{createTime},</if>
  321. <if test="updateTime != null">update_time = #{updateTime},</if>
  322. <if test="qwExternalContactId != null">qw_external_contact_id = #{qwExternalContactId},</if>
  323. <if test="duration != null">duration = #{duration},</if>
  324. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  325. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  326. <if test="companyId != null">company_id = #{companyId},</if>
  327. <if test="courseId != null">course_id = #{courseId},</if>
  328. <if test="sendType != null">send_type = #{sendType},</if>
  329. <if test="rewardType != null">reward_type = #{rewardType},</if>
  330. <if test="sopId != null">sop_id = #{sopId},</if>
  331. <if test="finishTime != null">finish_time = #{finishTime},</if>
  332. <if test="sendFinishMsg != null">send_finish_msg = #{sendFinishMsg},</if>
  333. <if test="lastHeartbeatTime != null">last_heartbeat_time = #{lastHeartbeatTime},</if>
  334. </trim>
  335. where log_id = #{logId}
  336. </update>
  337. <delete id="deleteFsCourseWatchLogByLogId" parameterType="Long">
  338. delete from fs_course_watch_log where log_id = #{logId}
  339. </delete>
  340. <delete id="deleteFsCourseWatchLogByLogIds" parameterType="String">
  341. delete from fs_course_watch_log where log_id in
  342. <foreach item="logId" collection="array" open="(" separator="," close=")">
  343. #{logId}
  344. </foreach>
  345. </delete>
  346. <select id="selectFsCourseWatchLogByFinishTime" resultType="com.fs.course.param.FsCourseWatchLogByFinishTimeParam">
  347. <![CDATA[
  348. SELECT
  349. fcwl.log_id,
  350. fcwl.create_time,
  351. fcwl.qw_external_contact_id,
  352. fcwl.qw_user_id,
  353. fcwl.user_id,
  354. fcwl.company_user_id,
  355. fcwl.company_id,
  356. fcwl.sop_id,
  357. fcwl.finish_time,
  358. fcwl.camp_period_time,
  359. qec.corp_id,
  360. qec.external_user_id,
  361. qec.tag_ids,
  362. qec.user_id AS qw_user,
  363. qec.name AS external_contact_name
  364. FROM
  365. fs_course_watch_log fcwl
  366. LEFT JOIN qw_external_contact qec ON fcwl.qw_external_contact_id = qec.id
  367. WHERE
  368. DATE(fcwl.finish_time)= '2025-02-09'
  369. and fcwl.camp_period_time is not NULL
  370. ]]>
  371. </select>
  372. <update id="batchUpdateWatchLog" parameterType="java.util.List">
  373. UPDATE fs_course_watch_log
  374. SET
  375. duration = CASE
  376. <foreach collection="list" item="item" index="index">
  377. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  378. CASE
  379. <!-- 仅当传入的duration > 当前值时才更新 -->
  380. WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
  381. ELSE duration <!-- 如果 duration 为 null,保持原值 -->
  382. END
  383. </foreach>
  384. END,
  385. last_heartbeat_time = CASE
  386. <foreach collection="list" item="item" index="index">
  387. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  388. CASE
  389. WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
  390. ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
  391. END
  392. </foreach>
  393. END,
  394. finish_time = CASE
  395. <foreach collection="list" item="item" index="index">
  396. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  397. CASE
  398. WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
  399. ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
  400. END
  401. </foreach>
  402. END,
  403. log_type = CASE
  404. <foreach collection="list" item="item" index="index">
  405. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  406. CASE
  407. WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
  408. WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
  409. ELSE log_type <!-- 其他情况保持原值 -->
  410. END
  411. </foreach>
  412. END
  413. WHERE
  414. (video_id, qw_external_contact_id, qw_user_id) IN
  415. <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
  416. (#{item.videoId}, #{item.qwExternalContactId}, #{item.qwUserId})
  417. </foreach>
  418. </update>
  419. <update id="batchUpdateWatchLogSendMsg" parameterType="java.util.List">
  420. UPDATE fs_course_watch_log
  421. SET send_finish_msg = CASE
  422. <foreach collection="list" item="item">
  423. WHEN log_id = #{item.logId} THEN #{item.sendFinishMsg}
  424. </foreach>
  425. ELSE send_finish_msg
  426. END
  427. WHERE log_id IN
  428. <foreach collection="list" item="item" open="(" separator="," close=")">
  429. #{item.logId}
  430. </foreach>
  431. </update>
  432. <select id="selectFsCourseWatchLogStatisticsListVONew"
  433. resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListVO">
  434. SELECT
  435. o.company_user_id,o.user_id,DATE(o.create_time) create_time,
  436. SUM(CASE WHEN o.log_type = '1' THEN 1 ELSE 0 END) AS type1,
  437. SUM(CASE WHEN o.log_type = '2' THEN 1 ELSE 0 END) AS type2,
  438. SUM(CASE WHEN o.log_type = '3' THEN 1 ELSE 0 END) AS type3,
  439. SUM(CASE WHEN o.log_type = '4' THEN 1 ELSE 0 END) AS type4,
  440. o.project as project,
  441. o.course_id as course_id,
  442. o.video_id as video_id
  443. FROM fs_course_watch_log o
  444. <where>
  445. <if test="companyId != null">
  446. o.company_id=#{companyId}
  447. </if>
  448. <if test= 'sTime != null '>
  449. and DATE(o.create_time) &gt;= DATE(#{sTime})
  450. </if>
  451. <if test='eTime != null '>
  452. and DATE(o.create_time) &lt;= DATE(#{eTime})
  453. </if>
  454. <if test ='courseId !=null'>
  455. and o.course_id = #{courseId}
  456. </if>
  457. <if test ='videoId !=null'>
  458. and o.video_id = #{videoId}
  459. </if>
  460. <if test="companyUserId != null">
  461. and o.company_user_id = #{companyUserId}
  462. </if>
  463. <if test="project != null">
  464. and o.project = #{project}
  465. </if>
  466. <if test="userId != null">
  467. and o.user_id = #{userId}
  468. </if>
  469. </where>
  470. GROUP BY o.video_id,o.user_id,DATE(o.create_time)
  471. ORDER BY o.video_id ,DATE(o.create_time)
  472. </select>
  473. <select id="selectFsCourseWatchLogListVONew" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
  474. SELECT
  475. l.log_id,
  476. l.project AS project,
  477. l.user_id,
  478. l.log_type,
  479. SEC_TO_TIME(l.duration) AS duration,
  480. l.camp_period_time,
  481. l.finish_time,
  482. l.send_type,
  483. l.create_time,
  484. l.update_time,
  485. l.last_heartbeat_time,
  486. l.company_id,
  487. l.company_user_id,
  488. l.course_id,
  489. l.video_id
  490. FROM
  491. fs_course_watch_log l
  492. INNER JOIN (
  493. SELECT log_id
  494. FROM fs_course_watch_log
  495. <where>
  496. <if test='maps.userId != null'>
  497. AND user_id = #{maps.userId}
  498. </if>
  499. <if test='maps.courseId != null'>
  500. AND course_id = #{maps.courseId}
  501. </if>
  502. <if test='maps.videoId != null'>
  503. AND video_id = #{maps.videoId}
  504. </if>
  505. <if test='maps.logType != null'>
  506. AND log_type = #{maps.logType}
  507. </if>
  508. <if test='maps.companyId != null'>
  509. AND company_id = #{maps.companyId}
  510. </if>
  511. <if test='maps.companyUserId != null'>
  512. AND company_user_id = #{maps.companyUserId}
  513. </if>
  514. <if test= 'maps.sTime != null '>
  515. and DATE(l.create_time) &gt;= DATE(#{maps.sTime})
  516. </if>
  517. <if test='maps.eTime != null '>
  518. and DATE(l.create_time) &lt;= DATE(#{maps.eTime})
  519. </if>
  520. <if test= 'maps.scheduleStartTime != null '>
  521. and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
  522. </if>
  523. <if test='maps.scheduleEndTime != null '>
  524. and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
  525. </if>
  526. <if test= 'maps.upSTime != null '>
  527. and DATE(l.update_time) &gt;= DATE(#{maps.upSTime})
  528. </if>
  529. <if test='maps.upETime != null '>
  530. and DATE(l.update_time) &lt;= DATE(#{maps.upETime})
  531. </if>
  532. <if test="maps.sopIds != null and maps.sopIds.size() > 0">
  533. and l.sop_id in
  534. AND sop_id IN
  535. <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
  536. #{sopId}
  537. </foreach>
  538. </if>
  539. </where>
  540. ORDER BY log_id DESC
  541. LIMIT ${(maps.pageNum-1)*maps.pageSize}, ${maps.pageSize}
  542. ) AS page_ids ON l.log_id = page_ids.log_id
  543. </select>
  544. <select id="selectFsCourseWatchLogListVONewCount" resultType="java.lang.Long">
  545. SELECT count(log_id)
  546. FROM fs_course_watch_log
  547. <where>
  548. <if test='maps.userId != null'>
  549. AND user_id = #{maps.userId}
  550. </if>
  551. <if test='maps.courseId != null'>
  552. AND course_id = #{maps.courseId}
  553. </if>
  554. <if test='maps.videoId != null'>
  555. AND video_id = #{maps.videoId}
  556. </if>
  557. <if test='maps.logType != null'>
  558. AND log_type = #{maps.logType}
  559. </if>
  560. <if test='maps.companyId != null'>
  561. AND company_id = #{maps.companyId}
  562. </if>
  563. <if test='maps.companyUserId != null'>
  564. AND company_user_id = #{maps.companyUserId}
  565. </if>
  566. <if test= 'maps.sTime != null '>
  567. and DATE(l.create_time) &gt;= DATE(#{maps.sTime})
  568. </if>
  569. <if test='maps.eTime != null '>
  570. and DATE(l.create_time) &lt;= DATE(#{maps.eTime})
  571. </if>
  572. <if test= 'maps.scheduleStartTime != null '>
  573. and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
  574. </if>
  575. <if test='maps.scheduleEndTime != null '>
  576. and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
  577. </if>
  578. <if test= 'maps.upSTime != null '>
  579. and DATE(l.update_time) &gt;= DATE(#{maps.upSTime})
  580. </if>
  581. <if test='maps.upETime != null '>
  582. and DATE(l.update_time) &lt;= DATE(#{maps.upETime})
  583. </if>
  584. <if test="maps.sopIds != null and maps.sopIds.size() > 0">
  585. and l.sop_id in
  586. AND sop_id IN
  587. <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
  588. #{sopId}
  589. </foreach>
  590. </if>
  591. </where>
  592. </select>
  593. </mapper>