ClassGradeUserMapper.xml 40 KB

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