CourseScheduleMapper.xml 130 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052
  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.CourseScheduleDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.CourseSchedule" id="CourseSchedule">
  9. <result column="id_" property="id"/>
  10. <result column="group_type_" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  11. <result column="music_group_id_" property="musicGroupId"/>
  12. <result column="class_group_id_" property="classGroupId"/>
  13. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  14. <result column="subsidy_" property="subsidy"/>
  15. <result column="class_date_" property="classDate"/>
  16. <result column="start_class_time_" property="startClassTime"/>
  17. <result column="end_class_time_" property="endClassTime"/>
  18. <result column="start_class_time_str_" property="startClassTimeStr"/>
  19. <result column="end_class_time_str_" property="endClassTimeStr"/>
  20. <result column="teacher_id_" property="teacherId"/>
  21. <result column="actual_teacher_id_" property="actualTeacherId"/>
  22. <result column="create_time_" property="createTime"/>
  23. <result column="update_time_" property="updateTime"/>
  24. <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  25. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  26. <result column="name_" property="name"/>
  27. <result column="student_num_" property="studentNum"/>
  28. <result column="leave_student_num_" property="leaveStudentNum"/>
  29. <result column="schoole_id_" property="schoolId"/>
  30. <result column="schoole_name_" property="schoolName"/>
  31. <result column="class_group_name_" property="classGroupName"/>
  32. <result column="class_group_type_" property="classGroupType"/>
  33. <result column="teaching_content_" property="teachingContent"/>
  34. <result column="note_" property="note"/>
  35. </resultMap>
  36. <resultMap type="com.ym.mec.biz.dal.dto.Mapper" id="Mapper">
  37. <result column="key_" property="key"/>
  38. <result column="value_" property="value"/>
  39. </resultMap>
  40. <resultMap id="CourseScheduleEndDto" type="com.ym.mec.biz.dal.dto.CourseScheduleEndDto" extends="CourseSchedule">
  41. <result column="course_start_time_" property="startClassTime"/>
  42. <result column="course_end_time_" property="endClassTime"/>
  43. <result column="settlement_time_" property="settlementTime"/>
  44. </resultMap>
  45. <resultMap type="com.ym.mec.biz.dal.dto.CourseScheduleDto" id="courseScheduleDto" extends="CourseSchedule">
  46. <result column="teacher_name_" property="teacherName"/>
  47. <result column="name_" property="classGroupName"/>
  48. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  49. <result column="school_name_" property="schoolName"/>
  50. <result column="sign_in_status_" property="signInStatus"/>
  51. <result column="sign_out_status_" property="signOutStatus"/>
  52. <result column="seal_class_id_" property="sealClassId"/>
  53. <result column="total_student_num_" property="totalStudentNum"/>
  54. <result column="expect_student_num_" property="expectStudentNum"/>
  55. <result column="teacher_role_" property="teacherRole"
  56. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  57. <result column="attendance_status_" property="attendanceStatus"
  58. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  59. <result column="complaint_status_" property="complaintStatus"/>
  60. <result column="student_id_" property="studentId"/>
  61. </resultMap>
  62. <resultMap type="com.ym.mec.biz.dal.entity.StudentCourseScheduleRecordDto" id="studentCourseScheduleRecord">
  63. <result column="id_" property="id"/>
  64. <result column="course_schedule_id_" property="courseScheduleId"/>
  65. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  66. <result column="name_" property="courseName"/>
  67. <result column="class_date_" property="classDate"/>
  68. <result column="start_class_time_" property="startClassTime"/>
  69. <result column="end_class_time_" property="endClassTime"/>
  70. <result column="teacher_id_" property="teacherId"/>
  71. <result column="teacher_name_" property="teacherName"/>
  72. <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  73. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  74. <result column="rest_of_class_" property="restOfClass"/>
  75. <result column="class_group_id_" property="classGroupId"/>
  76. </resultMap>
  77. <resultMap type="com.ym.mec.biz.dal.dto.StudentCourseInfoDto" id="StudentCourseInfoDto">
  78. <constructor>
  79. <arg column="class_date_" javaType="string"/>
  80. <arg column="start_class_time_" javaType="string"/>
  81. <arg column="end_class_time_" javaType="string"/>
  82. </constructor>
  83. <result column="id_" property="id"/>
  84. <result column="group_type_" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  85. <result column="music_group_id_" property="musicGroupId"/>
  86. <result column="class_group_id_" property="classGroupId"/>
  87. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  88. <result column="actual_teacher_id_" property="actualTeacherId"/>
  89. <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  90. <result column="expect_price_" property="expectPrice"/>
  91. </resultMap>
  92. <resultMap type="com.ym.mec.biz.dal.entity.StudentAttendance" id="StudentAttendance">
  93. <result column="music_group_id_" property="musicGroupId"/>
  94. <result column="class_group_id_" property="classGroupId"/>
  95. <result column="group_type_" property="groupType"/>
  96. <result column="course_schedule_id_" property="courseScheduleId"/>
  97. <result column="user_id_" property="userId"/>
  98. <result column="teacher_id_" property="teacherId"/>
  99. <result column="current_class_times_" property="currentClassTimes"/>
  100. </resultMap>
  101. <!-- 根据主键查询一条记录 -->
  102. <select id="get" resultMap="CourseSchedule">
  103. SELECT id_,
  104. music_group_id_,
  105. group_type_,
  106. class_group_id_,
  107. status_,
  108. subsidy_,
  109. class_date_,
  110. CONCAT(class_date_, ' ', start_class_time_) start_class_time_,
  111. CONCAT(class_date_, ' ', end_class_time_) end_class_time_,
  112. teacher_id_,
  113. actual_teacher_id_,
  114. create_time_,
  115. update_time_,
  116. teach_mode_,
  117. type_,
  118. name_,
  119. student_num_,
  120. leave_student_num_,
  121. teaching_content_,
  122. note_,
  123. schoole_id_
  124. FROM course_schedule
  125. WHERE id_ = #{id}
  126. </select>
  127. <!-- 全查询 -->
  128. <select id="findAll" resultMap="CourseSchedule">
  129. SELECT *
  130. FROM course_schedule
  131. ORDER BY id_
  132. </select>
  133. <!-- 向数据库增加一条记录 -->
  134. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseSchedule" useGeneratedKeys="true" keyColumn="id"
  135. keyProperty="id">
  136. <!--
  137. <selectKey resultClass="int" keyProperty="id" >
  138. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  139. </selectKey>
  140. -->
  141. INSERT INTO course_schedule
  142. (id_,group_type_,music_group_id_,class_group_id_,status_,subsidy_,class_date_,start_class_time_,end_class_time_,teacher_id_,actual_teacher_id_,create_time_,update_time_,type_,name_,teach_mode_,student_num_,leave_student_num_,schoole_id_,is_lock_,note_,teaching_content_)
  143. VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{classGroupId},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{subsidy},#{classDate},#{startClassTime},#{endClassTime},#{teacherId},#{teacherId},now(),now(),
  144. #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{name},#{teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{studentNum},#{leaveStudentNum},#{schoolId},#{isLock},#{note},#{teachingContent})
  145. </insert>
  146. <insert id="batchAddCourseSchedules" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
  147. keyProperty="id">
  148. INSERT INTO course_schedule
  149. (group_type_,music_group_id_,class_group_id_,status_,subsidy_,class_date_,start_class_time_,end_class_time_,
  150. teacher_id_,actual_teacher_id_,create_time_,update_time_,type_,name_,teach_mode_,student_num_,leave_student_num_,
  151. schoole_id_,is_lock_,note_,teaching_content_)
  152. VALUE
  153. <foreach collection="list" item="course" separator=",">
  154. (#{course.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.musicGroupId},
  155. #{course.classGroupId},#{course.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  156. #{course.subsidy},#{course.classDate},#{course.startClassTime},#{course.endClassTime},#{course.teacherId},
  157. #{course.teacherId},now(),now(),#{course.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  158. #{course.name},#{course.teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{course.studentNum},
  159. #{course.leaveStudentNum},#{course.schoolId},#{course.isLock},#{course.note},#{course.teachingContent})
  160. </foreach>
  161. </insert>
  162. <!-- 根据主键查询一条记录 -->
  163. <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseSchedule">
  164. UPDATE course_schedule
  165. <set>
  166. <if test="note != null">
  167. note_ = #{note},
  168. </if>
  169. <if test="teachingContent != null">
  170. teaching_content_ = #{teachingContent},
  171. </if>
  172. <if test="classDate != null">
  173. class_date_ = #{classDate},
  174. </if>
  175. <if test="musicGroupId != null">
  176. music_group_id_ = #{musicGroupId},
  177. </if>
  178. <if test="endClassTime != null">
  179. end_class_time_ = #{endClassTime},
  180. </if>
  181. <if test="status != null">
  182. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  183. </if>
  184. <if test="type != null">
  185. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  186. </if>
  187. <if test="groupType != null">
  188. group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  189. </if>
  190. <if test="actualTeacherId != null">
  191. actual_teacher_id_ = #{actualTeacherId},
  192. </if>
  193. <if test="subsidy != null">
  194. subsidy_ = #{subsidy},
  195. </if>
  196. <if test="classGroupId != null">
  197. class_group_id_ = #{classGroupId},
  198. </if>
  199. <if test="startClassTime != null">
  200. start_class_time_ = #{startClassTime},
  201. </if>
  202. <if test="teacherId != null">
  203. teacher_id_ = #{teacherId},
  204. </if>
  205. <if test="studentNum != null">
  206. student_num_ = #{studentNum},
  207. </if>
  208. <if test="leaveStudentNum != null">
  209. leave_student_num_ = #{leaveStudentNum},
  210. </if>
  211. <if test="schoolId != null">
  212. schoole_id_ = #{schoolId},
  213. </if>
  214. <if test="schoolId == null">
  215. schoole_id_ = null,
  216. </if>
  217. <if test="teachMode != null">
  218. teach_mode_ = #{teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  219. </if>
  220. <if test="isLock != null">
  221. is_lock_ = #{isLock},
  222. </if>
  223. update_time_ = NOW()
  224. </set>
  225. WHERE id_ = #{id}
  226. </update>
  227. <!-- 根据主键删除一条记录 -->
  228. <delete id="delete">
  229. DELETE
  230. FROM course_schedule
  231. WHERE id_ = #{id}
  232. </delete>
  233. <delete id="deleteCourseSchedulesByMusicGroupID" parameterType="map">
  234. DELETE
  235. FROM course_schedule
  236. WHERE music_group_id_ = #{musicGroupId}
  237. AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  238. and status_ = 'NOT_START'
  239. </delete>
  240. <update id="logicDeleteCourseSchedulesByMusicGroupID">
  241. update course_schedule
  242. set del_flag_ = '1',
  243. update_time_ = NOW()
  244. WHERE music_group_id_ = #{musicGroupID}
  245. AND group_type_ = 'MUSIC'
  246. and status_ = 'NOT_START'
  247. </update>
  248. <update id="resumeCourseScheduleByMusicGroupId">
  249. update course_schedule
  250. set del_flag_ = '0',
  251. update_time_ = NOW()
  252. WHERE music_group_id_ = #{musicGroupID}
  253. AND group_type_ = 'MUSIC'
  254. and status_ = 'NOT_START'
  255. and del_flag_ = '1'
  256. </update>
  257. <delete id="batchDeleteCourseSchedules">
  258. DELETE FROM course_schedule
  259. WHERE
  260. CONCAT( class_date_, ' ', start_class_time_ ) &gt; NOW()
  261. AND id_ IN
  262. <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
  263. #{courseScheduleId}
  264. </foreach>
  265. </delete>
  266. <delete id="batchDeleteAllCourseSchedules">
  267. DELETE FROM course_schedule
  268. WHERE id_ IN
  269. <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
  270. #{courseScheduleId}
  271. </foreach>
  272. </delete>
  273. <select id="filterNotStartCourseIdsWithIds" resultType="long">
  274. SELECT id_ FROM course_schedule
  275. WHERE
  276. CONCAT( class_date_, ' ', start_class_time_ ) &gt; NOW()
  277. AND id_ IN
  278. <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
  279. #{courseScheduleId}
  280. </foreach>
  281. </select>
  282. <!-- 分页查询 -->
  283. <select id="queryPage" resultMap="CourseSchedule" parameterType="map">
  284. SELECT * FROM course_schedule ORDER BY id_
  285. <include refid="global.limit"/>
  286. </select>
  287. <!-- 查询当前表的总记录数 -->
  288. <select id="queryCount" resultType="int">
  289. SELECT COUNT(*)
  290. FROM course_schedule
  291. </select>
  292. <resultMap type="com.ym.mec.biz.dal.dto.TeacherAttendanceDto" id="TeacherAttendanceViewUtilEntity">
  293. <result property="courseScheduleId" column="id_"/>
  294. <result property="courseScheduleName" column="course_schedule_name_"/>
  295. <result property="classDate" column="class_date_"/>
  296. <result property="startClassTime" column="start_class_time_"/>
  297. <result property="endClassTime" column="end_class_time_"/>
  298. <result property="courseStatus" column="course_status_"
  299. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  300. <result property="classId" column="class_id"/>
  301. <result property="className" column="class_name"/>
  302. <result property="classType" column="class_type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  303. <result property="musicGroupId" column="music_group_id"/>
  304. <result property="musicGroupName" column="music_group_name"/>
  305. <result property="schoolId" column="school_id_"/>
  306. <result property="address" column="address_"/>
  307. <result property="longitudeAndLatitude" column="longitude_latitude_"/>
  308. <result property="teacherName" column="teacher_name_"/>
  309. <result property="signInTime" column="sign_in_time_"/>
  310. <result column="total_class_times_" property="totalClassTimes"/>
  311. <result column="current_class_times_" property="currentClassTimes"/>
  312. <result column="student_num_" property="studentNum"/>
  313. </resultMap>
  314. <select id="getCurrentCourseDetail"
  315. resultMap="TeacherAttendanceViewUtilEntity">
  316. SELECT cs.id_,
  317. cs.name_ course_schedule_name_,
  318. cs.class_date_,
  319. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  320. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  321. cs.status_ course_status_,
  322. cg.id_ class_id,
  323. cg.name_ class_name,
  324. cg.total_class_times_,
  325. cg.current_class_times_,
  326. cg.student_num_,
  327. cs.type_ class_type,
  328. mg.id_ music_group_id,
  329. mg.name_ music_group_name,
  330. s.id_ school_id_,
  331. s.address_,
  332. s.longitude_latitude_,
  333. su.real_name_ teacher_name_,
  334. ta.sign_in_time_
  335. FROM course_schedule cs
  336. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  337. LEFT JOIN music_group mg ON cg.music_group_id_ = mg.id_
  338. LEFT JOIN school s ON cs.schoole_id_ = s.id_
  339. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  340. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_ AND ta.teacher_id_ = #{teacherId}
  341. WHERE cs.id_ = #{courseID}
  342. LIMIT 1
  343. </select>
  344. <select id="getTeacherCourseByDateSpeed"
  345. resultMap="TeacherAttendanceViewUtilEntity">
  346. SELECT cs.id_,
  347. cs.name_ course_schedule_name_,
  348. cs.class_date_,
  349. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  350. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  351. cs.status_ course_status_,
  352. cg.id_ class_id,
  353. cg.name_ class_name,
  354. cs.type_ class_type,
  355. mg.id_ music_group_id,
  356. mg.name_ music_group_name,
  357. s.id_ school_id_,
  358. s.address_,
  359. s.longitude_latitude_,
  360. su.real_name_ teacher_name_,
  361. ta.sign_in_time_,
  362. cs.schoole_id_
  363. FROM course_schedule cs
  364. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  365. LEFT JOIN music_group mg ON cg.music_group_id_ = mg.id_
  366. LEFT JOIN school s ON mg.school_id_ = s.id_
  367. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  368. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_
  369. WHERE cs.actual_teacher_id_ = #{teacherId}
  370. AND (CONCAT(cs.class_date_, ' ', cs.end_class_time_) BETWEEN #{startTime} AND #{endTime})
  371. AND cs.schoole_id_ = #{schoolId}
  372. AND ta.sign_in_time_ IS NOT NULL
  373. ORDER BY cs.id_
  374. </select>
  375. <resultMap id="studentAttendanceViewUtilEntity" type="com.ym.mec.biz.dal.dto.StudentAttendanceViewDto">
  376. <result property="classGroupId" column="class_group_id_"/>
  377. <result property="studentId" column="student_id_"/>
  378. <result property="userName" column="username_"/>
  379. <result property="musicGroupId" column="music_group_id_"/>
  380. <result property="subjectId" column="subject_id_"/>
  381. <result property="subjectName" column="subject_name_"/>
  382. <result property="status" column="status_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  383. </resultMap>
  384. <select id="getCurrentCourseStudents" resultMap="studentAttendanceViewUtilEntity">
  385. SELECT cgsm.class_group_id_,
  386. su.id_ student_id_,
  387. su.username_,
  388. mg.id_ music_group_id_,
  389. s.id_ subject_id_,
  390. s.name_ subject_name_,
  391. cgsm.status_
  392. FROM class_group cg
  393. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  394. LEFT JOIN sys_user su ON cgsm.user_id_ = su.id_
  395. LEFT JOIN music_group mg ON cg.music_group_id_ = mg.id_
  396. LEFT JOIN `subject` s ON cg.subject_id_ = s.id_
  397. WHERE cgsm.class_group_id_ = #{classID}
  398. AND cgsm.status_ != 'QUIT'
  399. AND cg.group_type_ = 'MUSIC'
  400. </select>
  401. <select id="countStudentInClass" resultType="java.lang.Integer">
  402. SELECT
  403. COUNT(class_group_id_)
  404. FROM
  405. class_group_student_mapper cgsm
  406. WHERE class_group_id_ IN
  407. <foreach collection="list" item="item" index="index" separator="," open="(" close=")">
  408. #{item}
  409. </foreach>
  410. AND cgsm.status_ != 'QUIT'
  411. GROUP BY user_id_
  412. </select>
  413. <select id="findByCourseScheduleIds" resultMap="CourseSchedule">
  414. SELECT
  415. cs.id_,
  416. cs.music_group_id_,
  417. cs.group_type_,
  418. cs.class_group_id_,
  419. cs.status_,
  420. cs.subsidy_,
  421. cs.class_date_,
  422. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  423. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  424. cs.teacher_id_,
  425. cs.actual_teacher_id_,
  426. cs.create_time_,
  427. cs.update_time_,
  428. cs.teach_mode_,
  429. cs.type_,
  430. cs.name_,
  431. cs.student_num_,
  432. cs.leave_student_num_,
  433. cs.schoole_id_
  434. FROM
  435. course_schedule cs
  436. WHERE cs.id_ IN
  437. <foreach collection="courseScheduleIds" item="id" open="(" close=")" separator=",">
  438. #{id}
  439. </foreach>
  440. ORDER BY cs.create_time_ DESC
  441. </select>
  442. <select id="findTeachingTeachers"
  443. resultMap="com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao.CourseScheduleTeacherSalary">
  444. SELECT
  445. csts.*
  446. FROM
  447. course_schedule_teacher_salary csts
  448. WHERE
  449. csts.teacher_role_ = 'TEACHING'
  450. AND csts.course_schedule_id_ IN
  451. <foreach collection="courseScheduleIds" item="id" open="(" close=")" separator=",">
  452. #{id}
  453. </foreach>
  454. </select>
  455. <select id="getCourseSchedulesWithDate" resultMap="courseScheduleDto">
  456. SELECT
  457. cs.id_ seal_class_id_,
  458. cg.name_,
  459. cs.type_,
  460. cs.id_,
  461. cs.class_date_,
  462. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  463. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  464. cs.actual_teacher_id_,
  465. cs.status_,
  466. cs.student_num_,
  467. cs.leave_student_num_,
  468. cs.teach_mode_,
  469. cs.music_group_id_,
  470. cs.group_type_,
  471. cs.class_group_id_,
  472. cg.student_num_ total_student_num_,
  473. su.real_name_ teacher_name_,
  474. IF(ta.sign_in_status_ IS NULL,3,ta.sign_in_status_) sign_in_status_,
  475. s.name_ school_name_
  476. FROM
  477. course_schedule cs
  478. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  479. LEFT JOIN sys_user su ON cs.actual_teacher_id_=su.id_
  480. LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_ AND ta.teacher_id_=cs.actual_teacher_id_
  481. LEFT JOIN school s ON cs.schoole_id_=s.id_
  482. WHERE
  483. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  484. <if test="classGroupIds != null and organIdList!=null">
  485. AND cs.class_group_id_ IN
  486. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  487. #{classGroupId}
  488. </foreach>
  489. </if>
  490. AND cs.id_ IS NOT NULL
  491. <if test="type!=null">
  492. AND cg.group_type_ = #{type}
  493. </if>
  494. <if test="musicGroupId!=null">
  495. AND cs.music_group_id_=#{musicGroupId} AND cs.group_type_='MUSIC'
  496. </if>
  497. AND cs.class_date_ = DATE_FORMAT(#{date},'%Y-%m-%d')
  498. ORDER BY CONCAT(cs.class_date_,' ',cs.start_class_time_)
  499. <include refid="global.limit"/>
  500. </select>
  501. <select id="countCourseSchedulesWithDate" resultType="int">
  502. SELECT
  503. count(*)
  504. FROM
  505. course_schedule cs
  506. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  507. WHERE
  508. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  509. AND cs.id_ IS NOT NULL
  510. <if test="type!=null">
  511. AND cg.group_type_ = #{type}
  512. </if>
  513. <if test="classGroupIds != null and organIdList!=null">
  514. AND cs.class_group_id_ IN
  515. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  516. #{classGroupId}
  517. </foreach>
  518. </if>
  519. <if test="musicGroupId!=null">
  520. AND cs.music_group_id_=#{musicGroupId} AND cs.group_type_='MUSIC'
  521. </if>
  522. AND cs.class_date_ = DATE_FORMAT(#{date},'%Y-%m-%d')
  523. </select>
  524. <select id="getStudentCourseSchedulesWithDate" resultMap="courseScheduleDto">
  525. SELECT
  526. cs.id_ seal_class_id_,
  527. cs.name_,
  528. cs.type_,
  529. cs.id_,
  530. cs.class_date_,
  531. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  532. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  533. cs.status_,
  534. su.real_name_ teacher_name_,
  535. IF(sa.status_ IS NULL,'NORMAL',sa.status_) attendance_status_,
  536. csc.id_ IS NOT NULL complaint_status_,
  537. cs.teach_mode_
  538. FROM
  539. course_schedule_student_payment cssp
  540. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
  541. LEFT JOIN sys_user su ON cs.actual_teacher_id_=su.id_
  542. LEFT JOIN course_schedule_complaints csc ON csc.course_schedule_id_=cssp.course_schedule_id_ AND
  543. csc.user_id_=#{studentId}
  544. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cs.id_ AND sa.user_id_=#{studentId}
  545. WHERE
  546. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  547. AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
  548. AND cs.class_date_ = DATE_FORMAT(#{classDate},'%Y%m%d')
  549. AND cssp.user_id_ = #{studentId}
  550. <if test="quitClassGroupIds != null and quitClassGroupIds.size()>0">
  551. AND cssp.class_group_id_ NOT IN
  552. <foreach collection="quitClassGroupIds" item="quitClassGroupId" open="(" close=")" separator=",">
  553. #{quitClassGroupId}
  554. </foreach>
  555. </if>
  556. ORDER BY start_class_time_
  557. </select>
  558. <select id="getTeacherCourseSchedulesWithDate" resultMap="courseScheduleDto">
  559. SELECT
  560. cs.id_ seal_class_id_,
  561. cg.name_,
  562. su.real_name_ teacher_name_,
  563. cs.type_,
  564. cs.id_,
  565. cs.class_group_id_,
  566. cs.class_date_,
  567. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  568. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  569. cs.status_,
  570. csts.user_id_ actual_teacher_id_,
  571. csts.teacher_role_,
  572. cg.expect_student_num_,
  573. cs.schoole_id_,
  574. s.name_ school_name_,
  575. if(ta.sign_in_status_ IS NULL,0,1) sign_in_status_,
  576. if(ta.sign_out_status_ IS NULL,0,1) sign_out_status_,
  577. cs.teach_mode_
  578. FROM
  579. course_schedule_teacher_salary csts
  580. LEFT JOIN course_schedule cs ON csts.course_schedule_id_=cs.id_
  581. LEFT JOIN sys_user su ON csts.user_id_ = su.id_
  582. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  583. LEFT JOIN school s ON cs.schoole_id_ = s.id_
  584. LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_ AND ta.teacher_id_=#{teacherId}
  585. WHERE
  586. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  587. AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
  588. AND cs.class_date_ = DATE_FORMAT(#{classDate},'%Y%m%d')
  589. <if test="type!=null and type!=''">
  590. AND cs.type_=#{type}
  591. </if>
  592. AND csts.user_id_ = #{teacherId}
  593. ORDER BY start_class_time_
  594. </select>
  595. <select id="findCourseSchedulesWithDate" resultMap="courseScheduleDto">
  596. SELECT
  597. cs.id_ seal_class_id_,
  598. cg.name_,
  599. su.real_name_ teacher_name_,
  600. cs.type_,
  601. cs.id_,
  602. cs.class_group_id_,
  603. cs.class_date_,
  604. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  605. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  606. cs.status_,
  607. cs.teacher_id_,
  608. cs.actual_teacher_id_,
  609. cg.expect_student_num_,
  610. cs.schoole_id_,
  611. s.name_ school_name_,
  612. if(ta.sign_in_status_ IS NULL,0,1) sign_in_status_,
  613. if(ta.sign_out_status_ IS NULL,0,1) sign_out_status_,
  614. cs.teach_mode_
  615. FROM
  616. course_schedule cs
  617. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  618. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  619. LEFT JOIN school s ON cs.schoole_id_ = s.id_
  620. LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_ AND ta.teacher_id_=#{teacherId}
  621. WHERE
  622. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  623. AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
  624. <if test="teacherId!=null">
  625. AND cs.actual_teacher_id_=#{teacherId}
  626. </if>
  627. <if test="classDate!=null">
  628. AND cs.class_date_ = DATE_FORMAT(#{classDate},'%Y-%m-%d')
  629. </if>
  630. <if test="groupId!=null">
  631. AND cs.music_group_id_=#{groupId}
  632. </if>
  633. <if test="type!=null and type!=''">
  634. AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  635. </if>
  636. ORDER BY start_class_time_
  637. </select>
  638. <select id="getTeacherHistoryCourseSchedulesWithDate" resultMap="courseScheduleDto">
  639. SELECT cs.id_ seal_class_id_,
  640. cg.name_,
  641. su.real_name_ teacher_name_,
  642. cs.type_,
  643. cs.id_,
  644. cs.class_group_id_,
  645. cs.class_date_,
  646. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  647. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  648. cs.status_,
  649. csts.user_id_ actual_teacher_id_,
  650. csts.teacher_role_,
  651. cs.schoole_id_,
  652. s.name_ school_name_,
  653. if(ta.sign_in_status_ IS NULL, 0, 1) sign_in_status_,
  654. if(ta.sign_out_status_ IS NULL, 0, 1) sign_out_status_,
  655. cs.teach_mode_
  656. FROM course_schedule_teacher_salary csts
  657. LEFT JOIN course_schedule cs ON csts.course_schedule_id_ = cs.id_
  658. LEFT JOIN sys_user su ON csts.user_id_ = su.id_
  659. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  660. LEFT JOIN school s ON cs.schoole_id_ = s.id_
  661. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_ AND ta.teacher_id_ = #{teacherId}
  662. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  663. AND cs.class_date_ = DATE_FORMAT(#{classDate}, '%Y%m%d')
  664. AND csts.user_id_ = #{teacherId}
  665. AND cg.del_flag_ = 0
  666. AND CONCAT(cs.class_date_, ' ', cs.end_class_time_) &lt; NOW()
  667. ORDER BY start_class_time_
  668. </select>
  669. <select id="getCourseScheduleDateByMonth" resultType="java.util.Date">
  670. SELECT cs.class_date_
  671. FROM course_schedule cs
  672. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  673. WHERE DATE_FORMAT(cs.class_date_, '%Y%m') = DATE_FORMAT(#{month}, '%Y%m')
  674. AND cg.music_group_id_ = #{musicGroupID}
  675. AND cg.group_type_ = 'MUSIC'
  676. GROUP BY cs.class_date_
  677. </select>
  678. <select id="countTeacherCourseInOnDayRepeats" parameterType="com.ym.mec.biz.dal.entity.CourseSchedule"
  679. resultType="int">
  680. SELECT COUNT(*)
  681. FROM course_schedule cs
  682. WHERE cs.teacher_id_ = #{teacherId}
  683. AND cs.class_date_ = DATE_FORMAT(#{classDate}, '%Y-%m-%d')
  684. AND (
  685. CONCAT(cs.class_date_, ' ', cs.start_class_time_) &lt;
  686. DATE_FORMAT('endClassTime', '%Y-%m-%d %H:%i:%s')
  687. OR CONCAT(cs.class_date_, ' ', cs.end_class_time_) &gt;
  688. DATE_FORMAT('startClassTime', '%Y-%m-%d %H:%i:%s')
  689. )
  690. </select>
  691. <select id="findTeacherCoursesInDates" resultMap="CourseSchedule">
  692. SELECT
  693. id_,
  694. class_group_id_,
  695. status_,
  696. subsidy_,
  697. class_date_,
  698. concat(class_date_,' ',start_class_time_) start_class_time_,
  699. concat(class_date_,' ',end_class_time_) end_class_time_,
  700. teacher_id_,
  701. actual_teacher_id_,
  702. create_time_,
  703. update_time_
  704. FROM
  705. course_schedule cs
  706. WHERE
  707. cs.teacher_id_ = #{teacherId}
  708. AND cs.class_date_ IN
  709. <foreach collection="dates" item="date" open="(" close=")" separator=",">
  710. #{date}
  711. </foreach>
  712. </select>
  713. <select id="findCoursesByDates" resultMap="CourseSchedule">
  714. SELECT
  715. *
  716. FROM
  717. course_schedule cs
  718. WHERE
  719. cs.class_date_ IN
  720. <foreach collection="dates" item="date" open="(" close=")" separator=",">
  721. DATE_FORMAT(#{date},'%Y-%m-%d')
  722. </foreach>
  723. </select>
  724. <select id="findOverLapCoursesInDay" resultMap="CourseSchedule">
  725. SELECT
  726. cs.id_,
  727. cs.class_group_id_,
  728. cs.status_,
  729. cs.subsidy_,
  730. cs.class_date_,
  731. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  732. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  733. cs.teacher_id_,
  734. csts.user_id_ actual_teacher_id_,
  735. cs.create_time_,
  736. cs.update_time_,
  737. cs.teach_mode_,
  738. cs.type_,
  739. cs.name_,
  740. cs.student_num_,
  741. cs.leave_student_num_,
  742. cs.schoole_id_
  743. FROM
  744. course_schedule cs
  745. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  746. WHERE
  747. cs.class_date_ IN
  748. <foreach collection="dates" item="date" open="(" close=")" separator=",">
  749. DATE_FORMAT(#{date},'%Y-%m-%d')
  750. </foreach>
  751. AND (
  752. DATE_FORMAT(cs.start_class_time_,"%H:%i:%s") &gt; DATE_FORMAT(#{endClassTime}, '%H:%i:%s' )
  753. OR DATE_FORMAT(cs.end_class_time_,"%H:%i:%s") &lt; DATE_FORMAT( #{startClassTime}, '%H:%i:%s' )
  754. )=0
  755. </select>
  756. <select id="findCourseSchedulesByIds" resultMap="CourseSchedule">
  757. SELECT
  758. *
  759. FROM
  760. course_schedule cs
  761. WHERE
  762. cs.id_ IN
  763. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  764. #{id}
  765. </foreach>
  766. </select>
  767. <!-- 获取班级未开始的课程 -->
  768. <select id="findClassGroupNoStartCourseSchedules" resultMap="CourseSchedule">
  769. SELECT * FROM course_schedule
  770. WHERE status_ = 'NOT_START'
  771. AND class_group_id_ IN
  772. <foreach collection="classGroupIds" item="classGroupId" index="index" open="(" close=")" separator=",">
  773. #{classGroupId}
  774. </foreach>
  775. <if test="groupType!= null ">
  776. AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  777. </if>
  778. </select>
  779. <select id="getStudentCourseScheduleDate" resultType="java.util.Date">
  780. SELECT
  781. cs.class_date_
  782. FROM
  783. course_schedule_student_payment cssp
  784. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
  785. WHERE
  786. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  787. AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
  788. AND cssp.user_id_ = #{studentId}
  789. <if test="month==null">
  790. AND DATE_FORMAT( NOW(), '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  791. </if>
  792. <if test="month!=null">
  793. AND DATE_FORMAT( #{month}, '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  794. </if>
  795. <if test="isAttend!=null">
  796. AND cs.status_='NOT_START'
  797. </if>
  798. GROUP BY
  799. cs.class_date_
  800. </select>
  801. <select id="getTeacherCourseScheduleDate" resultType="java.util.Date">
  802. SELECT
  803. cs.class_date_
  804. FROM
  805. course_schedule_teacher_salary csts
  806. LEFT JOIN course_schedule cs ON csts.course_schedule_id_=cs.id_
  807. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  808. WHERE
  809. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  810. AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
  811. AND csts.user_id_ = #{teacherId}
  812. <if test="month==null">
  813. AND DATE_FORMAT( NOW(), '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  814. </if>
  815. <if test="month!=null">
  816. AND DATE_FORMAT( #{month}, '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  817. </if>
  818. <if test="type!=null and type!=''">
  819. AND cs.type_=#{type}
  820. </if>
  821. GROUP BY cs.class_date_
  822. </select>
  823. <select id="findHaveClassesDatesWithMonth" resultType="java.util.Date">
  824. SELECT
  825. cs.class_date_
  826. FROM
  827. course_schedule cs
  828. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  829. WHERE
  830. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  831. AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
  832. AND cg.del_flag_ = 0
  833. <if test="teacherId!=null">
  834. AND cs.actual_teacher_id_=#{teacherId}
  835. </if>
  836. <if test="month==null">
  837. AND DATE_FORMAT( NOW(), '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  838. </if>
  839. <if test="month!=null">
  840. AND DATE_FORMAT( #{month}, '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  841. </if>
  842. <if test="groupId!=null">
  843. AND cs.music_group_id_=#{groupId}
  844. </if>
  845. <if test="type!=null and type!=''">
  846. AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  847. </if>
  848. GROUP BY cs.class_date_
  849. </select>
  850. <select id="getTeacherHistoryCourseScheduleDate" resultType="java.util.Date">
  851. SELECT
  852. cs.class_date_
  853. FROM
  854. course_schedule_teacher_salary csts
  855. LEFT JOIN course_schedule cs ON csts.course_schedule_id_=cs.id_
  856. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  857. WHERE
  858. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  859. AND CONCAT(cs.class_date_,' ',cs.start_class_time_) &lt; NOW()
  860. AND csts.user_id_ = #{teacherId}
  861. AND cg.del_flag_ = 0
  862. <if test="month==null">
  863. AND DATE_FORMAT( NOW(), '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  864. </if>
  865. <if test="month!=null">
  866. AND DATE_FORMAT( #{month}, '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  867. </if>
  868. GROUP BY cs.class_date_
  869. </select>
  870. <select id="getCourseScheduleDate" resultType="java.util.Date">
  871. SELECT
  872. cs.class_date_
  873. FROM
  874. music_group mg
  875. LEFT JOIN class_group cg ON mg.id_ = cg.music_group_id_
  876. LEFT JOIN course_schedule cs ON cg.id_ = cs.class_group_id_
  877. WHERE
  878. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  879. AND FIND_IN_SET(mg.organ_id_,#{organIdList}) AND cs.id_ IS NOT NULL
  880. <if test="month==null">
  881. AND DATE_FORMAT( NOW(), '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  882. </if>
  883. <if test="month!=null">
  884. AND DATE_FORMAT( #{month}, '%Y%m' ) = DATE_FORMAT( cs.class_date_, '%Y%m' )
  885. </if>
  886. <if test="type!=null and type!=''">
  887. AND cs.type_=#{type}
  888. </if>
  889. GROUP BY
  890. cs.class_date_
  891. </select>
  892. <select id="findClassSubjects" resultType="string">
  893. SELECT
  894. CONCAT(cg.id_,'-',IF(GROUP_CONCAT(s.name_) IS NULL,'',GROUP_CONCAT(s.name_)))
  895. FROM
  896. class_group cg
  897. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,cg.subject_id_list_)
  898. WHERE cg.id_ IN
  899. <foreach collection="list" item="id" open="(" close=")" separator=",">
  900. #{id}
  901. </foreach>
  902. GROUP BY cg.id_
  903. </select>
  904. <sql id="queryStudentCourseScheduleRecordCondition">
  905. <where>
  906. cssp.user_id_=#{userId}
  907. AND cs.status_ != 'NOT_START'
  908. AND cs.del_flag_ = 0
  909. <if test="teachMode!=null and teachMode!=''">
  910. AND cs.teach_mode_=#{teachMode}
  911. </if>
  912. <if test="type!=null and type!=''">
  913. AND cs.group_type_ = #{type}
  914. </if>
  915. <if test="status != null and status != 'TRUANT'">
  916. AND sa.status_ = #{status}
  917. </if>
  918. <if test="status != null and status == 'TRUANT'">
  919. AND (sa.status_ = #{status} OR sa.status_ IS NULL)
  920. </if>
  921. </where>
  922. </sql>
  923. <select id="findStudentCourseScheduleRecords" resultMap="studentCourseScheduleRecord">
  924. SELECT
  925. sa.id_,
  926. IF(sa.status_ IS NULL,'TRUANT',sa.status_) status_,
  927. sa.teacher_id_,
  928. su.username_,
  929. cs.id_ course_schedule_id_,
  930. cs.name_,
  931. cs.class_date_,
  932. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  933. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  934. cs.teacher_id_,
  935. cs.teach_mode_
  936. FROM course_schedule_student_payment cssp
  937. LEFT JOIN student_attendance sa ON cssp.course_schedule_id_ = sa.course_schedule_id_ AND cssp.user_id_ =
  938. sa.user_id_
  939. LEFT JOIN course_schedule cs ON sa.course_schedule_id_=cs.id_
  940. LEFT JOIN sys_user su ON sa.teacher_id_=su.id_
  941. <include refid="queryStudentCourseScheduleRecordCondition"/>
  942. ORDER BY cs.class_date_ DESC,cs.start_class_time_ DESC
  943. <include refid="global.limit"/>
  944. </select>
  945. <select id="countStudentCourseScheduleRecords" resultType="int">
  946. SELECT
  947. count(cssp.id_)
  948. FROM course_schedule_student_payment cssp
  949. LEFT JOIN student_attendance sa ON cssp.course_schedule_id_ = sa.course_schedule_id_ AND cssp.user_id_ =
  950. sa.user_id_
  951. LEFT JOIN course_schedule cs ON sa.course_schedule_id_=cs.id_
  952. LEFT JOIN sys_user su ON sa.teacher_id_=su.id_
  953. <include refid="queryStudentCourseScheduleRecordCondition"/>
  954. </select>
  955. <select id="findStudentCourseScheduleNotStartRecords" resultMap="studentCourseScheduleRecord">
  956. SELECT cs.teacher_id_,
  957. su.real_name_ teacher_name_,
  958. cs.id_ course_schedule_id_,
  959. cs.name_,
  960. cs.class_date_,
  961. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  962. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  963. cs.teach_mode_,
  964. cs.class_group_id_
  965. FROM class_group_student_mapper cgsm
  966. LEFT JOIN course_schedule cs ON cs.class_group_id_ = cgsm.class_group_id_
  967. LEFT JOIN sys_user su ON cs.teacher_id_ = su.id_
  968. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  969. AND cs.status_ = 'NOT_START'
  970. AND cgsm.user_id_ = #{userId}
  971. AND cs.class_date_ = DATE_FORMAT(#{date}, '%Y%m%d')
  972. AND cgsm.status_ != 'QUIT'
  973. ORDER BY cs.class_date_, cs.start_class_time_
  974. </select>
  975. <select id="findCourseScheduleByMusicGroup" resultMap="CourseSchedule">
  976. SELECT cs.*
  977. FROM class_group cg
  978. LEFT JOIN course_schedule cs ON cg.id_ = cs.class_group_id_
  979. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  980. AND cg.music_group_id_ = #{musicGroupId}
  981. </select>
  982. <select id="countClassTimes" resultType="int">
  983. SELECT COUNT(*)
  984. FROM course_schedule
  985. WHERE class_group_id_ = #{classGroupId}
  986. AND CONCAT(class_date_, ' ', end_class_time_) &lt;= #{startClassTime}
  987. </select>
  988. <select id="getCourseSchedules" resultMap="courseScheduleDto">
  989. SELECT cs.type_,
  990. cs.id_,
  991. cs.id_ seal_class_id_,
  992. cs.class_date_,
  993. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  994. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  995. cs.status_,
  996. sc.paran_value_
  997. FROM course_schedule cs
  998. LEFT JOIN sys_config sc ON sc.param_name_ = "vip_appeal_days_range"
  999. WHERE cs.id_ = #{courseScheduleId}
  1000. </select>
  1001. <select id="findStudentNamesByCourseSchedule" resultType="string">
  1002. SELECT su.username_
  1003. FROM student_attendance sa
  1004. LEFT JOIN sys_user su ON sa.user_id_ = su.id_
  1005. WHERE sa.course_schedule_id_ = #{courseScheduleId}
  1006. AND status_ = 'NORMAL'
  1007. </select>
  1008. <select id="findGroupCourseSchedules" resultMap="CourseSchedule">
  1009. SELECT cs.id_,
  1010. cs.group_type_,
  1011. cs.music_group_id_,
  1012. cs.class_group_id_,
  1013. cs.status_,
  1014. cs.subsidy_,
  1015. cs.class_date_,
  1016. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1017. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1018. cs.start_class_time_ start_class_time_str_,
  1019. cs.end_class_time_ end_class_time_str_,
  1020. cs.teacher_id_,
  1021. cs.actual_teacher_id_,
  1022. cs.create_time_,
  1023. cs.update_time_,
  1024. cs.teach_mode_,
  1025. cs.type_,
  1026. cs.name_,
  1027. cs.student_num_,
  1028. cs.leave_student_num_,
  1029. cs.schoole_id_,
  1030. s.name_ schoole_name_
  1031. FROM course_schedule cs
  1032. LEFT JOIN school s ON cs.schoole_id_ = s.id_
  1033. WHERE cs.music_group_id_ = #{groupId}
  1034. AND cs.group_type_ = #{groupType}
  1035. ORDER BY start_class_time_
  1036. </select>
  1037. <select id="findVipGroupNotStartCourseScheduleIds" resultType="long">
  1038. SELECT cs.id_
  1039. FROM course_schedule cs
  1040. WHERE cs.music_group_id_ = #{groupId}
  1041. AND cs.group_type_ = #{groupType}
  1042. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  1043. </select>
  1044. <select id="findByClassGroupAndDate" resultMap="CourseSchedule">
  1045. SELECT
  1046. id_,
  1047. class_group_id_,
  1048. status_,
  1049. subsidy_,
  1050. class_date_,
  1051. CONCAT(class_date_,' ',start_class_time_) start_class_time_,
  1052. CONCAT(class_date_,' ',end_class_time_) end_class_time_,
  1053. teacher_id_,
  1054. actual_teacher_id_,
  1055. create_time_,
  1056. update_time_,
  1057. type_,name_,
  1058. teach_mode_
  1059. FROM
  1060. course_schedule
  1061. <where>
  1062. <if test="classGroupId!=null">
  1063. AND class_group_id_ = #{classGroupId}
  1064. </if>
  1065. <if test="classDates!=null">
  1066. AND class_date_ IN
  1067. <foreach collection="classDates" item="classDate" open="(" close=")" separator=",">
  1068. #{classDate}
  1069. </foreach>
  1070. </if>
  1071. </where>
  1072. </select>
  1073. <select id="findClassTypeByCourse" resultType="string">
  1074. SELECT cg.type_
  1075. FROM course_schedule cs
  1076. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  1077. WHERE cs.id_ = #{courseScheduleId}
  1078. </select>
  1079. <select id="queryVipGroupTeachereClassTimesByMonth" resultType="map" parameterType="map">
  1080. SELECT vp.organ_id_ organ_id_,
  1081. cs.actual_teacher_id_ teacher_id_,
  1082. COUNT(cs.id_) times,
  1083. t.is_support_course_schedule_rewards_rules_
  1084. FROM course_schedule cs
  1085. LEFT JOIN vip_group vp ON cs.music_group_id_ = vp.id_
  1086. LEFT JOIN teacher t ON cs.actual_teacher_id_ = t.id_
  1087. WHERE cs.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  1088. AND date_format(#{monthDate}, '%Y%m') = date_format(cs.class_date_, '%Y%m')
  1089. GROUP BY vp.organ_id_, cs.actual_teacher_id_
  1090. </select>
  1091. <select id="queryFinishedWithNoUpdateStatus" resultMap="CourseSchedule">
  1092. select *
  1093. from course_schedule
  1094. where CONCAT(class_date_, ' ', end_class_time_) &lt;= now()
  1095. and status_ != 'OVER'
  1096. </select>
  1097. <select id="queryUnderwayWithNoUpdateStatus" resultMap="CourseSchedule">
  1098. select *
  1099. from course_schedule
  1100. where CONCAT(class_date_, ' ', start_class_time_) &lt;= now()
  1101. and status_ = 'NOT_START'
  1102. </select>
  1103. <update id="batchUpdate" parameterType="java.util.List">
  1104. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  1105. UPDATE course_schedule
  1106. <set>
  1107. <if test="item.classDate != null">
  1108. class_date_ = #{item.classDate},
  1109. </if>
  1110. <if test="item.endClassTime != null">
  1111. end_class_time_ = #{item.endClassTime},
  1112. </if>
  1113. <if test="item.status != null">
  1114. status_ = #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  1115. </if>
  1116. <if test="item.type != null">
  1117. type_ = #{item.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  1118. </if>
  1119. <if test="item.actualTeacherId != null">
  1120. actual_teacher_id_ = #{item.actualTeacherId},
  1121. </if>
  1122. <if test="item.subsidy != null">
  1123. subsidy_ = #{item.subsidy},
  1124. </if>
  1125. <if test="item.classGroupId != null">
  1126. class_group_id_ = #{item.classGroupId},
  1127. </if>
  1128. <if test="item.startClassTime != null">
  1129. start_class_time_ = #{item.startClassTime},
  1130. </if>
  1131. <if test="item.teacherId != null">
  1132. teacher_id_ = #{item.teacherId},
  1133. </if>
  1134. <if test="item.studentNum != null">
  1135. student_num_ = #{item.studentNum},
  1136. </if>
  1137. <if test="item.leaveStudentNum != null">
  1138. leave_student_num_ = #{item.leaveStudentNum},
  1139. </if>
  1140. schoole_id_ = #{item.schoolId},
  1141. <if test="item.schoolId == null">
  1142. schoole_id_ = null,
  1143. </if>
  1144. <if test="item.teachMode != null">
  1145. teach_mode_ = #{item.teachMode,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  1146. </if>
  1147. update_time_ = NOW()
  1148. </set>
  1149. WHERE id_ = #{item.id}
  1150. </foreach>
  1151. </update>
  1152. <update id="updateByMusicGroupId">
  1153. UPDATE course_schedule cs
  1154. SET cs.schoole_id_ = #{schoolId},
  1155. update_time_ = NOW()
  1156. WHERE cs.class_group_id_ IN (SELECT cg.id_
  1157. FROM class_group cg
  1158. WHERE cg.music_group_id_ = #{musicGroupId}
  1159. AND cg.group_type_ = 'MUSIC')
  1160. </update>
  1161. <update id="updateCourscheduleStatus">
  1162. UPDATE course_schedule
  1163. SET status_ = #{status},
  1164. update_time_ = NOW()
  1165. WHERE id_ = #{courseScheduleId}
  1166. </update>
  1167. <update id="updateCourseScheduleSchool">
  1168. UPDATE course_schedule cs
  1169. SET cs.schoole_id_ = #{schoolId},
  1170. update_time_ = NOW()
  1171. WHERE cs.music_group_id_ = #{musicGroupId}
  1172. AND cs.group_type_ = 'MUSIC'
  1173. AND NOW() &lt; CONCAT(cs.class_date_, " ", cs.start_class_time_);
  1174. </update>
  1175. <update id="updateCourseSchoolByGroup">
  1176. UPDATE course_schedule cs
  1177. SET cs.schoole_id_ = #{schoolId},
  1178. update_time_ = NOW()
  1179. WHERE cs.music_group_id_ = #{groupId}
  1180. AND cs.group_type_ = #{groupType}
  1181. AND cs.teach_mode_ = "OFFLINE"
  1182. AND NOW() &lt; CONCAT(cs.class_date_, " ", cs.start_class_time_);
  1183. </update>
  1184. <update id="updateGroupCourseLock">
  1185. UPDATE course_schedule
  1186. SET is_lock_ = #{isLock},
  1187. update_time_ = NOW()
  1188. WHERE music_group_id_ = #{groupId}
  1189. AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  1190. AND NOW() &lt; CONCAT(class_date_, " ", start_class_time_);
  1191. </update>
  1192. <select id="queryNoSignInListByBeforeMinutes" resultMap="CourseSchedule">
  1193. SELECT cs.*
  1194. FROM course_schedule cs
  1195. left join teacher_attendance ta on ta.course_schedule_id_ = cs.id_
  1196. WHERE ta.sign_in_time_ is null
  1197. and SUBTIME(start_class_time_, CONCAT(#{minutes}, '00')) &lt; CURRENT_TIME()
  1198. </select>
  1199. <resultMap id="teacherClassCourseSchedule" type="com.ym.mec.biz.dal.dto.TeacherClassCourseSchudeleDto">
  1200. <result property="classGroupId" column="class_group_id_"/>
  1201. <result property="courseScheduleId" column="course_schedule_id_"/>
  1202. <result property="courseScheduleName" column="course_schedule_name_"/>
  1203. <result property="status" column="status_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1204. <result property="classDate" column="class_date_"/>
  1205. <result property="startClassTime" column="start_class_time_"/>
  1206. <result property="endClassTime" column="end_class_time_"/>
  1207. <result property="actualTeacherId" column="actual_teacher_id_"/>
  1208. <result property="actualTeacherName" column="username_"/>
  1209. <result property="type" column="type_"/>
  1210. <result property="studentNum" column="student_num_"/>
  1211. <result property="leaveStudentNum" column="leave_student_num_"/>
  1212. <result property="currentClassTimes" column="current_class_times_"/>
  1213. <result property="totalClassTimes" column="total_class_times_"/>
  1214. <result property="studentNames" column="student_names_"/>
  1215. <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1216. </resultMap>
  1217. <sql id="teacherClassCourseScheduleQueryCondition">
  1218. <where>
  1219. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  1220. AND cs.class_group_id_ = #{classGroupId}
  1221. <if test="userId != null">
  1222. AND csts.user_id_ = #{userId}
  1223. </if>
  1224. <if test="onlyHistory!=null and onlyHistory==1">
  1225. AND CONCAT( cs.class_date_, ' ', cs.end_class_time_ )&lt;now()
  1226. </if>
  1227. </where>
  1228. </sql>
  1229. <select id="queryTeacherClassCourseSchedule" resultMap="teacherClassCourseSchedule">
  1230. SELECT
  1231. cs.class_group_id_,
  1232. cs.id_ course_schedule_id_,
  1233. cs.class_date_,
  1234. CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) start_class_time_,
  1235. CONCAT( cs.class_date_, ' ', cs.end_class_time_ ) end_class_time_,
  1236. cs.name_ course_schedule_name_,
  1237. cs.student_num_,
  1238. cs.leave_student_num_,
  1239. cs.type_,
  1240. cs.status_,
  1241. cs.actual_teacher_id_,
  1242. cs.teach_mode_,
  1243. su.real_name_ username_,
  1244. cg.total_class_times_
  1245. FROM
  1246. course_schedule_teacher_salary csts
  1247. LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_
  1248. LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
  1249. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  1250. <include refid="teacherClassCourseScheduleQueryCondition"/>
  1251. ORDER BY start_class_time_
  1252. <include refid="global.limit"/>
  1253. </select>
  1254. <sql id="teacherGroupCourseQueryCondition">
  1255. <where>
  1256. cs.actual_teacher_id_=#{teacherId}
  1257. AND cs.music_group_id_ = #{groupId}
  1258. AND cs.group_type_ = #{groupType}
  1259. </where>
  1260. </sql>
  1261. <select id="findTeacherGroupCourses" resultMap="teacherClassCourseSchedule">
  1262. SELECT
  1263. cs.class_group_id_,
  1264. cs.id_ course_schedule_id_,
  1265. cs.class_date_,
  1266. CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) start_class_time_,
  1267. CONCAT( cs.class_date_, ' ', cs.end_class_time_ ) end_class_time_,
  1268. cs.name_ course_schedule_name_,
  1269. cs.student_num_,
  1270. cs.leave_student_num_,
  1271. cs.type_,
  1272. cs.status_,
  1273. cs.actual_teacher_id_,
  1274. cs.teach_mode_
  1275. FROM course_schedule cs
  1276. <include refid="teacherGroupCourseQueryCondition"/>
  1277. ORDER BY CONCAT( cs.class_date_, ' ', cs.start_class_time_ )
  1278. <include refid="global.limit"/>
  1279. </select>
  1280. <select id="countTeacherGroupCourses" resultType="int">
  1281. SELECT
  1282. COUNT(cs.id_)
  1283. FROM course_schedule cs
  1284. <include refid="teacherGroupCourseQueryCondition"/>
  1285. </select>
  1286. <select id="queryTeacherHistoryClassCourseSchedule" resultMap="teacherClassCourseSchedule">
  1287. SELECT
  1288. cs.class_group_id_,
  1289. cs.id_ course_schedule_id_,
  1290. cs.class_date_,
  1291. CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) start_class_time_,
  1292. CONCAT( cs.class_date_, ' ', cs.end_class_time_ ) end_class_time_,
  1293. cs.name_ course_schedule_name_,
  1294. cs.student_num_,
  1295. cs.leave_student_num_,
  1296. cs.type_,
  1297. cs.status_,
  1298. cs.actual_teacher_id_,
  1299. cs.teach_mode_,
  1300. su.username_,
  1301. cg.total_class_times_,
  1302. GROUP_CONCAT(IF(sa.status_='NORMAL',ssu.username_,NULL)) student_names_,
  1303. MAX(sa.current_class_times_) current_class_times_
  1304. FROM
  1305. student_attendance sa
  1306. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1307. LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
  1308. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  1309. LEFT JOIN sys_user ssu ON sa.user_id_=ssu.id_
  1310. WHERE
  1311. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  1312. AND sa.class_group_id_=#{classGroupId}
  1313. <if test="userId != null">
  1314. AND sa.teacher_id_=#{userId}
  1315. </if>
  1316. GROUP BY sa.course_schedule_id_
  1317. ORDER BY cs.id_
  1318. <include refid="global.limit"/>
  1319. </select>
  1320. <select id="countTeacherClassCourseSchedule" resultType="int">
  1321. SELECT
  1322. COUNT(cs.id_)
  1323. FROM
  1324. course_schedule_teacher_salary csts
  1325. LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_
  1326. <include refid="teacherClassCourseScheduleQueryCondition"/>
  1327. </select>
  1328. <select id="countTeacherHistoryClassCourseSchedule" resultType="int">
  1329. SELECT
  1330. COUNT(DISTINCT sa.class_group_id_)
  1331. FROM
  1332. student_attendance sa
  1333. LEFT JOIN course_schedule cs ON sa.course_schedule_id_=cs.id_
  1334. WHERE
  1335. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  1336. AND sa.class_group_id_=#{classGroupId}
  1337. <if test="userId != null">
  1338. AND sa.teacher_id_=#{userId}
  1339. </if>
  1340. </select>
  1341. <select id="countClassCourseNumByMusicGroup" resultType="java.util.Map">
  1342. SELECT cg.id_ as 'key',
  1343. COUNT(cs.id_) as 'value'
  1344. FROM class_group cg
  1345. LEFT JOIN course_schedule cs ON cg.id_ = cs.class_group_id_
  1346. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  1347. AND music_group_id_ = #{musicGroupId}
  1348. GROUP BY cg.id_
  1349. </select>
  1350. <select id="findCourseScheduleCurrentTimes" resultType="java.util.Map">
  1351. SELECT
  1352. course_schedule_id_ AS 'key',
  1353. MAX(current_class_times_) AS 'value'
  1354. FROM
  1355. student_attendance sa
  1356. WHERE sa.course_schedule_id_ IN
  1357. <foreach collection="list" item="id" open="(" close=")" separator=",">
  1358. #{id}
  1359. </foreach>
  1360. GROUP BY course_schedule_id_
  1361. </select>
  1362. <!-- 获取班级某时间后对应节数的课程 -->
  1363. <select id="findCourseScheduleByClassGroupIdAndDate" resultMap="CourseSchedule">
  1364. SELECT *
  1365. FROM course_schedule
  1366. WHERE class_group_id_ = #{classGroupId}
  1367. AND class_date_ >= #{startDate}
  1368. ORDER BY class_date_ ASC
  1369. LIMIT #{times}
  1370. </select>
  1371. <select id="queryTeacherCourseScheduleListByTimeRangeAndType" resultMap="CourseSchedule" parameterType="map">
  1372. SELECT
  1373. cs.id_,
  1374. cs.music_group_id_,
  1375. cs.class_group_id_,
  1376. cs.status_,
  1377. cs.subsidy_,
  1378. cs.class_date_,
  1379. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  1380. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  1381. cs.teacher_id_,
  1382. cs.actual_teacher_id_,
  1383. cs.create_time_,
  1384. cs.update_time_,
  1385. cs.teach_mode_,
  1386. cs.type_,
  1387. cg.name_,
  1388. cs.student_num_,
  1389. cs.leave_student_num_,
  1390. cs.schoole_id_
  1391. FROM course_schedule cs
  1392. LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
  1393. LEFT JOIN music_group mg ON cs.music_group_id_=mg.id_
  1394. WHERE
  1395. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  1396. AND cs.teacher_id_=#{teacherId}
  1397. and CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) between #{startTime} and #{endTime}
  1398. <if test="type != null">
  1399. and cs.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  1400. </if>
  1401. ORDER BY CONCAT(cs.class_date_,' ',cs.start_class_time_)
  1402. </select>
  1403. <!-- 查找班级未开始的课程 -->
  1404. <select id="findNoStartCoursesByClassGroupId" resultMap="CourseSchedule">
  1405. SELECT *
  1406. FROM course_schedule
  1407. WHERE class_group_id_ = #{classGroupId}
  1408. AND status_ = 'NOT_START'
  1409. AND group_type_ = 'MUSIC'
  1410. </select>
  1411. <resultMap id="CourseAttendanceDetailHeadInfoDto" type="com.ym.mec.biz.dal.dto.CourseAttendanceDetailHeadInfoDto">
  1412. <result property="courseScheduleId" column="course_schedule_id_"/>
  1413. <result property="classGroupId" column="class_group_id_"/>
  1414. <result property="classGroupName" column="class_group_name_"/>
  1415. <result property="teacherId" column="user_id_"/>
  1416. <result property="teacherName" column="username_"/>
  1417. <result property="classDate" column="class_date_"/>
  1418. <result property="startClassTime" column="start_class_time_"/>
  1419. <result property="endClassTime" column="end_class_time_"/>
  1420. <result property="studentNum" column="student_num_"/>
  1421. <result property="leaveStudentNum" column="leave_student_num_"/>
  1422. <result property="totalStudentNum" column="total_student_num_"/>
  1423. </resultMap>
  1424. <select id="findByCourse" resultMap="CourseAttendanceDetailHeadInfoDto">
  1425. SELECT cs.id_ course_schedule_id_,
  1426. cg.id_ class_group_id_,
  1427. cg.name_ class_group_name_,
  1428. csts.user_id_,
  1429. su.real_name_ username_,
  1430. cs.student_num_,
  1431. cg.student_num_ total_student_num_,
  1432. cs.leave_student_num_,
  1433. cs.class_date_,
  1434. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1435. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_
  1436. FROM course_schedule cs
  1437. LEFT JOIN course_schedule_teacher_salary csts
  1438. ON cs.id_ = csts.course_schedule_id_ AND csts.teacher_role_ = 'BISHOP'
  1439. LEFT JOIN sys_user su ON csts.user_id_ = su.id_
  1440. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  1441. WHERE cs.id_ = #{courseScheduleId}
  1442. </select>
  1443. <select id="queryMusicGroupIds" resultMap="com.ym.mec.biz.dal.dao.GroupDao.Group">
  1444. SELECT DISTINCT cgsm.music_group_id_ group_id_,cgsm.group_type_ FROM class_group_student_mapper cgsm
  1445. LEFT JOIN music_group mg ON mg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'MUSIC'
  1446. LEFT JOIN vip_group vg ON vg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'VIP'
  1447. LEFT JOIN practice_group pg ON pg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'PRACTICE'
  1448. WHERE cgsm.user_id_ = #{userId} AND cgsm.status_ != 'QUIT'
  1449. AND (mg.status_ = 'PROGRESS' OR vg.group_status_ = 2 OR vg.group_status_ = 4 OR (pg.id_ IS NOT NULL AND
  1450. pg.group_status_!='LOCK' AND pg.group_status_!='CANCEL'))
  1451. ORDER BY cgsm.music_group_id_
  1452. <include refid="global.limit"/>
  1453. </select>
  1454. <select id="countMusicGroupIds" resultType="int">
  1455. SELECT COUNT(DISTINCT cgsm.music_group_id_)
  1456. FROM class_group_student_mapper cgsm
  1457. LEFT JOIN music_group mg ON mg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'MUSIC'
  1458. LEFT JOIN vip_group vg ON vg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'VIP'
  1459. LEFT JOIN practice_group pg ON pg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'PRACTICE'
  1460. WHERE cgsm.user_id_ = #{userId}
  1461. AND cgsm.status_ != 'QUIT'
  1462. AND (mg.status_ = 'PROGRESS' OR vg.group_status_ = 2 OR vg.group_status_ = 4 OR pg.id_ IS NOT NULL)
  1463. </select>
  1464. <select id="queryMusicGroupIdsWithoutOverGroup" resultMap="com.ym.mec.biz.dal.dao.GroupDao.Group">
  1465. SELECT DISTINCT spo.music_group_id_ group_id_,cgsm.group_type_ FROM student_payment_order spo
  1466. LEFT JOIN class_group_student_mapper cgsm ON spo.music_group_id_ = cgsm.music_group_id_
  1467. LEFT JOIN vip_group vg ON vg.id_=spo.music_group_id_ AND spo.group_type_='VIP'
  1468. LEFT JOIN class_group cg ON cgsm.class_group_id_ = cg.id_
  1469. WHERE spo.type_ != 'OTHER' AND spo.music_group_id_ IS NOT NULL
  1470. AND spo.user_id_ = #{userId} AND spo.status_='SUCCESS' AND cgsm.status_ != 'QUIT'
  1471. AND IF(spo.group_type_ = 'VIP', (vg.group_status_ = 4 OR vg.group_status_ = 3 ),0)=0 AND cg.del_flag_ = 0
  1472. <include refid="global.limit"/>
  1473. </select>
  1474. <select id="countMusicGroupIdsWithoutOverGroup" resultType="int">
  1475. SELECT COUNT(DISTINCT spo.music_group_id_)
  1476. FROM student_payment_order spo
  1477. LEFT JOIN class_group_student_mapper cgsm ON spo.music_group_id_ = cgsm.music_group_id_
  1478. LEFT JOIN vip_group vg ON vg.id_ = spo.music_group_id_ AND spo.group_type_ = 'VIP'
  1479. LEFT JOIN class_group cg ON cgsm.class_group_id_ = cg.id_
  1480. WHERE spo.type_ != 'OTHER'
  1481. AND spo.music_group_id_ IS NOT NULL
  1482. AND spo.user_id_ = #{userId}
  1483. AND spo.status_ = 'SUCCESS'
  1484. AND cgsm.status_ != 'QUIT'
  1485. AND IF(spo.group_type_ = 'VIP', (vg.group_status_ = 4 OR vg.group_status_ = 3), 0) = 0
  1486. AND cg.del_flag_ = 0
  1487. </select>
  1488. <select id="countExistRepeatInDateZone" resultType="int">
  1489. SELECT COUNT(csts.course_schedule_id_)
  1490. FROM course_schedule_teacher_salary csts
  1491. LEFT JOIN course_schedule cs ON csts.course_schedule_id_ = cs.id_
  1492. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  1493. AND csts.user_id_ = #{teacherId}
  1494. AND cs.class_date_ = DATE_FORMAT(#{classDate}, '%Y-%m-%d')
  1495. AND DATE_FORMAT(#{startTime}, '%H:%i:%S') &lt;= DATE_FORMAT(cs.end_class_time_, '%H:%i:%S')
  1496. AND DATE_FORMAT(#{endTime}, '%H:%i:%S') &gt;= DATE_FORMAT(cs.start_class_time_, '%H:%i:%S')
  1497. </select>
  1498. <select id="findByDateZone" resultMap="CourseSchedule">
  1499. SELECT cs.id_,
  1500. cs.class_group_id_,
  1501. cs.status_,
  1502. cs.subsidy_,
  1503. cs.class_date_,
  1504. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1505. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1506. cs.teacher_id_,
  1507. cs.actual_teacher_id_,
  1508. cs.create_time_,
  1509. cs.update_time_,
  1510. cs.teach_mode_,
  1511. cs.type_,
  1512. cs.name_,
  1513. cs.student_num_,
  1514. cs.leave_student_num_,
  1515. cs.schoole_id_
  1516. FROM course_schedule cs
  1517. WHERE (cs.class_date_ BETWEEN DATE_FORMAT(#{startTime}, '%Y%m%d') AND DATE_FORMAT(#{endTime}, '%Y%m%d'))
  1518. AND cs.status_ = 'NOT_START'
  1519. </select>
  1520. <select id="findAllCourseByDateZone" resultMap="CourseSchedule">
  1521. SELECT cs.id_,
  1522. cs.music_group_id_,
  1523. cs.group_type_,
  1524. cs.class_group_id_,
  1525. cs.status_,
  1526. cs.subsidy_,
  1527. cs.class_date_,
  1528. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1529. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1530. cs.teacher_id_,
  1531. cs.actual_teacher_id_,
  1532. cs.create_time_,
  1533. cs.update_time_,
  1534. cs.teach_mode_,
  1535. cs.type_,
  1536. cs.name_,
  1537. cs.student_num_,
  1538. cs.leave_student_num_,
  1539. cs.schoole_id_,
  1540. cg.type_ class_group_type_
  1541. FROM course_schedule cs
  1542. left join class_group cg on cs.class_group_id_ = cg.id_
  1543. WHERE (cs.class_date_ BETWEEN DATE_FORMAT(#{startTime}, '%Y%m%d') AND DATE_FORMAT(#{endTime}, '%Y%m%d'))
  1544. AND (cs.del_flag_ IS NULL OR cs.del_flag_ = 0)
  1545. AND (cg.del_flag_ IS NULL OR cg.del_flag_ = 0)
  1546. </select>
  1547. <select id="findByClassDate" resultMap="CourseSchedule">
  1548. SELECT
  1549. cs.id_,
  1550. cs.music_group_id_,
  1551. cs.class_group_id_,
  1552. cs.class_date_,
  1553. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  1554. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  1555. cs.type_,
  1556. cs.name_,
  1557. cs.actual_teacher_id_
  1558. FROM
  1559. course_schedule cs
  1560. WHERE (cs.class_date_ IN
  1561. <foreach collection="classDates" item="classDate" open="(" close=")" separator=",">
  1562. #{classDate}
  1563. </foreach>
  1564. )
  1565. AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
  1566. </select>
  1567. <select id="findByClassDateWithoutMusicGroup" resultMap="CourseSchedule">
  1568. SELECT
  1569. cs.id_,
  1570. cs.music_group_id_,
  1571. cs.class_group_id_,
  1572. cs.class_date_,
  1573. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  1574. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  1575. cs.type_,
  1576. cs.name_,
  1577. cs.actual_teacher_id_
  1578. FROM
  1579. course_schedule cs
  1580. WHERE
  1581. cs.group_type_!='MUSIC'
  1582. AND (cs.class_date_ IN
  1583. <foreach collection="classDates" item="classDate" open="(" close=")" separator=",">
  1584. #{classDate}
  1585. </foreach>
  1586. )
  1587. AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
  1588. </select>
  1589. <select id="findAllCourseByDateZone2" resultMap="CourseSchedule">
  1590. SELECT cs.id_,
  1591. cs.class_group_id_,
  1592. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1593. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1594. cs.actual_teacher_id_
  1595. FROM course_schedule cs
  1596. WHERE (cs.class_date_ BETWEEN DATE_FORMAT(#{startTime}, '%Y%m%d') AND DATE_FORMAT(#{endTime}, '%Y%m%d'))
  1597. AND (cs.del_flag_ IS NULL OR cs.del_flag_ = 0)
  1598. </select>
  1599. <select id="queryStudentCoursesTimesOfTomorrow" resultMap="Mapper">
  1600. select cssp.user_id_ key_, count(1) value_
  1601. from course_schedule cs
  1602. right join course_schedule_student_payment cssp on cs.id_ = cssp.course_schedule_id_
  1603. where class_date_ = date(DATE_ADD(now(), INTERVAL 1 DAY))
  1604. group by cssp.user_id_
  1605. </select>
  1606. <select id="queryStudentNotStartCourseScheduleIn90Mins" resultMap="Mapper">
  1607. select cssp.user_id_ key_, cs.name_ value_
  1608. from course_schedule cs
  1609. right join course_schedule_student_payment cssp on cs.id_ = cssp.course_schedule_id_
  1610. where CONCAT(cs.class_date_, ' ', cs.start_class_time_) &lt; DATE_ADD(now(), INTERVAL 90 MINUTE)
  1611. and cs.status_ = 'NOT_START'
  1612. </select>
  1613. <select id="queryTeacherCoursesTimesOfTomorrow" resultMap="Mapper">
  1614. select cssp.user_id_ key_, u.real_name_ value_
  1615. from course_schedule cs
  1616. right join course_schedule_teacher_salary cssp on cs.id_ = cssp.course_schedule_id_
  1617. left join sys_user u on u.id_ = cssp.user_id_
  1618. where class_date_ = date(DATE_ADD(now(), INTERVAL 1 DAY))
  1619. group by cssp.user_id_
  1620. </select>
  1621. <select id="queryTeacherNotStartCourseScheduleIn30Mins" resultMap="Mapper">
  1622. select cssp.user_id_ key_, cs.name_ value_
  1623. from course_schedule cs
  1624. right join course_schedule_teacher_salary cssp on cs.id_ = cssp.course_schedule_id_
  1625. where CONCAT(cs.class_date_, ' ', cs.start_class_time_) &lt; DATE_ADD(now(), INTERVAL 30 MINUTE)
  1626. and cs.status_ = 'NOT_START'
  1627. </select>
  1628. <resultMap id="IntegerAndIntegerListDto" type="com.ym.mec.biz.dal.dto.IntegerAndIntegerListDto">
  1629. <result property="id" column="id_"/>
  1630. <collection property="ids" ofType="int" javaType="list">
  1631. <result column="relate_ids"/>
  1632. </collection>
  1633. </resultMap>
  1634. <select id="findCourseScheduleIdAndUserIdsMap" resultMap="IntegerAndIntegerListDto">
  1635. select
  1636. course_schedule_id_ id_,
  1637. user_id_ relate_ids
  1638. from course_schedule_teacher_salary
  1639. where 1=1
  1640. <if test="teacherRole!=null and teacherRole!=''">
  1641. AND teacher_role_=#{teacherRole}
  1642. </if>
  1643. AND course_schedule_id_ IN
  1644. <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
  1645. #{courseScheduleId}
  1646. </foreach>
  1647. </select>
  1648. <select id="findClassGroupAndUserIdsMap" resultMap="IntegerAndIntegerListDto">
  1649. SELECT
  1650. class_group_id_ id_,
  1651. user_id_ relate_ids
  1652. FROM
  1653. class_group_teacher_mapper
  1654. WHERE 1=1
  1655. <if test="teacherRole!=null and teacherRole!=''">
  1656. AND teacher_role_=#{teacherRole}
  1657. </if>
  1658. AND class_group_id_ IN
  1659. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1660. #{classGroupId}
  1661. </foreach>
  1662. </select>
  1663. <select id="findCourseScheduleWithDate" resultMap="CourseSchedule">
  1664. SELECT cs.id_,
  1665. cs.class_group_id_,
  1666. cs.status_,
  1667. cs.subsidy_,
  1668. cs.class_date_,
  1669. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1670. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1671. cs.teacher_id_,
  1672. cs.actual_teacher_id_,
  1673. cs.create_time_,
  1674. cs.update_time_,
  1675. cs.teach_mode_,
  1676. cs.type_,
  1677. cs.name_,
  1678. cs.student_num_,
  1679. cs.leave_student_num_,
  1680. cs.schoole_id_
  1681. FROM course_schedule cs
  1682. WHERE cs.class_date_ &lt;= DATE_FORMAT(#{date}, '%Y-%m-%d')
  1683. AND cs.group_type_ = 'MUSIC'
  1684. AND (cs.del_flag_ IS NULL OR cs.del_flag_ = 0)
  1685. </select>
  1686. <select id="findByClassGroup" resultMap="CourseSchedule">
  1687. select cs.id_,
  1688. cs.class_group_id_,
  1689. cs.status_,
  1690. cs.subsidy_,
  1691. cs.class_date_,
  1692. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1693. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1694. cs.start_class_time_ start_class_time_str_,
  1695. cs.end_class_time_ end_class_time_str_,
  1696. cs.teacher_id_,
  1697. csts.user_id_ actual_teacher_id_,
  1698. cs.create_time_,
  1699. cs.update_time_,
  1700. cs.teach_mode_,
  1701. cs.type_,
  1702. cs.name_,
  1703. cs.student_num_,
  1704. cs.leave_student_num_,
  1705. cs.schoole_id_
  1706. from course_schedule cs
  1707. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  1708. where cs.class_group_id_ = #{classGroupId}
  1709. </select>
  1710. <select id="findByClassGroupAndStatus" resultMap="CourseSchedule">
  1711. select cs.id_,
  1712. cs.group_type_,
  1713. cs.music_group_id_,
  1714. cs.class_group_id_,
  1715. cs.status_,
  1716. cs.subsidy_,
  1717. cs.class_date_,
  1718. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1719. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1720. cs.start_class_time_ start_class_time_str_,
  1721. cs.end_class_time_ end_class_time_str_,
  1722. cs.teacher_id_,
  1723. csts.user_id_ actual_teacher_id_,
  1724. cs.create_time_,
  1725. cs.update_time_,
  1726. cs.teach_mode_,
  1727. cs.type_,
  1728. cs.name_,
  1729. cs.student_num_,
  1730. cs.leave_student_num_,
  1731. cs.schoole_id_
  1732. from course_schedule cs
  1733. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  1734. where cs.class_group_id_ = #{classGroupId}
  1735. AND cs.status_ = #{status}
  1736. </select>
  1737. <select id="findByClassGroups" resultMap="CourseSchedule">
  1738. select
  1739. cs.id_,
  1740. cs.class_group_id_,
  1741. cs.status_,
  1742. cs.subsidy_,
  1743. cs.class_date_,
  1744. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  1745. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  1746. cs.start_class_time_ start_class_time_str_,
  1747. cs.end_class_time_ end_class_time_str_,
  1748. cs.teacher_id_,
  1749. cs.actual_teacher_id_,
  1750. cs.create_time_,
  1751. cs.update_time_,
  1752. cs.teach_mode_,
  1753. cs.type_,
  1754. cs.name_,
  1755. cs.student_num_,
  1756. cs.leave_student_num_,
  1757. cs.schoole_id_,
  1758. cg.name_ class_group_name_
  1759. from course_schedule cs
  1760. LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
  1761. where cs.class_group_id_ IN
  1762. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1763. #{classGroupId}
  1764. </foreach>
  1765. ORDER BY start_class_time_
  1766. </select>
  1767. <select id="findStudentMap" resultType="java.util.Map">
  1768. SELECT cs.user_id_ 'key', cs.user_id_ 'value'
  1769. FROM course_schedule_student_payment cs
  1770. WHERE cs.course_schedule_id_ = #{courseScheduleId}
  1771. GROUP BY user_id_
  1772. </select>
  1773. <select id="findAllCourseSches" resultMap="CourseSchedule">
  1774. select cs.id_,
  1775. cs.class_group_id_,
  1776. cs.status_,
  1777. cs.subsidy_,
  1778. cs.class_date_,
  1779. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1780. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1781. cs.start_class_time_ start_class_time_str_,
  1782. cs.end_class_time_ end_class_time_str_,
  1783. cs.teacher_id_,
  1784. cs.actual_teacher_id_,
  1785. cs.create_time_,
  1786. cs.update_time_,
  1787. cs.teach_mode_,
  1788. cs.type_,
  1789. cs.name_,
  1790. cs.student_num_,
  1791. cs.leave_student_num_,
  1792. cs.schoole_id_
  1793. from course_schedule cs
  1794. </select>
  1795. <select id="findOneCourseScheduleByClassGroupId" resultMap="CourseSchedule">
  1796. SELECT *
  1797. FROM course_schedule
  1798. WHERE class_group_id_ = #{classGroupId}
  1799. LIMIT 1
  1800. </select>
  1801. <select id="countClassGroupCourseTimes" resultType="map">
  1802. SELECT
  1803. class_group_id_ AS 'key',
  1804. COUNT(id_) AS 'value'
  1805. FROM
  1806. course_schedule
  1807. <where>
  1808. <if test="classGroupIds!=null">
  1809. class_group_id_ IN
  1810. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1811. #{classGroupId}
  1812. </foreach>
  1813. AND del_flag_ = 0
  1814. </if>
  1815. </where>
  1816. GROUP BY class_group_id_
  1817. </select>
  1818. <select id="countClassGroupCourses" resultType="int">
  1819. SELECT COUNT(1)
  1820. FROM course_schedule
  1821. WHERE class_group_id_ = #{classGroupId}
  1822. AND (del_flag_ != 1 OR del_flag_ IS NULL)
  1823. </select>
  1824. <select id="findMusicGroupCourseSchedules" resultMap="CourseSchedule">
  1825. SELECT cs.*
  1826. FROM course_schedule cs
  1827. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  1828. WHERE cg.music_group_id_ = #{musicGroupId}
  1829. AND cs.group_type_ = #{groupType}
  1830. AND status_ = #{status}
  1831. AND cs.type_ != 'HIGH'
  1832. </select>
  1833. <select id="findMusicGroupCourseSchedulesWithStudent" resultMap="CourseSchedule">
  1834. SELECT cs.*
  1835. FROM course_schedule_student_payment cssp
  1836. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  1837. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  1838. AND cssp.music_group_id_ = #{musicGroupId}
  1839. AND cssp.group_type_ = #{groupType}
  1840. AND cs.status_ = #{status}
  1841. AND cssp.user_id_ = #{userId}
  1842. </select>
  1843. <delete id="deleteMusicGroupCourseSchedulesWithStudent">
  1844. DELETE
  1845. FROM
  1846. course_schedule_student_payment
  1847. WHERE user_id_ =#{userId} AND course_schedule_id_ IN
  1848. <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
  1849. #{courseScheduleId}
  1850. </foreach>
  1851. </delete>
  1852. <delete id="deleteCourseSchedulesByClassGroupIds">
  1853. DELETE FROM course_schedule WHERE id_ IN
  1854. <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
  1855. #{courseScheduleId}
  1856. </foreach>
  1857. </delete>
  1858. <delete id="deleteByGroup">
  1859. DELETE
  1860. FROM course_schedule
  1861. WHERE music_group_id_ = #{groupId}
  1862. AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  1863. </delete>
  1864. <select id="queryUnsignedStudentList" resultMap="StudentAttendance">
  1865. SELECT cssp.user_id_,
  1866. cs.actual_teacher_id_ teacher_id_,
  1867. cs.id_ course_schedule_id_,
  1868. cs.class_group_id_,
  1869. cs.music_group_id_,
  1870. cs.group_type_,
  1871. cg.current_class_times_
  1872. FROM course_schedule_student_payment cssp
  1873. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  1874. LEFT JOIN class_group cg ON cg.id_ = cs.class_group_id_
  1875. LEFT JOIN student_attendance sa
  1876. ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
  1877. WHERE CONCAT(cs.class_date_, ' ', cs.end_class_time_) &lt;= DATE_ADD(NOW(), INTERVAL -1 HOUR)
  1878. AND sa.id_ IS NULL
  1879. </select>
  1880. <select id="getNextCourseSchedule" resultMap="CourseSchedule">
  1881. SELECT cs.id_,
  1882. cs.class_group_id_,
  1883. cs.status_,
  1884. cs.subsidy_,
  1885. cs.class_date_,
  1886. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1887. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1888. cs.start_class_time_ start_class_time_str_,
  1889. cs.end_class_time_ end_class_time_str_,
  1890. cs.teacher_id_,
  1891. cs.actual_teacher_id_,
  1892. cs.create_time_,
  1893. cs.update_time_,
  1894. cs.teach_mode_,
  1895. cs.type_,
  1896. cs.name_,
  1897. cs.student_num_,
  1898. cs.leave_student_num_,
  1899. cs.schoole_id_
  1900. FROM course_schedule cs
  1901. WHERE cs.class_group_id_ = #{classGroupId}
  1902. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  1903. ORDER BY CONCAT(cs.class_date_, ' ', cs.start_class_time_)
  1904. LIMIT 1
  1905. </select>
  1906. <select id="countCurrentTimes" resultType="int">
  1907. SELECT COUNT(*)
  1908. FROM course_schedule
  1909. WHERE class_group_id_ = #{classGroupId}
  1910. AND CONCAT(class_date_, ' ', end_class_time_) &lt; #{currentCourseDate}
  1911. AND del_flag_ = 0
  1912. </select>
  1913. <select id="countCourseScheduleByMusicGroupId" resultType="java.lang.Integer">
  1914. SELECT count(cs.id_)
  1915. FROM course_schedule cs
  1916. WHERE cs.music_group_id_ = #{musicGroupId}
  1917. and cs.group_type_ = 'MUSIC'
  1918. and cs.status_ != 'OVER'
  1919. AND cs.del_flag_ = 0
  1920. LIMIT 1
  1921. </select>
  1922. <select id="findClassGroupCourseSchedules" resultMap="CourseSchedule">
  1923. SELECT cs.id_,
  1924. cs.class_group_id_,
  1925. cs.status_,
  1926. cs.subsidy_,
  1927. cs.class_date_,
  1928. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  1929. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  1930. cs.start_class_time_ start_class_time_str_,
  1931. cs.end_class_time_ end_class_time_str_,
  1932. cs.teacher_id_,
  1933. cs.actual_teacher_id_,
  1934. cs.create_time_,
  1935. cs.update_time_,
  1936. cs.teach_mode_,
  1937. cs.type_,
  1938. cs.name_,
  1939. cs.student_num_,
  1940. cs.leave_student_num_,
  1941. cs.schoole_id_
  1942. FROM course_schedule cs
  1943. WHERE cs.class_group_id_ = #{classGroupId}
  1944. AND (cs.del_flag_ = 0 OR cs.del_flag_ IS NULL)
  1945. </select>
  1946. <select id="countVipGroupCourses" resultType="int">
  1947. SELECT count(cs.id_)
  1948. FROM course_schedule cs
  1949. WHERE cs.music_group_id_ = #{vipGroupId}
  1950. AND cs.group_type_ = #{groupType}
  1951. </select>
  1952. <select id="findCourseNoStartNum" resultType="java.lang.Integer">
  1953. SELECT COUNT(cs.id_)
  1954. FROM course_schedule cs
  1955. WHERE cs.music_group_id_ = #{vipGroupId}
  1956. AND cs.group_type_ = 'VIP'
  1957. AND cs.status_ = 'NOT_START'
  1958. AND cs.del_flag_ != '1'
  1959. </select>
  1960. <select id="findCourseEndNum" resultType="java.lang.Integer">
  1961. SELECT COUNT(cs.id_)
  1962. FROM course_schedule cs
  1963. WHERE cs.music_group_id_ = #{vipGroupId}
  1964. AND cs.group_type_ = 'VIP'
  1965. AND cs.status_ != 'NOT_START'
  1966. AND cs.del_flag_ != '1'
  1967. </select>
  1968. <select id="countCourseNum" resultType="java.lang.Integer">
  1969. SELECT COUNT(cs.id_) FROM course_schedule cs
  1970. WHERE cs.music_group_id_ = #{vipGroupId} AND cs.group_type_ = 'VIP' AND cs.del_flag_ != '1'
  1971. <if test="teachMode != null">
  1972. AND cs.teach_mode_ = #{teachMode}
  1973. </if>
  1974. </select>
  1975. <select id="getTeachModeById" resultType="map">
  1976. SELECT id_ as 'key',teach_mode_ as 'value' FROM course_schedule WHERE id_ IN
  1977. <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
  1978. #{courseId}
  1979. </foreach>
  1980. </select>
  1981. <select id="countTotalCourseScheduleNum" resultType="java.util.Map">
  1982. SELECT cs.music_group_id_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs WHERE cs.music_group_id_ IN
  1983. <foreach collection="vipGroupIds" open="(" close=")" separator="," item="item">
  1984. #{item}
  1985. </foreach>
  1986. AND cs.group_type_ = #{groupType} AND cs.del_flag_ = 0
  1987. GROUP BY cs.music_group_id_
  1988. </select>
  1989. <select id="countCourseScheduleNum" resultType="java.util.Map">
  1990. SELECT cs.music_group_id_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs WHERE cs.music_group_id_ IN
  1991. <foreach collection="vipGroupIds" open="(" close=")" separator="," item="item">
  1992. #{item}
  1993. </foreach>
  1994. AND cs.group_type_ = #{groupType} AND cs.status_ != 'NOT_START' AND cs.del_flag_ = 0
  1995. GROUP BY cs.music_group_id_
  1996. </select>
  1997. <select id="countTotalNumByClassGroupId" resultType="java.util.Map">
  1998. SELECT cs.class_group_id_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs
  1999. WHERE cs.class_group_id_ IN
  2000. <foreach collection="classGroupIds" item="item" separator="," open="(" close=")">
  2001. #{item}
  2002. </foreach>
  2003. <if test="classDate != null">
  2004. AND cs.class_date_ = DATE_FORMAT(#{classDate}, '%Y%m%d')
  2005. </if>
  2006. AND cs.del_flag_ = 0
  2007. GROUP BY cs.class_group_id_
  2008. </select>
  2009. <select id="countCurrentNumByClassGroupId" resultType="java.util.Map">
  2010. SELECT cs.class_group_id_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs
  2011. WHERE cs.class_group_id_ IN
  2012. <foreach collection="classGroupIds" item="item" separator="," open="(" close=")">
  2013. #{item}
  2014. </foreach>
  2015. <if test="teacherId != null">
  2016. AND cs.actual_teacher_id_ = #{teacherId}
  2017. </if>
  2018. AND cs.status_ = 'NOT_START' AND cs.del_flag_ = 0
  2019. GROUP BY cs.class_group_id_
  2020. </select>
  2021. <select id="countExpendNumByClassGroupId" resultType="java.util.Map">
  2022. SELECT cs.class_group_id_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs
  2023. WHERE cs.class_group_id_ IN
  2024. <foreach collection="classGroupIds" item="item" separator="," open="(" close=")">
  2025. #{item}
  2026. </foreach>
  2027. AND cs.status_ != 'NOT_START' AND cs.del_flag_ = 0
  2028. GROUP BY cs.class_group_id_
  2029. </select>
  2030. <select id="findUserSurplusCourseInfoByGroup" resultMap="StudentCourseInfoDto">
  2031. SELECT cs.id_,
  2032. cs.music_group_id_,
  2033. cs.class_group_id_,
  2034. cs.status_,
  2035. cs.class_date_,
  2036. cs.start_class_time_,
  2037. cs.end_class_time_,
  2038. cs.actual_teacher_id_,
  2039. cs.teach_mode_,
  2040. cssp.expect_price_
  2041. FROM course_schedule cs
  2042. LEFT JOIN course_schedule_student_payment cssp ON cs.id_ = cssp.course_schedule_id_
  2043. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2044. AND cs.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2045. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) > NOW()
  2046. AND cs.music_group_id_ = #{groupId}
  2047. AND cssp.user_id_ = #{userId}
  2048. </select>
  2049. <select id="findUserCourseInfos" resultMap="StudentCourseInfoDto">
  2050. SELECT
  2051. cs.id_,
  2052. cs.music_group_id_,
  2053. cs.class_group_id_,
  2054. cs.status_,
  2055. cs.class_date_,
  2056. cs.start_class_time_,
  2057. cs.end_class_time_,
  2058. cs.actual_teacher_id_,
  2059. cs.teach_mode_,
  2060. cssp.expect_price_
  2061. FROM
  2062. course_schedule cs
  2063. LEFT JOIN course_schedule_student_payment cssp ON cs.id_ = cssp.course_schedule_id_
  2064. WHERE
  2065. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2066. AND cs.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2067. AND cs.music_group_id_ = #{groupId}
  2068. AND cssp.user_id_=#{userId}
  2069. <if test="type=='history'">
  2070. AND CONCAT( cs.class_date_, ' ', cs.end_class_time_ ) &lt;= NOW()
  2071. </if>
  2072. <if test="type=='surplus'">
  2073. AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) &gt; NOW()
  2074. </if>
  2075. </select>
  2076. <select id="getMinCourseTime" resultType="java.util.Date">
  2077. SELECT MIN(CONCAT(class_date_, ' ', start_class_time_))
  2078. FROM course_schedule
  2079. WHERE group_type_ = #{groupType}
  2080. AND music_group_id_ = #{groupId}
  2081. </select>
  2082. <select id="getMaxCourseTime" resultType="java.util.Date">
  2083. SELECT MAX(CONCAT(class_date_, ' ', end_class_time_))
  2084. FROM course_schedule
  2085. WHERE group_type_ = #{groupType}
  2086. AND music_group_id_ = #{groupId}
  2087. </select>
  2088. <select id="findSurplusCourseWithGroup" resultMap="CourseSchedule">
  2089. SELECT cs.id_,
  2090. cs.music_group_id_,
  2091. cs.class_group_id_,
  2092. cs.status_,
  2093. cs.class_date_,
  2094. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  2095. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  2096. cs.actual_teacher_id_,
  2097. cs.teach_mode_
  2098. FROM course_schedule cs
  2099. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2100. AND cs.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2101. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) > NOW()
  2102. AND cs.music_group_id_ = #{groupId}
  2103. </select>
  2104. <select id="getSurplusCourseWithGroup" resultMap="CourseSchedule">
  2105. SELECT cs.id_,
  2106. cs.music_group_id_,
  2107. cs.group_type_,
  2108. cs.class_group_id_,
  2109. cs.status_,
  2110. cs.subsidy_,
  2111. cs.class_date_,
  2112. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  2113. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  2114. cs.teacher_id_,
  2115. cs.actual_teacher_id_,
  2116. cs.create_time_,
  2117. cs.update_time_,
  2118. cs.teach_mode_,
  2119. cs.type_,
  2120. cs.name_,
  2121. cs.student_num_,
  2122. cs.leave_student_num_,
  2123. cs.schoole_id_
  2124. FROM course_schedule cs
  2125. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2126. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) > NOW()
  2127. AND cs.id_ = #{courseScheduleId}
  2128. </select>
  2129. <select id="countClassGroupOverCourseNum" resultType="int">
  2130. SELECT COUNT(*)
  2131. FROM course_schedule
  2132. WHERE class_group_id_ = #{classGroupId}
  2133. AND CONCAT(class_date_, ' ', end_class_time_) &lt; NOW()
  2134. </select>
  2135. <sql id="endFindCourseSchedulesCondition">
  2136. <where>
  2137. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2138. <include refid="queryVipCourseScheduleIds"/>
  2139. <if test="classGroupIds != null">
  2140. AND cs.class_group_id_ IN
  2141. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  2142. #{classGroupId}
  2143. </foreach>
  2144. </if>
  2145. </where>
  2146. </sql>
  2147. <select id="endFindCourseSchedules" resultMap="CourseScheduleEndDto">
  2148. SELECT
  2149. cs.id_,
  2150. cs.group_type_,
  2151. cs.music_group_id_,
  2152. cs.class_group_id_,
  2153. cs.status_,
  2154. cs.name_,
  2155. CONCAT(cs.class_date_,' ',cs.start_class_time_) course_start_time_,
  2156. CONCAT(cs.class_date_,' ',cs.end_class_time_) course_end_time_,
  2157. cs.actual_teacher_id_,
  2158. cs.teach_mode_,
  2159. cs.type_,
  2160. cs.schoole_id_,
  2161. s.name_ schoole_name_
  2162. FROM
  2163. course_schedule cs
  2164. LEFT JOIN school s ON cs.schoole_id_=s.id_
  2165. <include refid="endFindCourseSchedulesCondition"/>
  2166. ORDER BY course_start_time_,cs.id_
  2167. <include refid="global.limit"/>
  2168. </select>
  2169. <select id="endCountCourseSchedules" resultType="int">
  2170. SELECT
  2171. COUNT(cs.id_)
  2172. FROM
  2173. course_schedule cs
  2174. <include refid="endFindCourseSchedulesCondition"/>
  2175. </select>
  2176. <select id="findCourseIdsByStudent" resultType="int">
  2177. SELECT cssp.course_schedule_id_
  2178. FROM course_schedule_student_payment cssp
  2179. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  2180. WHERE su.username_ LIKE CONCAT('%', #{search}, '%')
  2181. OR su.id_ = #{search}
  2182. </select>
  2183. <select id="findCourseIdsByTeacher" resultType="int">
  2184. SELECT csts.course_schedule_id_
  2185. FROM course_schedule_teacher_salary csts
  2186. LEFT JOIN sys_user su ON csts.user_id_ = su.id_
  2187. WHERE real_name_ LIKE CONCAT('%', #{search}, '%')
  2188. OR su.id_ = #{search}
  2189. </select>
  2190. <select id="findClassGroupCourseSchedulesWithDate" resultMap="CourseSchedule">
  2191. SELECT cs.id_,
  2192. cs.class_group_id_,
  2193. cs.status_,
  2194. cs.subsidy_,
  2195. cs.class_date_,
  2196. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  2197. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  2198. cs.start_class_time_ start_class_time_str_,
  2199. cs.end_class_time_ end_class_time_str_,
  2200. cs.teacher_id_,
  2201. cs.actual_teacher_id_,
  2202. cs.create_time_,
  2203. cs.update_time_,
  2204. cs.teach_mode_,
  2205. cs.type_,
  2206. cs.name_,
  2207. cs.student_num_,
  2208. cs.leave_student_num_,
  2209. cs.schoole_id_
  2210. FROM course_schedule cs
  2211. WHERE FIND_IN_SET(cs.class_group_id_, #{classGroupIds})
  2212. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
  2213. AND cs.class_date_ &gt;= DATE_FORMAT(#{fromDate}, "%Y-%m-%d")
  2214. AND (cs.del_flag_ IS NULL OR cs.del_flag_ = 0)
  2215. </select>
  2216. <select id="findGroupCourseStartTime" resultType="java.util.Date">
  2217. SELECT MIN(CONCAT(class_date_, ' ', start_class_time_))
  2218. FROM course_schedule
  2219. WHERE group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2220. AND music_group_id_ = #{groupId}
  2221. </select>
  2222. <select id="findGroupCourseEndTime" resultType="java.util.Date">
  2223. SELECT MAX(CONCAT(class_date_, ' ', end_class_time_))
  2224. FROM course_schedule
  2225. WHERE group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2226. AND music_group_id_ = #{groupId}
  2227. </select>
  2228. <select id="countGroupAllCourses" resultType="int">
  2229. SELECT COUNT(*)
  2230. FROM course_schedule
  2231. WHERE group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2232. AND music_group_id_ = #{groupId}
  2233. </select>
  2234. <select id="queryMusicCourseScheduleIds" resultType="java.lang.Integer">
  2235. SELECT cs.id_ FROM course_schedule cs
  2236. LEFT JOIN music_group mg ON cs.music_group_id_ = mg.id_
  2237. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  2238. WHERE cs.group_type_ = 'MUSIC' AND cs.del_flag_ = 0 AND cg.del_flag_ = 0
  2239. <if test="search != null and search != ''">
  2240. AND (mg.id_ = #{search} OR mg.name_ LIKE CONCAT('%',#{search},'%')
  2241. OR cs.id_ = #{search} OR cs.name_ LIKE CONCAT('%',#{search},'%')
  2242. OR cg.id_ = #{search} OR cg.name_ LIKE CONCAT('%',#{search},'%'))
  2243. </if>
  2244. <if test="organIdList != null and organIdList != ''">
  2245. AND FIND_IN_SET(mg.organ_id_,#{organIdList})
  2246. </if>
  2247. <include refid="queryVipCourseScheduleIds"/>
  2248. </select>
  2249. <sql id="queryVipCourseScheduleIds">
  2250. <if test="startTime!=null and endTime==null">
  2251. AND cs.class_date_ &gt; DATE_FORMAT(#{startTime},"%Y-%m-%d")
  2252. </if>
  2253. <if test="startTime==null and endTime!=null">
  2254. AND cs.class_date_ &lt; DATE_FORMAT(#{endTime},"%Y-%m-%d")
  2255. </if>
  2256. <if test="startTime!=null and endTime!=null">
  2257. AND cs.class_date_ BETWEEN DATE_FORMAT(#{startTime},"%Y-%m-%d") AND DATE_FORMAT(#{endTime},"%Y-%m-%d")
  2258. </if>
  2259. <if test="courseStatus!=null">
  2260. AND cs.status_ = #{courseStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2261. </if>
  2262. <if test="courseType!=null">
  2263. AND cs.type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2264. </if>
  2265. <if test="schoolId!=null">
  2266. AND cs.schoole_id_ = #{schoolId}
  2267. </if>
  2268. <if test="teacherIdList != null">
  2269. AND cs.actual_teacher_id_=#{teacherIdList}
  2270. </if>
  2271. </sql>
  2272. <select id="queryPracticeCourseScheduleIds" resultType="java.lang.Integer">
  2273. SELECT cs.id_ FROM course_schedule cs
  2274. LEFT JOIN practice_group pg ON cs.music_group_id_ = pg.id_
  2275. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  2276. WHERE cs.group_type_ = 'PRACTICE' AND cs.del_flag_ = 0 AND cg.del_flag_ = 0
  2277. AND pg.group_status_='NORMAL'
  2278. <if test="search != null and search != ''">
  2279. AND (pg.id_ = #{search} OR pg.name_ LIKE CONCAT('%',#{search},'%')
  2280. OR cs.id_ = #{search} OR cs.name_ LIKE CONCAT('%',#{search},'%')
  2281. OR cg.id_ = #{search} OR cg.name_ LIKE CONCAT('%',#{search},'%'))
  2282. </if>
  2283. <if test="organIdList != null and organIdList != ''">
  2284. AND FIND_IN_SET(pg.organ_id_,#{organIdList})
  2285. </if>
  2286. <include refid="queryVipCourseScheduleIds"/>
  2287. </select>
  2288. <select id="queryVipCourseScheduleIds" resultType="java.lang.Integer">
  2289. SELECT cs.id_ FROM course_schedule cs
  2290. LEFT JOIN vip_group vg ON cs.music_group_id_ = vg.id_
  2291. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  2292. WHERE cs.group_type_ = 'VIP' AND cs.del_flag_ = 0 AND cg.del_flag_ = 0
  2293. <if test="search != null and search != ''">
  2294. AND (vg.id_ = #{search} OR vg.name_ LIKE CONCAT('%',#{search},'%')
  2295. OR cs.id_ = #{search} OR cs.name_ LIKE CONCAT('%',#{search},'%')
  2296. OR cg.id_ = #{search} OR cg.name_ LIKE CONCAT('%',#{search},'%'))
  2297. </if>
  2298. <if test="organIdList != null and organIdList != ''">
  2299. AND FIND_IN_SET(vg.organ_id_,#{organIdList})
  2300. </if>
  2301. <include refid="queryVipCourseScheduleIds"/>
  2302. </select>
  2303. <select id="findTeachersCoursesWithDateRange" resultMap="CourseSchedule">
  2304. SELECT
  2305. cs.id_,
  2306. cs.class_date_,
  2307. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  2308. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  2309. csts.user_id_ actual_teacher_id_,
  2310. cs.group_type_
  2311. FROM
  2312. course_schedule_teacher_salary csts
  2313. LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_
  2314. WHERE
  2315. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2316. AND cs.class_date_ BETWEEN DATE_FORMAT(#{startTime},"%Y-%m-%d") AND DATE_FORMAT(#{endTime},"%Y-%m-%d")
  2317. AND csts.user_id_ IN
  2318. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  2319. #{userId}
  2320. </foreach>
  2321. </select>
  2322. <select id="countTeacherPracticeCourse" resultType="int">
  2323. SELECT COUNT(1)
  2324. FROM course_schedule_teacher_salary csts
  2325. LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_
  2326. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2327. AND cs.group_type_ = 'PRACTICE'
  2328. AND cs.class_date_ BETWEEN DATE_FORMAT(#{startTime}, "%Y-%m-%d") AND DATE_FORMAT(#{endTime}, "%Y-%m-%d")
  2329. AND csts.user_id_ = #{userId}
  2330. </select>
  2331. <select id="findTeacherCoursesWithDateRange" resultMap="CourseSchedule">
  2332. SELECT cs.id_,
  2333. cs.class_date_,
  2334. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  2335. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  2336. csts.user_id_ actual_teacher_id_,
  2337. cs.group_type_
  2338. FROM course_schedule_teacher_salary csts
  2339. LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_
  2340. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2341. AND cs.class_date_ BETWEEN DATE_FORMAT(#{startTime}, "%Y-%m-%d") AND DATE_FORMAT(#{endTime}, "%Y-%m-%d")
  2342. AND csts.user_id_ = #{userId}
  2343. </select>
  2344. <select id="findTeacherCoursesWithDateRangeWithoutMusicGroup" resultMap="CourseSchedule">
  2345. SELECT cs.id_,
  2346. cs.class_date_,
  2347. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  2348. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  2349. csts.user_id_ actual_teacher_id_,
  2350. cs.group_type_
  2351. FROM course_schedule_teacher_salary csts
  2352. LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_
  2353. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2354. AND cs.group_type_ != 'MUSIC'
  2355. AND cs.class_date_ BETWEEN DATE_FORMAT(#{startTime}, "%Y-%m-%d") AND DATE_FORMAT(#{endTime}, "%Y-%m-%d")
  2356. AND csts.user_id_ = #{userId}
  2357. </select>
  2358. <select id="findStudentPracticeCourses" resultMap="courseScheduleDto">
  2359. SELECT cs.id_ seal_class_id_,
  2360. cs.type_,
  2361. cs.id_,
  2362. cs.class_date_,
  2363. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  2364. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  2365. cs.actual_teacher_id_,
  2366. cs.status_,
  2367. cs.student_num_,
  2368. cs.leave_student_num_,
  2369. cs.teach_mode_,
  2370. cs.music_group_id_,
  2371. cs.group_type_,
  2372. su.real_name_ teacher_name_,
  2373. pg.create_time_
  2374. FROM course_schedule_student_payment cssp
  2375. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  2376. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  2377. LEFT JOIN practice_group pg ON pg.id_ = cssp.music_group_id_
  2378. WHERE cs.group_type_ = 'PRACTICE'
  2379. AND cssp.user_id_ = #{userId}
  2380. AND cssp.expect_price_ = 0
  2381. AND pg.type_ = 'FREE'
  2382. </select>
  2383. <select id="findTeacherCoursesWithIncludeDateRange" resultMap="CourseSchedule" useCache="false" flushCache="true">
  2384. SELECT cs.id_,
  2385. cs.class_group_id_,
  2386. cs.group_type_,
  2387. cs.music_group_id_,
  2388. cs.status_,
  2389. cs.subsidy_,
  2390. cs.class_date_,
  2391. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  2392. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  2393. cs.start_class_time_ start_class_time_str_,
  2394. cs.end_class_time_ end_class_time_str_,
  2395. cs.teacher_id_,
  2396. cs.actual_teacher_id_,
  2397. cs.create_time_,
  2398. cs.update_time_,
  2399. cs.teach_mode_,
  2400. cs.type_,
  2401. cg.name_,
  2402. cs.student_num_,
  2403. cs.leave_student_num_,
  2404. cs.schoole_id_
  2405. FROM course_schedule_teacher_salary csts
  2406. LEFT JOIN course_schedule cs ON csts.course_schedule_id_ = cs.id_
  2407. LEFT JOIN class_group cg ON cg.id_ = csts.class_group_id_
  2408. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2409. AND csts.user_id_ = #{userId}
  2410. AND #{startTime} &lt; CONCAT(cs.class_date_, ' ', cs.end_class_time_)
  2411. AND #{endTime} &gt; CONCAT(cs.class_date_, ' ', cs.start_class_time_)
  2412. </select>
  2413. <select id="findStudentCoursesWithIncludeDateRange" resultMap="CourseSchedule">
  2414. SELECT cs.id_,
  2415. cs.class_group_id_,
  2416. cs.group_type_,
  2417. cs.music_group_id_,
  2418. cs.status_,
  2419. cs.subsidy_,
  2420. cs.class_date_,
  2421. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  2422. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  2423. cs.start_class_time_ start_class_time_str_,
  2424. cs.end_class_time_ end_class_time_str_,
  2425. cs.teacher_id_,
  2426. cs.actual_teacher_id_,
  2427. cs.create_time_,
  2428. cs.update_time_,
  2429. cs.teach_mode_,
  2430. cs.type_,
  2431. cs.name_,
  2432. cs.student_num_,
  2433. cs.leave_student_num_,
  2434. cs.schoole_id_
  2435. FROM course_schedule_student_payment cssp
  2436. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  2437. WHERE (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  2438. AND cssp.user_id_ = #{userId}
  2439. AND #{startTime} &lt; CONCAT(cs.class_date_, ' ', cs.end_class_time_)
  2440. AND #{endTime} &gt; CONCAT(cs.class_date_, ' ', cs.start_class_time_);
  2441. </select>
  2442. <select id="queryContinueCourse" resultMap="CourseSchedule">
  2443. SELECT cs.*
  2444. FROM course_schedule cs
  2445. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_
  2446. WHERE TIMESTAMPDIFF(MINUTE, #{endDateTime}, CONCAT(cs.class_date_, ' ', cs.start_class_time_)) >= 0
  2447. AND TIMESTAMPDIFF(MINUTE, #{endDateTime}, CONCAT(cs.class_date_, ' ', cs.start_class_time_)) &lt;= #{continueCourseTime}
  2448. AND cs.teacher_id_ = #{courseSchedule.teacherId}
  2449. AND cs.class_group_id_ = #{courseSchedule.classGroupId}
  2450. LIMIT 1
  2451. </select>
  2452. <select id="queryRepairContinueCourse" resultMap="CourseSchedule">
  2453. SELECT cs.*
  2454. FROM course_schedule cs
  2455. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_
  2456. WHERE TIMESTAMPDIFF(MINUTE, #{endDateTime}, CONCAT(cs.class_date_, ' ', cs.start_class_time_)) >= 0
  2457. AND TIMESTAMPDIFF(MINUTE, #{endDateTime}, CONCAT(cs.class_date_, ' ', cs.start_class_time_)) &lt;= #{continueCourseTime}
  2458. AND cs.teacher_id_ = #{courseSchedule.teacherId}
  2459. AND cs.class_group_id_ = #{courseSchedule.classGroupId}
  2460. LIMIT 1
  2461. </select>
  2462. <select id="getSingleClassMinutes" resultType="java.lang.Integer">
  2463. SELECT FLOOR((UNIX_TIMESTAMP(CONCAT(cs.class_date_, ' ', cs.end_class_time_)) -
  2464. UNIX_TIMESTAMP(CONCAT(cs.class_date_, ' ', cs.start_class_time_))) / 60)
  2465. FROM course_schedule cs
  2466. WHERE cs.id_ = #{courseScheduleId}
  2467. </select>
  2468. <select id="countGroupOverCourse" resultType="java.util.Map">
  2469. SELECT
  2470. cs.music_group_id_ AS 'key',
  2471. COUNT(cs.Id_) AS 'value'
  2472. FROM
  2473. course_schedule cs
  2474. WHERE cs.status_='OVER'
  2475. AND DATE_FORMAT(cs.class_date_,'%Y-%m')=DATE_FORMAT(NOW(),'%Y-%m')
  2476. AND cs.group_type_ = #{groupType}
  2477. AND cs.music_group_id_ IN
  2478. <foreach collection="groupIds" item="id" open="(" close=")" separator=",">
  2479. #{id}
  2480. </foreach>
  2481. GROUP BY cs.music_group_id_
  2482. </select>
  2483. <select id="findUserCourses" resultMap="CourseSchedule">
  2484. SELECT
  2485. cs.id_,
  2486. cs.`type_`,
  2487. cgtm.`user_id_` teacher_id_
  2488. FROM
  2489. `class_group_student_mapper` cgsm
  2490. LEFT JOIN `class_group` cg ON cgsm.`class_group_id_` = cg.`id_`
  2491. LEFT JOIN `class_group_teacher_mapper` cgtm ON cgtm.`class_group_id_` = cg.`id_`
  2492. AND cgtm.`teacher_role_` = 'BISHOP'
  2493. LEFT JOIN `course_schedule` cs ON cs.`class_group_id_` = cg.`id_`
  2494. WHERE
  2495. cgsm.user_id_=#{userId}
  2496. AND cgtm.teacher_role_='BISHOP'
  2497. AND cgsm.status_ = 'NORMAL'
  2498. AND cg.`type_` IN ( 'NORMAL', 'HIGH', 'VIP' )
  2499. AND cs.`id_` IS NOT NULL
  2500. AND cgtm.user_id_ IN
  2501. <foreach collection="teacherIds" item="teacherId" open="(" close=")" separator=",">
  2502. #{teacherId}
  2503. </foreach>
  2504. AND ( cs.del_flag_ != 1 OR cs.del_flag_ IS NULL )
  2505. </select>
  2506. <select id="findUserCourses2" resultMap="CourseSchedule">
  2507. SELECT
  2508. cs.id_,
  2509. cs.`type_`,
  2510. cgtm.`user_id_` teacher_id_
  2511. FROM
  2512. `class_group_student_mapper` cgsm
  2513. LEFT JOIN `class_group` cg ON cgsm.`class_group_id_` = cg.`id_`
  2514. LEFT JOIN `class_group_teacher_mapper` cgtm ON cgtm.`class_group_id_` = cg.`id_`
  2515. AND cgtm.`teacher_role_` = 'BISHOP'
  2516. LEFT JOIN `course_schedule` cs ON cs.`class_group_id_` = cg.`id_`
  2517. WHERE
  2518. cgsm.user_id_=#{userId}
  2519. AND cgtm.teacher_role_='BISHOP'
  2520. AND cgsm.status_ = 'NORMAL'
  2521. AND cg.`type_` IN ( 'PRACTICE', 'NORMAL', 'HIGH', 'VIP' )
  2522. AND cs.`id_` IS NOT NULL
  2523. AND cgtm.user_id_ IN
  2524. <foreach collection="teacherIds" item="teacherId" open="(" close=")" separator=",">
  2525. #{teacherId}
  2526. </foreach>
  2527. AND ( cs.del_flag_ != 1 OR cs.del_flag_ IS NULL )
  2528. </select>
  2529. <select id="findUserCoursesWithPay" resultMap="CourseSchedule">
  2530. SELECT
  2531. cs.id_,
  2532. cs.`type_`,
  2533. cgtm.`user_id_` teacher_id_
  2534. FROM
  2535. `class_group_student_mapper` cgsm
  2536. LEFT JOIN `class_group` cg ON cgsm.`class_group_id_` = cg.`id_`
  2537. LEFT JOIN `class_group_teacher_mapper` cgtm ON cgtm.`class_group_id_` = cg.`id_`
  2538. AND cgtm.`teacher_role_` = 'BISHOP'
  2539. LEFT JOIN `course_schedule` cs ON cs.`class_group_id_` = cg.`id_`
  2540. WHERE
  2541. cgsm.user_id_=#{userId}
  2542. AND cgtm.teacher_role_='BISHOP'
  2543. AND cgsm.status_ = 'NORMAL'
  2544. AND cg.`type_` IN ( 'NORMAL', 'HIGH', 'VIP', 'PRACTICE')
  2545. AND cs.`id_` IS NOT NULL
  2546. AND cgtm.user_id_ IN
  2547. <foreach collection="teacherIds" item="teacherId" open="(" close=")" separator=",">
  2548. #{teacherId}
  2549. </foreach>
  2550. AND ( cs.del_flag_ != 1 OR cs.del_flag_ IS NULL )
  2551. </select>
  2552. <select id="queryTeacherName" resultType="java.util.Map">
  2553. SELECT cs.id_ 'key',su.real_name_ 'value' FROM course_schedule cs
  2554. LEFT JOIN sys_user su ON cs.actual_teacher_id_ = su.id_
  2555. WHERE cs.id_ IN
  2556. <foreach collection="courseScheduleIds" item="id" open="(" close=")" separator=",">
  2557. #{id}
  2558. </foreach>
  2559. </select>
  2560. <select id="countCurrentCourseTime" resultType="java.lang.Integer">
  2561. SELECT COUNT(1) + 1
  2562. FROM course_schedule cs,
  2563. (SELECT CONCAT(class_date_, " ", start_class_time_) class_date_, class_group_id_
  2564. FROM course_schedule
  2565. WHERE id_ = #{courseScheduleId}
  2566. AND del_flag_ = 0) c
  2567. WHERE cs.class_group_id_ = c.class_group_id_
  2568. AND CONCAT(cs.class_date_, " ", cs.start_class_time_) &lt;= c.class_date_
  2569. AND cs.del_flag_ = 0
  2570. </select>
  2571. <select id="findCourseSchedulesByClassGroups" resultMap="CourseSchedule">
  2572. SELECT
  2573. cs.id_,
  2574. cs.group_type_,
  2575. cs.music_group_id_,
  2576. cs.class_group_id_,
  2577. cs.status_,
  2578. cs.subsidy_,
  2579. cs.class_date_,
  2580. CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
  2581. CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
  2582. cs.start_class_time_ start_class_time_str_,
  2583. cs.end_class_time_ end_class_time_str_,
  2584. cs.teacher_id_,
  2585. cs.actual_teacher_id_,
  2586. cs.create_time_,
  2587. cs.update_time_,
  2588. cs.teach_mode_,
  2589. cs.type_,
  2590. cs.name_,
  2591. cs.student_num_,
  2592. cs.leave_student_num_,
  2593. cs.schoole_id_
  2594. FROM
  2595. course_schedule cs
  2596. WHERE
  2597. cs.class_group_id_ IN
  2598. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  2599. #{classGroupId}
  2600. </foreach>
  2601. AND ( cs.del_flag_ != 1 OR cs.del_flag_ IS NULL )
  2602. ORDER BY start_class_time_
  2603. </select>
  2604. <select id="findFirstCourseWithGroup" resultMap="CourseSchedule">
  2605. SELECT cs.id_,
  2606. cs.group_type_,
  2607. cs.music_group_id_,
  2608. cs.class_group_id_,
  2609. cs.status_,
  2610. cs.subsidy_,
  2611. cs.class_date_,
  2612. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  2613. CONCAT(cs.class_date_, ' ', cs.end_class_time_) end_class_time_,
  2614. cs.teacher_id_,
  2615. cs.actual_teacher_id_,
  2616. cs.create_time_,
  2617. cs.update_time_,
  2618. cs.teach_mode_,
  2619. cs.type_,
  2620. cs.name_,
  2621. cs.student_num_,
  2622. cs.leave_student_num_,
  2623. cs.schoole_id_
  2624. FROM course_schedule cs
  2625. WHERE cs.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2626. AND cs.music_group_id_ = #{groupId}
  2627. ORDER BY CONCAT(cs.class_date_, ' ', cs.start_class_time_)
  2628. LIMIT 1
  2629. </select>
  2630. <select id="findClassGroupLastTeacher" resultMap="CourseSchedule">
  2631. SELECT *
  2632. FROM course_schedule
  2633. WHERE id_ IN (
  2634. SELECT MAX(id_)
  2635. FROM course_schedule
  2636. WHERE class_group_id_ IN
  2637. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  2638. #{classGroupId}
  2639. </foreach>
  2640. GROUP BY class_group_id_
  2641. )
  2642. </select>
  2643. <select id="findGroupNotStartCourses" resultMap="CourseSchedule">
  2644. SELECT id_,
  2645. group_type_,
  2646. music_group_id_,
  2647. class_group_id_,
  2648. status_,
  2649. subsidy_,
  2650. class_date_,
  2651. CONCAT(class_date_, ' ', start_class_time_) start_class_time_,
  2652. CONCAT(class_date_, ' ', end_class_time_) end_class_time_,
  2653. teacher_id_,
  2654. actual_teacher_id_,
  2655. create_time_,
  2656. update_time_,
  2657. teach_mode_,
  2658. type_,
  2659. name_,
  2660. student_num_,
  2661. leave_student_num_,
  2662. schoole_id_
  2663. FROM course_schedule
  2664. WHERE group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2665. AND music_group_id_ = #{groupId}
  2666. AND CONCAT(class_date_, ' ', start_class_time_) &gt; NOW()
  2667. </select>
  2668. <select id="findGroupNotFinishCourses" resultMap="CourseSchedule">
  2669. SELECT id_,
  2670. group_type_,
  2671. music_group_id_,
  2672. class_group_id_,
  2673. status_,
  2674. subsidy_,
  2675. class_date_,
  2676. CONCAT(class_date_, ' ', start_class_time_) start_class_time_,
  2677. CONCAT(class_date_, ' ', end_class_time_) end_class_time_,
  2678. teacher_id_,
  2679. actual_teacher_id_,
  2680. create_time_,
  2681. update_time_,
  2682. teach_mode_,
  2683. type_,
  2684. name_,
  2685. student_num_,
  2686. leave_student_num_,
  2687. schoole_id_
  2688. FROM course_schedule
  2689. WHERE group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2690. AND music_group_id_ = #{groupId}
  2691. AND CONCAT(class_date_, ' ', end_class_time_) &gt; NOW()
  2692. </select>
  2693. <select id="getSubjectNameById" resultType="java.lang.String">
  2694. SELECT GROUP_CONCAT(DISTINCT s.name_)
  2695. FROM course_schedule cs
  2696. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  2697. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_, cg.subject_id_list_)
  2698. WHERE cs.id_ = #{courseScheduleId}
  2699. GROUP BY cg.id_
  2700. </select>
  2701. <resultMap id="CourseScheduleRateDtoMap" type="com.ym.mec.biz.dal.dto.CourseScheduleRateDto">
  2702. <result property="teachingContent" column=""/>
  2703. <result property="classDate" column="class_date_"/>
  2704. <result property="startClassTime" column="start_class_time_"/>
  2705. <result property="comment" column="comment_"/>
  2706. <result property="endClassTime" column="end_class_time_"/>
  2707. <result property="courseStatus" column="status_"/>
  2708. <result property="courseScheduleId" column="id_"/>
  2709. </resultMap>
  2710. <select id="findCourseRate" resultMap="CourseScheduleRateDtoMap">
  2711. SELECT cs.class_date_,
  2712. cs.start_class_time_,
  2713. cs.end_class_time_,
  2714. cs.id_,
  2715. cs.teaching_content_,
  2716. GROUP_CONCAT(cse.comment_ SEPARATOR ";") comment_,
  2717. cs.status_
  2718. FROM course_schedule cs
  2719. LEFT JOIN course_schedule_evaluate cse ON cs.id_ = cse.course_schedule_id_
  2720. WHERE cs.music_group_id_ = #{groupId}
  2721. AND cs.group_type_ = #{groupType}
  2722. GROUP BY cs.id_
  2723. ORDER BY cs.class_date_, cs.start_class_time_ ASC
  2724. </select>
  2725. <select id="getLastEndCourse" resultMap="CourseSchedule">
  2726. SELECT cs.id_
  2727. FROM course_schedule cs
  2728. WHERE cs.music_group_id_ = #{groupId}
  2729. AND cs.group_type_ = #{groupType}
  2730. AND NOW() > CONCAT(cs.class_date_, ' ', cs.end_class_time_)
  2731. ORDER BY cs.class_date_, cs.end_class_time_ ASC
  2732. LIMIT 1
  2733. </select>
  2734. <resultMap id="GroupCourseTimesDto" type="com.ym.mec.biz.dal.dto.GroupCourseTimesDto">
  2735. <result property="groupId" column="group_id_"/>
  2736. <result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  2737. <result property="classGroupId" column="class_group_id_"/>
  2738. <result property="totalCourseTimes" column="total_course_times_"/>
  2739. <result property="surplusClassTimes" column="surplus_class_times_"/>
  2740. <result property="startDate" column="start_date_"/>
  2741. <result property="endDate" column="end_date_"/>
  2742. </resultMap>
  2743. <select id="findGroupsCourseTimesInfo" resultMap="GroupCourseTimesDto">
  2744. SELECT
  2745. cg.music_group_id_ group_id_,
  2746. cg.group_type_,
  2747. cg.id_ class_group_id_,
  2748. cg.total_class_times_ total_course_times_,
  2749. COUNT( cs.id_ ) surplus_class_times_,
  2750. MIN( CONCAT( class_date_, ' ', start_class_time_ ) ) start_date_,
  2751. MAX( CONCAT( class_date_, ' ', end_class_time_ ) ) end_date_
  2752. FROM
  2753. class_group cg
  2754. LEFT JOIN course_schedule cs ON cs.class_group_id_ = cg.id_ AND CONCAT( cs.class_date_, ' ',
  2755. cs.start_class_time_ ) > NOW( )
  2756. WHERE
  2757. cg.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2758. AND cg.music_group_id_ IN
  2759. <foreach collection="groupIds" item="groupId" separator="," open="(" close=")">
  2760. #{groupId}
  2761. </foreach>
  2762. GROUP BY
  2763. cg.id_
  2764. </select>
  2765. <select id="findGroupsValidate" resultType="com.ym.mec.biz.dal.dto.GroupValidDateDto">
  2766. SELECT
  2767. cs.music_group_id_ groupId,
  2768. MIN( CONCAT( class_date_, ' ', start_class_time_ ) ) startDate,
  2769. MAX( CONCAT( class_date_, ' ', end_class_time_ ) ) endDate
  2770. FROM
  2771. course_schedule cs
  2772. WHERE
  2773. cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2774. AND cs.music_group_id_ IN
  2775. <foreach collection="groupIds" item="groupId" separator="," open="(" close=")">
  2776. #{groupId}
  2777. </foreach>
  2778. GROUP BY
  2779. cs.music_group_id_
  2780. </select>
  2781. <select id="findCourseByGroupId" resultMap="CourseSchedule">
  2782. SELECT *
  2783. FROM course_schedule cs
  2784. WHERE cs.music_group_id_ = #{groupId}
  2785. AND cs.group_type_ = #{groupType}
  2786. AND cs.del_flag_ = 0
  2787. </select>
  2788. <select id="queryScheduleByAttendance" resultMap="CourseSchedule">
  2789. SELECT cs.*
  2790. FROM teacher_attendance ta
  2791. LEFT JOIN course_schedule cs ON ta.course_schedule_id_ = cs.id_
  2792. LEFT JOIN student_attendance sa ON ta.course_schedule_id_ = sa.course_schedule_id_
  2793. WHERE ta.sign_out_status_ = 1
  2794. AND ta.sign_in_time_ IS NOT NULL
  2795. AND MONTH(ta.sign_in_time_) = #{month}
  2796. AND cs.teach_mode_ = 'ONLINE'
  2797. AND ta.teacher_id_ = cs.actual_teacher_id_
  2798. GROUP BY ta.course_schedule_id_
  2799. HAVING COUNT(sa.id_) > 0
  2800. </select>
  2801. <update id="updateCourseNameByGroup">
  2802. UPDATE course_schedule
  2803. SET name_=#{name}
  2804. WHERE group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2805. AND music_group_id_ = #{groupId};
  2806. </update>
  2807. <select id="getStudentCourseScheduleNum" resultMap="com.ym.mec.biz.dal.dao.PracticeGroupDao.courseGroupExport">
  2808. SELECT COUNT(*) total_class_times_,cssp.user_id_ student_id_
  2809. FROM course_schedule_student_payment cssp
  2810. LEFT JOIN course_schedule cs on cs.id_ = cssp.course_schedule_id_
  2811. WHERE cssp.user_id_ IN
  2812. <foreach collection="studentIds" separator="," open="(" close=")" item="studentId">
  2813. #{studentId}
  2814. </foreach>
  2815. AND cssp.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2816. <if test="status != null">
  2817. AND cs.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2818. </if>
  2819. AND (cs.is_lock_ IS NULL OR cs.is_lock_ =0)
  2820. AND (cs.del_flag_ IS NULL OR cs.del_flag_ =0)
  2821. GROUP BY cssp.user_id_
  2822. </select>
  2823. <select id="getVipGroupExport" resultMap="com.ym.mec.biz.dal.dao.PracticeGroupDao.courseGroupExport">
  2824. SELECT cssp.user_id_ student_id_,
  2825. su.username_ student_name_,
  2826. o.name_ organ_name_
  2827. FROM `course_schedule_student_payment` cssp
  2828. LEFT JOIN `vip_group` vg ON vg.`id_` = cssp.`music_group_id_` AND cssp.`group_type_` = 'VIP'
  2829. LEFT JOIN `organization` o ON o.`id_` = vg.`organ_id_`
  2830. LEFT JOIN `sys_user` su ON su.`id_` = cssp.`user_id_`
  2831. WHERE cssp.`group_type_` = 'VIP'
  2832. <if test="organIds != null and organIds != ''">
  2833. AND FIND_IN_SET(vg.organ_id_, #{organIds})
  2834. </if>
  2835. GROUP BY cssp.`user_id_`,o.id_
  2836. </select>
  2837. <select id="getStudentCourseInfo" resultMap="com.ym.mec.biz.dal.dao.PracticeGroupDao.courseGroupExport">
  2838. SELECT MIN(concat(cs.`class_date_`,' ',cs.`start_class_time_` )) class_start_date_,
  2839. MAX(concat(cs.`class_date_`,' ',cs.`start_class_time_` )) class_end_date_,cssp.user_id_ student_id_,
  2840. GROUP_CONCAT(DISTINCT su.`real_name_`) teacher_name_,GROUP_CONCAT(DISTINCT cs.`actual_teacher_id_`) teacher_ids_
  2841. FROM course_schedule_student_payment cssp
  2842. LEFT JOIN course_schedule cs on cs.id_ = cssp.course_schedule_id_
  2843. LEFT JOIN sys_user su on cs.actual_teacher_id_ = su.id_
  2844. WHERE cssp.user_id_ IN
  2845. <foreach collection="studentIds" separator="," open="(" close=")" item="studentId">
  2846. #{studentId}
  2847. </foreach>
  2848. AND cssp.group_type_ = #{groupType}
  2849. AND (cs.is_lock_ IS NULL OR cs.is_lock_ =0)
  2850. AND (cs.del_flag_ IS NULL OR cs.del_flag_ =0)
  2851. GROUP BY cssp.user_id_;
  2852. </select>
  2853. <select id="getLastCourse" resultMap="CourseSchedule">
  2854. SELECT cs.* FROM course_schedule cs
  2855. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_ AND ta.teacher_id_ = cs.actual_teacher_id_
  2856. LEFT JOIN student_attendance sa ON cs.id_ = sa.course_schedule_id_
  2857. WHERE cs.class_group_id_ = #{classGroupId}
  2858. AND TIMESTAMPDIFF(MINUTE, CONCAT(cs.class_date_," ",cs.end_class_time_),#{startTime}) &lt;= #{continueCourseTime}
  2859. AND TIMESTAMPDIFF(MINUTE, CONCAT(cs.class_date_," ",cs.end_class_time_),#{startTime}) >= 0
  2860. AND cs.actual_teacher_id_ = #{teacherId} AND ta.sign_in_time_ IS NOT NULL AND sa.id_ IS NOT NULL
  2861. ORDER BY cs.class_date_ DESC,cs.end_class_time_ DESC
  2862. LIMIT 1
  2863. </select>
  2864. <select id="findLastOverTime" resultType="java.util.Map">
  2865. SELECT cs.music_group_id_ 'key',MAX(CONCAT(cs.class_date_,' ',cs.start_class_time_)) 'value'
  2866. FROM course_schedule cs
  2867. WHERE cs.status_ = 'OVER' AND cs.group_type_ = 'VIP' AND cs.music_group_id_ IN
  2868. <foreach collection="vipGroupIds" open="(" close=")" separator="," item="item">
  2869. #{item}
  2870. </foreach>
  2871. GROUP BY cs.music_group_id_
  2872. </select>
  2873. <select id="findNotStartCourseByIds" resultType="java.lang.Long">
  2874. SELECT cs.id_ FROM course_schedule cs WHERE cs.id_ IN
  2875. <foreach collection="courseScheduleIds" open="(" close=")" separator="," item="item">
  2876. #{item}
  2877. </foreach>
  2878. AND cs.status_ = 'NOT_START'
  2879. </select>
  2880. <select id="getLastTime" resultType="java.util.Date">
  2881. SELECT MAX(CONCAT(cs.class_date_," ",cs.end_class_time_))
  2882. FROM course_schedule cs
  2883. WHERE cs.music_group_id_ = #{practiceGroupId} AND cs.del_flag_ = 0 AND cs.group_type_ = #{groupType};
  2884. </select>
  2885. <select id="getFirstTime" resultType="java.util.Date">
  2886. SELECT MIN(CONCAT(cs.class_date_," ",cs.end_class_time_))
  2887. FROM course_schedule cs
  2888. WHERE cs.music_group_id_ = #{practiceGroupId} AND cs.del_flag_ = 0 AND cs.group_type_ = #{groupType};
  2889. </select>
  2890. <select id="countStudentVipCoursesWithDate" resultType="map">
  2891. SELECT
  2892. cssp.user_id_ as 'key',
  2893. COUNT( cs.id_ ) as 'value'
  2894. FROM
  2895. course_schedule_student_payment cssp
  2896. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  2897. WHERE
  2898. cssp.user_id_ IN
  2899. <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
  2900. #{studentId}
  2901. </foreach>
  2902. AND cssp.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  2903. AND cs.class_date_ BETWEEN #{startTime} AND #{endTime}
  2904. GROUP BY
  2905. cssp.user_id_
  2906. </select>
  2907. <select id="countStudentPayPracticeCoursesWithDate" resultType="map">
  2908. SELECT
  2909. cssp.user_id_ as 'key',
  2910. COUNT( cs.id_ ) as 'value'
  2911. FROM
  2912. course_schedule_student_payment cssp
  2913. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  2914. LEFT JOIN practice_group pg ON pg.id_=cssp.music_group_id_
  2915. WHERE
  2916. cssp.user_id_ IN
  2917. <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
  2918. #{studentId}
  2919. </foreach>
  2920. AND cssp.group_type_ = 'PRACTICE'
  2921. AND pg.type_='CHARGE'
  2922. AND cs.class_date_ BETWEEN #{startTime} AND #{endTime}
  2923. GROUP BY
  2924. cssp.user_id_
  2925. </select>
  2926. <select id="countStudentVipCoursesInFuture" resultType="map">
  2927. SELECT
  2928. cssp.user_id_ as 'key',
  2929. COUNT( cs.id_ ) as 'value'
  2930. FROM
  2931. course_schedule_student_payment cssp
  2932. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  2933. WHERE
  2934. cssp.user_id_ IN
  2935. <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
  2936. #{studentId}
  2937. </foreach>
  2938. AND cssp.group_type_ = 'VIP'
  2939. AND CONCAT(cs.class_date_," ",cs.start_class_time_) &gt; NOW()
  2940. GROUP BY
  2941. cssp.user_id_
  2942. </select>
  2943. </mapper>