ClassGradeUserMapper.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  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="student_code"/>
  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. </resultMap>
  45. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodStudentVo" id="ClassPeriodStudentVo">
  46. <result property="userId" column="user_id"/>
  47. <result property="gradeId" column="grade_id"/>
  48. <result property="studentCode" column="student_code"/>
  49. <result property="realName" column="realname"/>
  50. <result property="idCard" column="id_card"/>
  51. <result property="telPhone" column="telphone"/>
  52. <result property="status" column="status"/>
  53. <result property="classHours" column="class_hours"/>
  54. <result property="periodStatus" column="period_status"/>
  55. <result property="secAllNum" column="sec_all_num"/>
  56. <result property="examNum" column="exam_num"/>
  57. <result property="recordNum" column="record_num"/>
  58. </resultMap>
  59. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodUserVo" id="ClassPeriodUserVo">
  60. <result property="userId" column="user_id"/>
  61. <result property="studentCode" column="student_code"/>
  62. <result property="realName" column="realname"/>
  63. <result property="oneInchPhotos" column="one_inch_photos"/>
  64. <result property="idCardImg1" column="id_card_img1"/>
  65. <result property="idCardImg2" column="id_card_img2"/>
  66. <result property="idCard" column="id_card"/>
  67. <result property="telPhone" column="telphone"/>
  68. <result property="secAllNum" column="sec_all_num"/>
  69. <result property="examNum" column="exam_num"/>
  70. <result property="recordNum" column="record_num"/>
  71. <result property="pass" column="pass"/>
  72. <result property="cheat" column="cheat"/>
  73. </resultMap>
  74. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodVo" id="ClassPeriodVo">
  75. <result property="userId" column="user_id"/>
  76. <result property="id" column="id"/>
  77. <result property="typeName" column="type_name"/>
  78. <result property="realName" column="realname"/>
  79. <result property="classHours" column="class_hours"/>
  80. <result property="studyStartTime" column="study_start_time"/>
  81. <result property="status" column="status"/>
  82. <result property="auditTime" column="audit_time"/>
  83. <result property="type" column="type"/>
  84. <result property="courseId" column="course_id"/>
  85. <result property="studyEndTime" column="study_end_time"/>
  86. </resultMap>
  87. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodChapterVo" id="ClassPeriodChapterVo">
  88. <result property="userId" column="user_id"/>
  89. <result property="id" column="id"/>
  90. <result property="courseId" column="course_id"/>
  91. <result property="typeName" column="type_name"/>
  92. <result property="realName" column="realname"/>
  93. <result property="classHours" column="class_hours"/>
  94. <result property="studyStartTime" column="study_start_time"/>
  95. <result property="status" column="status"/>
  96. <result property="auditTime" column="audit_time"/>
  97. <result property="type" column="type"/>
  98. <result property="studyEndTime" column="study_end_time"/>
  99. <result property="performance" column="performance"/>
  100. </resultMap>
  101. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodSectionVo" id="ClassPeriodSectionVo">
  102. <result property="userId" column="user_id"/>
  103. <result property="id" column="id"/>
  104. <result property="typeName" column="type_name"/>
  105. <result property="realName" column="realname"/>
  106. <result property="classHours" column="class_hours"/>
  107. <result property="studyStartTime" column="study_start_time"/>
  108. <result property="status" column="status"/>
  109. <result property="auditTime" column="audit_time"/>
  110. <result property="type" column="type"/>
  111. <result property="studyEndTime" column="study_end_time"/>
  112. <result property="auditNum" column="audit_num"/>
  113. </resultMap>
  114. <select id="select" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  115. resultMap="ClassGradeUserVoResult">
  116. SELECT
  117. g.*,
  118. u.student_code,
  119. u.realname,
  120. u.id_card,
  121. u.telphone
  122. FROM
  123. class_grade_user g
  124. LEFT JOIN `user` u ON g.user_id = u.user_id
  125. WHERE
  126. 1 = 1
  127. <if test="status != null and status.size()!=0 ">
  128. AND g.status in
  129. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  130. #{item}
  131. </foreach>
  132. </if>
  133. <if test="gradeId != null and gradeId != ''">
  134. AND g.grade_id = #{gradeId}
  135. </if>
  136. <if test="userId != null and userId != ''">
  137. AND g.user_id = #{userId}
  138. </if>
  139. order by g.update_time desc
  140. </select>
  141. <select id="listUser" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  142. resultMap="ClassGradeUserGoodsVoResult">
  143. SELECT
  144. * ,
  145. (select `code` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  146. u.grade_id) as goods_code,
  147. (select `year` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  148. u.grade_id) as year,
  149. (select goods_name FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  150. u.grade_id) as goods_name,
  151. (select b.business_name FROM course_business b LEFT JOIN goods g on b.id = g.business_id LEFT JOIN
  152. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as business_name,
  153. (select b.project_name FROM course_project_type b LEFT JOIN goods g on b.id = g.project_id LEFT JOIN
  154. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as project_name,
  155. (select b.school_name FROM school b LEFT JOIN goods g on b.id = g.school_id LEFT JOIN class_grade_goods c on
  156. g.goods_id = c.goods_id where c.grade_id = u.grade_id) as school_name,
  157. (select b.education_name FROM course_education_type b LEFT JOIN goods g on b.id = g.education_type_id LEFT JOIN
  158. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as education_name,
  159. (SELECT g.grade_code FROM class_grade g where u.grade_id = g.grade_id) as grade_code,
  160. (SELECT g.class_name FROM class_grade g where u.grade_id = g.grade_id) as grade_name,
  161. (SELECT g.status FROM class_grade g where u.grade_id = g.grade_id) as grade_status
  162. FROM
  163. class_grade_user u
  164. where 1=1
  165. <if test="status != null and status.size()!=0 ">
  166. AND u.status in
  167. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  168. #{item}
  169. </foreach>
  170. </if>
  171. <if test="userId != null and userId != ''">
  172. and u.user_id= #{userId}
  173. </if>
  174. order by u.update_time desc
  175. </select>
  176. <select id="listUserPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  177. resultMap="ClassPeriodStudentVo">
  178. SELECT
  179. u.student_code,
  180. u.user_id,
  181. cgu.`status`,
  182. u.realname,
  183. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  184. u.id_card,
  185. cgu.grade_id,
  186. u.telphone,
  187. (SELECT g.class_hours FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where
  188. cg.grade_id = cgg.grade_id) as class_hours,
  189. cgu.period_status,
  190. (SELECT g.study_start_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where
  191. cg.grade_id = cgg.grade_id) as study_start_time,
  192. (SELECT g.study_end_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where
  193. cg.grade_id = cgg.grade_id) as study_end_time,
  194. cg.class_start_time,
  195. cg.class_end_time,
  196. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
  197. 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,
  198. (SELECT COUNT(DISTINCT ubr.record_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id
  199. = ubr.goods_id where ubr.`status`=1) as record_num
  200. FROM
  201. class_grade_user cgu
  202. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  203. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  204. where 1=1
  205. and cgu.`status` =1
  206. <if test="gradeId != null and gradeId !='' ">
  207. and cgu.grade_id = #{gradeId}
  208. </if>
  209. <if test="periodStatus != null ">
  210. and cgu.period_status = #{periodStatus}
  211. </if>
  212. order by cgu.update_time desc
  213. </select>
  214. <select id="listPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  215. resultMap="ClassPeriodUserVo">
  216. SELECT
  217. u.student_code,
  218. u.realname,
  219. u.id_card,
  220. u.user_id,
  221. u.telphone,
  222. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  223. u.one_inch_photos,
  224. u.id_card_img1,
  225. u.id_card_img2,
  226. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
  227. 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,
  228. (SELECT COUNT(DISTINCT ubr.record_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id
  229. = ubr.goods_id where ubr.`status`=1) as record_num,
  230. (SELECT COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  231. ups.`status` =1) as pass,
  232. (SELECT COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id) - (SELECT
  233. COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  234. =1) as cheat
  235. FROM
  236. class_grade_user cgu
  237. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  238. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  239. where 1=1
  240. <if test="userId != null and userId !='' ">
  241. and u.user_id = #{userId}
  242. </if>
  243. <if test="gradeId != null and gradeId !='' ">
  244. and cgu.grade_id = #{gradeId}
  245. </if>
  246. <if test="periodStatus != null and periodStatus !='' ">
  247. and cgu.period_status = #{periodStatus}
  248. </if>
  249. </select>
  250. <select id="listPeriodAudit" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  251. resultMap="ClassPeriodVo">
  252. SELECT
  253. cm.menu_id as id,
  254. cm.course_id,
  255. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  256. and u.user_id = #{userId}
  257. </if>) as realname,
  258. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  259. and u.user_id = #{userId}
  260. </if>) as user_id,
  261. (SELECT cm.module_name FROM course_module cm where cm.menu_id = cm.module_id) as type_name,
  262. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs LEFT JOIN course_module_chapter cmc on
  263. cmc.chapter_id=ccs.chapter_id where cmc.module_id=cm.menu_id) as class_hours,
  264. 1 as type,
  265. NULL as study_start_time,
  266. NULL as study_end_time
  267. FROM
  268. course_menu cm
  269. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  270. where 1=1
  271. <if test="goodsId != null and goodsId !='' ">
  272. and gc.goods_id=#{goodsId}
  273. </if>
  274. AND cm.type=1
  275. UNION
  276. SELECT
  277. cm.menu_id as id,
  278. cm.course_id,
  279. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  280. and u.user_id = #{userId}
  281. </if>) as realname,
  282. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  283. and u.user_id = #{userId}
  284. </if>) as user_id,
  285. (SELECT cc.`name` FROM course_chapter cc where cm.menu_id = cc.chapter_id) as type_name,
  286. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs where ccs.chapter_id=cm.menu_id) as class_hours,
  287. 2 as type,
  288. (SELECT usr.create_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  289. ccs.section_id where ccs.chapter_id = cm.menu_id and usr.goods_id = gc.goods_id ORDER BY usr.create_time ASC
  290. limit 1) as study_start_time,
  291. (SELECT usr.update_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  292. ccs.section_id where ccs.chapter_id = cm.menu_id and usr.goods_id = gc.goods_id ORDER BY usr.create_time DESC
  293. limit 1) as study_end_time
  294. FROM
  295. course_menu cm
  296. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  297. where 1=1 <if test="goodsId != null and goodsId !='' ">
  298. and gc.goods_id=#{goodsId}
  299. </if> AND cm.type=2
  300. </select>
  301. <select id="listPeriodAuditSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  302. resultMap="ClassPeriodVo">
  303. SELECT
  304. cm.menu_id as id,
  305. cm.course_id,
  306. (SELECT u.realname FROM `user` u where 1=1
  307. <if test="userId != null and userId !='' ">
  308. and u.user_id = #{userId}
  309. </if>
  310. ) as realname,
  311. (SELECT u.user_id FROM `user` u where 1=1
  312. <if test="userId != null and userId !='' ">
  313. and u.user_id = #{userId}
  314. </if>
  315. ) as user_id,
  316. (SELECT cs.`name` FROM course_section cs where cm.menu_id = cs.section_id) as type_name,
  317. null as class_hours,
  318. 3 as type,
  319. (
  320. SELECT
  321. ups.record_start_time
  322. FROM
  323. user_period_status ups
  324. LEFT JOIN user_period up ON up.id = ups.period_id
  325. WHERE
  326. period_status = 1
  327. AND up.course_id = gc.course_id
  328. <if test="goodsId != null and goodsId !='' ">
  329. AND up.goods_id = #{goodsId}
  330. </if>
  331. AND up.section_id = cm.menu_id
  332. ) AS study_start_time,
  333. (
  334. SELECT
  335. ups.record_end_time
  336. FROM
  337. user_period_status ups
  338. LEFT JOIN user_period up ON up.id = ups.period_id
  339. WHERE
  340. period_status = 1
  341. AND up.course_id = gc.course_id
  342. <if test="goodsId != null and goodsId !='' ">
  343. AND up.goods_id = #{goodsId}
  344. </if>
  345. AND up.section_id = cm.menu_id
  346. ) AS study_end_time,
  347. (
  348. SELECT
  349. ups.`status`
  350. FROM
  351. user_period_status ups
  352. LEFT JOIN user_period up ON up.id = ups.period_id
  353. WHERE
  354. period_status = 1
  355. AND up.course_id = gc.course_id
  356. <if test="goodsId != null and goodsId !='' ">
  357. AND up.goods_id = #{goodsId}
  358. </if>
  359. AND up.section_id = cm.menu_id
  360. ) AS STATUS,
  361. (
  362. SELECT
  363. ups.create_time
  364. FROM
  365. user_period_status ups
  366. LEFT JOIN user_period up ON up.id = ups.period_id
  367. WHERE
  368. period_status = 1
  369. AND up.course_id = gc.course_id
  370. <if test="goodsId != null and goodsId !='' ">
  371. AND up.goods_id = #{goodsId}
  372. </if>
  373. AND up.section_id = cm.menu_id
  374. ) AS audit_time,
  375. (
  376. SELECT
  377. COUNT( ups.id )
  378. FROM
  379. user_period_status ups
  380. LEFT JOIN user_period up ON up.id = ups.period_id
  381. WHERE
  382. period_status = 1
  383. AND up.course_id = gc.course_id
  384. <if test="goodsId != null and goodsId !='' ">
  385. AND up.goods_id = #{goodsId}
  386. </if>
  387. AND up.section_id = cm.menu_id
  388. ) AS audit_num
  389. FROM
  390. course_menu cm
  391. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  392. where 1=1
  393. <if test="goodsId != null and goodsId !='' ">
  394. and gc.goods_id = #{goodsId}
  395. </if>
  396. AND cm.type=3
  397. </select>
  398. <select id="listPeriodAuditExam" parameterType="map" resultMap="ClassPeriodChapterVo">
  399. SELECT
  400. cme.exam_id as id,
  401. cme.course_id,
  402. (SELECT u.realname FROM `user` u where 1=1
  403. <if test="userId != null and userId !='' ">
  404. and u.user_id = #{userId}
  405. </if>
  406. ) as realname,
  407. (SELECT u.user_id FROM `user` u where 1=1
  408. <if test="userId != null and userId !='' ">
  409. and u.user_id = #{userId}
  410. </if>
  411. ) as user_id,
  412. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  413. null as class_hours,
  414. 4 as type,
  415. (
  416. SELECT
  417. ups.record_start_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 study_start_time,
  430. (
  431. SELECT
  432. ups.record_end_time
  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 up.exam_id = cme.exam_id
  443. ) AS study_end_time,
  444. (
  445. SELECT
  446. ups.`status`
  447. FROM
  448. user_period_status ups
  449. LEFT JOIN user_period up ON up.id = ups.period_id
  450. WHERE
  451. period_status = 1
  452. AND up.course_id = gc.course_id
  453. <if test="goodsId != null and goodsId !='' ">
  454. AND up.goods_id = #{goodsId}
  455. </if>
  456. and cme.section_id =up.section_id
  457. AND up.exam_id = cme.exam_id
  458. ) AS STATUS,
  459. (
  460. SELECT
  461. ups.create_time
  462. FROM
  463. user_period_status ups
  464. LEFT JOIN user_period up ON up.id = ups.period_id
  465. WHERE
  466. period_status = 1
  467. AND up.course_id = gc.course_id
  468. <if test="goodsId != null and goodsId !='' ">
  469. AND up.goods_id = #{goodsId}
  470. </if>
  471. and cme.section_id =up.section_id
  472. AND up.exam_id = cme.exam_id
  473. ) AS audit_time,
  474. (
  475. SELECT
  476. COUNT( ups.id )
  477. FROM
  478. user_period_status ups
  479. LEFT JOIN user_period up ON up.id = ups.period_id
  480. WHERE
  481. period_status = 1
  482. AND up.course_id = gc.course_id
  483. <if test="goodsId != null and goodsId !='' ">
  484. AND up.goods_id = #{goodsId}
  485. </if>
  486. and cme.section_id =up.section_id
  487. AND up.exam_id = cme.exam_id
  488. ) AS audit_num
  489. FROM
  490. course_menu_exam cme
  491. LEFT JOIN goods_course gc on gc.course_id = cme.course_id
  492. LEFT JOIN course_menu cm on cme.section_id = cm.menu_id
  493. where 1=1
  494. <if test="goodsId != null and goodsId !='' ">
  495. and gc.goods_id= #{goodsId}
  496. </if>
  497. AND cm.type=3 and cme.chapter_id=0 and cme.module_id=0 and cme.type=1 and cm.type=3
  498. </select>
  499. <select id="listperiodChapter" parameterType="map" resultMap="ClassPeriodChapterVo">
  500. SELECT
  501. cc.chapter_id as id,
  502. cm.course_id,
  503. ( SELECT u.realname FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  504. and u.user_id = #{userId}
  505. </if> ) AS realname,
  506. ( SELECT u.user_id FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  507. and u.user_id = #{userId}
  508. </if>) AS user_id,
  509. cc.`name` as type_name,
  510. ( SELECT COUNT( ccs.section_id ) FROM course_chapter_section ccs WHERE ccs.chapter_id = cc.chapter_id ) AS
  511. class_hours,
  512. 2 AS type,
  513. (
  514. SELECT
  515. usr.create_time
  516. FROM
  517. user_study_record usr
  518. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id
  519. WHERE
  520. ccs.chapter_id = cc.chapter_id
  521. <if test="goodsId != null and goodsId !='' ">
  522. AND usr.goods_id=#{goodsId}
  523. </if>
  524. ORDER BY
  525. usr.create_time ASC
  526. LIMIT 1
  527. ) AS study_start_time,
  528. (
  529. SELECT
  530. usr.update_time
  531. FROM
  532. user_study_record usr
  533. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id
  534. WHERE
  535. ccs.chapter_id = cc.chapter_id
  536. <if test="goodsId != null and goodsId !='' ">
  537. AND usr.goods_id=#{goodsId}
  538. </if>
  539. ORDER BY
  540. usr.create_time DESC
  541. LIMIT 1
  542. ) AS study_end_time,
  543. (
  544. SELECT
  545. ubr.performance
  546. FROM
  547. user_bank_record ubr
  548. LEFT JOIN course_menu_exam cme ON cme.exam_id = ubr.exam_id
  549. WHERE 1=1
  550. <if test="goodsId != null and goodsId !='' ">
  551. AND ubr.goods_id=#{goodsId}
  552. </if>
  553. <if test="moduleId != null and moduleId !='' ">
  554. AND cme.module_id=#{moduleId}
  555. </if>
  556. <if test="courseId != null and courseId !='' ">
  557. AND cme.course_id =#{courseId}
  558. </if>
  559. AND cme.chapter_id = cmc.chapter_id
  560. ) AS performance
  561. FROM
  562. course_menu cm
  563. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  564. LEFT JOIN course_chapter cc ON cmc.chapter_id = cc.chapter_id
  565. WHERE
  566. 1 = 1
  567. <if test="moduleId != null and moduleId !='' ">
  568. AND cmc.module_id=#{moduleId}
  569. </if>
  570. <if test="courseId != null and courseId !='' ">
  571. AND cm.course_id =#{courseId}
  572. </if>
  573. </select>
  574. <select id="listperiodExam" parameterType="map" resultMap="ClassPeriodChapterVo">
  575. SELECT
  576. cme.exam_id as id,
  577. cme.course_id,
  578. (SELECT u.realname FROM `user` u where 1=1
  579. <if test="userId != null and userId !='' ">
  580. and u.user_id = #{userId}
  581. </if>
  582. ) as realname,
  583. (SELECT u.user_id FROM `user` u where 1=1
  584. <if test="userId != null and userId !='' ">
  585. and u.user_id = #{userId}
  586. </if>
  587. ) as user_id,
  588. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  589. null as class_hours,
  590. 4 as type,
  591. (
  592. SELECT
  593. ups.record_start_time
  594. FROM
  595. user_period_status ups
  596. LEFT JOIN user_period up ON up.id = ups.period_id
  597. WHERE
  598. period_status = 1
  599. AND up.course_id = cme.course_id
  600. <if test="goodsId != null and goodsId !='' ">
  601. AND up.goods_id = #{goodsId}
  602. </if>
  603. and cme.module_id = up.module_id
  604. AND up.exam_id = cme.exam_id
  605. ) AS study_start_time,
  606. (
  607. SELECT
  608. ups.record_end_time
  609. FROM
  610. user_period_status ups
  611. LEFT JOIN user_period up ON up.id = ups.period_id
  612. WHERE
  613. period_status = 1
  614. AND up.course_id = cme.course_id
  615. <if test="goodsId != null and goodsId !='' ">
  616. AND up.goods_id = #{goodsId}
  617. </if>
  618. and cme.module_id = up.module_id
  619. AND up.exam_id = cme.exam_id
  620. ) AS study_end_time,
  621. (
  622. SELECT
  623. ups.`status`
  624. FROM
  625. user_period_status ups
  626. LEFT JOIN user_period up ON up.id = ups.period_id
  627. WHERE
  628. period_status = 1
  629. AND up.course_id = cme.course_id
  630. <if test="goodsId != null and goodsId !='' ">
  631. AND up.goods_id = #{goodsId}
  632. </if>
  633. and cme.module_id = up.module_id
  634. AND up.exam_id = cme.exam_id
  635. ) AS STATUS,
  636. (
  637. SELECT
  638. ups.create_time
  639. FROM
  640. user_period_status ups
  641. LEFT JOIN user_period up ON up.id = ups.period_id
  642. WHERE
  643. period_status = 1
  644. AND up.course_id = cme.course_id
  645. <if test="goodsId != null and goodsId !='' ">
  646. AND up.goods_id = #{goodsId}
  647. </if>
  648. and cme.module_id = up.module_id
  649. AND up.exam_id = cme.exam_id
  650. ) AS audit_time,
  651. (
  652. SELECT
  653. COUNT( ups.id )
  654. FROM
  655. user_period_status ups
  656. LEFT JOIN user_period up ON up.id = ups.period_id
  657. WHERE
  658. period_status = 1
  659. AND up.course_id = cme.course_id
  660. <if test="goodsId != null and goodsId !='' ">
  661. AND up.goods_id = #{goodsId}
  662. </if>
  663. and cme.module_id = up.module_id
  664. AND up.exam_id = cme.exam_id
  665. ) AS audit_num
  666. FROM
  667. course_menu_exam cme
  668. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  669. WHERE 1=1
  670. <if test="courseId != null and courseId !='' ">
  671. AND cme.course_id=#{courseId}
  672. </if>
  673. <if test="moduleId != null and moduleId !='' ">
  674. AND cme.module_id =#{moduleId}
  675. </if>
  676. </select>
  677. <select id="listPeriodSection" parameterType="map" resultMap="ClassPeriodSectionVo">
  678. SELECT
  679. cs.section_id AS id,
  680. #{courseId} AS course_id,
  681. ( SELECT u.realname FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  682. and u.user_id = #{userId}
  683. </if> ) AS realname,
  684. ( SELECT u.user_id FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  685. and u.user_id = #{userId}
  686. </if> ) AS user_id,
  687. cs.NAME AS type_name,
  688. NULL AS class_hours,
  689. 3 AS type,
  690. (
  691. SELECT
  692. ups.record_start_time
  693. FROM
  694. user_period_status ups
  695. LEFT JOIN user_period up ON up.id = ups.period_id
  696. WHERE
  697. period_status = 1
  698. <if test="courseId != null and courseId !='' ">
  699. AND up.course_id = #{courseId}
  700. </if>
  701. <if test="goodsId != null and goodsId !='' ">
  702. AND up.goods_id = #{goodsId}
  703. </if>
  704. AND up.section_id = cs.section_id
  705. ) AS study_start_time,
  706. (
  707. SELECT
  708. ups.record_end_time
  709. FROM
  710. user_period_status ups
  711. LEFT JOIN user_period up ON up.id = ups.period_id
  712. WHERE
  713. period_status = 1
  714. <if test="courseId != null and courseId !='' ">
  715. AND up.course_id = #{courseId}
  716. </if>
  717. <if test="goodsId != null and goodsId !='' ">
  718. AND up.goods_id = #{goodsId}
  719. </if>
  720. AND up.section_id = cs.section_id
  721. ) AS study_end_time,
  722. (
  723. SELECT
  724. ups.`status`
  725. FROM
  726. user_period_status ups
  727. LEFT JOIN user_period up ON up.id = ups.period_id
  728. WHERE
  729. period_status = 1
  730. <if test="courseId != null and courseId !='' ">
  731. AND up.course_id = #{courseId}
  732. </if>
  733. <if test="goodsId != null and goodsId !='' ">
  734. AND up.goods_id = #{goodsId}
  735. </if>
  736. AND up.section_id = cs.section_id
  737. ) AS STATUS,
  738. (
  739. SELECT
  740. ups.create_time
  741. FROM
  742. user_period_status ups
  743. LEFT JOIN user_period up ON up.id = ups.period_id
  744. WHERE
  745. period_status = 1
  746. <if test="courseId != null and courseId !='' ">
  747. AND up.course_id = #{courseId}
  748. </if>
  749. <if test="goodsId != null and goodsId !='' ">
  750. AND up.goods_id = #{goodsId}
  751. </if>
  752. AND up.section_id = cs.section_id
  753. ) AS audit_time,
  754. (
  755. SELECT
  756. COUNT( ups.id )
  757. FROM
  758. user_period_status ups
  759. LEFT JOIN user_period up ON up.id = ups.period_id
  760. WHERE
  761. period_status = 1
  762. <if test="courseId != null and courseId !='' ">
  763. AND up.course_id = #{courseId}
  764. </if>
  765. <if test="goodsId != null and goodsId !='' ">
  766. AND up.goods_id = #{goodsId}
  767. </if>
  768. AND up.section_id = cs.section_id
  769. ) AS audit_num
  770. FROM
  771. course_chapter_section ccs
  772. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  773. WHERE
  774. 1 = 1
  775. <if test="chapterId != null and chapterId !='' ">
  776. AND ccs.chapter_id = #{chapterId}
  777. </if>
  778. </select>
  779. <select id="listPeriodSectionExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  780. SELECT
  781. cme.exam_id as id,
  782. cme.course_id,
  783. (SELECT u.realname FROM `user` u where 1=1
  784. <if test="userId != null and userId !='' ">
  785. and u.user_id = #{userId}
  786. </if>
  787. ) as realname,
  788. (SELECT u.user_id FROM `user` u where 1=1
  789. <if test="userId != null and userId !='' ">
  790. and u.user_id = #{userId}
  791. </if>
  792. ) as user_id,
  793. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  794. null as class_hours,
  795. 4 as type,
  796. (
  797. SELECT
  798. ups.record_start_time
  799. FROM
  800. user_period_status ups
  801. LEFT JOIN user_period up ON up.id = ups.period_id
  802. WHERE
  803. period_status = 1
  804. AND up.course_id = cme.course_id
  805. <if test="goodsId != null and goodsId !='' ">
  806. AND up.goods_id = #{goodsId}
  807. </if>
  808. and cme.module_id =0
  809. and cme.chapter_id = up.chapter_id
  810. AND up.exam_id = cme.exam_id
  811. ) AS study_start_time,
  812. (
  813. SELECT
  814. ups.record_end_time
  815. FROM
  816. user_period_status ups
  817. LEFT JOIN user_period up ON up.id = ups.period_id
  818. WHERE
  819. period_status = 1
  820. AND up.course_id = cme.course_id
  821. <if test="goodsId != null and goodsId !='' ">
  822. AND up.goods_id = #{goodsId}
  823. </if>
  824. and cme.module_id =0
  825. and cme.chapter_id = up.chapter_id
  826. AND up.exam_id = cme.exam_id
  827. ) AS study_end_time,
  828. (
  829. SELECT
  830. ups.`status`
  831. FROM
  832. user_period_status ups
  833. LEFT JOIN user_period up ON up.id = ups.period_id
  834. WHERE
  835. period_status = 1
  836. AND up.course_id = cme.course_id
  837. <if test="goodsId != null and goodsId !='' ">
  838. AND up.goods_id = #{goodsId}
  839. </if>
  840. and cme.module_id =0
  841. and cme.chapter_id = up.chapter_id
  842. AND up.exam_id = cme.exam_id
  843. ) AS STATUS,
  844. (
  845. SELECT
  846. ups.create_time
  847. FROM
  848. user_period_status ups
  849. LEFT JOIN user_period up ON up.id = ups.period_id
  850. WHERE
  851. period_status = 1
  852. AND up.course_id = cme.course_id
  853. <if test="goodsId != null and goodsId !='' ">
  854. AND up.goods_id = #{goodsId}
  855. </if>
  856. and cme.module_id =0
  857. and cme.chapter_id = up.chapter_id
  858. AND up.exam_id = cme.exam_id
  859. ) AS audit_time,
  860. (
  861. SELECT
  862. COUNT( ups.id )
  863. FROM
  864. user_period_status ups
  865. LEFT JOIN user_period up ON up.id = ups.period_id
  866. WHERE
  867. period_status = 1
  868. AND up.course_id = cme.course_id
  869. <if test="goodsId != null and goodsId !='' ">
  870. AND up.goods_id = #{goodsId}
  871. </if>
  872. and cme.module_id =0
  873. and cme.chapter_id = up.chapter_id
  874. AND up.exam_id = cme.exam_id
  875. ) AS audit_num
  876. FROM
  877. course_menu_exam cme
  878. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  879. WHERE 1=1
  880. and cme.module_id =0
  881. <if test="courseId != null and courseId !='' ">
  882. AND cme.course_id=#{courseId}
  883. </if>
  884. <if test="chapterId != null and chapterId !='' ">
  885. AND cme.chapter_id = #{chapterId}
  886. </if>
  887. </select>
  888. </mapper>