ClassGradeUserMapper.xml 35 KB

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