ClassGradeUserMapper.xml 36 KB

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