ClassGradeUserMapper.xml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  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.zhongzheng.modules.grade.mapper.ClassGradeUserMapper">
  6. <resultMap type="com.zhongzheng.modules.grade.domain.ClassGradeUser" id="ClassGradeUserResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="gradeId" column="grade_id"/>
  10. <result property="status" column="status"/>
  11. <result property="createTime" column="create_time"/>
  12. <result property="updateTime" column="update_time"/>
  13. <result property="fromType" column="from_type"/>
  14. <result property="orderGoodsId" column="order_goods_id"/>
  15. </resultMap>
  16. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserVo" id="ClassGradeUserVoResult">
  17. <result property="id" column="id"/>
  18. <result property="userId" column="user_id"/>
  19. <result property="gradeId" column="grade_id"/>
  20. <result property="status" column="status"/>
  21. <result property="code" column="user_account"/>
  22. <result property="realName" column="realname"/>
  23. <result property="idCard" column="id_card"/>
  24. <result property="createBy" column="create_by"/>
  25. <result property="telPhone" column="telphone"/>
  26. </resultMap>
  27. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserGoodsVo" id="ClassGradeUserGoodsVoResult">
  28. <result property="id" column="id"/>
  29. <result property="userId" column="user_id"/>
  30. <result property="gradeId" column="grade_id"/>
  31. <result property="status" column="status"/>
  32. <result property="goodsCode" column="goods_code"/>
  33. <result property="goodsName" column="goods_name"/>
  34. <result property="gradeStatus" column="grade_status"/>
  35. <result property="gradeCode" column="grade_code"/>
  36. <result property="gradeName" column="grade_name"/>
  37. <result property="year" column="year"/>
  38. <result property="educationName" column="education_name"/>
  39. <result property="projectName" column="project_name"/>
  40. <result property="businessName" column="business_name"/>
  41. <result property="schoolName" column="school_name"/>
  42. <result property="createTime" column="create_time"/>
  43. <result property="createBy" column="create_by"/>
  44. <result property="goodsId" column="goods_id"/>
  45. <result property="classStartTime" column="class_start_time"/>
  46. <result property="classEndTime" column="class_end_time"/>
  47. </resultMap>
  48. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodStudentVo" id="ClassPeriodStudentVo">
  49. <result property="userId" column="user_id"/>
  50. <result property="gradeId" column="grade_id"/>
  51. <result property="studentCode" column="user_account"/>
  52. <result property="realName" column="realname"/>
  53. <result property="idCard" column="id_card"/>
  54. <result property="telPhone" column="telphone"/>
  55. <result property="status" column="status"/>
  56. <result property="classHours" column="class_hours"/>
  57. <result property="periodStatus" column="period_status"/>
  58. <result property="secAllNum" column="sec_all_num"/>
  59. <result property="examNum" column="exam_num"/>
  60. <result property="recordNum" column="record_num"/>
  61. <result property="periodPlush" column="period_plush"/>
  62. <result property="startTime" column="start_time"/>
  63. <result property="endTime" column="end_time"/>
  64. <result property="studyStartTime" column="study_start_time"/>
  65. <result property="studyEndTime" column="study_end_time"/>
  66. <result property="rebuildNum" column="rebuild_num"/>
  67. </resultMap>
  68. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodUserVo" id="ClassPeriodUserVo">
  69. <result property="userId" column="user_id"/>
  70. <result property="studentCode" column="user_account"/>
  71. <result property="realName" column="realname"/>
  72. <result property="oneInchPhotos" column="one_inch_photos"/>
  73. <result property="idCardImg1" column="id_card_img1"/>
  74. <result property="idCardImg2" column="id_card_img2"/>
  75. <result property="idCard" column="id_card"/>
  76. <result property="telPhone" column="telphone"/>
  77. <result property="secAllNum" column="sec_all_num"/>
  78. <result property="examNum" column="exam_num"/>
  79. <result property="recordNum" column="record_num"/>
  80. <result property="pass" column="pass"/>
  81. <result property="cheat" column="cheat"/>
  82. <result property="examPass" column="exam_pass"/>
  83. <result property="examCheat" column="exam_cheat"/>
  84. <result property="keyValue" column="key_value"/>
  85. </resultMap>
  86. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodVo" id="ClassPeriodVo">
  87. <result property="userId" column="user_id"/>
  88. <result property="id" column="id"/>
  89. <result property="typeName" column="type_name"/>
  90. <result property="realName" column="realname"/>
  91. <result property="classHours" column="class_hours"/>
  92. <result property="studyStartTime" column="study_start_time"/>
  93. <result property="status" column="status"/>
  94. <result property="auditTime" column="audit_time"/>
  95. <result property="type" column="type"/>
  96. <result property="courseId" column="course_id"/>
  97. <result property="studyEndTime" column="study_end_time"/>
  98. </resultMap>
  99. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodChapterVo" id="ClassPeriodChapterVo">
  100. <result property="userId" column="user_id"/>
  101. <result property="id" column="id"/>
  102. <result property="courseId" column="course_id"/>
  103. <result property="typeName" column="type_name"/>
  104. <result property="realName" column="realname"/>
  105. <result property="classHours" column="class_hours"/>
  106. <result property="studyStartTime" column="study_start_time"/>
  107. <result property="status" column="status"/>
  108. <result property="auditTime" column="audit_time"/>
  109. <result property="type" column="type"/>
  110. <result property="studyEndTime" column="study_end_time"/>
  111. <result property="performance" column="performance"/>
  112. </resultMap>
  113. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodSectionVo" id="ClassPeriodSectionVo">
  114. <result property="userId" column="user_id"/>
  115. <result property="id" column="id"/>
  116. <result property="typeName" column="type_name"/>
  117. <result property="realName" column="realname"/>
  118. <result property="classHours" column="class_hours"/>
  119. <result property="studyStartTime" column="study_start_time"/>
  120. <result property="status" column="status"/>
  121. <result property="auditTime" column="audit_time"/>
  122. <result property="type" column="type"/>
  123. <result property="studyEndTime" column="study_end_time"/>
  124. <result property="auditNum" column="audit_num"/>
  125. </resultMap>
  126. <select id="select" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  127. resultMap="ClassGradeUserVoResult">
  128. SELECT
  129. g.*,
  130. u.user_account,
  131. u.realname,
  132. u.id_card,
  133. u.telphone
  134. FROM
  135. class_grade_user g
  136. LEFT JOIN `user` u ON g.user_id = u.user_id
  137. WHERE
  138. 1 = 1
  139. <if test="status != null and status.size()!=0 ">
  140. AND g.status in
  141. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  142. #{item}
  143. </foreach>
  144. </if>
  145. <if test="gradeId != null and gradeId != ''">
  146. AND g.grade_id = #{gradeId}
  147. </if>
  148. <if test="userId != null and userId != ''">
  149. AND g.user_id = #{userId}
  150. </if>
  151. <if test="classStartTime != null or classEndTime != null ">
  152. AND #{classStartTime} BETWEEN g.class_start_time
  153. </if>
  154. order by g.update_time desc
  155. </select>
  156. <select id="listUser" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  157. resultMap="ClassGradeUserGoodsVoResult">
  158. SELECT
  159. * ,
  160. (select `code` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  161. u.grade_id) as goods_code,
  162. (select `year` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  163. u.grade_id) as year,
  164. (select goods_name FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  165. u.grade_id) as goods_name,
  166. (select b.business_name FROM course_business b LEFT JOIN goods g on b.id = g.business_id LEFT JOIN
  167. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as business_name,
  168. (select b.project_name FROM course_project_type b LEFT JOIN goods g on b.id = g.project_id LEFT JOIN
  169. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as project_name,
  170. (select b.school_name FROM school b LEFT JOIN goods g on b.id = g.school_id LEFT JOIN class_grade_goods c on
  171. g.goods_id = c.goods_id where c.grade_id = u.grade_id) as school_name,
  172. (select b.education_name FROM course_education_type b LEFT JOIN goods g on b.id = g.education_type_id LEFT JOIN
  173. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as education_name,
  174. (SELECT g.grade_code FROM class_grade g where u.grade_id = g.grade_id) as grade_code,
  175. (SELECT g.class_name FROM class_grade g where u.grade_id = g.grade_id) as grade_name,
  176. (SELECT g.status FROM class_grade g where u.grade_id = g.grade_id) as grade_status
  177. FROM
  178. class_grade_user u
  179. where 1=1
  180. <if test="status != null and status.size()!=0 ">
  181. AND u.status in
  182. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  183. #{item}
  184. </foreach>
  185. </if>
  186. <if test="userId != null and userId != ''">
  187. and u.user_id= #{userId}
  188. </if>
  189. order by u.update_time desc
  190. </select>
  191. <select id="listUserPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  192. resultMap="ClassPeriodStudentVo">
  193. SELECT
  194. u.user_account,
  195. u.user_id,
  196. cgu.`status`,
  197. u.realname,
  198. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  199. u.id_card,
  200. cgu.grade_id,
  201. u.telphone,
  202. (SELECT g.class_hours FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where
  203. cg.grade_id = cgg.grade_id) as class_hours,
  204. (SELECT g.study_start_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where
  205. cg.grade_id = cgg.grade_id) as study_start_time,
  206. (SELECT g.study_end_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where
  207. cg.grade_id = cgg.grade_id) as study_end_time,
  208. cgu.period_status,
  209. cg.class_start_time,
  210. cg.class_end_time,
  211. cgu.period_plush,
  212. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
  213. class_grade_goods cgg on cgg.goods_id = c.goods_id where cg.grade_id=cgg.grade_id and m.type = 1 ) as exam_num,
  214. (SELECT COUNT(DISTINCT ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id
  215. = ubr.goods_id where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id) as record_num,
  216. cgu.period_time as end_time,
  217. (select COUNT(up.id) from user_period up LEFT JOIN user_period_status ups on up.id=ups.period_id where up.goods_id = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) and up.grade_id = #{gradeId} and up.user_id = u.user_id
  218. and ups.period_status=0 and ups.`status`=0 and (SELECT COUNT(upss.id) from user_period_status upss where upss.id = ups.id and upss.period_status = 1 and upss.`status` = 2) > 0 ) as rebuild_num
  219. FROM
  220. class_grade_user cgu
  221. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  222. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  223. where 1=1
  224. and cgu.`status` =1
  225. <if test="gradeId != null and gradeId !='' ">
  226. and cgu.grade_id = #{gradeId}
  227. </if>
  228. <if test="periodStatus != null ">
  229. and cgu.period_status = #{periodStatus}
  230. </if>
  231. order by cgu.update_time desc
  232. </select>
  233. <select id="listPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  234. resultMap="ClassPeriodUserVo">
  235. SELECT
  236. u.user_account,
  237. u.realname,
  238. u.id_card,
  239. u.user_id,
  240. u.telphone,
  241. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  242. u.one_inch_photos,
  243. u.id_card_img1,
  244. u.id_card_img2,
  245. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
  246. class_grade_goods cgg on cgg.goods_id = c.goods_id where cg.grade_id=cgg.grade_id and m.type = 1 ) as exam_num,
  247. (SELECT COUNT(DISTINCT ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id
  248. = ubr.goods_id where ubr.`status`=1 and ubr.report_status =1 and ubr.user_id=#{userId} and cg.grade_id=cgg.grade_id ) as record_num,
  249. (SELECT COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  250. ups.`status` =1 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.user_id = #{userId} and up.type = 1) as pass,
  251. (SELECT
  252. COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  253. =0 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.user_id = #{userId} and up.type = 1) as cheat,
  254. (SELECT COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  255. ups.`status` =1 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.user_id = #{userId} and up.type = 2) as exam_pass,
  256. (SELECT
  257. COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  258. =0 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.user_id = #{userId} and up.type = 2) as exam_cheat,
  259. (SELECT up.key_value FROM user_profile up where up.goods_id = #{goodsId} and up.user_id =#{userId} and up.current_status = 1 and up.type_status =1) as key_value
  260. FROM
  261. class_grade_user cgu
  262. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  263. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  264. where 1=1
  265. <if test="userId != null and userId !='' ">
  266. and u.user_id = #{userId}
  267. </if>
  268. <if test="gradeId != null and gradeId !='' ">
  269. and cgu.grade_id = #{gradeId}
  270. </if>
  271. <if test="periodStatus != null and periodStatus !='' ">
  272. and cgu.period_status = #{periodStatus}
  273. </if>
  274. LIMIT 1
  275. </select>
  276. <select id="listPeriodAudit" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  277. resultMap="ClassPeriodVo">
  278. SELECT
  279. cm.menu_id as id,
  280. cm.course_id,
  281. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  282. and u.user_id = #{userId}
  283. </if>) as realname,
  284. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  285. and u.user_id = #{userId}
  286. </if>) as user_id,
  287. (SELECT cm.module_name FROM course_module cm where cm.menu_id = cm.module_id) as type_name,
  288. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs LEFT JOIN course_module_chapter cmc on
  289. cmc.chapter_id=ccs.chapter_id where cmc.module_id=cm.menu_id) as class_hours,
  290. 1 as type,
  291. NULL as study_start_time,
  292. NULL as study_end_time
  293. FROM
  294. course_menu cm
  295. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  296. where 1=1
  297. <if test="goodsId != null and goodsId !='' ">
  298. and gc.goods_id=#{goodsId}
  299. </if>
  300. AND cm.type=1
  301. UNION
  302. SELECT
  303. cm.menu_id as id,
  304. cm.course_id,
  305. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  306. and u.user_id = #{userId}
  307. </if>) as realname,
  308. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  309. and u.user_id = #{userId}
  310. </if>) as user_id,
  311. (SELECT cc.`name` FROM course_chapter cc where cm.menu_id = cc.chapter_id) as type_name,
  312. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs where ccs.chapter_id=cm.menu_id) as class_hours,
  313. 2 as type,
  314. (SELECT usr.create_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  315. ccs.section_id where ccs.chapter_id = cm.menu_id and usr.goods_id = gc.goods_id ORDER BY usr.create_time ASC
  316. limit 1) as study_start_time,
  317. (SELECT usr.update_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  318. ccs.section_id where ccs.chapter_id = cm.menu_id and usr.goods_id = gc.goods_id ORDER BY usr.create_time DESC
  319. limit 1) as study_end_time
  320. FROM
  321. course_menu cm
  322. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  323. where 1=1 <if test="goodsId != null and goodsId !='' ">
  324. and gc.goods_id=#{goodsId}
  325. </if> AND cm.type=2
  326. </select>
  327. <select id="listPeriodAuditSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  328. resultMap="ClassPeriodVo">
  329. SELECT
  330. cm.menu_id as id,
  331. cm.course_id,
  332. (SELECT u.realname FROM `user` u where 1=1
  333. <if test="userId != null and userId !='' ">
  334. and u.user_id = #{userId}
  335. </if>
  336. ) as realname,
  337. (SELECT u.user_id FROM `user` u where 1=1
  338. <if test="userId != null and userId !='' ">
  339. and u.user_id = #{userId}
  340. </if>
  341. ) as user_id,
  342. (SELECT cs.`name` FROM course_section cs where cm.menu_id = cs.section_id) as type_name,
  343. null as class_hours,
  344. 3 as type
  345. FROM
  346. course_menu cm
  347. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  348. where 1=1
  349. <if test="goodsId != null and goodsId !='' ">
  350. and gc.goods_id = #{goodsId}
  351. </if>
  352. AND cm.type=3
  353. </select>
  354. <select id="listPeriodAuditExam" parameterType="map" resultMap="ClassPeriodChapterVo">
  355. SELECT
  356. cme.exam_id as id,
  357. cme.course_id,
  358. (SELECT u.realname FROM `user` u where 1=1
  359. <if test="userId != null and userId !='' ">
  360. and u.user_id = #{userId}
  361. </if>
  362. ) as realname,
  363. (SELECT u.user_id FROM `user` u where 1=1
  364. <if test="userId != null and userId !='' ">
  365. and u.user_id = #{userId}
  366. </if>
  367. ) as user_id,
  368. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  369. null as class_hours,
  370. 4 as type,
  371. (
  372. SELECT
  373. ups.record_start_time
  374. FROM
  375. user_period_status ups
  376. LEFT JOIN user_period up ON up.id = ups.period_id
  377. WHERE
  378. period_status = 1
  379. AND up.course_id = gc.course_id
  380. <if test="goodsId != null and goodsId !='' ">
  381. AND up.goods_id = #{goodsId}
  382. </if>
  383. and cme.section_id =up.section_id
  384. AND up.exam_id = cme.exam_id
  385. ) AS study_start_time,
  386. (
  387. SELECT
  388. ups.record_end_time
  389. FROM
  390. user_period_status ups
  391. LEFT JOIN user_period up ON up.id = ups.period_id
  392. WHERE
  393. period_status = 1
  394. AND up.course_id = gc.course_id
  395. <if test="goodsId != null and goodsId !='' ">
  396. AND up.goods_id = #{goodsId}
  397. </if>
  398. AND up.exam_id = cme.exam_id
  399. ) AS study_end_time,
  400. (
  401. SELECT
  402. ups.`status`
  403. FROM
  404. user_period_status ups
  405. LEFT JOIN user_period up ON up.id = ups.period_id
  406. WHERE
  407. period_status = 1
  408. AND up.course_id = gc.course_id
  409. <if test="goodsId != null and goodsId !='' ">
  410. AND up.goods_id = #{goodsId}
  411. </if>
  412. and cme.section_id =up.section_id
  413. AND up.exam_id = cme.exam_id
  414. ) AS STATUS,
  415. (
  416. SELECT
  417. ups.create_time
  418. FROM
  419. user_period_status ups
  420. LEFT JOIN user_period up ON up.id = ups.period_id
  421. WHERE
  422. period_status = 1
  423. AND up.course_id = gc.course_id
  424. <if test="goodsId != null and goodsId !='' ">
  425. AND up.goods_id = #{goodsId}
  426. </if>
  427. and cme.section_id =up.section_id
  428. AND up.exam_id = cme.exam_id
  429. ) AS audit_time,
  430. (
  431. SELECT
  432. COUNT( ups.id )
  433. FROM
  434. user_period_status ups
  435. LEFT JOIN user_period up ON up.id = ups.period_id
  436. WHERE
  437. period_status = 1
  438. AND up.course_id = gc.course_id
  439. <if test="goodsId != null and goodsId !='' ">
  440. AND up.goods_id = #{goodsId}
  441. </if>
  442. and cme.section_id =up.section_id
  443. AND up.exam_id = cme.exam_id
  444. ) AS audit_num
  445. FROM
  446. course_menu_exam cme
  447. LEFT JOIN goods_course gc on gc.course_id = cme.course_id
  448. LEFT JOIN course_menu cm on cme.section_id = cm.menu_id
  449. where 1=1
  450. <if test="goodsId != null and goodsId !='' ">
  451. and gc.goods_id= #{goodsId}
  452. </if>
  453. AND cm.type=3 and cme.chapter_id=0 and cme.module_id=0 and cme.type=1 and cm.type=3
  454. </select>
  455. <select id="listperiodChapter" parameterType="map" resultMap="ClassPeriodChapterVo">
  456. SELECT
  457. cc.chapter_id as id,
  458. cm.course_id,
  459. ( SELECT u.realname FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  460. and u.user_id = #{userId}
  461. </if> ) AS realname,
  462. ( SELECT u.user_id FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  463. and u.user_id = #{userId}
  464. </if>) AS user_id,
  465. cc.`name` as type_name,
  466. ( SELECT COUNT( ccs.section_id ) FROM course_chapter_section ccs WHERE ccs.chapter_id = cc.chapter_id ) AS
  467. class_hours,
  468. 2 AS type,
  469. (
  470. SELECT
  471. usr.create_time
  472. FROM
  473. user_study_record usr
  474. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id
  475. WHERE
  476. ccs.chapter_id = cc.chapter_id
  477. <if test="goodsId != null and goodsId !='' ">
  478. AND usr.goods_id=#{goodsId}
  479. </if>
  480. <if test="gradeId != null and gradeId !='' ">
  481. AND usr.gradeId=#{gradeId}
  482. </if>
  483. ORDER BY
  484. usr.create_time ASC
  485. LIMIT 1
  486. ) AS study_start_time,
  487. (
  488. SELECT
  489. usr.update_time
  490. FROM
  491. user_study_record usr
  492. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id
  493. WHERE
  494. ccs.chapter_id = cc.chapter_id
  495. <if test="goodsId != null and goodsId !='' ">
  496. AND usr.goods_id=#{goodsId}
  497. </if>
  498. <if test="gradeId != null and gradeId !='' ">
  499. AND usr.gradeId=#{gradeId}
  500. </if>
  501. ORDER BY
  502. usr.create_time DESC
  503. LIMIT 1
  504. ) AS study_end_time,
  505. (
  506. SELECT
  507. ubr.performance
  508. FROM
  509. user_bank_record ubr
  510. LEFT JOIN course_menu_exam cme ON cme.exam_id = ubr.exam_id
  511. WHERE 1=1
  512. <if test="goodsId != null and goodsId !='' ">
  513. AND ubr.goods_id=#{goodsId}
  514. </if>
  515. <if test="moduleId != null and moduleId !='' ">
  516. AND cme.module_id=#{moduleId}
  517. </if>
  518. <if test="courseId != null and courseId !='' ">
  519. AND cme.course_id =#{courseId}
  520. </if>
  521. AND cme.chapter_id = cmc.chapter_id
  522. ) AS performance
  523. FROM
  524. course_menu cm
  525. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  526. LEFT JOIN course_chapter cc ON cmc.chapter_id = cc.chapter_id
  527. WHERE
  528. 1 = 1
  529. <if test="moduleId != null and moduleId !='' ">
  530. AND cmc.module_id=#{moduleId}
  531. </if>
  532. <if test="courseId != null and courseId !='' ">
  533. AND cm.course_id =#{courseId}
  534. </if>
  535. </select>
  536. <select id="listperiodExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  537. SELECT
  538. cme.exam_id as id,
  539. cme.course_id,
  540. (SELECT u.realname FROM `user` u where 1=1
  541. <if test="userId != null and userId !='' ">
  542. and u.user_id = #{userId}
  543. </if>
  544. ) as realname,
  545. (SELECT u.user_id FROM `user` u where 1=1
  546. <if test="userId != null and userId !='' ">
  547. and u.user_id = #{userId}
  548. </if>
  549. ) as user_id,
  550. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  551. null as class_hours,
  552. 4 as type
  553. FROM
  554. course_menu_exam cme
  555. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  556. WHERE 1=1
  557. <if test="courseId != null and courseId !='' ">
  558. AND cme.course_id=#{courseId}
  559. </if>
  560. <if test="chapterId != null and chapterId !='' ">
  561. AND cme.chapter_id =#{chapterId}
  562. </if>
  563. <if test="moduleId != null and moduleId !='' ">
  564. AND cme.module_id =#{moduleId}
  565. </if>
  566. </select>
  567. <select id="listPeriodSection" parameterType="map" resultMap="ClassPeriodSectionVo">
  568. SELECT
  569. cs.section_id AS id,
  570. #{courseId} AS course_id,
  571. ( SELECT u.realname FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  572. and u.user_id = #{userId}
  573. </if> ) AS realname,
  574. ( SELECT u.user_id FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  575. and u.user_id = #{userId}
  576. </if> ) AS user_id,
  577. cs.NAME AS type_name,
  578. NULL AS class_hours,
  579. 3 AS type
  580. FROM
  581. course_chapter_section ccs
  582. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  583. WHERE
  584. 1 = 1
  585. <if test="chapterId != null and chapterId !='' ">
  586. AND ccs.chapter_id = #{chapterId}
  587. </if>
  588. </select>
  589. <select id="listPeriodSectionExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  590. SELECT
  591. cme.exam_id as id,
  592. cme.course_id,
  593. (SELECT u.realname FROM `user` u where 1=1
  594. <if test="userId != null and userId !='' ">
  595. and u.user_id = #{userId}
  596. </if>
  597. ) as realname,
  598. (SELECT u.user_id FROM `user` u where 1=1
  599. <if test="userId != null and userId !='' ">
  600. and u.user_id = #{userId}
  601. </if>
  602. ) as user_id,
  603. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  604. null as class_hours,
  605. 4 as type
  606. FROM
  607. course_menu_exam cme
  608. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  609. WHERE 1=1
  610. and cme.module_id =0
  611. <if test="courseId != null and courseId !='' ">
  612. AND cme.course_id=#{courseId}
  613. </if>
  614. <if test="chapterId != null and chapterId !='' ">
  615. AND cme.chapter_id = #{chapterId}
  616. </if>
  617. </select>
  618. <select id="selectStart" parameterType="map" resultType="long">
  619. SELECT
  620. usr.create_time
  621. FROM
  622. user_study_record usr
  623. WHERE
  624. usr.goods_id = #{goodsId}
  625. AND usr.grade_id = #{gradeId}
  626. AND usr.user_id = #{userId} UNION
  627. SELECT
  628. ubr.create_time
  629. FROM
  630. user_bank_record ubr
  631. WHERE
  632. ubr.goods_id =#{goodsId}
  633. AND ubr.grade_id = #{gradeId}
  634. AND ubr.user_id = #{userId}
  635. ORDER BY create_time ASC
  636. </select>
  637. <select id="sendClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  638. SELECT
  639. cgu.user_id,
  640. cg.class_start_time,
  641. cg.class_end_time,
  642. cgg.goods_id,
  643. cg.grade_id
  644. FROM
  645. class_grade_user cgu
  646. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  647. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  648. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  649. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  650. where 1=1
  651. and irb.remind_id =5
  652. AND unix_timestamp(now()) BETWEEN cg.class_end_time-1728000 and cg.class_end_time-1641600
  653. AND (SELECT COUNT(1) FROM inform_user iu where 1=1 and iu.remind_id = 5 and cgu.user_id = iu.user_id and cgu.grade_id = iu.grade_id and iu.system_status=3) &lt; 1
  654. </select>
  655. <select id="sendTenClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  656. SELECT
  657. cgu.user_id,
  658. cg.class_start_time,
  659. cg.class_end_time,
  660. cgg.goods_id,
  661. cg.grade_id
  662. FROM
  663. class_grade_user cgu
  664. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  665. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  666. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  667. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  668. where 1=1
  669. and irb.remind_id =5
  670. AND unix_timestamp(now()) BETWEEN cg.class_end_time-864000 and cg.class_end_time-777600
  671. AND (SELECT COUNT(1) FROM inform_user iu where 1=1 and iu.remind_id = 6 and cgu.user_id = iu.user_id and cgu.grade_id = iu.grade_id and iu.system_status=3) &lt; 1
  672. </select>
  673. <select id="sendFiveClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  674. SELECT
  675. cgu.user_id,
  676. cg.class_start_time,
  677. cg.class_end_time,
  678. cgg.goods_id,
  679. cg.grade_id
  680. FROM
  681. class_grade_user cgu
  682. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  683. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  684. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  685. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  686. where 1=1
  687. and irb.remind_id =5
  688. AND unix_timestamp(now()) BETWEEN cg.class_end_time-432000 and cg.class_end_time-345600
  689. AND (SELECT COUNT(1) FROM inform_user iu where 1=1 and iu.remind_id = 6 and cgu.user_id = iu.user_id and cgu.grade_id = iu.grade_id and iu.system_status=3) &lt; 1
  690. </select>
  691. </mapper>