StudentCourseHomeworkMapper.xml 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.StudentCourseHomeworkDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentCourseHomework" id="StudentCourseHomework">
  9. <result column="id_" property="id"/>
  10. <result column="user_id_" property="userId"/>
  11. <result column="username_" property="userName"/>
  12. <result column="phone_" property="phone"/>
  13. <result column="avatar_" property="avatar"/>
  14. <result column="course_homework_id_" property="courseHomeworkId"/>
  15. <result column="course_schedule_id_" property="courseScheduleId"/>
  16. <result column="attachments_" property="attachments"/>
  17. <result column="score_" property="score"/>
  18. <result column="create_time_" property="createTime"/>
  19. <result column="update_time_" property="updateTime"/>
  20. <result column="remark_" property="remark"/>
  21. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  22. <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  23. <result column="is_replied_timely_" property="isRepliedTimely"/>
  24. <result column="is_view_" property="isView" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  25. <result column="submit_time_" property="submitTime"/>
  26. <result column="music_score_name_" property="musicScoreName"/>
  27. <result column="music_score_id_" property="musicScoreId"/>
  28. <result column="music_score_content_" property="musicScoreContent"/>
  29. <result column="tenant_id_" property="tenantId"/>
  30. <result column="standard_flag_" property="standardFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  31. </resultMap>
  32. <resultMap type="com.ym.mec.biz.dal.dto.CourseHomeworkStudentDetailDto" id="CourseHomeworkStudentDetailDto">
  33. <result column="musicGroupName" property="musicGroupName"/>
  34. <result column="classGroupName" property="classGroupName"/>
  35. <result column="courseHomeworkId" property="courseHomeworkId"/>
  36. <result column="course_schedule_id_" property="courseScheduleId"/>
  37. <result column="studentCourseHomeworkId" property="studentCourseHomeworkId"/>
  38. <result column="content_" property="content"/>
  39. <result column="expiry_date_" property="expiryDate"/>
  40. <result column="completed_num_" property="completedNum"/>
  41. <result column="expect_num_" property="expectNum"/>
  42. <result column="attachments_" property="attachments"/>
  43. <result column="create_time_" property="createTime"/>
  44. <result column="score_" property="score"/>
  45. <result column="music_score_id_" property="musicScoreId"/>
  46. <result column="music_score_content_" property="musicScoreContent"/>
  47. <result column="submit_time_" property="submitTime"/>
  48. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  49. <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  50. <result column="standard_flag_" property="standardFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  51. </resultMap>
  52. <resultMap type="com.ym.mec.biz.dal.entity.StudentCourseHomework" id="StudentCourseHomeworkFull"
  53. extends="StudentCourseHomework">
  54. <result column="musicGroupName" property="courseHomework.musicGroup.name"/>
  55. <result column="classGroupName" property="courseHomework.classGroup.name"/>
  56. </resultMap>
  57. <!-- 根据主键查询一条记录 -->
  58. <select id="get" resultMap="StudentCourseHomework">
  59. SELECT *
  60. FROM student_course_homework
  61. WHERE id_ = #{id}
  62. </select>
  63. <!-- 全查询 -->
  64. <select id="findAll" resultMap="StudentCourseHomework">
  65. SELECT *
  66. FROM student_course_homework where tenant_id_ = #{tenantId}
  67. ORDER BY id_
  68. </select>
  69. <!-- 向数据库增加一条记录 -->
  70. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomework" useGeneratedKeys="true"
  71. keyColumn="id" keyProperty="id">
  72. INSERT INTO student_course_homework
  73. (user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,update_time_,
  74. remark_,status_,is_replied_,is_view_,is_replied_timely_,music_score_id_,music_score_content_,tenant_id_,standard_flag_)
  75. VALUES(#{userId},#{courseScheduleId},#{courseHomeworkId},#{attachments},#{score},now(),now(),#{remark},
  76. #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  77. #{isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isRepliedTimely},
  78. #{musicScoreId},#{musicScoreContent},#{tenantId},#{standardFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  79. </insert>
  80. <insert id="batchInsertStudentCourseHomeworkRecord" parameterType="java.util.List" useGeneratedKeys="true"
  81. keyColumn="id" keyProperty="id">
  82. INSERT INTO student_course_homework
  83. (user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,
  84. update_time_,remark_,status_,is_replied_,is_view_,is_replied_timely_,music_score_id_,music_score_content_,tenant_id_,standard_flag_,group_type_)
  85. VALUE
  86. <foreach collection="list" item="homework" separator=",">
  87. (#{homework.userId},#{homework.courseScheduleId},#{homework.courseHomeworkId},#{homework.attachments},
  88. #{homework.score},now(),now(),#{homework.remark},#{homework.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  89. #{homework.isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  90. #{homework.isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{homework.isRepliedTimely},
  91. #{homework.musicScoreId},#{homework.musicScoreContent},#{homework.tenantId},
  92. #{homework.standardFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  93. #{homework.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  94. </foreach>
  95. </insert>
  96. <!-- 根据主键查询一条记录 -->
  97. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomework">
  98. UPDATE student_course_homework
  99. <set>
  100. <if test="standardFlag != null">
  101. standard_flag_ = #{standardFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  102. </if>
  103. <if test="musicScoreId != null">
  104. music_score_id_ = #{musicScoreId},
  105. </if>
  106. <if test="musicScoreContent != null and musicScoreContent != ''">
  107. music_score_content_ = #{musicScoreContent},
  108. </if>
  109. <if test="courseHomeworkId != null">
  110. course_homework_id_ = #{courseHomeworkId},
  111. </if>
  112. <if test="courseScheduleId != null">
  113. course_schedule_id_ = #{courseScheduleId},
  114. </if>
  115. update_time_ = NOW(),
  116. <if test="score != null">
  117. score_ = #{score},
  118. </if>
  119. <if test="attachments != null">
  120. attachments_ = #{attachments},
  121. </if>
  122. <if test="remark != null">
  123. remark_ = #{remark},
  124. </if>
  125. <if test="status != null">
  126. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  127. </if>
  128. <if test="isReplied != null">
  129. is_replied_ = #{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  130. </if>
  131. <if test="isRepliedTimely != null">
  132. is_replied_timely_ = #{isRepliedTimely},
  133. </if>
  134. <if test="isView != null">
  135. is_view_ = #{isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  136. </if>
  137. <if test="submitTime!=null">
  138. submit_time_ = #{submitTime}
  139. </if>
  140. </set>
  141. WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  142. </update>
  143. <!-- 根据主键删除一条记录 -->
  144. <delete id="delete">
  145. DELETE
  146. FROM student_course_homework
  147. WHERE id_ = #{id}
  148. </delete>
  149. <resultMap type="com.ym.mec.biz.dal.dto.CourseHomeworkListDto" id="CourseHomeworkDto">
  150. <result column="id_" property="id"/>
  151. <result column="course_schedule_id_" property="courseScheduleId"/>
  152. <result column="content_" property="content"/>
  153. <result column="create_time_" property="createTime"/>
  154. <result column="start_class_time_" property="startClassTime"/>
  155. <result column="expiry_date_" property="expiryDate"/>
  156. <result column="music_group_id_" property="musicGroupId"/>
  157. <result column="music_group_name_" property="musicGroupName"/>
  158. <result column="class_group_id_" property="classGroupId"/>
  159. <result column="class_group_name_" property="classGroupName"/>
  160. <result column="completed_num_" property="completedNum"/>
  161. <result column="expect_num_" property="expectNum"/>
  162. <result column="expiry_date_" property="expiryDate"/>
  163. <result column="remark_" property="remark"/>
  164. <result column="real_name_" property="teacherName"/>
  165. <result column="avatar_" property="headUrl"/>
  166. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  167. <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  168. </resultMap>
  169. <sql id="queryCondition">
  170. <where>
  171. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL) AND cs.pre_course_flag_ = 0 and cs.tenant_id_ = #{tenantId}
  172. <if test="createTime != null">
  173. AND DATE_FORMAT(ch.create_time_,"%Y%m%d") = DATE_FORMAT(#{createTime},"%Y%m%d")
  174. </if>
  175. <if test="musicGroupId != null">
  176. AND cg.music_group_id_ = #{musicGroupId}
  177. </if>
  178. <if test="groupType!=null">
  179. AND cg.group_type_= #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  180. </if>
  181. <if test="classGroupId != null">
  182. AND ch.class_group_id_ = #{classGroupId}
  183. </if>
  184. <if test="userId != null">
  185. AND sch.user_id_ = #{userId}
  186. </if>
  187. </where>
  188. </sql>
  189. <!-- 分页查询 -->
  190. <select id="queryPage" resultMap="CourseHomeworkDto" parameterType="map">
  191. SELECT
  192. sch.id_,
  193. ch.*,
  194. IF(cs.group_type_='MUSIC',mg.name_,NULL) music_group_name_,
  195. cg.name_ class_group_name_,
  196. CONCAT( class_date_, ' ', start_class_time_ ) start_class_time_,
  197. ch.expiry_date_,
  198. sch.remark_,
  199. sch.status_,
  200. sch.is_replied_,
  201. su.real_name_,
  202. su.avatar_
  203. FROM student_course_homework sch
  204. LEFT JOIN course_homework ch ON sch.course_homework_id_=ch.id_
  205. LEFT JOIN course_schedule cs ON ch.course_schedule_id_=cs.id_
  206. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  207. LEFT JOIN music_group mg ON ch.music_group_id_=mg.id_
  208. LEFT JOIN class_group cg ON ch.class_group_id_=cg.id_
  209. <include refid="queryCondition"/>
  210. ORDER BY CONCAT( class_date_, ' ', start_class_time_ ) DESC
  211. <include refid="global.limit"/>
  212. </select>
  213. <!-- 查询当前表的总记录数 -->
  214. <select id="queryCount" resultType="int">
  215. SELECT COUNT(*) FROM student_course_homework sch
  216. LEFT JOIN course_homework ch ON sch.course_homework_id_=ch.id_
  217. LEFT JOIN course_schedule cs ON ch.course_schedule_id_=cs.id_
  218. LEFT JOIN music_group mg ON ch.music_group_id_=mg.id_
  219. LEFT JOIN class_group cg ON ch.class_group_id_=cg.id_
  220. <include refid="queryCondition"/>
  221. </select>
  222. <select id="findCourseHomeworkStudentDetail" resultMap="CourseHomeworkStudentDetailDto">
  223. SELECT mg.name_ musicGroupName,
  224. cg.name_ classGroupName,
  225. ch.id_ courseHomeworkId,
  226. ch.content_,
  227. ch.expiry_date_,
  228. ch.completed_num_,
  229. ch.expect_num_,
  230. ch.expiry_date_,
  231. ch.create_time_,
  232. sch.music_score_id_,
  233. sch.music_score_content_,
  234. sch.id_ studentCourseHomeworkId,
  235. sch.attachments_,
  236. sch.score_,
  237. sch.status_,
  238. sch.is_replied_,
  239. sch.course_schedule_id_,
  240. sch.standard_flag_,
  241. sch.submit_time_
  242. FROM course_homework ch
  243. LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
  244. LEFT JOIN music_group mg ON ch.music_group_id_ = mg.id_
  245. LEFT JOIN class_group cg ON ch.class_group_id_ = cg.id_
  246. WHERE ch.course_schedule_id_ = #{courseScheduleID}
  247. AND sch.user_id_ = #{userID}
  248. </select>
  249. <select id="constructInitialStudentHomeworkRecords" resultMap="StudentCourseHomework">
  250. SELECT #{courseHomeworkID} course_homework_id_,
  251. sa.user_id_,
  252. 0 status_,
  253. 0 is_replied_
  254. FROM student_attendance sa
  255. WHERE sa.course_schedule_id_ = #{courseScheduleID}
  256. AND status_ = "NORMAL"
  257. </select>
  258. <select id="constructInitialStudentHomeworkRecordsWithPayment" resultMap="StudentCourseHomework">
  259. SELECT #{courseHomeworkID} course_homework_id_,
  260. #{courseScheduleID} course_schedule_id_,
  261. #{musicScoreId} music_score_id_,
  262. #{musicScoreContent} music_score_content_,
  263. sa.user_id_,
  264. 0 status_,
  265. 0 is_replied_,
  266. 0 is_replied_timely_
  267. FROM course_schedule_student_payment sa
  268. WHERE sa.course_schedule_id_ = #{courseScheduleID}
  269. <if test="userIdList != null and userIdList.size > 0">
  270. AND sa.user_id_ IN
  271. <foreach collection="userIdList" open="(" close=")" separator="," item="userId">
  272. #{userId}
  273. </foreach>
  274. </if>
  275. </select>
  276. <select id="findByCourseSchedule" resultMap="StudentCourseHomework">
  277. SELECT
  278. sch.*,
  279. su.username_,
  280. su.avatar_,
  281. su.phone_
  282. FROM
  283. student_course_homework sch
  284. LEFT JOIN sys_user su ON sch.user_id_=su.id_
  285. <where>
  286. sch.course_schedule_id_=#{courseScheduleId}
  287. <if test="homeworkId!=null">
  288. AND sch.course_homework_id_=#{homeworkId}
  289. </if>
  290. <if test="userName!=null and userName!=''">
  291. AND su.username_ LIKE CONCAT('%',#{userName},'%')
  292. </if>
  293. </where>
  294. </select>
  295. <select id="findByStudentAndCourseHomewok" resultMap="StudentCourseHomework">
  296. SELECT *
  297. FROM student_course_homework
  298. WHERE user_id_ = #{userId}
  299. AND course_homework_id_ = #{courseHomeworkId}
  300. </select>
  301. <select id="queryNotDoneHomeworkList" resultMap="StudentCourseHomeworkFull">
  302. SELECT sch.*,
  303. cg.name_ classGroupName,
  304. mg.name_ musicGroupName
  305. FROM student_course_homework sch
  306. LEFT JOIN course_homework ch ON sch.course_homework_id_ = ch.id_
  307. LEFT JOIN music_group mg ON ch.music_group_id_ = mg.id_
  308. LEFT JOIN class_group cg ON ch.class_group_id_ = cg.id_
  309. WHERE date_format(date_add(ch.expiry_date_,interval -1 day),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
  310. AND (sch.standard_flag_ not in ('STANDARD', 'EXCELLENT') or sch.standard_flag_ is null)
  311. AND ch.version_tag_ = 'v2'
  312. </select>
  313. <select id="countStudentCourseHomeworks" resultType="java.lang.Integer">
  314. SELECT COUNT(id_)
  315. FROM student_course_homework
  316. WHERE course_schedule_id_ = #{search}
  317. </select>
  318. <resultMap id="StudentCourseHomeworkDtoMap" type="com.ym.mec.biz.dal.dto.StudentCourseHomeworkDto">
  319. <result column="student_course_homework_id_" property="studentCourseHomeworkId"/>
  320. <result column="user_id_" property="studentId"/>
  321. <result column="username_" property="studentName"/>
  322. <result column="phone_" property="phone"/>
  323. <result column="subject_name_" property="subjectNames"/>
  324. <result column="attachments_" property="url"/>
  325. <result column="is_replied_" property="isReplied"/>
  326. <result column="is_view_" property="isView"/>
  327. <result column="update_time_" property="createTime"/>
  328. <result column="submit_time_" property="submitTime"/>
  329. </resultMap>
  330. <select id="findStudentCourseHomeworks" resultMap="StudentCourseHomeworkDtoMap">
  331. SELECT sch.id_ student_course_homework_id_,sch.attachments_,sch.is_replied_,sch.is_view_,
  332. sch.update_time_,cssp.user_id_,su.username_,su.phone_,sch.submit_time_,s.name_ subject_name_
  333. FROM student_course_homework sch
  334. LEFT JOIN course_schedule_student_payment cssp ON sch.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ =
  335. sch.user_id_
  336. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  337. LEFT JOIN student_registration sr ON cssp.music_group_id_ = sr.music_group_id_ AND cssp.user_id_ = sr.user_id_
  338. LEFT JOIN `subject` s ON s.id_ = sr.actual_subject_id_
  339. WHERE sch.course_schedule_id_ = #{search}
  340. ORDER BY sch.id_ DESC
  341. <include refid="global.limit"/>
  342. </select>
  343. <resultMap id="StudentHomeworkRecordDto" type="com.ym.mec.biz.dal.dto.StudentHomeworkRecordDto">
  344. <result property="studentCourseHomeworkId" column="student_course_homework_id_"/>
  345. <result property="courseScheduleId" column="course_schedule_id_"/>
  346. <result property="courseName" column="course_name_"/>
  347. <result property="startClassTime" column="start_class_time_"/>
  348. <result property="teacherId" column="actual_teacher_id_"/>
  349. <result property="status" column="status_"/>
  350. <result property="expiryDate" column="expiry_date_"/>
  351. <result property="teacherName" column="real_name_"/>
  352. <result property="headUrl" column="avatar_"/>
  353. <result property="endClassTime" column="endClassTime"/>
  354. <result property="musicGroupId" column="musicGroupId"/>
  355. <result property="classGroupId" column="classGroupId"/>
  356. <result property="teachMode" column="teachMode"/>
  357. <result property="submitTime" column="submitTime"/>
  358. <result property="standardFlag" column="standardFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  359. </resultMap>
  360. <select id="findStudentHomeworkRecord" resultMap="StudentHomeworkRecordDto">
  361. SELECT
  362. sch.id_ student_course_homework_id_,
  363. sch.course_schedule_id_,
  364. cs.name_ course_name_,
  365. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  366. CONCAT(cs.class_date_,' ',cs.end_class_time_) endClassTime,
  367. cs.actual_teacher_id_,
  368. sch.status_,
  369. sch.submit_time_ as submitTime,
  370. sch.standard_flag_ as standardFlag,
  371. ch.expiry_date_,
  372. su.real_name_,
  373. su.avatar_,
  374. cs.music_group_id_ as musicGroupId,
  375. cs.class_group_id_ as classGroupId,
  376. cs.teach_mode_ as teachMode
  377. FROM
  378. student_course_homework sch
  379. LEFT JOIN course_homework ch ON ch.id_ = sch.course_homework_id_
  380. LEFT JOIN course_schedule cs ON cs.id_ = sch.course_schedule_id_
  381. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  382. WHERE sch.user_id_=#{userId} AND cs.pre_course_flag_ = 0
  383. AND DATE_FORMAT(class_date_, '%Y-%m')=DATE_FORMAT(#{classDate}, '%Y-%m')
  384. <if test="finishStatus != null">
  385. <if test="finishStatus == true">
  386. and sch.standard_flag_ in ('STANDARD','EXCELLENT')
  387. </if>
  388. <if test="finishStatus == false">
  389. and (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
  390. </if>
  391. </if>
  392. <if test="versionTag != null">
  393. and ch.version_tag_ = #{versionTag}
  394. </if>
  395. ORDER BY CONCAT(cs.class_date_,' ',cs.start_class_time_) DESC
  396. <include refid="global.limit"/>
  397. </select>
  398. <select id="countStudentHomeworkRecord" resultType="int">
  399. SELECT COUNT(sch.id_)
  400. FROM student_course_homework sch
  401. LEFT JOIN course_homework ch ON ch.id_ = sch.course_homework_id_
  402. LEFT JOIN course_schedule cs ON cs.id_ = sch.course_schedule_id_
  403. WHERE sch.user_id_ = #{userId}
  404. AND DATE_FORMAT(class_date_, '%Y-%m') = DATE_FORMAT(#{classDate}, '%Y-%m')
  405. <if test="finishStatus != null">
  406. <if test="finishStatus == true">
  407. and sch.standard_flag_ in ('STANDARD','EXCELLENT')
  408. </if>
  409. <if test="finishStatus == false">
  410. and (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
  411. </if>
  412. </if>
  413. <if test="versionTag != null">
  414. and ch.version_tag_ = #{versionTag}
  415. </if>
  416. </select>
  417. <select id="findByCourses" resultMap="StudentCourseHomework">
  418. SELECT * FROM student_course_homework WHERE course_schedule_id_ IN
  419. <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
  420. #{courseId}
  421. </foreach>
  422. </select>
  423. <resultMap id="StudentServeCourseHomeworkDto" type="com.ym.mec.biz.dal.dto.StudentServeCourseHomeworkDto"
  424. extends="StudentCourseHomework">
  425. <result property="courseStartTime" column="course_start_time_"/>
  426. <result property="homeworkCreateTime" column="homework_create_time_"/>
  427. <result property="musicGroupId" column="music_group_id_"/>
  428. </resultMap>
  429. <select id="findStudentHomeworkWithCourseDateRange" resultMap="StudentServeCourseHomeworkDto">
  430. SELECT
  431. sch.*,
  432. DATE_FORMAT(sch.create_time_, '%Y-%m-%d') homework_create_time_,
  433. cs.class_date_ course_start_time_,
  434. cs.music_group_id_
  435. FROM
  436. student_course_homework sch
  437. LEFT JOIN course_schedule cs ON sch.course_schedule_id_ = cs.id_
  438. WHERE
  439. cs.class_date_ BETWEEN #{startDate} AND #{endDate}
  440. AND sch.user_id_ IN
  441. <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
  442. #{studentId}
  443. </foreach>
  444. </select>
  445. <select id="checkStudentHaveHomeworkInDateRange" resultType="java.lang.Integer">
  446. SELECT
  447. DISTINCT sch.user_id_
  448. FROM
  449. student_course_homework sch
  450. LEFT JOIN course_schedule cs ON sch.course_schedule_id_ = cs.id_
  451. WHERE
  452. cs.class_date_ BETWEEN #{startDate}
  453. AND #{endDate}
  454. AND sch.user_id_ IN
  455. <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
  456. #{studentId}
  457. </foreach>
  458. </select>
  459. <select id="queryReplied" resultType="java.util.Map">
  460. SELECT sch.course_homework_id_ AS 'key',COUNT(0) AS 'value'
  461. FROM student_course_homework sch
  462. WHERE sch.course_homework_id_ IN
  463. <foreach collection="homeWorkIds" open="(" close=")" separator="," item="item">
  464. #{item}
  465. </foreach>
  466. AND sch.is_replied_ = 1
  467. GROUP BY sch.course_homework_id_
  468. </select>
  469. <sql id="queryAllCondition">
  470. <where>
  471. tenant_id_ = #{tenantId}
  472. <if test="courseScheduleId!=null">
  473. AND course_schedule_id_=#{courseScheduleId}
  474. </if>
  475. <if test="isReplied!=null">
  476. AND is_replied_=#{isReplied}
  477. </if>
  478. </where>
  479. </sql>
  480. <select id="queryAll" resultMap="StudentCourseHomework">
  481. SELECT * FROM student_course_homework
  482. <include refid="queryAllCondition"/>
  483. ORDER BY id_
  484. <include refid="global.limit"></include>
  485. </select>
  486. <select id="countAll" resultType="int">
  487. SELECT COUNT(*) FROM student_course_homework
  488. <include refid="queryAllCondition"/>
  489. </select>
  490. <delete id="delByCourseScheduleId">
  491. DELETE
  492. FROM student_course_homework
  493. WHERE course_schedule_id_ = #{courseScheduleId}
  494. </delete>
  495. <delete id="batchDelByCourseScheduleId">
  496. DELETE FROM student_course_homework WHERE course_schedule_id_ IN
  497. <foreach collection="courseScheduleIdList" item="courseScheduleId" open="(" close=")" separator=",">
  498. #{courseScheduleId}
  499. </foreach>
  500. </delete>
  501. <resultMap id="StudentVisitCourseHomeWorkDto" type="com.ym.mec.biz.dal.dto.StudentVisitCourseHomeWorkDto">
  502. <result column="groupType" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  503. <result column="groupId" property="groupId"/>
  504. <result column="courseName" property="courseName"/>
  505. <result column="createTime" property="createTime"/>
  506. <result column="teacherName" property="teacherName"/>
  507. <result column="content" property="content"/>
  508. <result column="status" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  509. <result column="isReplied" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  510. <result column="isView" property="isView" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  511. </resultMap>
  512. <select id="getStudentCourseHomeWorks" resultMap="StudentVisitCourseHomeWorkDto">
  513. SELECT sch.course_schedule_id_ courseScheduleId,
  514. cs.group_type_ groupType,
  515. cs.music_group_id_ groupId,
  516. cs.name_ courseName,
  517. sch.create_time_ createTime,
  518. t.real_name_ teacherName,
  519. ch.content_ content,
  520. sch.status_ status,
  521. sch.is_replied_ isReplied,
  522. sch.is_view_ isView
  523. FROM student_course_homework sch
  524. LEFT JOIN course_homework ch ON ch.id_ = sch.course_homework_id_
  525. LEFT JOIN course_schedule cs ON cs.id_ = sch.course_schedule_id_
  526. LEFT JOIN sys_user t ON t.id_ = cs.actual_teacher_id_
  527. <include refid="homeWorkCondition"/>
  528. ORDER BY sch.create_time_ DESC
  529. <include refid="global.limit"/>
  530. </select>
  531. <select id="getStudentCourseHomeWorksCount" resultType="int">
  532. SELECT COUNT(*) FROM student_course_homework sch
  533. <include refid="homeWorkCondition"/>
  534. </select>
  535. <sql id="getEduCourseHomeworkListCondition">
  536. <where>
  537. mg.transaction_teacher_id_ = #{transactionTeacherId}
  538. AND mg.status_ = "PROGRESS"
  539. AND sr.music_group_status_='NORMAL'
  540. <if test="search != null and search != ''">
  541. AND (su.real_name_ LIKE CONCAT('%',#{search},'%') OR su.id_ = #{search})
  542. </if>
  543. <if test="startTime!=null">
  544. AND cs.class_date_ &gt;= DATE_FORMAT(#{startTime}, "%Y-%m-%d")
  545. </if>
  546. <if test="endTime!=null">
  547. AND cs.class_date_ &lt;= DATE_FORMAT(#{endTime}, "%Y-%m-%d")
  548. </if>
  549. </where>
  550. </sql>
  551. <select id="getEduCourseHomeworkList" resultType="com.ym.mec.biz.dal.dto.EduHomeworkCardDto">
  552. SELECT
  553. ch.id_ homeworkId,
  554. cs.id_ courseId,
  555. cs.name_ courseName,
  556. CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) courseStartTime,
  557. cs.actual_teacher_id_ teacherId,
  558. su.real_name_ teacherName,
  559. su.avatar_ teacherAvatar,
  560. COUNT( sch.user_id_ ) exceptStudentNum,
  561. SUM( sch.status_ ) submitStudentNum,
  562. SUM( sch.is_replied_ ) repliedStudentNum,
  563. sch.music_score_id_ musicScoreId
  564. FROM
  565. course_homework ch
  566. LEFT JOIN music_group mg ON mg.id_ = ch.music_group_id_
  567. LEFT JOIN course_schedule cs ON ch.course_schedule_id_ = cs.id_
  568. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  569. LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
  570. LEFT JOIN student_registration sr ON sch.user_id_=sr.user_id_ AND ch.music_group_id_=sr.music_group_id_
  571. <include refid="getEduCourseHomeworkListCondition" />
  572. GROUP BY ch.id_
  573. ORDER BY courseStartTime DESC
  574. <include refid="global.limit"></include>
  575. </select>
  576. <select id="countEduCourseHomeworkList" resultType="int">
  577. SELECT
  578. COUNT(DISTINCT cs.id_)
  579. FROM
  580. course_homework ch
  581. LEFT JOIN music_group mg ON mg.id_ = ch.music_group_id_
  582. LEFT JOIN course_schedule cs ON ch.course_schedule_id_ = cs.id_
  583. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  584. LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
  585. LEFT JOIN student_registration sr ON sch.user_id_=sr.user_id_ AND ch.music_group_id_=sr.music_group_id_
  586. <include refid="getEduCourseHomeworkListCondition" />
  587. </select>
  588. <select id="countHomeworkStudentInfoWithMusicGroup" resultType="com.ym.mec.biz.dal.dto.EduHomeworkCardDto">
  589. SELECT
  590. ch.music_group_id_ groupId,
  591. COUNT( sch.user_id_ ) exceptStudentNum,
  592. SUM( sch.status_ ) submitStudentNum,
  593. SUM( sch.is_replied_ ) repliedStudentNum
  594. FROM
  595. course_homework ch
  596. LEFT JOIN course_schedule cs ON ch.course_schedule_id_ = cs.id_
  597. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  598. LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
  599. LEFT JOIN student_registration sr ON sch.user_id_=sr.user_id_ AND ch.music_group_id_=sr.music_group_id_
  600. WHERE sr.music_group_status_='NORMAL'
  601. AND ch.music_group_id_ IN
  602. <foreach collection="groupIds" item="groupId" open="(" close=")" separator=",">
  603. #{groupId}
  604. </foreach>
  605. <if test="startTime!=null">
  606. AND cs.class_date_ &gt;= DATE_FORMAT(#{startTime}, "%Y-%m-%d")
  607. </if>
  608. <if test="endTime!=null">
  609. AND cs.class_date_ &lt;= DATE_FORMAT(#{endTime}, "%Y-%m-%d")
  610. </if>
  611. GROUP BY ch.music_group_id_
  612. </select>
  613. <select id="countHomeworkSubjectStudentInfoWithMusicGroup" resultType="com.ym.mec.biz.dal.dto.EduHomeworkCardDto">
  614. SELECT
  615. sr.actual_subject_id_ subjectId,
  616. COUNT( sch.user_id_ ) exceptStudentNum,
  617. SUM( sch.status_ ) submitStudentNum,
  618. SUM( sch.is_replied_ ) repliedStudentNum
  619. FROM course_homework ch
  620. LEFT JOIN course_schedule cs ON ch.course_schedule_id_ = cs.id_
  621. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  622. LEFT JOIN student_course_homework sch ON ch.id_ = sch.course_homework_id_
  623. LEFT JOIN student_registration sr ON sch.user_id_=sr.user_id_ AND ch.music_group_id_=sr.music_group_id_
  624. WHERE sr.music_group_status_='NORMAL'
  625. AND ch.music_group_id_ = #{groupId}
  626. <if test="startTime!=null">
  627. AND cs.class_date_ &gt;= #{startTime}
  628. </if>
  629. <if test="endTime!=null">
  630. AND cs.class_date_ &lt;= #{endTime}
  631. </if>
  632. GROUP BY sr.actual_subject_id_
  633. </select>
  634. <sql id="homeWorkCondition">
  635. <where>
  636. sch.tenant_id_ = #{tenantId}
  637. <if test="userId!=null">
  638. AND sch.user_id_=#{userId}
  639. </if>
  640. <if test="status!=null">
  641. AND sch.status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  642. </if>
  643. <if test="isReplied!=null">
  644. AND sch.is_replied_=#{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  645. </if>
  646. <if test="startTime != null">
  647. AND sch.create_time_ >=#{startTime}
  648. </if>
  649. <if test="endTime != null">
  650. <![CDATA[AND sch.create_time_<=#{endTime}
  651. ]]></if>
  652. </where>
  653. </sql>
  654. <select id="findByCourseScheduleIds" resultMap="StudentCourseHomework">
  655. select *
  656. from student_course_homework
  657. where course_schedule_id_ in
  658. <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
  659. #{courseScheduleId}
  660. </foreach>
  661. </select>
  662. <select id="findByStudentIdsAndCourseScheduleId"
  663. resultType="com.ym.mec.biz.dal.dto.StudentLessonTrainingDetailWrapper$StudentLessonTrainingDetail">
  664. SELECT s.*,sms.name_ as musicScoreName,s2.name_ as subjectName from student_lesson_training_detail s
  665. left join sys_music_score sms on s.music_score_id_ = sms.id_
  666. left join subject s2 on s.subject_id_ = s2.id_
  667. where s.user_id_ in
  668. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  669. #{studentId}
  670. </foreach>
  671. and s.course_homework_id_ = #{courseHomeworkId}
  672. and s.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  673. order by s.id_
  674. </select>
  675. <select id="findStudentCourseHomeworkByCourse" resultMap="StudentCourseHomework">
  676. SELECT
  677. sch.*,
  678. su.username_,
  679. su.avatar_,
  680. su.phone_
  681. FROM
  682. student_course_homework sch
  683. LEFT JOIN sys_user su ON sch.user_id_=su.id_
  684. left join student s on s.user_id_ = su.id_
  685. <where>
  686. sch.course_schedule_id_=#{query.courseScheduleId}
  687. <if test="query.subjectId != null">
  688. and s.subject_id_list_ = #{query.subjectId}
  689. </if>
  690. </where>
  691. </select>
  692. <select id="queryNotSuccessHomeworkList" resultType="int">
  693. SELECT
  694. count(sch.id_)
  695. FROM
  696. student_course_homework sch
  697. left join course_homework ch on ch.id_ = sch.course_homework_id_
  698. WHERE
  699. sch.user_id_ = #{userId}
  700. AND (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
  701. and ch.expiry_date_ &gt;= now()
  702. and ch.version_tag_ = 'v2'
  703. </select>
  704. <select id="getHomeworkByUserIdAndCourseHomeworkId" resultMap="StudentCourseHomework">
  705. SELECT
  706. sch.*
  707. FROM
  708. student_course_homework sch
  709. WHERE
  710. sch.user_id_ = #{userId}
  711. AND sch.course_homework_id_ = #{courseHomeworkId}
  712. </select>
  713. <select id="queryNotSuccessUserIdByHomeworkIds" resultType="java.lang.Integer">
  714. SELECT
  715. distinct sch.user_id_
  716. FROM
  717. student_course_homework sch
  718. left join course_homework ch on ch.id_ = sch.course_homework_id_
  719. WHERE
  720. sch.course_homework_id_ in
  721. <foreach collection="homeworkIds" item="homeworkId" open="(" close=")" separator=",">
  722. #{homeworkId}
  723. </foreach>
  724. AND (sch.standard_flag_ not in ('STANDARD','EXCELLENT') or sch.standard_flag_ is null)
  725. and ch.version_tag_ = 'v2'
  726. </select>
  727. <select id="queryNotSuccessExtraHomeworkList2" resultType="int">
  728. SELECT
  729. count(ee.id_)
  730. FROM
  731. extracurricular_exercises ee
  732. left join extracurricular_exercises_reply eer on eer.extracurricular_exercises_id_ = ee.id_
  733. WHERE
  734. eer.user_id_ = #{userId}
  735. AND (eer.standard_flag_ not in ('STANDARD','EXCELLENT') or eer.standard_flag_ is null)
  736. and ee.expire_date_ &gt;= now()
  737. and ee.version_tag_ = 'v2'
  738. </select>
  739. </mapper>