ClassGradeUserMapper.xml 36 KB

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