FsCourseWatchLogMapper.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  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. <result property="periodId" column="period_id" />
  28. <result property="appid" column="appid" />
  29. </resultMap>
  30. <sql id="selectFsCourseWatchLogVo">
  31. 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,period_id,appid from fs_course_watch_log
  32. </sql>
  33. <select id="selectFsCourseWatchLogList" parameterType="FsCourseWatchLog" resultMap="FsCourseWatchLogResult">
  34. <include refid="selectFsCourseWatchLogVo"/>
  35. <where>
  36. <if test="userId != null "> and user_id = #{userId}</if>
  37. <if test="videoId != null "> and video_id = #{videoId}</if>
  38. <if test="logType != null "> and log_type = #{logType}</if>
  39. <if test="qwExternalContactId != null "> and qw_external_contact_id = #{qwExternalContactId}</if>
  40. <if test="duration != null "> and duration = #{duration}</if>
  41. <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
  42. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  43. <if test="companyId != null "> and company_id = #{companyId}</if>
  44. <if test="courseId != null "> and course_id = #{courseId}</if>
  45. <if test="sendType != null "> and send_type = #{sendType}</if>
  46. <if test="campPeriodTime != null "> and camp_period_time = #{campPeriodTime}</if>
  47. <if test="project != null "> and project = #{project}</if>
  48. <if test="appid != null "> and appid = #{appid}</if>
  49. </where>
  50. </select>
  51. <select id="selectFsCourseWatchLogByLogId" parameterType="Long" resultMap="FsCourseWatchLogResult">
  52. <include refid="selectFsCourseWatchLogVo"/>
  53. where log_id = #{logId}
  54. </select>
  55. <select id="selectFsCourseWatchLogListVO" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
  56. select l.log_id,l.project,l.period_id,l.user_id,uc.course_name,v.title as video_name,qec.avatar as external_user_avatar,
  57. l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,l.appid,
  58. cu.nick_name as company_user_name ,l.send_type,l.create_time,l.update_time,l.last_heartbeat_time,fcpsc.name,
  59. CASE
  60. WHEN qu.qw_user_name IS NOT NULL AND qu.qw_user_name LIKE '{%' THEN JSON_UNQUOTE(JSON_EXTRACT(qu.qw_user_name, '$.name'))
  61. ELSE qu.qw_user_name
  62. END as qw_user_name,
  63. 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,
  64. u.is_vip isVip, l.project, l.im_msg_send_detail_id,l.reward_type
  65. from fs_course_watch_log l
  66. left join fs_user_course_video v on v.video_id = l.video_id
  67. left join fs_user_course uc on uc.course_id = l.course_id
  68. left join fs_user u on u.user_id = l.user_id
  69. left join company_user cu on cu.user_id = l.company_user_id
  70. left join company c on c.company_id = l.company_id
  71. LEFT JOIN qw_user qu on qu.id= l.qw_user_id
  72. LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
  73. LEFT JOIN fs_course_play_source_config fcpsc on l.appid = fcpsc.appid
  74. <where>
  75. <if test ='maps.appid != null'>
  76. and l.appid = #{maps.appid}
  77. </if>
  78. <if test ='maps.isVip != null and maps.isVip == 0'>
  79. and (l.user_id = 0 or l.user_id is null)
  80. </if>
  81. <if test ='maps.isVip != null and maps.isVip == 1'>
  82. and l.user_id != 0 and l.user_id is not null
  83. </if>
  84. <if test ='maps.sendType !=null'>
  85. and l.send_type = #{maps.sendType}
  86. </if>
  87. <if test ='maps.userId !=null'>
  88. and l.user_id = #{maps.userId}
  89. </if>
  90. <!-- <if test ='maps.project !=null'>-->
  91. <!-- and l.project = #{maps.project}-->
  92. <!-- </if>-->
  93. <if test ='maps.qwExternalContactId !=null'>
  94. and l.qw_external_contact_id = #{maps.qwExternalContactId}
  95. </if>
  96. <if test ='maps.qwUserId !=null'>
  97. and l.qw_user_id = #{maps.qwUserId}
  98. </if>
  99. <if test ='maps.courseId !=null'>
  100. and l.course_id = #{maps.courseId}
  101. </if>
  102. <if test ='maps.videoId !=null'>
  103. and l.video_id = #{maps.videoId}
  104. </if>
  105. <if test ='maps.logType !=null'>
  106. and l.log_type = #{maps.logType}
  107. </if>
  108. <if test ='maps.companyId !=null'>
  109. and l.company_id = #{maps.companyId}
  110. </if>
  111. <if test ='maps.companyUserId !=null'>
  112. and l.company_user_id = #{maps.companyUserId}
  113. </if>
  114. <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
  115. and cu.nick_name like concat('%', #{maps.companyUserName}, '%')
  116. </if>
  117. <if test ='maps.nickName !=null and maps.nickName!=""'>
  118. and u.nick_name like concat('%', #{maps.nickName}, '%')
  119. </if>
  120. <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
  121. and qec.name like concat('%', #{maps.externalUserName}, '%')
  122. </if>
  123. <if test= 'maps.qecSTime != null '>
  124. and DATE(qec.create_time) &gt;= DATE(#{maps.qecSTime})
  125. </if>
  126. <if test='maps.qecETime != null '>
  127. and DATE(qec.create_time) &lt;= DATE(#{maps.qecETime})
  128. </if>
  129. <if test= 'maps.sTime != null '>
  130. and l.create_time &gt;= CONCAT(#{maps.sTime}," 00:00:00")
  131. </if>
  132. <if test='maps.eTime != null '>
  133. and l.create_time &lt; CONCAT(#{maps.eTime}, ' 00:00:00')
  134. </if>
  135. <if test= 'maps.scheduleStartTime != null '>
  136. and l.camp_period_time &gt;= #{maps.scheduleStartTime}
  137. </if>
  138. <if test='maps.scheduleEndTime != null '>
  139. and l.camp_period_time &lt;= #{maps.scheduleEndTime}
  140. </if>
  141. <if test= 'maps.upSTime != null '>
  142. and DATE(l.update_time) &gt;= DATE(#{maps.upSTime})
  143. </if>
  144. <if test='maps.upETime != null '>
  145. and DATE(l.update_time) &lt;= DATE(#{maps.upETime})
  146. </if>
  147. <if test="maps.sopIds != null and maps.sopIds.size() > 0">
  148. and l.sop_id in
  149. <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
  150. #{sopId}
  151. </foreach>
  152. </if>
  153. <!-- <if test ='maps.project !=null'>-->
  154. <!-- and l.project = #{maps.project}-->
  155. <!-- </if>-->
  156. <!-- <if test ='maps.project !=null'>-->
  157. <!-- and l.project = #{maps.project}-->
  158. <!-- </if>-->
  159. <if test="maps.sopId != null and maps.sopId != '' ">
  160. and l.sop_id = #{maps.sopId}
  161. </if>
  162. <if test="maps.periodId != null">
  163. and l.period_id = #{maps.periodId}
  164. </if>
  165. <if test="maps.periodIds != null and maps.periodIds.size() > 0">
  166. and l.period_id in
  167. <foreach item="periodId" index="index" collection="maps.periodIds" open="(" separator="," close=")">
  168. #{periodId}
  169. </foreach>
  170. </if>
  171. <if test="maps.qwUserName != null and maps.qwUserName != '' ">
  172. and (
  173. qu.qw_user_name = #{maps.qwUserName}
  174. OR (qu.qw_user_name LIKE '{%' AND JSON_UNQUOTE(JSON_EXTRACT(qu.qw_user_name, '$.name')) = #{maps.qwUserName})
  175. )
  176. </if>
  177. <if test="maps.deptId != null and maps.deptId != '' ">
  178. and cu.dept_id = #{maps.deptId}
  179. </if>
  180. <if test='maps.cuDeptIdList != null and !maps.cuDeptIdList.isEmpty() and maps.userType != "00" '>
  181. AND cu.dept_id IN
  182. <foreach collection='maps.cuDeptIdList' item='item' open='(' separator=',' close=')'>
  183. #{item}
  184. </foreach>
  185. </if>
  186. </where>
  187. order by l.finish_time desc,l.update_time desc,l.create_time desc
  188. </select>
  189. <select id="selectFsCourseWatchLogListByParam" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
  190. select l.log_id,l.user_id,uc.course_name,v.title as video_name,u.nick_name as fsNickName, u.avatar as fsAvatar,
  191. l.log_type,SEC_TO_TIME(l.duration) as duration,c.company_name,l.camp_period_time,l.finish_time,
  192. cu.nick_name as company_user_name ,l.send_type,l.create_time,
  193. CASE
  194. WHEN qu.qw_user_name IS NOT NULL AND qu.qw_user_name LIKE '{%' THEN JSON_UNQUOTE(JSON_EXTRACT(qu.qw_user_name, '$.name'))
  195. ELSE qu.qw_user_name
  196. END as qw_user_name,
  197. qec.name as external_user_name
  198. from fs_course_watch_log l
  199. left join fs_user_course_video v on v.video_id = l.video_id
  200. left join fs_user_course uc on uc.course_id = l.course_id
  201. left join fs_user u on u.user_id = l.user_id
  202. left join company_user cu on cu.user_id = l.company_user_id
  203. left join company c on c.company_id = l.company_id
  204. LEFT JOIN qw_user qu on qu.id= l.qw_user_id
  205. LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
  206. <where>
  207. <if test ='userId !=null'>
  208. and l.user_id = #{userId}
  209. </if>
  210. <if test ='qwUserId !=null'>
  211. and l.qw_user_id = #{qwUserId}
  212. </if>
  213. <if test ='courseId !=null'>
  214. and l.course_id = #{courseId}
  215. </if>
  216. <if test ='videoId !=null'>
  217. and l.video_id = #{videoId}
  218. </if>
  219. <if test ='logType !=null'>
  220. and l.log_type = #{logType}
  221. </if>
  222. <if test ='companyId !=null'>
  223. and l.company_id = #{companyId}
  224. </if>
  225. <if test ='companyUserId !=null'>
  226. and l.company_user_id = #{companyUserId}
  227. </if>
  228. <if test ='companyUserName !=null and maps.companyUserName!=""'>
  229. and cu.nick_name like concat('%', #{companyUserName}, '%')
  230. </if>
  231. <if test ='nickName !=null and maps.nickName!=""'>
  232. and u.nick_name like concat('%', #{nickName}, '%')
  233. </if>
  234. <if test= 'sTime != null '>
  235. and DATE(l.create_time) &gt;= DATE(#{sTime})
  236. </if>
  237. <if test='eTime != null '>
  238. and DATE(l.create_time) &lt;= DATE(#{eTime})
  239. </if>
  240. <if test= 'maps.scheduleStartTime != null '>
  241. and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
  242. </if>
  243. <if test='maps.scheduleEndTime != null '>
  244. and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
  245. </if>
  246. <if test="sopIds != null and sopIds.size() > 0">
  247. and l.sop_id in
  248. <foreach item="sopId" index="index" collection="sopIds" open="(" separator="," close=")">
  249. #{sopId}
  250. </foreach>
  251. </if>
  252. <if test="periodId != null">
  253. and l.period_id = #{periodId}
  254. </if>
  255. </where>
  256. order by l.log_id desc
  257. </select>
  258. <insert id="insertFsCourseWatchLog" parameterType="FsCourseWatchLog" useGeneratedKeys="true" keyProperty="logId">
  259. insert into fs_course_watch_log
  260. <trim prefix="(" suffix=")" suffixOverrides=",">
  261. <if test="userId != null">user_id,</if>
  262. <if test="videoId != null">video_id,</if>
  263. <if test="logType != null">log_type,</if>
  264. <if test="createTime != null">create_time,</if>
  265. <if test="updateTime != null">update_time,</if>
  266. <if test="qwExternalContactId != null">qw_external_contact_id,</if>
  267. <if test="duration != null">duration,</if>
  268. <if test="qwUserId != null">qw_user_id,</if>
  269. <if test="companyUserId != null">company_user_id,</if>
  270. <if test="companyId != null">company_id,</if>
  271. <if test="courseId != null">course_id,</if>
  272. <if test="sendType != null">send_type,</if>
  273. <if test="rewardType != null">reward_type,</if>
  274. <if test="sopId != null">sop_id,</if>
  275. <if test="finishTime != null">finish_time,</if>
  276. <if test="sendFinishMsg != null">send_finish_msg,</if>
  277. <if test="campPeriodTime != null">camp_period_time,</if>
  278. <if test="periodId != null">period_id,</if>
  279. <if test="project != null">project,</if>
  280. <if test="appid != null">appid,</if>
  281. </trim>
  282. <trim prefix="values (" suffix=")" suffixOverrides=",">
  283. <if test="userId != null">#{userId},</if>
  284. <if test="videoId != null">#{videoId},</if>
  285. <if test="logType != null">#{logType},</if>
  286. <if test="createTime != null">#{createTime},</if>
  287. <if test="updateTime != null">#{updateTime},</if>
  288. <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
  289. <if test="duration != null">#{duration},</if>
  290. <if test="qwUserId != null">#{qwUserId},</if>
  291. <if test="companyUserId != null">#{companyUserId},</if>
  292. <if test="companyId != null">#{companyId},</if>
  293. <if test="courseId != null">#{courseId},</if>
  294. <if test="sendType != null">#{sendType},</if>
  295. <if test="rewardType != null">#{rewardType},</if>
  296. <if test="sopId != null">#{sopId},</if>
  297. <if test="finishTime != null">#{finishTime},</if>
  298. <if test="sendFinishMsg != null">#{sendFinishMsg},</if>
  299. <if test="campPeriodTime != null">#{campPeriodTime},</if>
  300. <if test="periodId != null">#{periodId},</if>
  301. <if test="project != null">#{project},</if>
  302. <if test="appid != null">#{appid},</if>
  303. </trim>
  304. </insert>
  305. <insert id="insertOrUpdateFsCourseWatchLog" parameterType="FsCourseWatchLog">
  306. insert into fs_course_watch_log
  307. <trim prefix="(" suffix=")" suffixOverrides=",">
  308. <if test="userId != null">user_id,</if>
  309. <if test="videoId != null">video_id,</if>
  310. <if test="logType != null">log_type,</if>
  311. <if test="createTime != null">create_time,</if>
  312. <if test="updateTime != null">update_time,</if>
  313. <if test="qwExternalContactId != null">qw_external_contact_id,</if>
  314. <if test="duration != null">duration,</if>
  315. <if test="qwUserId != null">qw_user_id,</if>
  316. <if test="companyUserId != null">company_user_id,</if>
  317. <if test="companyId != null">company_id,</if>
  318. <if test="courseId != null">course_id,</if>
  319. <if test="sendType != null">send_type,</if>
  320. <if test="rewardType != null">reward_type,</if>
  321. <if test="sopId != null">sop_id,</if>
  322. <if test="finishTime != null">finish_time,</if>
  323. <if test="sendFinishMsg != null">send_finish_msg,</if>
  324. <if test="campPeriodTime != null">camp_period_time,</if>
  325. <if test="project != null">project,</if>
  326. <if test="appid != null">appid,</if>
  327. </trim>
  328. <trim prefix="values (" suffix=")" suffixOverrides=",">
  329. <if test="userId != null">#{userId},</if>
  330. <if test="videoId != null">#{videoId},</if>
  331. <if test="logType != null">#{logType},</if>
  332. <if test="createTime != null">#{createTime},</if>
  333. <if test="updateTime != null">#{updateTime},</if>
  334. <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
  335. <if test="duration != null">#{duration},</if>
  336. <if test="qwUserId != null">#{qwUserId},</if>
  337. <if test="companyUserId != null">#{companyUserId},</if>
  338. <if test="companyId != null">#{companyId},</if>
  339. <if test="courseId != null">#{courseId},</if>
  340. <if test="sendType != null">#{sendType},</if>
  341. <if test="rewardType != null">#{rewardType},</if>
  342. <if test="sopId != null">#{sopId},</if>
  343. <if test="finishTime != null">#{finishTime},</if>
  344. <if test="sendFinishMsg != null">#{sendFinishMsg},</if>
  345. <if test="campPeriodTime != null">#{campPeriodTime},</if>
  346. <if test="project != null">#{project},</if>
  347. <if test="appid != null">#{appid},</if>
  348. </trim>
  349. on duplicate key update
  350. <trim suffixOverrides=",">
  351. <if test="updateTime != null">update_time = #{updateTime},</if>
  352. </trim>
  353. </insert>
  354. <insert id="insertFsCourseWatchLogBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="logId">
  355. INSERT INTO fs_course_watch_log (
  356. user_id,
  357. video_id,
  358. log_type,
  359. create_time,
  360. update_time,
  361. qw_external_contact_id,
  362. duration,
  363. qw_user_id,
  364. company_user_id,
  365. company_id,
  366. course_id,
  367. send_type,
  368. reward_type,
  369. sop_id,
  370. camp_period_time,
  371. project,
  372. period_id,
  373. im_msg_send_detail_id
  374. )
  375. VALUES
  376. <foreach collection="watchLogs" item="log" separator=",">
  377. (
  378. #{log.userId},
  379. #{log.videoId},
  380. #{log.logType},
  381. #{log.createTime},
  382. #{log.updateTime},
  383. #{log.qwExternalContactId},
  384. #{log.duration},
  385. #{log.qwUserId},
  386. #{log.companyUserId},
  387. #{log.companyId},
  388. #{log.courseId},
  389. #{log.sendType},
  390. #{log.rewardType},
  391. #{log.sopId},
  392. #{log.campPeriodTime},
  393. #{log.project},
  394. #{log.periodId},
  395. #{log.imMsgSendDetailId}
  396. )
  397. </foreach>
  398. ON DUPLICATE KEY UPDATE
  399. update_time = NOW(),
  400. im_msg_send_detail_id = VALUES(im_msg_send_detail_id)
  401. </insert>
  402. <update id="updateFsCourseWatchLog" parameterType="FsCourseWatchLog">
  403. update fs_course_watch_log
  404. <trim prefix="SET" suffixOverrides=",">
  405. <if test="userId != null">user_id = #{userId},</if>
  406. <if test="videoId != null">video_id = #{videoId},</if>
  407. <if test="logType != null">log_type = #{logType},</if>
  408. <if test="createTime != null">create_time = #{createTime},</if>
  409. <if test="updateTime != null">update_time = #{updateTime},</if>
  410. <if test="qwExternalContactId != null">qw_external_contact_id = #{qwExternalContactId},</if>
  411. <if test="duration != null">duration = #{duration},</if>
  412. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  413. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  414. <if test="companyId != null">company_id = #{companyId},</if>
  415. <if test="courseId != null">course_id = #{courseId},</if>
  416. <if test="sendType != null">send_type = #{sendType},</if>
  417. <if test="rewardType != null">reward_type = #{rewardType},</if>
  418. <if test="sopId != null">sop_id = #{sopId},</if>
  419. <if test="finishTime != null">finish_time = #{finishTime},</if>
  420. <if test="sendFinishMsg != null">send_finish_msg = #{sendFinishMsg},</if>
  421. <if test="lastHeartbeatTime != null">last_heartbeat_time = #{lastHeartbeatTime},</if>
  422. <if test="periodId != null">period_id = #{periodId},</if>
  423. <if test="project != null">project = #{project},</if>
  424. <if test="appid != null">appid = #{appid},</if>
  425. </trim>
  426. where log_id = #{logId}
  427. </update>
  428. <delete id="deleteFsCourseWatchLogByLogId" parameterType="Long">
  429. delete from fs_course_watch_log where log_id = #{logId}
  430. </delete>
  431. <delete id="deleteFsCourseWatchLogByLogIds" parameterType="String">
  432. delete from fs_course_watch_log where log_id in
  433. <foreach item="logId" collection="array" open="(" separator="," close=")">
  434. #{logId}
  435. </foreach>
  436. </delete>
  437. <select id="selectFsCourseWatchLogByFinishTime" resultType="com.fs.course.param.FsCourseWatchLogByFinishTimeParam">
  438. <![CDATA[
  439. SELECT
  440. fcwl.log_id,
  441. fcwl.create_time,
  442. fcwl.qw_external_contact_id,
  443. fcwl.qw_user_id,
  444. fcwl.user_id,
  445. fcwl.company_user_id,
  446. fcwl.company_id,
  447. fcwl.sop_id,
  448. fcwl.finish_time,
  449. fcwl.camp_period_time,
  450. qec.corp_id,
  451. qec.external_user_id,
  452. qec.tag_ids,
  453. qec.user_id AS qw_user,
  454. qec.name AS external_contact_name
  455. FROM
  456. fs_course_watch_log fcwl
  457. LEFT JOIN qw_external_contact qec ON fcwl.qw_external_contact_id = qec.id
  458. WHERE
  459. DATE(fcwl.finish_time)= '2025-02-09'
  460. and fcwl.camp_period_time is not NULL
  461. ]]>
  462. </select>
  463. <select id="getWatchLogByFsUser" resultType="com.fs.course.domain.FsCourseWatchLog">
  464. SELECT
  465. log_id,
  466. user_id,
  467. video_id,
  468. log_type,
  469. create_time,
  470. update_time,
  471. duration,
  472. company_user_id,
  473. company_id,
  474. course_id,
  475. send_type,
  476. reward_type,
  477. last_heartbeat_time,
  478. sop_id,
  479. finish_time,
  480. send_finish_msg,
  481. camp_period_time
  482. FROM
  483. fs_course_watch_log
  484. WHERE
  485. send_type = 1
  486. AND video_id = #{videoId}
  487. AND user_id = #{fsUserId}
  488. AND company_user_id = #{companyUserId} order by log_id desc limit 1
  489. </select>
  490. <select id="selectFsCourseWatchLogStatisticsListVONew"
  491. resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListVO">
  492. SELECT
  493. o.company_user_id,o.user_id,DATE(o.create_time) create_time,
  494. SUM(CASE WHEN o.log_type = '1' THEN 1 ELSE 0 END) AS type1,
  495. SUM(CASE WHEN o.log_type = '2' THEN 1 ELSE 0 END) AS type2,
  496. SUM(CASE WHEN o.log_type = '3' THEN 1 ELSE 0 END) AS type3,
  497. SUM(CASE WHEN o.log_type = '4' THEN 1 ELSE 0 END) AS type4,
  498. o.project as project,
  499. o.course_id as course_id,
  500. o.video_id as video_id
  501. FROM fs_course_watch_log o
  502. <where>
  503. send_type=1
  504. <if test="companyId != null">
  505. and o.company_id=#{companyId}
  506. </if>
  507. <if test= 'sTime != null '>
  508. and DATE(o.create_time) &gt;= #{sTime}
  509. </if>
  510. <if test='eTime != null '>
  511. and DATE(o.create_time) &lt;= #{eTime}
  512. </if>
  513. <if test ='courseId !=null'>
  514. and o.course_id = #{courseId}
  515. </if>
  516. <if test ='videoId !=null'>
  517. and o.video_id = #{videoId}
  518. </if>
  519. <if test="companyUserId != null">
  520. and o.company_user_id = #{companyUserId}
  521. </if>
  522. <if test="project != null">
  523. and o.project = #{project}
  524. </if>
  525. <if test="userId != null">
  526. and o.user_id = #{userId}
  527. </if>
  528. </where>
  529. GROUP BY o.video_id,o.user_id,DATE(o.create_time),o.project,o.course_id
  530. ORDER BY o.video_id ,DATE(o.create_time)
  531. <!-- limit ${(pageNum-1)*pageSize},${pageSize}-->
  532. </select>
  533. <select id="selectFsCourseWatchLogStatisticsListVONewCount" resultType="java.lang.Long">
  534. SELECT COUNT(*)
  535. FROM (
  536. SELECT 1
  537. FROM fs_course_watch_log o
  538. <where>
  539. send_type=2
  540. <if test="companyId != null">
  541. and o.company_id=#{companyId}
  542. </if>
  543. <if test= 'sTime != null '>
  544. and o.create_time &gt;= #{startDate}
  545. </if>
  546. <if test='eTime != null '>
  547. and o.create_time &lt;= #{endDate}
  548. </if>
  549. <if test ='courseId !=null'>
  550. and o.course_id = #{courseId}
  551. </if>
  552. <if test ='videoId !=null'>
  553. and o.video_id = #{videoId}
  554. </if>
  555. <if test="companyUserId != null">
  556. and o.company_user_id = #{companyUserId}
  557. </if>
  558. <if test="project != null">
  559. and o.project = #{project}
  560. </if>
  561. <if test="userId != null">
  562. and o.user_id = #{userId}
  563. </if>
  564. </where>
  565. GROUP BY o.video_id, o.user_id, DATE(o.create_time), o.project, o.course_id
  566. ) AS grouped_results_count
  567. </select>
  568. <!-- 根据条件查询条数 -->
  569. <select id="countByMap" resultType="java.lang.Integer">
  570. select count(fcwl.log_id) from fs_course_watch_log fcwl
  571. <where>
  572. <if test="params.logTypes != null and params.logTypes.size() > 0">
  573. and fcwl.log_type in
  574. <foreach collection="params.logTypes" open="(" close=")" separator="," item="logType">
  575. #{logType}
  576. </foreach>
  577. </if>
  578. <if test="params.companyUserId != null">
  579. and fcwl.company_user_id = #{params.companyUserId}
  580. </if>
  581. <if test="params.date != null">
  582. and date(fcwl.create_time) = #{params.date}
  583. </if>
  584. </where>
  585. </select>
  586. <update id="batchUpdateWatchLog" parameterType="java.util.List">
  587. UPDATE fs_course_watch_log
  588. SET
  589. duration = CASE
  590. <foreach collection="list" item="item" index="index">
  591. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  592. CASE
  593. <!-- 仅当传入的duration > 当前值时才更新 -->
  594. WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
  595. ELSE duration <!-- 如果 duration 为 null,保持原值 -->
  596. END
  597. </foreach>
  598. END,
  599. last_heartbeat_time = CASE
  600. <foreach collection="list" item="item" index="index">
  601. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  602. CASE
  603. WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
  604. ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
  605. END
  606. </foreach>
  607. END,
  608. finish_time = CASE
  609. <foreach collection="list" item="item" index="index">
  610. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  611. CASE
  612. WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
  613. ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
  614. END
  615. </foreach>
  616. END,
  617. log_type = CASE
  618. <foreach collection="list" item="item" index="index">
  619. WHEN video_id = #{item.videoId} AND qw_external_contact_id = #{item.qwExternalContactId} AND qw_user_id = #{item.qwUserId} THEN
  620. CASE
  621. WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
  622. WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
  623. ELSE log_type <!-- 其他情况保持原值 -->
  624. END
  625. </foreach>
  626. END
  627. WHERE
  628. (video_id, qw_external_contact_id, qw_user_id) IN
  629. <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
  630. (#{item.videoId}, #{item.qwExternalContactId}, #{item.qwUserId})
  631. </foreach>
  632. </update>
  633. <update id="batchUpdateWatchLogSendMsg" parameterType="java.util.List">
  634. UPDATE fs_course_watch_log
  635. SET send_finish_msg = CASE
  636. <foreach collection="list" item="item">
  637. WHEN log_id = #{item.logId} THEN #{item.sendFinishMsg}
  638. </foreach>
  639. ELSE send_finish_msg
  640. END
  641. WHERE log_id IN
  642. <foreach collection="list" item="item" open="(" separator="," close=")">
  643. #{item.logId}
  644. </foreach>
  645. </update>
  646. <update id="batchUpdateFsUserWatchLog" parameterType="java.util.List">
  647. UPDATE fs_course_watch_log
  648. SET
  649. duration = CASE
  650. <foreach collection="list" item="item" index="index">
  651. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
  652. CASE
  653. <!-- 仅当传入的duration > 当前值时才更新 -->
  654. WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
  655. ELSE duration <!-- 如果 duration 为 null,保持原值 -->
  656. END
  657. </foreach>
  658. END,
  659. last_heartbeat_time = CASE
  660. <foreach collection="list" item="item" index="index">
  661. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
  662. CASE
  663. WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
  664. ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
  665. END
  666. </foreach>
  667. END,
  668. finish_time = CASE
  669. <foreach collection="list" item="item" index="index">
  670. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
  671. CASE
  672. WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
  673. ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
  674. END
  675. </foreach>
  676. END,
  677. log_type = CASE
  678. <foreach collection="list" item="item" index="index">
  679. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} AND company_user_id = #{item.companyUserId} THEN
  680. CASE
  681. WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
  682. WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
  683. ELSE log_type <!-- 其他情况保持原值 -->
  684. END
  685. </foreach>
  686. END
  687. WHERE
  688. (video_id, user_id, company_user_id) IN
  689. <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
  690. (#{item.videoId}, #{item.userId}, #{item.companyUserId})
  691. </foreach>
  692. </update>
  693. <update id="batchUpdateWatchLogIsOpen">
  694. UPDATE fs_course_watch_log
  695. SET
  696. duration = CASE
  697. <foreach collection="list" item="item" index="index">
  698. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
  699. CASE
  700. <!-- 仅当传入的duration > 当前值时才更新 -->
  701. WHEN #{item.duration} IS NOT NULL AND #{item.duration} > duration THEN #{item.duration}
  702. ELSE duration <!-- 如果 duration 为 null,保持原值 -->
  703. END
  704. </foreach>
  705. END,
  706. last_heartbeat_time = CASE
  707. <foreach collection="list" item="item" index="index">
  708. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
  709. CASE
  710. WHEN #{item.lastHeartbeatTime} IS NOT NULL THEN #{item.lastHeartbeatTime}
  711. ELSE last_heartbeat_time <!-- 如果 last_heartbeat_time 为 null,保持原值 -->
  712. END
  713. </foreach>
  714. END,
  715. finish_time = CASE
  716. <foreach collection="list" item="item" index="index">
  717. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
  718. CASE
  719. WHEN finish_time IS NULL THEN #{item.finishTime} <!-- 如果表中 finish_time 为 null,更新为传入的值 -->
  720. ELSE finish_time <!-- 如果表中 finish_time 不为 null,保持原值 -->
  721. END
  722. </foreach>
  723. END,
  724. log_type = CASE
  725. <foreach collection="list" item="item" index="index">
  726. WHEN video_id = #{item.videoId} AND user_id = #{item.userId} THEN
  727. CASE
  728. WHEN log_type = 2 THEN log_type <!-- 如果 log_type 已经是 2,保持原值 -->
  729. WHEN #{item.logType} IS NOT NULL AND log_type != 2 THEN #{item.logType} <!-- 如果 log_type 不是 2,更新为传入的值 -->
  730. ELSE log_type <!-- 其他情况保持原值 -->
  731. END
  732. </foreach>
  733. END
  734. WHERE
  735. (video_id, user_id) IN
  736. <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
  737. (#{item.videoId}, #{item.userId})
  738. </foreach>
  739. </update>
  740. <select id="selectListBytrainingCampId" resultType="com.fs.course.vo.FsCourseWatchLogVO">
  741. select
  742. uc.course_name,v.title as video_name,
  743. watch.log_id,
  744. watch.user_id,
  745. watch.finish_time,
  746. watch.send_finish_msg,
  747. watch.sop_id,
  748. watch.video_id,
  749. watch.reward_type,
  750. watch.log_type,
  751. watch.create_time,
  752. watch.update_time,
  753. watch.qw_external_contact_id,
  754. watch.duration,
  755. watch.qw_user_id,
  756. watch.company_user_id,
  757. watch.company_id,
  758. watch.course_id,
  759. watch.camp_period_time
  760. from
  761. fs_user_course_training_camp camp
  762. left join fs_user_course_period period on
  763. camp.training_camp_id = period.training_camp_id
  764. left join fs_course_watch_log watch on
  765. period.period_id = watch.period_id
  766. left join fs_user_course uc on uc.course_id = watch.course_id
  767. left join fs_user_course_video v on v.video_id = watch.video_id
  768. <where>
  769. `period`.del_flag = '0' and watch.log_type &lt;&gt; 3
  770. <if test="trainingCampId != null">and camp.training_camp_id = #{trainingCampId}</if>
  771. <if test="userId != null">and watch.user_id = #{userId}</if>
  772. <if test="periodId != null">and `period`.period_id = #{periodId}</if>
  773. </where>
  774. </select>
  775. <select id="selectFsCourseWatchLogListVOexport" resultType="com.fs.course.vo.FsCourseWatchLogListVO">
  776. SELECT
  777. l.log_id,
  778. l.project AS project,
  779. l.period_id,
  780. l.user_id,
  781. l.log_type,
  782. SEC_TO_TIME(l.duration) AS duration,
  783. l.camp_period_time,
  784. l.finish_time,
  785. l.send_type,
  786. l.create_time,
  787. l.update_time,
  788. l.last_heartbeat_time,
  789. l.company_id,
  790. l.company_user_id,
  791. l.course_id,
  792. l.video_id,
  793. l.qw_user_id,
  794. l.qw_external_contact_id,
  795. l.sop_id,
  796. qec.create_time as qec_create_time
  797. FROM
  798. fs_course_watch_log l LEFT JOIN qw_external_contact qec on l.qw_external_contact_id = qec.id
  799. left join fs_user u on u.user_id = l.user_id
  800. left join company_user cu on cu.user_id = l.company_user_id
  801. <where>
  802. <if test ='maps.sendType !=null'>
  803. and l.send_type = #{maps.sendType}
  804. </if>
  805. <if test ='maps.userId !=null'>
  806. and l.user_id = #{maps.userId}
  807. </if>
  808. <if test ='maps.qwExternalContactId !=null'>
  809. and l.qw_external_contact_id = #{maps.qwExternalContactId}
  810. </if>
  811. <if test ='maps.qwUserId !=null'>
  812. and l.qw_user_id = #{maps.qwUserId}
  813. </if>
  814. <if test ='maps.courseId !=null'>
  815. and l.course_id = #{maps.courseId}
  816. </if>
  817. <if test ='maps.videoId !=null'>
  818. and l.video_id = #{maps.videoId}
  819. </if>
  820. <if test ='maps.logType !=null'>
  821. and l.log_type = #{maps.logType}
  822. </if>
  823. <if test ='maps.companyId !=null'>
  824. and l.company_id = #{maps.companyId}
  825. </if>
  826. <if test ='maps.companyUserId !=null'>
  827. and l.company_user_id = #{maps.companyUserId}
  828. </if>
  829. <if test ='maps.companyUserName !=null and maps.companyUserName!=""'>
  830. and cu.nick_name like concat('%', #{maps.companyUserName}, '%')
  831. </if>
  832. <if test ='maps.nickName !=null and maps.nickName!=""'>
  833. and u.nick_name like concat('%', #{maps.nickName}, '%')
  834. </if>
  835. <if test ='maps.externalUserName !=null and maps.externalUserName!=""'>
  836. and qec.name like concat('%', #{maps.externalUserName}, '%')
  837. </if>
  838. <if test= 'maps.qecSTime != null '>
  839. and DATE(qec.create_time) &gt;= DATE(#{maps.qecSTime})
  840. </if>
  841. <if test='maps.qecETime != null '>
  842. and DATE(qec.create_time) &lt;= DATE(#{maps.qecETime})
  843. </if>
  844. <if test= 'maps.sTime != null '>
  845. and DATE(l.create_time) &gt;= DATE(#{maps.sTime})
  846. </if>
  847. <if test='maps.eTime != null '>
  848. and DATE(l.create_time) &lt;= DATE(#{maps.eTime})
  849. </if>
  850. <if test= 'maps.scheduleStartTime != null '>
  851. and DATE(l.camp_period_time) &gt;= DATE(#{maps.scheduleStartTime})
  852. </if>
  853. <if test='maps.scheduleEndTime != null '>
  854. and DATE(l.camp_period_time) &lt;= DATE(#{maps.scheduleEndTime})
  855. </if>
  856. <if test= 'maps.upSTime != null '>
  857. and DATE(l.update_time) &gt;= DATE(#{maps.upSTime})
  858. </if>
  859. <if test='maps.upETime != null '>
  860. and DATE(l.update_time) &lt;= DATE(#{maps.upETime})
  861. </if>
  862. <if test="maps.sopIds != null and maps.sopIds.size() > 0">
  863. and l.sop_id in
  864. <foreach item="sopId" index="index" collection="maps.sopIds" open="(" separator="," close=")">
  865. #{sopId}
  866. </foreach>
  867. </if>
  868. <if test="maps.periodIds != null and maps.periodIds.size() > 0">
  869. and l.period_id in
  870. <foreach item="periodId" index="index" collection="maps.periodIds" open="(" separator="," close=")">
  871. #{periodId}
  872. </foreach>
  873. </if>
  874. </where>
  875. order by l.finish_time desc,l.update_time desc,l.create_time desc
  876. </select>
  877. <select id="getWatchCourseByVideoId" resultType="com.fs.course.domain.FsCourseWatchLog">
  878. SELECT
  879. *
  880. FROM
  881. fs_course_watch_log
  882. WHERE
  883. send_type = 1
  884. AND video_id = #{videoId}
  885. AND user_id in
  886. <foreach item="userId" index="index" collection="userIds" open="(" separator="," close=")">
  887. #{userId}
  888. </foreach>
  889. ORDER BY
  890. log_id DESC
  891. </select>
  892. <select id="getUserCountByCampId" resultType="java.lang.Integer">
  893. select count(distinct cwl.user_id)
  894. from fs_user_course_period ucp
  895. inner join fs_course_watch_log cwl on ucp.period_id = cwl.period_id
  896. where ucp.training_camp_id = #{trainingCampId}
  897. </select>
  898. <select id="selectFsCourseWatchLogStatisticsListByCompanyVO"
  899. resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListByCompanyVO">
  900. SELECT
  901. o.video_id,
  902. o.company_id,
  903. comp.company_name,
  904. o.qw_user_id,
  905. DATE(o.create_time) create_time,
  906. v.title videoName,
  907. uc.course_name,
  908. SUM(CASE WHEN o.log_type = '1' THEN 1 ELSE 0 END) AS type1,
  909. SUM(CASE WHEN o.log_type = '2' THEN 1 ELSE 0 END) AS type2,
  910. SUM(CASE WHEN o.log_type = '3' THEN 1 ELSE 0 END) AS type3,
  911. SUM(CASE WHEN o.log_type = '4' THEN 1 ELSE 0 END) AS type4
  912. FROM
  913. fs_course_watch_log o
  914. LEFT JOIN fs_user_course_video v ON v.video_id = o.video_id
  915. LEFT JOIN company comp ON comp.company_id = o.company_id
  916. LEFT JOIN qw_user qu ON qu.id = o.qw_user_id
  917. LEFT JOIN fs_user_course uc ON uc.course_id = v.course_id
  918. <where>
  919. <if test="sendType != null">
  920. and send_type = #{sendType}
  921. </if>
  922. <if test="companyId != null">
  923. and o.company_id = #{companyId}
  924. </if>
  925. <if test="sTime != null">
  926. AND DATE (o.create_time) &gt;= DATE (#{sTime})
  927. </if>
  928. <if test="eTime != null">
  929. AND DATE (o.create_time) &lt;= DATE (#{eTime})
  930. </if>
  931. <if test="courseId != null">
  932. and o.course_id = #{courseId}
  933. </if>
  934. <if test="videoId != null">
  935. and o.video_id = #{videoId}
  936. </if>
  937. </where>
  938. GROUP BY
  939. DATE (o.create_time),
  940. o.company_id
  941. ORDER BY
  942. comp.company_id,
  943. DATE (o.create_time)
  944. </select>
  945. <select id="selectQwFsCourseWatchLogStatisticsListVO"
  946. resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListVO" parameterType="com.fs.qw.param.QwSidebarStatsParam">
  947. SELECT
  948. o.project,
  949. o.course_id AS courseId,
  950. uc.course_name AS courseName,
  951. o.video_id AS videoId,
  952. v.title AS videoName,
  953. CASE WHEN o.log_type = 1 THEN 1 END AS type1,
  954. CASE WHEN o.log_type = 2 THEN 1 END AS type2,
  955. CASE WHEN o.log_type = 3 THEN 1 END AS type3,
  956. CASE WHEN o.log_type = 4 THEN 1 END AS type4,
  957. o.qw_user_id,
  958. o.user_id AS userId,
  959. o.company_user_id AS companyUserId,
  960. o.company_id AS companyId,
  961. o.create_time AS createTime
  962. FROM
  963. fs_course_watch_log o
  964. LEFT JOIN fs_user_course_video v ON v.video_id = o.video_id
  965. LEFT JOIN fs_user_course uc ON uc.course_id = v.course_id
  966. WHERE o.qw_external_contact_id=#{qwExternalContactId}
  967. <if test="sendType != null">
  968. AND send_type = #{sendType}
  969. </if>
  970. <if test="startTime != null">
  971. AND DATE(o.create_time) &gt;= DATE(#{startTime})
  972. </if>
  973. <if test="endTime != null">
  974. AND DATE(o.create_time) &lt;= DATE(#{endTime})
  975. </if>
  976. o.create_time DESC
  977. </select>
  978. <!-- 统计当天各公司的观看人数和完播人数, 存到redis中,定时任务每 ? 分钟执行一次 -->
  979. <select id="watchCourseStatisticsGroupByCompany" resultType="com.fs.statis.dto.WatchCourseStatisticsResultDTO">
  980. SELECT
  981. o.company_id AS companyId,
  982. c.company_name AS companyName,
  983. o.send_type,
  984. COUNT(DISTINCT o.user_id) AS watchUserCount,
  985. COUNT(o.log_id) AS watchCount,
  986. sum(case when o.log_type = 2 then 1 else 0 end) AS finishCount,
  987. COUNT(DISTINCT CASE WHEN o.log_type = 2 THEN o.user_id END) AS finishUserCount
  988. FROM
  989. fs_course_watch_log o
  990. LEFT JOIN company c ON c.company_id = o.company_id
  991. WHERE
  992. o.create_time &gt;= #{params.startTime}
  993. AND o.create_time &lt;= #{params.endTime}
  994. GROUP BY
  995. o.company_id,
  996. o.send_type
  997. </select>
  998. <select id="getWatchCourseByVideoId" resultType="com.fs.course.domain.FsCourseWatchLog">
  999. SELECT
  1000. *
  1001. FROM
  1002. fs_course_watch_log
  1003. WHERE
  1004. send_type = 1
  1005. AND video_id = #{videoId}
  1006. AND user_id in
  1007. <foreach item="userId" index="index" collection="userIds" open="(" separator="," close=")">
  1008. #{userId}
  1009. </foreach>
  1010. ORDER BY
  1011. log_id DESC
  1012. </select>
  1013. </mapper>