ClassGradeUserMapper.xml 31 KB

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