ClassGradeUserMapper.xml 37 KB

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