ClassGradeUserMapper.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  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="educationTypeId != null and educationTypeId != ''">
  294. AND g.education_type_id = #{educationTypeId}
  295. </if>
  296. <if test="schoolId != null and schoolId != ''">
  297. AND g.school_id = #{schoolId}
  298. </if>
  299. <if test="majorId != null and majorId != ''">
  300. AND g.major_id = #{majorId}
  301. </if>
  302. <if test="periodStatus != null ">
  303. and cgu.period_status = #{periodStatus}
  304. </if>
  305. <if test="classStartTime != null and classStartTime != '' ">
  306. AND cg.class_start_time > #{classStartTime}
  307. </if>
  308. <if test="classEndTime != null and classEndTime != '' ">
  309. AND #{classEndTime} > cg.class_end_time
  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="searchKey != null and searchKey != '' ">
  318. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%') or g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
  319. </if>
  320. <if test="periodStatus != 2 ">
  321. order by cgu.update_time desc
  322. </if>
  323. <if test="periodStatus == 2 ">
  324. order by cgu.period_wait_time,cgu.create_time
  325. </if>
  326. </select>
  327. <select id="userPeriodStatus" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  328. resultMap="ClassPeriodStudentVo">
  329. SELECT
  330. IFNULL(ge.exam_num,0) as exam_num,
  331. cg.class_start_time,
  332. cg.class_end_time,
  333. g.study_start_time,
  334. g.study_end_time,
  335. (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
  336. = 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,
  337. cgu.user_id,
  338. cgg.goods_id
  339. FROM
  340. class_grade_user cgu
  341. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  342. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  343. LEFT JOIN goods g on g.goods_id=cgg.goods_id
  344. LEFT JOIN (SELECT
  345. COUNT( m.id ) AS exam_num,
  346. c.goods_id
  347. FROM
  348. course_menu_exam m
  349. LEFT JOIN goods_course c ON m.course_id = c.course_id
  350. where
  351. m.type = 1
  352. GROUP BY c.goods_id ) ge on cgg.goods_id = ge.goods_id
  353. where 1=1
  354. and cgu.`status` =1
  355. <if test="gradeId != null and gradeId !='' ">
  356. and cgu.grade_id = #{gradeId}
  357. </if>
  358. <if test="userId != null ">
  359. and cgu.user_id = #{userId}
  360. </if>
  361. LIMIT 1
  362. </select>
  363. <select id="listPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  364. resultMap="ClassPeriodUserVo">
  365. SELECT
  366. u.user_account,
  367. u.realname,
  368. u.id_card,
  369. u.user_id,
  370. u.telphone,
  371. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  372. u.one_inch_photos,
  373. u.id_card_img1,
  374. u.id_card_img2,
  375. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
  376. 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,
  377. (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,
  378. (SELECT COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  379. 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,
  380. (SELECT COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  381. 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,
  382. (SELECT
  383. COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  384. =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,
  385. (SELECT COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  386. 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,
  387. (SELECT
  388. COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  389. =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,
  390. (SELECT
  391. COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  392. =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,
  393. (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
  394. FROM
  395. class_grade_user cgu
  396. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  397. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  398. where 1=1
  399. <if test="userId != null and userId !='' ">
  400. and u.user_id = #{userId}
  401. </if>
  402. <if test="gradeId != null and gradeId !='' ">
  403. and cgu.grade_id = #{gradeId}
  404. </if>
  405. <if test="periodStatus != null and periodStatus !='' ">
  406. and cgu.period_status = #{periodStatus}
  407. </if>
  408. LIMIT 1
  409. </select>
  410. <select id="listPeriodAudit" 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 <if test="userId != null and userId !='' ">
  416. and u.user_id = #{userId}
  417. </if>) as realname,
  418. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  419. and u.user_id = #{userId}
  420. </if>) as user_id,
  421. (SELECT cm.module_name FROM course_module cm where cm.menu_id = cm.module_id) as type_name,
  422. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs LEFT JOIN course_module_chapter cmc on
  423. cmc.chapter_id=ccs.chapter_id where cmc.module_id=cm.menu_id) as class_hours,
  424. 1 as type,
  425. NULL as study_start_time,
  426. NULL as study_end_time
  427. FROM
  428. course_menu cm
  429. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  430. where 1=1
  431. <if test="goodsId != null and goodsId !='' ">
  432. and gc.goods_id=#{goodsId}
  433. </if>
  434. AND cm.type=1
  435. UNION
  436. SELECT
  437. cm.menu_id as id,
  438. cm.course_id,
  439. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  440. and u.user_id = #{userId}
  441. </if>) as realname,
  442. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  443. and u.user_id = #{userId}
  444. </if>) as user_id,
  445. (SELECT cc.`name` FROM course_chapter cc where cm.menu_id = cc.chapter_id) as type_name,
  446. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs where ccs.chapter_id=cm.menu_id) as class_hours,
  447. 2 as type,
  448. (SELECT usr.create_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  449. 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
  450. limit 1) as study_start_time,
  451. (SELECT usr.update_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  452. 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
  453. limit 1) as study_end_time
  454. FROM
  455. course_menu cm
  456. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  457. where 1=1 <if test="goodsId != null and goodsId !='' ">
  458. and gc.goods_id=#{goodsId}
  459. </if> AND cm.type=2
  460. </select>
  461. <select id="listPeriodAuditSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  462. resultMap="ClassPeriodVo">
  463. SELECT
  464. cm.menu_id as id,
  465. cm.course_id,
  466. (SELECT u.realname FROM `user` u where 1=1
  467. <if test="userId != null and userId !='' ">
  468. and u.user_id = #{userId}
  469. </if>
  470. ) as realname,
  471. (SELECT u.user_id FROM `user` u where 1=1
  472. <if test="userId != null and userId !='' ">
  473. and u.user_id = #{userId}
  474. </if>
  475. ) as user_id,
  476. cs.`name` as type_name,
  477. cs.duration_time,
  478. null as class_hours,
  479. 3 as type
  480. FROM
  481. course_menu cm
  482. LEFT JOIN course_section cs on cm.menu_id = cs.section_id
  483. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  484. where 1=1
  485. <if test="goodsId != null and goodsId !='' ">
  486. and gc.goods_id = #{goodsId}
  487. </if>
  488. AND cm.type=3
  489. </select>
  490. <select id="listPeriodAuditExam" parameterType="map" resultMap="ClassPeriodChapterVo">
  491. SELECT
  492. cme.exam_id as id,
  493. cme.course_id,
  494. (SELECT u.realname FROM `user` u where 1=1
  495. <if test="userId != null and userId !='' ">
  496. and u.user_id = #{userId}
  497. </if>
  498. ) as realname,
  499. (SELECT u.user_id FROM `user` u where 1=1
  500. <if test="userId != null and userId !='' ">
  501. and u.user_id = #{userId}
  502. </if>
  503. ) as user_id,
  504. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  505. null as class_hours,
  506. 4 as type,
  507. (
  508. SELECT
  509. ups.record_start_time
  510. FROM
  511. user_period_status ups
  512. LEFT JOIN user_period up ON up.id = ups.period_id
  513. WHERE
  514. period_status = 1
  515. AND up.course_id = gc.course_id
  516. <if test="goodsId != null and goodsId !='' ">
  517. AND up.goods_id = #{goodsId}
  518. </if>
  519. and cme.section_id =up.section_id
  520. AND up.exam_id = cme.exam_id
  521. ) AS study_start_time,
  522. (
  523. SELECT
  524. ups.record_end_time
  525. FROM
  526. user_period_status ups
  527. LEFT JOIN user_period up ON up.id = ups.period_id
  528. WHERE
  529. period_status = 1
  530. AND up.course_id = gc.course_id
  531. <if test="goodsId != null and goodsId !='' ">
  532. AND up.goods_id = #{goodsId}
  533. </if>
  534. AND up.exam_id = cme.exam_id
  535. ) AS study_end_time,
  536. (
  537. SELECT
  538. ups.`status`
  539. FROM
  540. user_period_status ups
  541. LEFT JOIN user_period up ON up.id = ups.period_id
  542. WHERE
  543. period_status = 1
  544. AND up.course_id = gc.course_id
  545. <if test="goodsId != null and goodsId !='' ">
  546. AND up.goods_id = #{goodsId}
  547. </if>
  548. and cme.section_id =up.section_id
  549. AND up.exam_id = cme.exam_id
  550. ) AS STATUS,
  551. (
  552. SELECT
  553. ups.create_time
  554. FROM
  555. user_period_status ups
  556. LEFT JOIN user_period up ON up.id = ups.period_id
  557. WHERE
  558. period_status = 1
  559. AND up.course_id = gc.course_id
  560. <if test="goodsId != null and goodsId !='' ">
  561. AND up.goods_id = #{goodsId}
  562. </if>
  563. and cme.section_id =up.section_id
  564. AND up.exam_id = cme.exam_id
  565. ) AS audit_time,
  566. (
  567. SELECT
  568. COUNT( ups.id )
  569. FROM
  570. user_period_status ups
  571. LEFT JOIN user_period up ON up.id = ups.period_id
  572. WHERE
  573. period_status = 1
  574. AND up.course_id = gc.course_id
  575. <if test="goodsId != null and goodsId !='' ">
  576. AND up.goods_id = #{goodsId}
  577. </if>
  578. and cme.section_id =up.section_id
  579. AND up.exam_id = cme.exam_id
  580. ) AS audit_num
  581. FROM
  582. course_menu_exam cme
  583. LEFT JOIN goods_course gc on gc.course_id = cme.course_id
  584. LEFT JOIN course_menu cm on cme.section_id = cm.menu_id
  585. where 1=1
  586. <if test="goodsId != null and goodsId !='' ">
  587. and gc.goods_id= #{goodsId}
  588. </if>
  589. AND cm.type=3 and cme.chapter_id=0 and cme.module_id=0 and cme.type=1 and cm.type=3
  590. </select>
  591. <select id="listperiodChapter" parameterType="map" resultMap="ClassPeriodChapterVo">
  592. SELECT
  593. cc.chapter_id as id,
  594. cm.course_id,
  595. ( SELECT u.realname FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  596. and u.user_id = #{userId}
  597. </if> LIMIT 1) AS realname,
  598. ( SELECT u.user_id FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  599. and u.user_id = #{userId}
  600. </if> LIMIT 1) AS user_id,
  601. cc.`name` as type_name,
  602. ( SELECT COUNT( ccs.section_id ) FROM course_chapter_section ccs WHERE ccs.chapter_id = cc.chapter_id ) AS
  603. class_hours,
  604. 2 AS type,
  605. (
  606. SELECT
  607. usr.create_time
  608. FROM
  609. user_study_record usr
  610. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id and ccs.chapter_id = usr.chapter_id
  611. WHERE
  612. ccs.chapter_id = cc.chapter_id
  613. AND usr.current_status = 1
  614. <if test="courseId != null and courseId !='' ">
  615. AND usr.course_id=#{courseId}
  616. </if>
  617. <if test="moduleId != null and moduleId !='' ">
  618. AND usr.module_id=#{moduleId}
  619. </if>
  620. <if test="goodsId != null and goodsId !='' ">
  621. AND usr.goods_id=#{goodsId}
  622. </if>
  623. <if test="gradeId != null and gradeId !='' ">
  624. AND usr.grade_id=#{gradeId}
  625. </if>
  626. <if test="userId != null and userId !='' ">
  627. AND usr.user_id=#{userId}
  628. </if>
  629. ORDER BY
  630. usr.create_time ASC
  631. LIMIT 1
  632. ) AS study_start_time,
  633. (
  634. SELECT
  635. usr.update_time
  636. FROM
  637. user_study_record usr
  638. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id and ccs.chapter_id = usr.chapter_id
  639. WHERE
  640. ccs.chapter_id = cc.chapter_id
  641. AND usr.current_status = 1
  642. <if test="courseId != null and courseId !='' ">
  643. AND usr.course_id=#{courseId}
  644. </if>
  645. <if test="moduleId != null and moduleId !='' ">
  646. AND usr.module_id=#{moduleId}
  647. </if>
  648. <if test="goodsId != null and goodsId !='' ">
  649. AND usr.goods_id=#{goodsId}
  650. </if>
  651. <if test="gradeId != null and gradeId !='' ">
  652. AND usr.grade_id=#{gradeId}
  653. </if>
  654. <if test="userId != null and userId !='' ">
  655. AND usr.user_id=#{userId}
  656. </if>
  657. ORDER BY
  658. usr.create_time DESC
  659. LIMIT 1
  660. ) AS study_end_time,
  661. (
  662. SELECT
  663. ubr.performance
  664. FROM
  665. user_bank_record ubr
  666. LEFT JOIN course_menu_exam cme ON cme.exam_id = ubr.exam_id and cme.chapter_id = ubr.chapter_id
  667. WHERE 1=1
  668. AND ubr.current_status = 1
  669. <if test="moduleId != null and moduleId !='' ">
  670. AND ubr.module_id=#{moduleId}
  671. </if>
  672. <if test="goodsId != null and goodsId !='' ">
  673. AND ubr.goods_id=#{goodsId}
  674. </if>
  675. <if test="moduleId != null and moduleId !='' ">
  676. AND cme.module_id=#{moduleId}
  677. </if>
  678. <if test="courseId != null and courseId !='' ">
  679. AND cme.course_id =#{courseId}
  680. </if>
  681. <if test="userId != null and userId !='' ">
  682. AND ubr.user_id=#{userId}
  683. </if>
  684. AND cme.chapter_id = cmc.chapter_id
  685. LIMIT 1 ) AS performance
  686. FROM
  687. course_menu cm
  688. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  689. LEFT JOIN course_chapter cc ON cmc.chapter_id = cc.chapter_id
  690. WHERE
  691. 1 = 1
  692. <if test="moduleId != null and moduleId !='' ">
  693. AND cmc.module_id=#{moduleId}
  694. </if>
  695. <if test="courseId != null and courseId !='' ">
  696. AND cm.course_id =#{courseId}
  697. </if>
  698. </select>
  699. <select id="listperiodExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  700. SELECT
  701. cme.exam_id as id,
  702. cme.course_id,
  703. (SELECT u.realname FROM `user` u where 1=1
  704. <if test="userId != null and userId !='' ">
  705. and u.user_id = #{userId}
  706. </if>
  707. ) as realname,
  708. (SELECT u.user_id FROM `user` u where 1=1
  709. <if test="userId != null and userId !='' ">
  710. and u.user_id = #{userId}
  711. </if>
  712. ) as user_id,
  713. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  714. null as class_hours,
  715. 4 as type
  716. FROM
  717. course_menu_exam cme
  718. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  719. WHERE 1=1
  720. <if test="courseId != null and courseId !='' ">
  721. AND cme.course_id=#{courseId}
  722. </if>
  723. <if test="chapterId != null and chapterId !='' ">
  724. AND cme.chapter_id =#{chapterId}
  725. </if>
  726. <if test="moduleId != null and moduleId !='' ">
  727. AND cme.module_id =#{moduleId}
  728. </if>
  729. </select>
  730. <select id="listPeriodSection" parameterType="map" resultMap="ClassPeriodSectionVo">
  731. SELECT
  732. cs.section_id AS id,
  733. #{courseId} AS course_id,
  734. ( SELECT u.realname FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  735. and u.user_id = #{userId}
  736. </if> ) AS realname,
  737. ( SELECT u.user_id FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  738. and u.user_id = #{userId}
  739. </if> ) AS user_id,
  740. cs.NAME AS type_name,
  741. cs.duration_time,
  742. NULL AS class_hours,
  743. 3 AS type
  744. FROM
  745. course_chapter_section ccs
  746. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  747. WHERE
  748. 1 = 1
  749. <if test="chapterId != null and chapterId !='' ">
  750. AND ccs.chapter_id = #{chapterId}
  751. </if>
  752. </select>
  753. <select id="listPeriodSectionExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  754. SELECT
  755. cme.exam_id as id,
  756. cme.course_id,
  757. (SELECT u.realname FROM `user` u where 1=1
  758. <if test="userId != null and userId !='' ">
  759. and u.user_id = #{userId}
  760. </if>
  761. ) as realname,
  762. (SELECT u.user_id FROM `user` u where 1=1
  763. <if test="userId != null and userId !='' ">
  764. and u.user_id = #{userId}
  765. </if>
  766. ) as user_id,
  767. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  768. null as class_hours,
  769. 4 as type
  770. FROM
  771. course_menu_exam cme
  772. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  773. WHERE 1=1
  774. and cme.module_id =0
  775. <if test="courseId != null and courseId !='' ">
  776. AND cme.course_id=#{courseId}
  777. </if>
  778. <if test="chapterId != null and chapterId !='' ">
  779. AND cme.chapter_id = #{chapterId}
  780. </if>
  781. </select>
  782. <select id="selectStart" parameterType="map" resultType="long">
  783. SELECT
  784. usr.create_time
  785. FROM
  786. user_study_record usr
  787. WHERE
  788. usr.goods_id = #{goodsId}
  789. AND usr.grade_id = #{gradeId}
  790. AND usr.user_id = #{userId} UNION
  791. SELECT
  792. ubr.create_time
  793. FROM
  794. user_bank_record ubr
  795. WHERE
  796. ubr.goods_id =#{goodsId}
  797. AND ubr.grade_id = #{gradeId}
  798. AND ubr.user_id = #{userId}
  799. ORDER BY create_time ASC
  800. </select>
  801. <select id="sendClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  802. SELECT
  803. cgu.user_id,
  804. cg.class_start_time,
  805. cg.class_end_time,
  806. cgg.goods_id,
  807. cg.grade_id
  808. FROM
  809. class_grade_user cgu
  810. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  811. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  812. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  813. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  814. where 1=1
  815. and irb.remind_id =5
  816. and cgu.status = 1
  817. AND unix_timestamp(now()) BETWEEN cg.class_end_time-1728000 and cg.class_end_time-1641600
  818. 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
  819. </select>
  820. <select id="sendTenClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  821. SELECT
  822. cgu.user_id,
  823. cg.class_start_time,
  824. cg.class_end_time,
  825. cgg.goods_id,
  826. cg.grade_id
  827. FROM
  828. class_grade_user cgu
  829. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  830. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  831. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  832. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  833. where 1=1
  834. and irb.remind_id =6
  835. and cgu.status = 1
  836. AND unix_timestamp(now()) BETWEEN cg.class_end_time-864000 and cg.class_end_time-777600
  837. 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
  838. </select>
  839. <select id="sendFiveClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  840. SELECT
  841. cgu.user_id,
  842. cg.class_start_time,
  843. cg.class_end_time,
  844. cgg.goods_id,
  845. cg.grade_id
  846. FROM
  847. class_grade_user cgu
  848. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  849. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  850. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  851. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  852. where 1=1
  853. and irb.remind_id =7
  854. and cgu.status = 1
  855. AND unix_timestamp(now()) BETWEEN cg.class_end_time-432000 and cg.class_end_time-345600
  856. 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
  857. </select>
  858. <select id="selectUserCount" parameterType="com.zhongzheng.modules.user.domain.User" resultType="long">
  859. SELECT
  860. COUNT( 1 )
  861. FROM
  862. `user`
  863. WHERE
  864. id_card = #{idCard} and user_id != #{userId} and `status` = 1
  865. </select>
  866. <select id="selectUserCertificate" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  867. resultMap="ClassGradeUserVoResult">
  868. </select>
  869. <select id="findChapterList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="CourseChapterResultVo">
  870. SELECT
  871. cc.chapter_id,
  872. cc.`name`
  873. FROM
  874. course_module_chapter p
  875. LEFT JOIN course_chapter cc ON p.chapter_id = cc.chapter_id
  876. LEFT JOIN course_menu m ON m.menu_id = p.module_id
  877. LEFT JOIN goods_course gc ON gc.course_id = m.course_id
  878. WHERE
  879. gc.goods_id = #{goodsId}
  880. AND m.type IN ( 1 ) UNION
  881. SELECT
  882. cc.chapter_id,
  883. cc.`name`
  884. FROM
  885. course_menu m
  886. LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id
  887. LEFT JOIN goods_course gc ON gc.course_id = m.course_id
  888. WHERE
  889. gc.goods_id = #{goodsId}
  890. AND m.type IN ( 2 )
  891. </select>
  892. </mapper>