ClassGradeUserMapper.xml 39 KB

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