CourseScheduleStatisticsMapper.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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.CourseScheduleStatisticsDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.CourseScheduleStatistics" id="CourseScheduleStatistics">
  9. <result column="course_schedule_id_" property="courseScheduleId" />
  10. <result column="music_group_id_" property="musicGroupId" />
  11. <result column="course_student_total_num_" property="courseStudentTotalNum" />
  12. <result column="attendance_num_" property="attendanceNum" />
  13. <result column="late_num_" property="lateNum" />
  14. <result column="standard_num_" property="standardNum" />
  15. <result column="homework_flag_" property="homeworkFlag" />
  16. <result column="homework_commit_num_" property="homeworkCommitNum" />
  17. <result column="service_flag_" property="serviceFlag" />
  18. <result column="attendance_rate_" property="attendanceRate" />
  19. <result column="standard_rate_" property="standardRate" />
  20. <result column="homework_commit_rate_" property="homeworkCommitRate" />
  21. <result column="class_date_" property="classDate" />
  22. <result column="course_status_" property="courseStatus" />
  23. </resultMap>
  24. <!-- 根据主键查询一条记录 -->
  25. <select id="get" resultMap="CourseScheduleStatistics" >
  26. SELECT * FROM course_schedule_statistics WHERE course_schedule_id_ = #{courseScheduleId}
  27. </select>
  28. <!-- 全查询 -->
  29. <select id="findAll" resultMap="CourseScheduleStatistics">
  30. SELECT * FROM course_schedule_statistics
  31. </select>
  32. <!-- 向数据库增加一条记录 -->
  33. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStatistics" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  34. INSERT INTO course_schedule_statistics (course_schedule_id_,music_group_id_,course_student_total_num_,
  35. attendance_num_,late_num_,standard_num_,homework_flag_,homework_commit_num_,service_flag_,class_date_,course_status_)
  36. VALUES(#{courseScheduleId},#{musicGroupId},#{courseStudentTotalNum},#{attendanceNum},
  37. #{lateNum},#{standardNum},#{homeworkFlag},#{homeworkCommitNum},#{serviceFlag},#{classDate},#{courseStatus})
  38. </insert>
  39. <insert id="batchInsert">
  40. INSERT INTO course_schedule_statistics (course_schedule_id_,music_group_id_,course_student_total_num_,
  41. attendance_num_,late_num_,standard_num_,homework_flag_,homework_commit_num_,service_flag_,class_date_,course_status_) VALUES
  42. <foreach collection="scheduleStatisticsList" separator="," item="item">
  43. (#{item.courseScheduleId},#{item.musicGroupId},#{item.courseStudentTotalNum},#{item.attendanceNum},
  44. #{item.lateNum},#{item.standardNum},#{item.homeworkFlag},#{item.homeworkCommitNum},#{item.serviceFlag},#{classDate},#{courseStatus})
  45. </foreach>
  46. </insert>
  47. <!-- 根据主键查询一条记录 -->
  48. <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStatistics">
  49. UPDATE course_schedule_statistics <set>
  50. <if test="classDate != null and classDate != ''">
  51. class_date_ = #{classDate},
  52. </if>
  53. <if test="courseStatus != null and courseStatus != ''">
  54. course_status_ = #{courseStatus},
  55. </if>
  56. <if test="homeworkFlag != null">
  57. homework_flag_ = #{homeworkFlag},
  58. </if>
  59. <if test="attendanceNum != null">
  60. attendance_num_ = #{attendanceNum},
  61. </if>
  62. <if test="serviceFlag != null">
  63. service_flag_ = #{serviceFlag},
  64. </if>
  65. <if test="standardNum != null">
  66. standard_num_ = #{standardNum},
  67. </if>
  68. <if test="homeworkCommitNum != null">
  69. homework_commit_num_ = #{homeworkCommitNum},
  70. </if>
  71. <if test="courseStudentTotalNum != null">
  72. course_student_total_num_ = #{courseStudentTotalNum},
  73. </if>
  74. <if test="lateNum != null">
  75. late_num_ = #{lateNum},
  76. </if>
  77. <if test="musicGroupId != null">
  78. music_group_id_ = #{musicGroupId},
  79. </if>
  80. </set> WHERE course_schedule_id_ = #{courseScheduleId}
  81. </update>
  82. <update id="batchUpdate">
  83. <foreach collection="scheduleStatisticsList" item="item" index="index" open="" close="" separator=";">
  84. UPDATE course_schedule_statistics
  85. <set>
  86. <if test="item.courseStatus != null and item.courseStatus != ''">
  87. course_status_ = #{item.courseStatus},
  88. </if>
  89. <if test="item.classDate != null and item.classDate != ''">
  90. class_date_ = #{item.classDate},
  91. </if>
  92. <if test="item.homeworkFlag != null">
  93. homework_flag_ = #{item.homeworkFlag},
  94. </if>
  95. <if test="item.attendanceNum != null">
  96. attendance_num_ = #{item.attendanceNum},
  97. </if>
  98. <if test="item.serviceFlag != null">
  99. service_flag_ = #{item.serviceFlag},
  100. </if>
  101. <if test="item.standardNum != null">
  102. standard_num_ = #{item.standardNum},
  103. </if>
  104. <if test="item.homeworkCommitNum != null">
  105. homework_commit_num_ = #{item.homeworkCommitNum},
  106. </if>
  107. <if test="item.courseStudentTotalNum != null">
  108. course_student_total_num_ = #{item.courseStudentTotalNum},
  109. </if>
  110. <if test="item.lateNum != null">
  111. late_num_ = #{item.lateNum},
  112. </if>
  113. </set> WHERE course_schedule_id_ = #{item.courseScheduleId}
  114. </foreach>
  115. </update>
  116. <update id="updateCourseService">
  117. UPDATE course_schedule_statistics SET service_flag_ = #{serviceFlag} WHERE FIND_IN_SET(course_schedule_id_,#{courseIds})
  118. </update>
  119. <update id="updateNum">
  120. update student_extracurricular_exercises_situation_
  121. set actual_exercises_num_ = 1,update_time_ = NOW()
  122. where teacher_id_ = #{teacherId}
  123. and student_id_ IN
  124. <foreach collection="studentIds" open="(" close=")" item="userId" separator=",">
  125. #{userId}
  126. </foreach>
  127. <if test="courseScheduleId != null">
  128. AND FIND_IN_SET(#{courseScheduleId},course_ids_)
  129. </if>
  130. AND DATE_FORMAT(NOW(),'%Y-%m-%d') BETWEEN monday_ AND sunday_ AND actual_exercises_num_ = 0
  131. </update>
  132. <update id="updateLastSubmitTime">
  133. update student_extracurricular_exercises_situation_
  134. set exercises_reply_num_ = 1,last_submit_time_ = NOW(),update_time_ = NOW()
  135. where teacher_id_ = #{teacherId} and student_id_ = #{userId}
  136. <if test="courseScheduleId != null">
  137. AND FIND_IN_SET(#{courseScheduleId},course_ids_)
  138. </if>
  139. AND DATE_FORMAT(NOW(),'%Y-%m-%d') BETWEEN monday_ AND sunday_
  140. </update>
  141. <!-- 根据主键删除一条记录 -->
  142. <delete id="delete" >
  143. DELETE FROM course_schedule_statistics WHERE course_schedule_id_ = #{courseScheduleId}
  144. </delete>
  145. <delete id="delWaitByCourseId">
  146. DELETE FROM course_schedule_statistics_wait WHERE course_schedule_id_ IN
  147. <foreach collection="courseIdList" item="courseId" separator="," open="(" close=")">
  148. #{courseId}
  149. </foreach>
  150. </delete>
  151. <!-- 分页查询 -->
  152. <select id="queryPage" resultMap="CourseScheduleStatistics" parameterType="map">
  153. SELECT * FROM course_schedule_statistics <include refid="global.limit"/>
  154. </select>
  155. <!-- 查询当前表的总记录数 -->
  156. <select id="queryCount" resultType="int">
  157. SELECT COUNT(*) FROM course_schedule_statistics
  158. </select>
  159. <select id="queryUpdateCourseScheduleStatistics" resultMap="CourseScheduleStatistics">
  160. SELECT cssw.course_schedule_id_,cs.music_group_id_,
  161. COUNT(DISTINCT cssp.id_) course_student_total_num_,
  162. COUNT(DISTINCT CASE WHEN sa.status_ = 'NORMAL' THEN sa.id_ ELSE NULL END) attendance_num_,
  163. COUNT(DISTINCT CASE WHEN sa.status_ = 'LATE' THEN sa.id_ ELSE NULL END) late_num_,
  164. COUNT(DISTINCT CASE WHEN sa.qualified_flag_ = 1 THEN sa.id_ ELSE NULL END) standard_num_,
  165. CASE WHEN sch.id_ IS NOT NULL THEN 1 ELSE 0 END homework_flag_,
  166. COUNT(DISTINCT CASE WHEN sch.status_ = 1 THEN sch.id_ ELSE NULL END) homework_commit_num_,cs.class_date_,cs.status_ course_status_
  167. FROM course_schedule_statistics_wait cssw
  168. LEFT JOIN course_schedule_statistics css ON css.course_schedule_id_ = cssw.course_schedule_id_
  169. LEFT JOIN course_schedule cs ON cs.id_ = cssw.course_schedule_id_
  170. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cssw.course_schedule_id_
  171. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssw.course_schedule_id_
  172. LEFT JOIN student_course_homework sch ON sch.course_schedule_id_ = cssw.course_schedule_id_
  173. WHERE cs.group_type_ = 'MUSIC' AND css.course_schedule_id_ IS NOT NULL
  174. GROUP BY cssw.course_schedule_id_;
  175. </select>
  176. <select id="queryInsertCourseScheduleStatistics" resultMap="CourseScheduleStatistics">
  177. SELECT cssw.course_schedule_id_,cs.music_group_id_,COUNT(cssp.id_) course_student_total_num_,
  178. COUNT(CASE WHEN sa.status_ = 'NORMAL' THEN 1 ELSE NULL END) attendance_num_,
  179. COUNT(CASE WHEN sa.status_ = 'LATE' THEN 1 ELSE NULL END) late_num_,COUNT(CASE WHEN sa.qualified_flag_ = 1 THEN 1 ELSE NULL END) standard_num_,
  180. CASE WHEN sch.id_ IS NOT NULL THEN 1 ELSE 0 END homework_flag_,
  181. COUNT(DISTINCT CASE WHEN sch.status_ = 1 THEN sch.id_ ELSE NULL END) homework_commit_num_,
  182. CASE WHEN sees.course_ids_ IS NOT NULL THEN 1 ELSE 0 END service_flag_,cs.class_date_,cs.status_ course_status_
  183. FROM course_schedule_statistics_wait cssw
  184. LEFT JOIN course_schedule_statistics css ON css.course_schedule_id_ = cssw.course_schedule_id_
  185. LEFT JOIN course_schedule cs ON cs.id_ = cssw.course_schedule_id_
  186. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cssw.course_schedule_id_
  187. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssw.course_schedule_id_
  188. LEFT JOIN student_course_homework sch ON sch.course_schedule_id_ = cssw.course_schedule_id_
  189. LEFT JOIN (SELECT DISTINCT course_ids_ FROM student_extracurricular_exercises_situation_ WHERE course_ids_ IS NOT NULL) sees ON FIND_IN_SET(cssw.course_schedule_id_,sees.course_ids_)
  190. WHERE cs.group_type_ = 'MUSIC' AND css.course_schedule_id_ IS NULL
  191. GROUP BY cssw.course_schedule_id_;
  192. </select>
  193. </mapper>