ExtracurricularExercisesReplyMapper.xml 23 KB

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