ClassGradeUserMapper.xml 31 KB

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