MxjbStudyMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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.ruoyi.mxjb.mapper.MxjbStudyMapper">
  6. <resultMap type="MxjbStudyStat" id="MxjbStudyStatResult">
  7. <result property="time" column="time" />
  8. <result property="id" column="id" />
  9. <result property="count" column="cnt" />
  10. <result property="cardNo" column="card_no" />
  11. <result property="account" column="account" />
  12. <result property="title" column="title" />
  13. <result property="school" column="school" />
  14. <result property="gradeName" column="grade_name" />
  15. <result property="className" column="class_name" />
  16. <result property="videoCount" column="video_count" />
  17. <result property="videoAvgTime" column="video_avg_time" />
  18. <result property="microClassCount" column="micro_class_count" />
  19. <result property="microClassTime" column="micro_class_time" />
  20. <result property="questionCount" column="question_count" />
  21. <result property="questionTime" column="question_time" />
  22. <result property="scoreRate" column="scoreRate" />
  23. <result property="workCount" column="work_count" />
  24. <result property="workRate" column="work_rate" />
  25. </resultMap>
  26. <select id="selectStudyLoginStatByStudent" parameterType="map" resultMap="MxjbStudyStatResult">
  27. SELECT max(l.login_time) `time`, sum(IF(l.msg = '登录成功', 1, 0)) cnt
  28. FROM sys_user u
  29. JOIN sys_logininfor l ON u.user_name = SUBSTRING_INDEX(l.user_name, ':', -1)
  30. AND l.msg IN ('退出成功', '登录成功') AND l.status = 0
  31. <where>
  32. <if test="userId != null "> and u.`user_id` = #{userId}</if>
  33. <if test="beginTime != null "> and l.login_time &gt;= #{beginTime}</if>
  34. <if test="endTime != null "> and l.login_time &lt; #{endTime}</if>
  35. </where>
  36. ORDER BY l.login_time DESC
  37. </select>
  38. <select id="selectStudyRegisters" parameterType="map" resultMap="MxjbStudyStatResult">
  39. SELECT cc.`schoolId` id, s.`name` school, COUNT(*) cnt
  40. FROM `b_customer_class` cc
  41. JOIN `b_busi_schools` s ON cc.`schoolId` = s.`id`
  42. <where> cc.`type` = 3
  43. <if test="schoolId != null "> and cc.schoolId = #{schoolId}</if>
  44. <if test="gradeId != null "> and cc.gradeId = #{gradeId}</if>
  45. <if test="classId != null ">and cc.classId in <foreach item="s" collection="classId" open="(" separator="," close=")">#{s}</foreach></if>
  46. </where>
  47. GROUP BY s.`id`, s.`name`
  48. </select>
  49. <select id="selectStudyVideoByStudent" parameterType="map" resultMap="MxjbStudyStatResult">
  50. SELECT s.`name` school, bc.`name` class_name, cb.`name` account, cvw.`time`, cvw.`title`, cvw.`course` card_no, cvw.`time`, ROUND(IF(cvw.duration * cvw.percent &lt; 6000, 6000, cvw.duration * cvw.percent) / 100) video_avg_time
  51. FROM `b_customer_class` cc
  52. JOIN b_customer_video_watches cvw ON cvw.customerCode = cc.`customerCode`
  53. JOIN `b_busi_schools` s ON cc.`schoolId` = s.`id`
  54. JOIN `b_customer_basic` cb ON cb.`code` = cc.`customerCode`
  55. JOIN `b_busi_classes` bc ON bc.`id` = cc.`classId`
  56. <where> cc.`type` = 3
  57. <if test="schoolId != null "> and cc.`schoolId` = #{schoolId}</if>
  58. <if test="customerCode != null "> and cc.`customerCode` = #{customerCode}</if>
  59. <if test="gradeId != null "> and cc.gradeId = #{gradeId}</if>
  60. <if test="classId != null "> and cc.classId in <foreach item="s" collection="classId" open="(" separator="," close=")">#{s}</foreach></if>
  61. <if test="types != null "> and cvw.type IN <foreach item="v" collection="types" open="(" separator="," close=")">#{v}</foreach></if>
  62. <if test="beginTime != null "> and cvw.time &gt;= #{beginTime}</if>
  63. <if test="endTime != null "> and cvw.time &lt; #{endTime}</if>
  64. </where>
  65. </select>
  66. <select id="selectSchoolQuestionByStudent" parameterType="map" resultMap="MxjbStudyStatResult">
  67. SELECT s.`name` school, bc.`name` class_name, cb.`name` account, ab.`courseName` card_no, SUM(ab.rights) video_count, SUM(ab.wrongs) question_count
  68. FROM `b_customer_class` cc
  69. JOIN mxjb_customer_answer_batches ab ON ab.customerCode = cc.`customerCode`
  70. JOIN `b_busi_schools` s ON cc.`schoolId` = s.`id`
  71. JOIN `b_customer_basic` cb ON cb.`code` = cc.`customerCode`
  72. JOIN `b_busi_classes` bc ON bc.`id` = cc.`classId`
  73. <where> cc.`type` = 3
  74. <if test="schoolId != null "> and cc.`schoolId` = #{schoolId}</if>
  75. <if test="customerCode != null "> and cc.`customerCode` = #{customerCode}</if>
  76. <if test="gradeId != null "> and cc.gradeId = #{gradeId}</if>
  77. <if test="classId != null "> and cc.classId in <foreach item="s" collection="classId" open="(" separator="," close=")">#{s}</foreach></if>
  78. <if test="beginTime != null "> and ab.day &gt;= #{beginTime}</if>
  79. <if test="endTime != null "> and ab.day &lt; #{endTime}</if>
  80. </where>
  81. GROUP BY s.`name`, cb.`name`, bc.`name`, ab.`courseName`
  82. </select>
  83. <select id="selectStudyLogins" parameterType="map" resultMap="MxjbStudyStatResult">
  84. SELECT l.login_time `time`, u.`user_name` account, IF(l.msg = '登录成功', 1, 0) cnt
  85. FROM sys_user u
  86. JOIN sys_logininfor l ON u.user_name = SUBSTRING_INDEX(l.user_name, ':', -1)
  87. AND l.msg IN ('退出成功', '登录成功') AND l.status = 0
  88. <where>
  89. <if test="userId != null "> and u.`user_id` = #{userId}</if>
  90. <if test="beginTime != null "> and l.login_time &gt;= #{beginTime}</if>
  91. <if test="endTime != null "> and l.login_time &lt; #{endTime}</if>
  92. </where>
  93. ORDER BY l.login_time DESC
  94. </select>
  95. <select id="selectStudyVideos" parameterType="map" resultMap="MxjbStudyStatResult">
  96. SELECT cc.`schoolId` id, COUNT(*) video_count, ROUND(SUM(IF(cvw.duration * cvw.percent &lt; 6000, 6000, cvw.duration * cvw.percent)) / 100 ) video_avg_time, COUNT(DISTINCT cc.customerCode) cnt
  97. FROM b_customer_class cc
  98. JOIN b_customer_video_watches cvw ON cvw.customerCode = cc.customerCode
  99. <where> cc.type = 3
  100. <if test="schoolId != null "> and cc.schoolId = #{schoolId}</if>
  101. <if test="gradeId != null "> and cc.gradeId = #{gradeId}</if>
  102. <if test="classId != null ">and cc.classId in <foreach item="s" collection="classId" open="(" separator="," close=")">#{s}</foreach></if>
  103. <if test="types != null "> and cvw.type IN <foreach item="v" collection="types" open="(" separator="," close=")">#{v}</foreach></if>
  104. <if test="course != null "> and cvw.course = #{course}</if>
  105. <if test="beginTime != null "> and cvw.time &gt;= #{beginTime}</if>
  106. <if test="endTime != null "> and cvw.time &lt;= #{endTime}</if>
  107. </where>
  108. GROUP BY cc.`schoolId`
  109. </select>
  110. <select id="selectStudyQuestions" parameterType="map" resultMap="MxjbStudyStatResult">
  111. SELECT cc.`schoolId` id, SUM(ab.rights) video_count, SUM(ab.wrongs) question_count, SUM(ab.seconds) question_time, COUNT(DISTINCT cc.customerCode) cnt
  112. FROM b_customer_class cc
  113. JOIN mxjb_customer_answer_batches ab ON ab.customerCode = cc.customerCode
  114. <where> cc.type = 3
  115. <if test="schoolId != null "> and cc.schoolId = #{schoolId}</if>
  116. <if test="gradeId != null "> and cc.gradeId = #{gradeId}</if>
  117. <if test="classId != null ">and cc.classId in <foreach item="s" collection="classId" open="(" separator="," close=")">#{s}</foreach></if>
  118. <if test="course != null "> and ab.courseName = #{course}</if>
  119. <if test="beginTime != null "> and ab.day &gt;= #{beginTime}</if>
  120. <if test="endTime != null "> and ab.day &lt; #{endTime}</if>
  121. </where>
  122. GROUP BY cc.`schoolId`
  123. </select>
  124. <select id="selectStudyVideoByCourse" parameterType="map" resultMap="MxjbStudyStatResult">
  125. SELECT cvw.course account, COUNT(DISTINCT cc.customerCode) cnt, COUNT(*) video_count, ROUND(SUM(IF(cvw.duration * cvw.percent &lt; 6000, 6000, cvw.duration * cvw.percent)) / 100) video_avg_time
  126. FROM b_customer_class cc
  127. JOIN b_customer_video_watches cvw ON cvw.customerCode = cc.customerCode
  128. <where> cc.type = 3
  129. <if test="schoolId != null "> and cc.schoolId = #{schoolId}</if>
  130. <if test="gradeId != null "> and cc.gradeId = #{gradeId}</if>
  131. <if test="classId != null ">and cc.classId in <foreach item="s" collection="classId" open="(" separator="," close=")">#{s}</foreach></if>
  132. <if test="types != null "> and cvw.type IN <foreach item="v" collection="types" open="(" separator="," close=")">#{v}</foreach></if>
  133. <if test="course != null "> and cvw.course = #{course}</if>
  134. <if test="beginTime != null "> and cvw.time &gt;= #{beginTime}</if>
  135. <if test="endTime != null "> and cvw.time &lt; #{endTime}</if>
  136. </where>
  137. GROUP BY cvw.course
  138. </select>
  139. <select id="selectStudyQuestionByCourse" parameterType="map" resultMap="MxjbStudyStatResult">
  140. SELECT ab.courseName account, COUNT(DISTINCT cc.customerCode) cnt, SUM(ab.rights) video_count, SUM(ab.wrongs) question_count, SUM(ab.seconds) question_time
  141. FROM b_customer_class cc
  142. JOIN mxjb_customer_answer_batches ab ON ab.customerCode = cc.customerCode
  143. <where> cc.type = 3
  144. <if test="schoolId != null "> and cc.schoolId = #{schoolId}</if>
  145. <if test="gradeId != null "> and cc.gradeId = #{gradeId}</if>
  146. <if test="classId != null ">and cc.classId in <foreach item="s" collection="classId" open="(" separator="," close=")">#{s}</foreach></if>
  147. <if test="course != null "> and ab.courseName = #{course}</if>
  148. <if test="beginTime != null "> and ab.day &gt;= #{beginTime}</if>
  149. <if test="endTime != null "> and ab.day &lt; #{endTime}</if>
  150. </where>
  151. GROUP BY ab.courseName
  152. </select>
  153. <select id="selectStudyVideoDetails" parameterType="map" resultMap="MxjbStudyStatResult">
  154. SELECT cvw.time, cvw.course class_name, cvw.title card_no, ROUND(IF(cvw.duration * cvw.percent &lt; 6000, 6000, cvw.duration * cvw.percent) / 100) video_avg_time
  155. FROM b_customer_video_watches cvw
  156. <where> cvw.customerCode = #{customerCode}
  157. <if test="types != null "> and cvw.type IN <foreach item="v" collection="types" open="(" separator="," close=")">#{v}</foreach></if>
  158. <if test="beginTime != null "> and cvw.time &gt;= #{beginTime}</if>
  159. <if test="endTime != null "> and cvw.time &lt; #{endTime}</if>
  160. </where>
  161. </select>
  162. <select id="selectStudyQuestionDetails" parameterType="map" resultMap="MxjbStudyStatResult">
  163. SELECT ab.day `time`, ab.courseName class_name, a.questionId account, q.title card_no, ab.source school, a.seconds question_time, IF(a.answer = a.correct, 1, 0) scoreRate
  164. FROM mxjb_customer_answers a
  165. JOIN mxjb_customer_answer_batches ab ON a.customerCode = ab.customerCode AND a.batchNo = ab.batchNo
  166. JOIN questions q ON q.id = a.questionId
  167. <where> a.customerCode = #{customerCode}
  168. <if test="beginTime != null "> and ab.day &gt;= #{beginTime}</if>
  169. <if test="endTime != null "> and ab.day &lt; #{endTime}</if>
  170. </where>
  171. </select>
  172. <select id="selectStudyVideoTotal" parameterType="map" resultMap="MxjbStudyStatResult">
  173. SELECT count(*) cnt, ROUND(sum(IF(cvw.duration * cvw.percent &lt; 6000, 6000, cvw.duration * cvw.percent)) / 100) video_avg_time
  174. FROM b_customer_video_watches cvw
  175. <where> cvw.customerCode = #{customerCode}
  176. <if test="types != null "> and cvw.type IN <foreach item="v" collection="types" open="(" separator="," close=")">#{v}</foreach></if>
  177. <if test="beginTime != null "> and cvw.time &gt;= #{beginTime}</if>
  178. <if test="endTime != null "> and cvw.time &lt; #{endTime}</if>
  179. </where>
  180. </select>
  181. <select id="selectStudyQuestionTotal" parameterType="map" resultMap="MxjbStudyStatResult">
  182. SELECT COUNT(DISTINCT e.`examinee_id`) cnt, SUM(a.`duration`)
  183. FROM `mxjb_paper_examinee` e
  184. JOIN `mxjb_paper_answers` a ON a.`examinee_id` = e.`examinee_id`
  185. <where> e.`state` > 3 and e.`customer_code` = #{customerCode}
  186. <if test="beginTime != null "> and e.`end_time` &gt;= #{beginTime}</if>
  187. <if test="endTime != null "> and e.`begin_time` &lt;= #{endTime}</if>
  188. </where>
  189. </select>
  190. <select id="selectMxjbStudyStatList" parameterType="MxjbStudyStatCond" resultMap="MxjbStudyStatResult">
  191. SELECT cc.customerCode id, c.cardNo card_no, CONCAT(cb.name, '_' , cb.username) account, bs.name school, g.gradeName grade_name, bc.name class_name
  192. , t1.video_count, t1.video_avg_time, t5.micro_class_count, t5.micro_class_time, t2.question_count, t2.scoreRate, t3.work_count, t4.work_rate
  193. FROM b_busi_schools bs
  194. JOIN b_busi_classes bc ON bc.schoolId = bs.id
  195. JOIN b_customer_class cc ON cc.classId = bc.id
  196. JOIN b_busi_cards c ON c.customerCode = cc.customerCode
  197. JOIN b_customer_basic cb ON cb.code = cc.customerCode
  198. JOIN grade g ON g.gradeId = cc.gradeId
  199. LEFT JOIN ( SELECT cvw.customerCode, COUNT(section_id) video_count, ROUND(sum(IF(cvw.duration is null, 0, IF(cvw.duration * cvw.percent &lt; 6000, 6000, cvw.duration * cvw.percent))) / 100 / 60) video_avg_time FROM b_customer_video_watches cvw
  200. WHERE cvw.type IN (1, 12)
  201. <if test="begin != null "> and cvw.time &gt;= #{begin}</if>
  202. <if test="end != null "> and cvw.time &lt;= #{end}</if>
  203. GROUP BY cvw.customerCode ) t1 ON t1.customerCode = cc.customerCode
  204. LEFT JOIN ( SELECT cvw.customerCode, COUNT(section_id) micro_class_count, ROUND(sum(IF(cvw.duration is null, 0, IF(cvw.duration * cvw.percent &lt; 6000, 6000, cvw.duration * cvw.percent))) / 100 / 60) micro_class_time FROM b_customer_video_watches cvw
  205. WHERE cvw.type IN (2, 3, 4, 5, 6, 7, 8, 9, 10)
  206. <if test="begin != null "> and cvw.time &gt;= #{begin}</if>
  207. <if test="end != null "> and cvw.time &lt;= #{end}</if>
  208. GROUP BY cvw.customerCode ) t5 ON t5.customerCode = cc.customerCode
  209. LEFT JOIN ( SELECT ab.customerCode, IFNULL(SUM(rights+wrongs),0) question_count, ROUND(SUM(rate)/COUNT(1)) scoreRate FROM mxjb_customer_answer_batches ab where 1 = 1
  210. <if test="begin != null "> and ab.day &gt;= #{begin}</if>
  211. <if test="end != null "> and ab.day &lt;= #{end}</if>
  212. GROUP BY ab.customerCode ) t2 ON t2.customerCode = cc.customerCode
  213. LEFT JOIN ( SELECT ch.customerCode, COUNT(*) work_count FROM b_customer_homework ch WHERE ch.status > 0
  214. <if test="begin != null "> and ch.createTime &gt;= #{begin}</if>
  215. <if test="end != null "> and ch.createTime &lt;= #{end}</if>
  216. GROUP BY ch.customerCode ) t3 ON t3.customerCode = cc.customerCode
  217. LEFT JOIN ( SELECT chs.customerCode, ROUND(SUM(IF(chs.answer = chs.correct, 1, 0)) * 100 / COUNT(*)) work_rate FROM b_customer_homework_answers chs
  218. GROUP BY chs.customerCode ) t4 ON t4.customerCode = cc.customerCode
  219. <where> cc.status > 0 and cc.type = 3 AND c.status > 0 AND (t1.customerCode IS NOT NULL OR t2.customerCode IS NOT NULL OR t3.customerCode IS NOT NULL OR t4.customerCode IS NOT NULL)
  220. <if test="schoolId != null "> and bs.id = #{schoolId}</if>
  221. <if test="cardNo != null "> and c.cardNo like concat('%', #{cardNo},'%')</if>
  222. <if test="gradeId != null "> and cb.greadId = #{gradeId}</if>
  223. </where>
  224. order by c.cardNo
  225. </select>
  226. </mapper>