ClassGradeUserMapper.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  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. (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,
  234. cgu.period_time as end_time,
  235. (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
  236. 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
  237. FROM
  238. class_grade_user cgu
  239. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  240. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  241. LEFT JOIN (SELECT
  242. COUNT( m.id ) AS exam_num,
  243. c.goods_id
  244. FROM
  245. course_menu_exam m
  246. LEFT JOIN goods_course c ON m.course_id = c.course_id
  247. where
  248. m.type = 1
  249. GROUP BY c.goods_id ) ge on cgg.goods_id = ge.goods_id
  250. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  251. 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
  252. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  253. where 1=1
  254. and cgu.`status` =1
  255. <if test="changeGrade != null and changeGrade != ''">
  256. AND cgu.change_grade = #{changeGrade}
  257. </if>
  258. <if test="profileStatus != null and profileStatus != ''">
  259. AND up.status = #{profileStatus}
  260. </if>
  261. <if test="gradeId != null and gradeId !='' ">
  262. and cgu.grade_id = #{gradeId}
  263. </if>
  264. <if test="businessId != null and businessId != ''">
  265. AND g.business_id = #{businessId}
  266. </if>
  267. <if test="schoolId != null and schoolId != ''">
  268. AND g.school_id = #{schoolId}
  269. </if>
  270. <if test="majorId != null and majorId != ''">
  271. AND g.major_id = #{majorId}
  272. </if>
  273. <if test="periodStatus != null ">
  274. and cgu.period_status = #{periodStatus}
  275. </if>
  276. <if test="classStartTime != null and classStartTime != '' ">
  277. AND cg.class_start_time > #{classStartTime}
  278. </if>
  279. <if test="classEndTime != null and classEndTime != '' ">
  280. AND #{classEndTime} > cg.class_end_time
  281. </if>
  282. <if test="periodStatus == 2 ">
  283. order by cgu.period_wait_time,cgu.update_time desc
  284. </if>
  285. <if test="periodStatus != 2 ">
  286. order by cgu.update_time desc
  287. </if>
  288. </select>
  289. <select id="getUserPeriodStatus" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  290. resultMap="ClassPeriodStudentVo">
  291. SELECT
  292. IFNULL(ge.exam_num,0) as exam_num,
  293. (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
  294. = 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
  295. FROM
  296. class_grade_user cgu
  297. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  298. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  299. LEFT JOIN (SELECT
  300. COUNT( m.id ) AS exam_num,
  301. c.goods_id
  302. FROM
  303. course_menu_exam m
  304. LEFT JOIN goods_course c ON m.course_id = c.course_id
  305. where
  306. m.type = 1
  307. GROUP BY c.goods_id ) ge on cgg.goods_id = ge.goods_id
  308. where 1=1
  309. and cgu.`status` =1
  310. <if test="gradeId != null and gradeId !='' ">
  311. and cgu.grade_id = #{gradeId}
  312. </if>
  313. <if test="userId != null ">
  314. and cgu.user_id = #{userId}
  315. </if>
  316. LIMIT 1
  317. </select>
  318. <select id="listPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  319. resultMap="ClassPeriodUserVo">
  320. SELECT
  321. u.user_account,
  322. u.realname,
  323. u.id_card,
  324. u.user_id,
  325. u.telphone,
  326. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  327. u.one_inch_photos,
  328. u.id_card_img1,
  329. u.id_card_img2,
  330. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
  331. 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,
  332. (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,
  333. (SELECT COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  334. 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,
  335. (SELECT COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  336. 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,
  337. (SELECT
  338. COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  339. =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,
  340. (SELECT COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  341. 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,
  342. (SELECT
  343. COUNT(up.id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  344. =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,
  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. =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,
  348. (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
  349. FROM
  350. class_grade_user cgu
  351. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  352. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  353. where 1=1
  354. <if test="userId != null and userId !='' ">
  355. and u.user_id = #{userId}
  356. </if>
  357. <if test="gradeId != null and gradeId !='' ">
  358. and cgu.grade_id = #{gradeId}
  359. </if>
  360. <if test="periodStatus != null and periodStatus !='' ">
  361. and cgu.period_status = #{periodStatus}
  362. </if>
  363. LIMIT 1
  364. </select>
  365. <select id="listPeriodAudit" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  366. resultMap="ClassPeriodVo">
  367. SELECT
  368. cm.menu_id as id,
  369. cm.course_id,
  370. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  371. and u.user_id = #{userId}
  372. </if>) as realname,
  373. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  374. and u.user_id = #{userId}
  375. </if>) as user_id,
  376. (SELECT cm.module_name FROM course_module cm where cm.menu_id = cm.module_id) as type_name,
  377. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs LEFT JOIN course_module_chapter cmc on
  378. cmc.chapter_id=ccs.chapter_id where cmc.module_id=cm.menu_id) as class_hours,
  379. 1 as type,
  380. NULL as study_start_time,
  381. NULL as study_end_time
  382. FROM
  383. course_menu cm
  384. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  385. where 1=1
  386. <if test="goodsId != null and goodsId !='' ">
  387. and gc.goods_id=#{goodsId}
  388. </if>
  389. AND cm.type=1
  390. UNION
  391. SELECT
  392. cm.menu_id as id,
  393. cm.course_id,
  394. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  395. and u.user_id = #{userId}
  396. </if>) as realname,
  397. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  398. and u.user_id = #{userId}
  399. </if>) as user_id,
  400. (SELECT cc.`name` FROM course_chapter cc where cm.menu_id = cc.chapter_id) as type_name,
  401. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs where ccs.chapter_id=cm.menu_id) as class_hours,
  402. 2 as type,
  403. (SELECT usr.create_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  404. ccs.section_id where ccs.chapter_id = cm.menu_id and usr.goods_id = gc.goods_id and usr.grade_id = #{gradeId} ORDER BY usr.create_time ASC
  405. limit 1) as study_start_time,
  406. (SELECT usr.update_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  407. ccs.section_id where ccs.chapter_id = cm.menu_id and usr.goods_id = gc.goods_id and usr.grade_id = #{gradeId} ORDER BY usr.create_time DESC
  408. limit 1) as study_end_time
  409. FROM
  410. course_menu cm
  411. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  412. where 1=1 <if test="goodsId != null and goodsId !='' ">
  413. and gc.goods_id=#{goodsId}
  414. </if> AND cm.type=2
  415. </select>
  416. <select id="listPeriodAuditSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  417. resultMap="ClassPeriodVo">
  418. SELECT
  419. cm.menu_id as id,
  420. cm.course_id,
  421. (SELECT u.realname FROM `user` u where 1=1
  422. <if test="userId != null and userId !='' ">
  423. and u.user_id = #{userId}
  424. </if>
  425. ) as realname,
  426. (SELECT u.user_id FROM `user` u where 1=1
  427. <if test="userId != null and userId !='' ">
  428. and u.user_id = #{userId}
  429. </if>
  430. ) as user_id,
  431. cs.`name` as type_name,
  432. cs.duration_time,
  433. null as class_hours,
  434. 3 as type
  435. FROM
  436. course_menu cm
  437. LEFT JOIN course_section cs on cm.menu_id = cs.section_id
  438. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  439. where 1=1
  440. <if test="goodsId != null and goodsId !='' ">
  441. and gc.goods_id = #{goodsId}
  442. </if>
  443. AND cm.type=3
  444. </select>
  445. <select id="listPeriodAuditExam" parameterType="map" resultMap="ClassPeriodChapterVo">
  446. SELECT
  447. cme.exam_id as id,
  448. cme.course_id,
  449. (SELECT u.realname FROM `user` u where 1=1
  450. <if test="userId != null and userId !='' ">
  451. and u.user_id = #{userId}
  452. </if>
  453. ) as realname,
  454. (SELECT u.user_id FROM `user` u where 1=1
  455. <if test="userId != null and userId !='' ">
  456. and u.user_id = #{userId}
  457. </if>
  458. ) as user_id,
  459. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  460. null as class_hours,
  461. 4 as type,
  462. (
  463. SELECT
  464. ups.record_start_time
  465. FROM
  466. user_period_status ups
  467. LEFT JOIN user_period up ON up.id = ups.period_id
  468. WHERE
  469. period_status = 1
  470. AND up.course_id = gc.course_id
  471. <if test="goodsId != null and goodsId !='' ">
  472. AND up.goods_id = #{goodsId}
  473. </if>
  474. and cme.section_id =up.section_id
  475. AND up.exam_id = cme.exam_id
  476. ) AS study_start_time,
  477. (
  478. SELECT
  479. ups.record_end_time
  480. FROM
  481. user_period_status ups
  482. LEFT JOIN user_period up ON up.id = ups.period_id
  483. WHERE
  484. period_status = 1
  485. AND up.course_id = gc.course_id
  486. <if test="goodsId != null and goodsId !='' ">
  487. AND up.goods_id = #{goodsId}
  488. </if>
  489. AND up.exam_id = cme.exam_id
  490. ) AS study_end_time,
  491. (
  492. SELECT
  493. ups.`status`
  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 STATUS,
  506. (
  507. SELECT
  508. ups.create_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 cme.section_id =up.section_id
  519. AND up.exam_id = cme.exam_id
  520. ) AS audit_time,
  521. (
  522. SELECT
  523. COUNT( ups.id )
  524. FROM
  525. user_period_status ups
  526. LEFT JOIN user_period up ON up.id = ups.period_id
  527. WHERE
  528. period_status = 1
  529. AND up.course_id = gc.course_id
  530. <if test="goodsId != null and goodsId !='' ">
  531. AND up.goods_id = #{goodsId}
  532. </if>
  533. and cme.section_id =up.section_id
  534. AND up.exam_id = cme.exam_id
  535. ) AS audit_num
  536. FROM
  537. course_menu_exam cme
  538. LEFT JOIN goods_course gc on gc.course_id = cme.course_id
  539. LEFT JOIN course_menu cm on cme.section_id = cm.menu_id
  540. where 1=1
  541. <if test="goodsId != null and goodsId !='' ">
  542. and gc.goods_id= #{goodsId}
  543. </if>
  544. AND cm.type=3 and cme.chapter_id=0 and cme.module_id=0 and cme.type=1 and cm.type=3
  545. </select>
  546. <select id="listperiodChapter" parameterType="map" resultMap="ClassPeriodChapterVo">
  547. SELECT
  548. cc.chapter_id as id,
  549. cm.course_id,
  550. ( SELECT u.realname FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  551. and u.user_id = #{userId}
  552. </if> LIMIT 1) AS realname,
  553. ( SELECT u.user_id FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  554. and u.user_id = #{userId}
  555. </if> LIMIT 1) AS user_id,
  556. cc.`name` as type_name,
  557. ( SELECT COUNT( ccs.section_id ) FROM course_chapter_section ccs WHERE ccs.chapter_id = cc.chapter_id ) AS
  558. class_hours,
  559. 2 AS type,
  560. (
  561. SELECT
  562. usr.create_time
  563. FROM
  564. user_study_record usr
  565. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id
  566. WHERE
  567. ccs.chapter_id = cc.chapter_id
  568. <if test="goodsId != null and goodsId !='' ">
  569. AND usr.goods_id=#{goodsId}
  570. </if>
  571. <if test="gradeId != null and gradeId !='' ">
  572. AND usr.grade_id=#{gradeId}
  573. </if>
  574. ORDER BY
  575. usr.create_time ASC
  576. LIMIT 1
  577. ) AS study_start_time,
  578. (
  579. SELECT
  580. usr.update_time
  581. FROM
  582. user_study_record usr
  583. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id
  584. WHERE
  585. ccs.chapter_id = cc.chapter_id
  586. <if test="goodsId != null and goodsId !='' ">
  587. AND usr.goods_id=#{goodsId}
  588. </if>
  589. <if test="gradeId != null and gradeId !='' ">
  590. AND usr.grade_id=#{gradeId}
  591. </if>
  592. ORDER BY
  593. usr.create_time DESC
  594. LIMIT 1
  595. ) AS study_end_time,
  596. (
  597. SELECT
  598. ubr.performance
  599. FROM
  600. user_bank_record ubr
  601. LEFT JOIN course_menu_exam cme ON cme.exam_id = ubr.exam_id
  602. WHERE 1=1
  603. <if test="goodsId != null and goodsId !='' ">
  604. AND ubr.goods_id=#{goodsId}
  605. </if>
  606. <if test="moduleId != null and moduleId !='' ">
  607. AND cme.module_id=#{moduleId}
  608. </if>
  609. <if test="courseId != null and courseId !='' ">
  610. AND cme.course_id =#{courseId}
  611. </if>
  612. AND cme.chapter_id = cmc.chapter_id
  613. LIMIT 1 ) AS performance
  614. FROM
  615. course_menu cm
  616. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  617. LEFT JOIN course_chapter cc ON cmc.chapter_id = cc.chapter_id
  618. WHERE
  619. 1 = 1
  620. <if test="moduleId != null and moduleId !='' ">
  621. AND cmc.module_id=#{moduleId}
  622. </if>
  623. <if test="courseId != null and courseId !='' ">
  624. AND cm.course_id =#{courseId}
  625. </if>
  626. </select>
  627. <select id="listperiodExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  628. SELECT
  629. cme.exam_id as id,
  630. cme.course_id,
  631. (SELECT u.realname FROM `user` u where 1=1
  632. <if test="userId != null and userId !='' ">
  633. and u.user_id = #{userId}
  634. </if>
  635. ) as realname,
  636. (SELECT u.user_id FROM `user` u where 1=1
  637. <if test="userId != null and userId !='' ">
  638. and u.user_id = #{userId}
  639. </if>
  640. ) as user_id,
  641. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  642. null as class_hours,
  643. 4 as type
  644. FROM
  645. course_menu_exam cme
  646. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  647. WHERE 1=1
  648. <if test="courseId != null and courseId !='' ">
  649. AND cme.course_id=#{courseId}
  650. </if>
  651. <if test="chapterId != null and chapterId !='' ">
  652. AND cme.chapter_id =#{chapterId}
  653. </if>
  654. <if test="moduleId != null and moduleId !='' ">
  655. AND cme.module_id =#{moduleId}
  656. </if>
  657. </select>
  658. <select id="listPeriodSection" parameterType="map" resultMap="ClassPeriodSectionVo">
  659. SELECT
  660. cs.section_id AS id,
  661. #{courseId} AS course_id,
  662. ( SELECT u.realname FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  663. and u.user_id = #{userId}
  664. </if> ) AS realname,
  665. ( SELECT u.user_id FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  666. and u.user_id = #{userId}
  667. </if> ) AS user_id,
  668. cs.NAME AS type_name,
  669. cs.duration_time,
  670. NULL AS class_hours,
  671. 3 AS type
  672. FROM
  673. course_chapter_section ccs
  674. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  675. WHERE
  676. 1 = 1
  677. <if test="chapterId != null and chapterId !='' ">
  678. AND ccs.chapter_id = #{chapterId}
  679. </if>
  680. </select>
  681. <select id="listPeriodSectionExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  682. SELECT
  683. cme.exam_id as id,
  684. cme.course_id,
  685. (SELECT u.realname FROM `user` u where 1=1
  686. <if test="userId != null and userId !='' ">
  687. and u.user_id = #{userId}
  688. </if>
  689. ) as realname,
  690. (SELECT u.user_id FROM `user` u where 1=1
  691. <if test="userId != null and userId !='' ">
  692. and u.user_id = #{userId}
  693. </if>
  694. ) as user_id,
  695. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  696. null as class_hours,
  697. 4 as type
  698. FROM
  699. course_menu_exam cme
  700. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  701. WHERE 1=1
  702. and cme.module_id =0
  703. <if test="courseId != null and courseId !='' ">
  704. AND cme.course_id=#{courseId}
  705. </if>
  706. <if test="chapterId != null and chapterId !='' ">
  707. AND cme.chapter_id = #{chapterId}
  708. </if>
  709. </select>
  710. <select id="selectStart" parameterType="map" resultType="long">
  711. SELECT
  712. usr.create_time
  713. FROM
  714. user_study_record usr
  715. WHERE
  716. usr.goods_id = #{goodsId}
  717. AND usr.grade_id = #{gradeId}
  718. AND usr.user_id = #{userId} UNION
  719. SELECT
  720. ubr.create_time
  721. FROM
  722. user_bank_record ubr
  723. WHERE
  724. ubr.goods_id =#{goodsId}
  725. AND ubr.grade_id = #{gradeId}
  726. AND ubr.user_id = #{userId}
  727. ORDER BY create_time ASC
  728. </select>
  729. <select id="sendClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  730. SELECT
  731. cgu.user_id,
  732. cg.class_start_time,
  733. cg.class_end_time,
  734. cgg.goods_id,
  735. cg.grade_id
  736. FROM
  737. class_grade_user cgu
  738. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  739. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  740. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  741. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  742. where 1=1
  743. and irb.remind_id =5
  744. and cgu.status = 1
  745. AND unix_timestamp(now()) BETWEEN cg.class_end_time-1728000 and cg.class_end_time-1641600
  746. 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
  747. </select>
  748. <select id="sendTenClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  749. SELECT
  750. cgu.user_id,
  751. cg.class_start_time,
  752. cg.class_end_time,
  753. cgg.goods_id,
  754. cg.grade_id
  755. FROM
  756. class_grade_user cgu
  757. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  758. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  759. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  760. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  761. where 1=1
  762. and irb.remind_id =6
  763. and cgu.status = 1
  764. AND unix_timestamp(now()) BETWEEN cg.class_end_time-864000 and cg.class_end_time-777600
  765. 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
  766. </select>
  767. <select id="sendFiveClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  768. SELECT
  769. cgu.user_id,
  770. cg.class_start_time,
  771. cg.class_end_time,
  772. cgg.goods_id,
  773. cg.grade_id
  774. FROM
  775. class_grade_user cgu
  776. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  777. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  778. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  779. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  780. where 1=1
  781. and irb.remind_id =7
  782. and cgu.status = 1
  783. AND unix_timestamp(now()) BETWEEN cg.class_end_time-432000 and cg.class_end_time-345600
  784. 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
  785. </select>
  786. <select id="selectUserCount" parameterType="com.zhongzheng.modules.user.domain.User" resultType="long">
  787. SELECT
  788. COUNT( 1 )
  789. FROM
  790. `user`
  791. WHERE
  792. id_card = #{idCard} and user_id != #{userId} and `status` = 1
  793. </select>
  794. </mapper>