ExtracurricularExercisesReplyMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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.ExtracurricularExercisesReplyDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply" id="ExtracurricularExercisesReply">
  9. <result column="id_" property="id" />
  10. <result column="extracurricular_exercises_id_" property="extracurricularExercisesId" />
  11. <result column="title_" property="extracurricularExercises.title" />
  12. <result column="user_id_" property="userId" />
  13. <result column="username_" property="user.username" />
  14. <result column="attachments_" property="attachments" />
  15. <result column="create_time_" property="createTime" />
  16. <result column="update_time_" property="updateTime" />
  17. <result column="remark_" property="remark" />
  18. <result column="status_" property="status" />
  19. <result column="is_replied_" property="isReplied" />
  20. <result column="is_replied_timely_" property="isRepliedTimely" />
  21. <result column="is_view_" property="isView" />
  22. <result column="organ_name_" property="organName" />
  23. <result column="submit_time_" property="submitTime" />
  24. <result column="music_score_id_" property="musicScoreId" />
  25. <result column="music_score_content_" property="musicScoreContent" />
  26. <result column="tenant_id_" property="tenantId" />
  27. <result column="standard_flag_" property="standardFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  28. <association property="extracurricularExercises" columnPrefix="ee_" resultMap="com.ym.mec.biz.dal.dao.ExtracurricularExercisesDao.ExtracurricularExercises"/>
  29. </resultMap>
  30. <resultMap id="ExtraExerciseStudentsDto" type="com.ym.mec.biz.dal.dto.ExtraExerciseStudentsDto" extends="ExtracurricularExercisesReply">
  31. <result column="student_name_" property="studentName"/>
  32. <result column="teacher_id_" property="teacherId"/>
  33. <result column="teacher_name_" property="teacherName"/>
  34. <result column="avatar_" property="headUrl"/>
  35. <result column="phone_" property="phone"/>
  36. <result column="title_" property="title"/>
  37. <result column="content_" property="content"/>
  38. <result column="expire_date_" property="expireDate"/>
  39. <result column="music_score_id_" property="musicScoreId" />
  40. <result column="music_score_content_" property="musicScoreContent" />
  41. <result column="homework_create_time_" property="homeworkCreateTime" />
  42. <result column="extracurricularExercisesId" property="extracurricularExercisesId" />
  43. <result column="musicGroupId" property="musicGroupId" />
  44. <result column="type" property="type" />
  45. <result column="classGroupId" property="classGroupId" />
  46. <result column="subjectId" property="subjectId" />
  47. </resultMap>
  48. <sql id="queryPageCondition">
  49. <where>
  50. eer.tenant_id_ = #{tenantId}
  51. <if test="extracurricularExercisesId != null">
  52. AND extracurricular_exercises_id_ = #{extracurricularExercisesId}
  53. </if>
  54. <if test="teacherId != null">
  55. AND teacher_id_ = #{teacherId}
  56. </if>
  57. <if test="organIdList != null">
  58. AND FIND_IN_SET(o.id_, #{organIdList})
  59. </if>
  60. <if test="studentId != null">
  61. AND user_id_ = #{studentId}
  62. </if>
  63. <if test="title != null">
  64. AND title_ like '%' #{title} '%'
  65. </if>
  66. <if test="status != null">
  67. AND eer.status_ = #{status}
  68. </if>
  69. <if test="isReplied != null">
  70. AND is_replied_ = #{isReplied}
  71. </if>
  72. <if test="isView != null">
  73. AND is_view_ = #{isView}
  74. </if>
  75. <if test="search != null">
  76. AND (title_ like concat('%',#{search},'%') or u.username_ like concat('%',#{search},'%'))
  77. </if>
  78. <if test="submitStartTime != null">
  79. AND date(eer.create_time_) &gt;= #{submitStartTime}
  80. </if>
  81. <if test="submitEndTime != null">
  82. AND date(eer.create_time_) &lt;= #{submitEndTime}
  83. </if>
  84. </where>
  85. </sql>
  86. <!-- 根据主键查询一条记录 -->
  87. <select id="get" resultMap="ExtracurricularExercisesReply" >
  88. SELECT * FROM extracurricular_exercises_reply WHERE id_ = #{id}
  89. </select>
  90. <!-- 全查询 -->
  91. <select id="findAll" resultMap="ExtracurricularExercisesReply">
  92. SELECT * FROM extracurricular_exercises_reply where tenant_id_ = #{tenantId} ORDER BY id_
  93. </select>
  94. <!-- 向数据库增加一条记录 -->
  95. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  96. INSERT INTO extracurricular_exercises_reply (extracurricular_exercises_id_,user_id_,attachments_,create_time_,
  97. update_time_,remark_,status_,is_replied_,is_view_,is_replied_timely_,
  98. music_score_id_,music_score_content_,tenant_id_,standard_flag_)
  99. VALUES(#{extracurricularExercisesId},#{userId},#{attachments},NOW(),NOW(),#{remark},#{status},#{isReplied},#{isView},
  100. #{isRepliedTimely},#{musicScoreId},#{musicScoreContent},#{tenantId},#{standardFlag})
  101. </insert>
  102. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  103. INSERT INTO extracurricular_exercises_reply (extracurricular_exercises_id_,user_id_,attachments_,
  104. create_time_,update_time_,remark_,status_,is_replied_,is_view_,
  105. is_replied_timely_,music_score_id_,music_score_content_,tenant_id_,standard_flag_)
  106. VALUES
  107. <foreach collection="replies" item="reply" separator=",">
  108. (#{reply.extracurricularExercisesId},#{reply.userId},#{reply.attachments},NOW(),NOW(),
  109. #{reply.remark},#{reply.status},#{reply.isReplied},#{reply.isView},#{reply.isRepliedTimely},
  110. #{reply.musicScoreId},#{reply.musicScoreContent},#{replay.tenantId},#{replay.standardFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  111. </foreach>
  112. </insert>
  113. <!-- 根据主键查询一条记录 -->
  114. <update id="update" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply">
  115. UPDATE extracurricular_exercises_reply
  116. <set>
  117. <if test="standardFlag != null">
  118. standard_flag_ = #{standardFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  119. </if>
  120. <if test="musicScoreId != null">
  121. music_score_id_ = #{musicScoreId},
  122. </if>
  123. <if test="musicScoreContent != null and musicScoreContent != ''">
  124. music_score_content_ = #{musicScoreContent},
  125. </if>
  126. <if test="status != null">
  127. status_ = #{status},
  128. </if>
  129. <if test="isView != null">
  130. is_view_ = #{isView},
  131. </if>
  132. <if test="userId != null">
  133. user_id_ = #{userId},
  134. </if>
  135. <if test="remark != null">
  136. remark_ = #{remark},
  137. </if>
  138. <if test="id != null">
  139. id_ = #{id},
  140. </if>
  141. <if test="isReplied != null">
  142. is_replied_ = #{isReplied},
  143. </if>
  144. <if test="isRepliedTimely != null">
  145. is_replied_timely_ = #{isRepliedTimely},
  146. </if>
  147. <if test="extracurricularExercisesId != null">
  148. extracurricular_exercises_id_ = #{extracurricularExercisesId},
  149. </if>
  150. <if test="attachments != null">
  151. attachments_ = #{attachments},
  152. </if>
  153. <if test="submitTime != null">
  154. submit_time_ = #{submitTime},
  155. </if>
  156. update_time_ = NOW()
  157. </set> WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  158. </update>
  159. <!-- 根据主键删除一条记录 -->
  160. <delete id="delete" >
  161. DELETE FROM extracurricular_exercises_reply WHERE id_ = #{id}
  162. </delete>
  163. <!-- 分页查询 -->
  164. <select id="queryPage" resultMap="ExtraExerciseStudentsDto" parameterType="map">
  165. SELECT eer.*,u.username_,ee.title_,o.name_ organ_name_,ee.teacher_id_,ee.expire_date_
  166. FROM extracurricular_exercises_reply eer
  167. left join extracurricular_exercises ee on eer.extracurricular_exercises_id_ = ee.id_
  168. left join sys_user u on eer.user_id_ = u.id_
  169. left join teacher t on t.id_ = ee.teacher_id_
  170. left join organization o on o.id_ = t.organ_id_
  171. <include refid="queryPageCondition"/>
  172. ORDER BY eer.id_ <include refid="global.limit"/>
  173. </select>
  174. <!-- 查询当前表的总记录数 -->
  175. <select id="queryCount" resultType="int">
  176. SELECT COUNT(eer.id_) FROM extracurricular_exercises_reply eer
  177. left join extracurricular_exercises ee on eer.extracurricular_exercises_id_ = ee.id_
  178. left join sys_user u on eer.user_id_ = u.id_
  179. left join teacher t on t.id_ = ee.teacher_id_
  180. left join organization o on o.id_ = t.organ_id_
  181. <include refid="queryPageCondition"/>
  182. </select>
  183. <select id="findExtraExerciseStudents" resultMap="ExtraExerciseStudentsDto">
  184. SELECT
  185. eer.*,
  186. su.username_ student_name_,
  187. su.avatar_,
  188. su.phone_,
  189. s.subject_id_list_ as subjectId
  190. FROM
  191. extracurricular_exercises_reply eer
  192. LEFT JOIN sys_user su ON su.id_ = eer.user_id_
  193. left join student s on s.user_id_ = su.id_
  194. WHERE eer.extracurricular_exercises_id_= #{extraExerciseId}
  195. <if test="studentName != null">
  196. AND su.username_ LIKE CONCAT('%',#{studentName},'%')
  197. </if>
  198. </select>
  199. <select id="findExtraExerciseStudentsByExtraExercises" resultMap="ExtracurricularExercisesReply">
  200. SELECT * FROM extracurricular_exercises_reply WHERE extracurricular_exercises_id_ IN
  201. <foreach collection="extraExerciseIds" item="extraExerciseId" open="(" close=")" separator=",">
  202. #{extraExerciseId}
  203. </foreach>
  204. </select>
  205. <select id="findExtraExerciseReply" resultMap="ExtraExerciseStudentsDto">
  206. SELECT
  207. eer.*,
  208. ee.title_,
  209. ee.content_,
  210. ee.expire_date_,
  211. ee.teacher_id_,
  212. eer.music_score_id_,
  213. eer.music_score_content_,
  214. eer.standard_flag_,
  215. su.username_ student_name_,
  216. ee.create_time_ homework_create_time_
  217. FROM
  218. extracurricular_exercises_reply eer
  219. LEFT JOIN extracurricular_exercises ee ON ee.id_=eer.extracurricular_exercises_id_
  220. LEFT JOIN sys_user su ON su.id_ = eer.user_id_
  221. WHERE
  222. eer.id_ = #{extraExerciseReplyId}
  223. </select>
  224. <sql id="queryStudentExtraExercisesCondition">
  225. <where>
  226. eer.tenant_id_ = #{tenantId}
  227. <if test="studentId!=null">
  228. AND eer.user_id_=#{studentId}
  229. </if>
  230. <if test="createTime!=null">
  231. AND DATE_FORMAT(eer.create_time_, '%Y-%m') = DATE_FORMAT(#{createTime}, '%Y-%m')
  232. </if>
  233. <if test="type != null">
  234. and ee.group_type_ = #{type}
  235. </if>
  236. <if test="finishStatus != null">
  237. <if test="finishStatus == true">
  238. and eer.standard_flag_ in ('STANDARD','EXCELLENT')
  239. </if>
  240. <if test="finishStatus == false">
  241. and (eer.standard_flag_ not in ('STANDARD','EXCELLENT') or eer.standard_flag_ is null)
  242. </if>
  243. </if>
  244. <if test="versionTag != null">
  245. and ee.version_tag_ = #{versionTag}
  246. </if>
  247. </where>
  248. </sql>
  249. <select id="countStudentExtraExercises" resultType="int">
  250. SELECT COUNT(eer.id_) FROM extracurricular_exercises_reply eer
  251. left join extracurricular_exercises ee on eer.extracurricular_exercises_id_ = ee.id_
  252. <include refid="queryStudentExtraExercisesCondition"/>
  253. </select>
  254. <select id="findStudentExtraExercises" resultMap="ExtraExerciseStudentsDto">
  255. SELECT
  256. eer.*,
  257. ee.title_,
  258. ee.expire_date_,
  259. ee.teacher_id_,
  260. ee.group_type_ as `type`,
  261. ee.id_ as extracurricularExercisesId,
  262. ee.music_group_id_ as musicGroupId,
  263. ee.class_group_id_ as classGroupId,
  264. tea.real_name_ teacher_name_,
  265. tea.avatar_,
  266. su.username_ student_name_
  267. FROM
  268. extracurricular_exercises_reply eer
  269. LEFT JOIN extracurricular_exercises ee ON ee.id_=eer.extracurricular_exercises_id_
  270. LEFT JOIN sys_user su ON su.id_ = eer.user_id_
  271. LEFT JOIN sys_user tea ON tea.id_ = ee.teacher_id_
  272. <include refid="queryStudentExtraExercisesCondition"/>
  273. ORDER BY eer.create_time_ DESC
  274. <include refid="global.limit"/>
  275. </select>
  276. <select id="countIsSubmitStudents" resultType="int">
  277. SELECT COUNT(id_) FROM extracurricular_exercises_reply WHERE extracurricular_exercises_id_=#{extraExerciseId} AND attachments_ IS NOT NULL
  278. </select>
  279. <sql id="queryExtraExercisesCondition">
  280. <where>
  281. eer.tenant_id_ = #{tenantId}
  282. <if test="cloudHomeworkFlag != null and cloudHomeworkFlag == true">
  283. AND eer.music_score_id_ IS NOT NULL AND eer.music_score_id_ != ''
  284. </if>
  285. <if test="cloudHomeworkFlag != null and cloudHomeworkFlag == false">
  286. AND (eer.music_score_id_ IS NULL OR eer.music_score_id_ = '')
  287. </if>
  288. <if test="extracurricularExercisesId != null">
  289. AND extracurricular_exercises_id_ = #{extracurricularExercisesId}
  290. </if>
  291. <if test="teacherId != null">
  292. AND teacher_id_ = #{teacherId}
  293. </if>
  294. <if test="organIdList != null">
  295. AND FIND_IN_SET(o.id_, #{organIdList})
  296. </if>
  297. <if test="studentId != null">
  298. AND user_id_ = #{studentId}
  299. </if>
  300. <if test="title != null">
  301. AND title_ like '%' #{title} '%'
  302. </if>
  303. <if test="status != null">
  304. AND eer.status_ = #{status}
  305. </if>
  306. <if test="isReplied != null">
  307. AND is_replied_ = #{isReplied}
  308. </if>
  309. <if test="isView != null">
  310. AND is_view_ = #{isView}
  311. </if>
  312. <if test="search != null">
  313. AND (title_ like concat('%',#{search},'%') or u.id_=#{search} or u.username_ like concat('%',#{search},'%'))
  314. </if>
  315. <if test="submitStartTime != null">
  316. AND date(eer.create_time_) &gt;= #{submitStartTime}
  317. </if>
  318. <if test="submitEndTime != null">
  319. AND date(eer.create_time_) &lt;= #{submitEndTime}
  320. </if>
  321. <if test="expireStartDate != null and expireEndDate != null">
  322. AND DATE_FORMAT(ee.expire_date_,"%Y%m%d") BETWEEN DATE_FORMAT(#{expireStartDate},"%Y%m%d") AND DATE_FORMAT(#{expireEndDate},"%Y%m%d")
  323. </if>
  324. <if test="isRepliedTimely!=null">
  325. AND eer.is_replied_timely_=#{isRepliedTimely}
  326. </if>
  327. <if test="existVipCourse!=null and existVipCourse==1">
  328. AND EXISTS (SELECT cssp.id_ FROM course_schedule_student_payment cssp LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_ WHERE cssp.user_id_=eer.user_id_ AND cssp.group_type_='VIP' AND CONCAT(cs.class_date_," ",cs.start_class_time_) &gt; NOW())
  329. </if>
  330. <if test="existVipCourse!=null and existVipCourse==0">
  331. AND NOT EXISTS (SELECT cssp.id_ FROM course_schedule_student_payment cssp LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_ WHERE cssp.user_id_=eer.user_id_ AND cssp.group_type_='VIP' AND CONCAT(cs.class_date_," ",cs.start_class_time_) &gt; NOW())
  332. </if>
  333. <if test="versionTag != null and versionTag != ''">
  334. and ee.version_tag_ = #{versionTag}
  335. </if>
  336. </where>
  337. </sql>
  338. <select id="findExtraExercises" resultMap="ExtraExerciseStudentsDto">
  339. SELECT eer.*,u.username_,ee.title_,ee.content_,o.name_ organ_name_,ee.teacher_id_,ee.expire_date_
  340. FROM extracurricular_exercises_reply eer
  341. left join extracurricular_exercises ee on eer.extracurricular_exercises_id_ = ee.id_
  342. left join sys_user u on eer.user_id_ = u.id_
  343. left join teacher t on t.id_ = ee.teacher_id_
  344. left join organization o on o.id_ = u.organ_id_
  345. <include refid="queryExtraExercisesCondition"/>
  346. ORDER BY eer.id_ <include refid="global.limit"/>
  347. </select>
  348. <select id="countExtraExercises" resultType="int">
  349. SELECT COUNT(eer.id_) FROM extracurricular_exercises_reply eer
  350. left join extracurricular_exercises ee on eer.extracurricular_exercises_id_ = ee.id_
  351. left join sys_user u on eer.user_id_ = u.id_
  352. left join teacher t on t.id_ = ee.teacher_id_
  353. left join organization o on o.id_ = u.organ_id_
  354. <include refid="queryExtraExercisesCondition"/>
  355. </select>
  356. <resultMap id="StudentServiceHomeworkDto" type="com.ym.mec.biz.dal.dto.StudentServiceHomeworkDto">
  357. <result column="id_" property="id" />
  358. <result column="user_id_" property="userId" />
  359. <result column="status_" property="status" />
  360. <result column="is_replied_" property="isReplied" />
  361. <result column="is_replied_timely_" property="isRepliedTimely" />
  362. <result column="is_view_" property="isView" />
  363. <result column="submit_time_" property="submitTime" />
  364. <result column="type_" property="type" />
  365. </resultMap>
  366. <select id="findStudentHomewarksInWeek" resultMap="StudentServiceHomeworkDto">
  367. SELECT
  368. eer.id_,
  369. eer.user_id_,
  370. eer.status_,
  371. eer.submit_time_,
  372. eer.is_replied_,
  373. eer.is_replied_timely_,
  374. 'EXTRA' type_
  375. FROM
  376. extracurricular_exercises_reply eer
  377. WHERE
  378. DATE_FORMAT( eer.create_time_, '%Y-%m-%d' ) BETWEEN #{monday} AND #{sunday} and eer.tenant_id_ = #{tenantId}
  379. UNION ALL
  380. SELECT
  381. sch.id_,
  382. sch.user_id_,
  383. sch.status_,
  384. sch.submit_time_,
  385. sch.is_replied_,
  386. sch.is_replied_timely_,
  387. 'HOMEWORK' type_
  388. FROM
  389. student_course_homework sch
  390. LEFT JOIN course_schedule cs ON cs.id_ = sch.course_schedule_id_
  391. WHERE
  392. cs.group_type_='PRACTICE' AND DATE_FORMAT( sch.create_time_, '%Y-%m-%d' ) BETWEEN #{monday} AND #{sunday} and sch.tenant_id_ = #{tenantId}
  393. </select>
  394. <resultMap id="StudentServiceDetailDto" type="com.ym.mec.biz.dal.dto.StudentServiceDetailDto">
  395. <result property="homeworkId" column="homework_id_"/>
  396. <result property="studentHomeworkId" column="student_homework_id_"/>
  397. <result property="homeworkType" column="homework_type_"/>
  398. <result property="title" column="title_"/>
  399. <result property="content" column="content_"/>
  400. <result property="courseScheduleId" column="course_schedule_id_"/>
  401. <result property="groupId" column="group_id_"/>
  402. <result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  403. <result property="groupName" column="group_name_"/>
  404. <result property="courseStartTime" column="course_start_time_"/>
  405. <result property="courseEndTime" column="course_end_time_"/>
  406. <result property="teacherId" column="teacher_id_"/>
  407. <result property="teacherName" column="teacher_name_"/>
  408. <result property="homeworkCreateTime" column="homework_create_time_"/>
  409. <result property="submitTime" column="submit_time_"/>
  410. <result property="isSubmit" column="is_submit_"/>
  411. <result property="isReplied" column="is_replied_"/>
  412. <result property="attachments" column="attachments_"/>
  413. <result property="musicScoreId" column="music_score_id_"/>
  414. </resultMap>
  415. <select id="findStudentHomeworkDetailsInTimeZone" resultMap="StudentServiceDetailDto">
  416. (SELECT
  417. ee.id_ homework_id_,
  418. eer.id_ student_homework_id_,
  419. eer.music_score_id_,
  420. ee.title_,
  421. NULL course_schedule_id_,
  422. ee.teacher_id_,
  423. tea.real_name_ teacher_name_,
  424. NULL group_id_,
  425. NULL group_type_,
  426. NULL group_name_,
  427. ee.create_time_ course_start_time_,
  428. NULL course_end_time_,
  429. ee.content_,
  430. ee.create_time_ homework_create_time_,
  431. eer.user_id_,
  432. eer.attachments_,
  433. eer.submit_time_,
  434. eer.is_replied_,
  435. 'EXTRA' homework_type_
  436. FROM
  437. extracurricular_exercises_reply eer
  438. LEFT JOIN extracurricular_exercises ee ON ee.id_=eer.extracurricular_exercises_id_
  439. LEFT JOIN sys_user tea ON ee.teacher_id_=tea.id_
  440. WHERE
  441. eer.user_id_=#{studentId} AND DATE_FORMAT( eer.create_time_, '%Y-%m-%d' ) BETWEEN #{monday} AND #{sunday})
  442. UNION ALL
  443. (SELECT
  444. ch.id_ homework_id_,
  445. sch.id_ student_homework_id_,
  446. sch.music_score_id_,
  447. NULL title_,
  448. cs.id_ course_schedule_id_,
  449. cs.actual_teacher_id_,
  450. tea.real_name_ teacher_name_,
  451. cs.music_group_id_ group_id_,
  452. cs.group_type_,
  453. cs.name_ group_name_,
  454. CONCAT(cs.class_date_, ' ', cs.start_class_time_) course_start_time_,
  455. CONCAT(cs.class_date_, ' ', cs.end_class_time_) course_end_time_,
  456. ch.content_,
  457. ch.create_time_ homework_create_time_,
  458. sch.user_id_,
  459. sch.attachments_,
  460. sch.submit_time_,
  461. sch.is_replied_,
  462. 'HOMEWORK' homework_type_
  463. FROM
  464. student_course_homework sch
  465. LEFT JOIN course_homework ch ON ch.id_=sch.course_homework_id_
  466. LEFT JOIN course_schedule cs ON cs.id_=ch.course_schedule_id_
  467. LEFT JOIN sys_user tea ON cs.actual_teacher_id_=tea.id_
  468. WHERE
  469. sch.user_id_=#{studentId} AND cs.class_date_ BETWEEN #{monday} AND #{sunday})
  470. ORDER BY homework_create_time_ DESC
  471. <include refid="global.limit"/>
  472. </select>
  473. <select id="countStudentHomeworkDetailsInTimeZone" resultType="int">
  474. SELECT COUNT(t.id_) FROM (
  475. (SELECT
  476. eer.id_
  477. FROM
  478. extracurricular_exercises_reply eer
  479. WHERE
  480. eer.user_id_=#{studentId} AND DATE_FORMAT( eer.create_time_, '%Y-%m-%d' ) BETWEEN #{monday} AND #{sunday})
  481. UNION ALL
  482. (SELECT
  483. sch.id_
  484. FROM
  485. student_course_homework sch
  486. LEFT JOIN course_schedule cs ON cs.id_=sch.course_schedule_id_
  487. WHERE
  488. sch.user_id_=#{studentId} AND cs.class_date_ BETWEEN #{monday} AND #{sunday})
  489. ) t
  490. </select>
  491. <select id="getStudentExercisesWithTimeZone" resultMap="ExtracurricularExercisesReply">
  492. SELECT
  493. eer.id_,
  494. eer.user_id_,
  495. eer.status_,
  496. eer.submit_time_,
  497. eer.is_replied_,
  498. eer.is_replied_timely_,
  499. ee.teacher_id_ ee_teacher_id_,
  500. eer.music_score_id_,
  501. ee.music_group_id_ ee_music_group_id_
  502. FROM
  503. extracurricular_exercises_reply eer
  504. LEFT JOIN extracurricular_exercises ee ON eer.extracurricular_exercises_id_=ee.id_
  505. WHERE
  506. DATE_FORMAT( eer.create_time_, '%Y-%m-%d' ) BETWEEN #{startDate} AND #{endDate} and eer.tenant_id_ = #{tenantId}
  507. </select>
  508. <select id="checkStudentHaveExercisesInDateRange" resultType="java.lang.Integer">
  509. SELECT
  510. DISTINCT user_id_
  511. FROM
  512. extracurricular_exercises_reply
  513. WHERE
  514. DATE_FORMAT( create_time_, '%Y-%m-%d' ) BETWEEN #{startDate} AND #{endDate}
  515. AND user_id_ IN
  516. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  517. #{studentId}
  518. </foreach>
  519. </select>
  520. <sql id="getEduHomeworkListCondition">
  521. <where>
  522. EXISTS (SELECT user_id_ FROM student_registration sr
  523. LEFT JOIN music_group mg ON mg.id_=sr.music_group_id_
  524. WHERE sr.user_id_ = eer.user_id_ AND sr.music_group_status_='NORMAL'
  525. AND mg.status_ = 'PROGRESS' AND mg.transaction_teacher_id_=#{transactionTeacherId})
  526. <if test="search != null and search != ''">
  527. AND (su.real_name_ LIKE CONCAT('%',#{search},'%') OR su.id_ = #{search})
  528. </if>
  529. <if test="startTime!=null">
  530. AND DATE_FORMAT(ee.create_time_, "%Y-%m-%d") &gt;= DATE_FORMAT(#{startTime}, "%Y-%m-%d")
  531. </if>
  532. <if test="endTime!=null">
  533. AND DATE_FORMAT(ee.create_time_, "%Y-%m-%d") &lt;= DATE_FORMAT(#{endTime}, "%Y-%m-%d")
  534. </if>
  535. </where>
  536. </sql>
  537. <select id="getEduHomeworkList" resultType="com.ym.mec.biz.dal.dto.EduHomeworkCardDto">
  538. SELECT
  539. ee.id_ homeworkId,
  540. su.real_name_ teacherName,
  541. su.avatar_ teacherAvatar,
  542. ee.create_time_ createTime,
  543. COUNT( eer.user_id_ ) exceptStudentNum,
  544. SUM( eer.status_ ) submitStudentNum,
  545. SUM( eer.is_replied_ ) repliedStudentNum,
  546. eer.music_score_id_ musicScoreId
  547. FROM
  548. extracurricular_exercises ee
  549. LEFT JOIN sys_user su ON ee.teacher_id_ = su.id_
  550. LEFT JOIN extracurricular_exercises_reply eer ON ee.id_ = eer.extracurricular_exercises_id_
  551. <include refid="getEduHomeworkListCondition" />
  552. GROUP BY ee.id_
  553. ORDER BY ee.create_time_ DESC
  554. <include refid="global.limit"></include>
  555. </select>
  556. <select id="countEduHomeworkList" resultType="int">
  557. SELECT
  558. COUNT(DISTINCT ee.id_)
  559. FROM
  560. extracurricular_exercises ee
  561. LEFT JOIN sys_user su ON ee.teacher_id_ = su.id_
  562. LEFT JOIN extracurricular_exercises_reply eer ON ee.id_ = eer.extracurricular_exercises_id_
  563. <include refid="getEduHomeworkListCondition" />
  564. </select>
  565. <select id="countEduHomeworkStudentNumWithMusicGroup"
  566. resultType="com.ym.mec.biz.dal.dto.EduHomeworkCardDto">
  567. SELECT
  568. sr.music_group_id_ groupId,
  569. COUNT( eer.user_id_ ) exceptStudentNum,
  570. SUM( eer.status_ ) submitStudentNum,
  571. SUM( eer.is_replied_ ) repliedStudentNum
  572. FROM
  573. extracurricular_exercises ee
  574. LEFT JOIN sys_user su ON ee.teacher_id_ = su.id_
  575. LEFT JOIN extracurricular_exercises_reply eer ON ee.id_ = eer.extracurricular_exercises_id_
  576. LEFT JOIN student_registration sr ON eer.user_id_ = sr.user_id_
  577. WHERE sr.music_group_status_='NORMAL' and ee.tenant_id_ = #{tenantId}
  578. <if test="groupIds!=null and groupIds.size()>0">
  579. AND sr.music_group_id_ IN
  580. <foreach collection="groupIds" item="groupId" open="(" close=")" separator=",">
  581. #{groupId}
  582. </foreach>
  583. </if>
  584. <if test="startTime!=null">
  585. AND DATE_FORMAT(ee.create_time_, "%Y-%m-%d") &gt;= DATE_FORMAT(#{startTime}, "%Y-%m-%d")
  586. </if>
  587. <if test="endTime!=null">
  588. AND DATE_FORMAT(ee.create_time_, "%Y-%m-%d") &lt;= DATE_FORMAT(#{endTime}, "%Y-%m-%d")
  589. </if>
  590. GROUP BY sr.music_group_id_
  591. </select>
  592. <select id="countEduHomeworkSubjectStudentNumWithMusicGroup"
  593. resultType="com.ym.mec.biz.dal.dto.EduHomeworkCardDto">
  594. SELECT
  595. sr.actual_subject_id_ subjectId,
  596. COUNT( eer.user_id_ ) exceptStudentNum,
  597. SUM( eer.status_ ) submitStudentNum,
  598. SUM( eer.is_replied_ ) repliedStudentNum
  599. FROM
  600. extracurricular_exercises ee
  601. LEFT JOIN sys_user su ON ee.teacher_id_ = su.id_
  602. LEFT JOIN extracurricular_exercises_reply eer ON ee.id_ = eer.extracurricular_exercises_id_
  603. LEFT JOIN student_registration sr ON eer.user_id_ = sr.user_id_
  604. WHERE sr.music_group_status_='NORMAL'
  605. AND sr.music_group_id_ = #{groupId}
  606. <if test="startTime!=null">
  607. AND DATE_FORMAT(ee.create_time_, "%Y-%m-%d") &gt;= DATE_FORMAT(#{startTime}, "%Y-%m-%d")
  608. </if>
  609. <if test="endTime!=null">
  610. AND DATE_FORMAT(ee.create_time_, "%Y-%m-%d") &lt;= DATE_FORMAT(#{endTime}, "%Y-%m-%d")
  611. </if>
  612. GROUP BY sr.actual_subject_id_
  613. </select>
  614. <select id="getByExtraIdAndUserId" resultType="com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply">
  615. SELECT * from extracurricular_exercises_reply where extracurricular_exercises_id_ = #{extraId} and user_id_ = #{userId}
  616. </select>
  617. <select id="queryNotDoneHomeworkList" resultMap="ExtracurricularExercisesReply">
  618. SELECT eer.*, ee.group_type_ as ee_group_type_
  619. from extracurricular_exercises_reply eer
  620. left join extracurricular_exercises ee on ee.id_ = eer.extracurricular_exercises_id_
  621. WHERE date_format(date_add(ee.expire_date_,interval -1 day),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
  622. AND (eer.standard_flag_ not in ('STANDARD', 'EXCELLENT') or eer.standard_flag_ is null)
  623. AND ee.version_tag_ = 'v2'
  624. </select>
  625. </mapper>