IndexBaseMonthDataMapper.xml 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876
  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.IndexBaseMonthDataDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.IndexBaseMonthData" id="IndexBaseMonthData">
  9. <result column="id_" property="id" />
  10. <result column="month_" property="month" />
  11. <result column="month_" property="monthStr" />
  12. <result column="organ_id_" property="organId" />
  13. <result column="total_num_" property="totalNum" />
  14. <result column="activate_num_" property="activateNum" />
  15. <result column="percent_" property="percent" />
  16. <result column="data_type_" property="dataType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  17. <result column="extend_info_" property="extendInfo"/>
  18. <result column="order_type_" property="orderType"/>
  19. <result column="create_time_" property="createTime" />
  20. <result column="update_time_" property="updateTime" />
  21. </resultMap>
  22. <!-- 根据主键查询一条记录 -->
  23. <select id="get" resultMap="IndexBaseMonthData" >
  24. SELECT * FROM index_base_month_data WHERE id_ = #{id}
  25. </select>
  26. <!-- 全查询 -->
  27. <select id="findAll" resultMap="IndexBaseMonthData">
  28. SELECT * FROM index_base_month_data ORDER BY id_
  29. </select>
  30. <select id="getOrganDataWithDayAndDataType" resultMap="IndexBaseMonthData">
  31. SELECT * FROM index_base_month_data WHERE organ_id_=#{organId} AND month_ = #{day} AND data_type_=#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} ORDER BY month_ DESC LIMIT 1;
  32. </select>
  33. <!-- 向数据库增加一条记录 -->
  34. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  35. <!--
  36. <selectKey resultClass="int" keyProperty="id" >
  37. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  38. </selectKey>
  39. -->
  40. INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,extend_info_,create_time_,update_time_)
  41. VALUES(#{month},#{organId},#{totalNum},#{activateNum},#{percent},#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{extendInfo},NOW(),NOW())
  42. </insert>
  43. <insert id="batchInsertWithDataType" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  44. INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,extend_info_,create_time_,update_time_)
  45. VALUES
  46. <foreach collection="datas" item="data" separator=",">
  47. (#{data.month},#{data.organId},#{data.totalNum},#{data.activateNum},#{data.percent},
  48. #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.extendInfo},NOW(),NOW())
  49. </foreach>
  50. </insert>
  51. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  52. INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,extend_info_,create_time_,update_time_)
  53. VALUES
  54. <foreach collection="datas" item="data" separator=",">
  55. (#{data.month},#{data.organId},#{data.totalNum},#{data.activateNum},#{data.percent},
  56. #{data.dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.extendInfo},NOW(),NOW())
  57. </foreach>
  58. </insert>
  59. <!-- 根据主键查询一条记录 -->
  60. <update id="update" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData">
  61. UPDATE index_base_month_data
  62. <set>
  63. <if test="organId != null">
  64. organ_id_ = #{organId},
  65. </if>
  66. <if test="id != null">
  67. id_ = #{id},
  68. </if>
  69. <if test="activateNum != null">
  70. activate_num_ = #{activateNum},
  71. </if>
  72. <if test="totalNum != null">
  73. total_num_ = #{totalNum},
  74. </if>
  75. <if test="percent != null">
  76. percent_ = #{percent},
  77. </if>
  78. <if test="month != null">
  79. month_ = #{month},
  80. </if>
  81. <if test="dataType != null">
  82. data_type_ = #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  83. </if>
  84. <if test="extendInfo != null">
  85. extend_info_ = #{extendInfo},
  86. </if>
  87. update_time_ = NOW()
  88. </set>
  89. WHERE id_ = #{id}
  90. </update>
  91. <!-- 根据主键删除一条记录 -->
  92. <delete id="delete" >
  93. DELETE FROM index_base_month_data WHERE id_ = #{id}
  94. </delete>
  95. <delete id="deleteWithMonthAndType">
  96. DELETE FROM index_base_month_data
  97. WHERE DATE_FORMAT(month_, '%Y-%m-%d') IN
  98. <foreach collection="months" item="month" open="(" close=")" separator=",">
  99. #{month}
  100. </foreach>
  101. <if test="dataType!=null">
  102. AND data_type_=#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  103. </if>
  104. </delete>
  105. <!-- 分页查询 -->
  106. <select id="queryPage" resultMap="IndexBaseMonthData" parameterType="map">
  107. SELECT * FROM index_base_month_data ORDER BY id_ <include refid="global.limit"/>
  108. </select>
  109. <!-- 查询当前表的总记录数 -->
  110. <select id="queryCount" resultType="int">
  111. SELECT COUNT(*) FROM index_base_month_data
  112. </select>
  113. <select id="getIndexBaseData" resultMap="IndexBaseMonthData">
  114. SELECT
  115. month_,data_type_,SUM(total_num_) total_num_,SUM(activate_num_) activate_num_,SUM(percent_) percent_
  116. FROM index_base_month_data
  117. <where>
  118. <if test="dataTypes!=null and dataTypes.size()>0">
  119. AND data_type_ IN
  120. <foreach collection="dataTypes" item="dataType" open="(" close=")" separator=",">
  121. #{dataType}
  122. </foreach>
  123. </if>
  124. <if test="organIds!=null and organIds.size()>0">
  125. AND organ_id_ IN
  126. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  127. #{organId}
  128. </foreach>
  129. </if>
  130. <if test="startMonth!=null and startMonth!=''">
  131. AND month_&gt;=#{startMonth}
  132. </if>
  133. <if test="endMonth!=null and endMonth!=''">
  134. AND month_&lt;=#{endMonth}
  135. </if>
  136. </where>
  137. GROUP BY month_,data_type_
  138. </select>
  139. <select id="getAllIndexBaseData" resultMap="IndexBaseMonthData">
  140. SELECT
  141. *
  142. FROM index_base_month_data
  143. <where>
  144. <if test="dataTypes!=null and dataTypes.size()>0">
  145. AND data_type_ IN
  146. <foreach collection="dataTypes" item="dataType" open="(" close=")" separator=",">
  147. #{dataType}
  148. </foreach>
  149. </if>
  150. <if test="organIds!=null and organIds.size()>0">
  151. AND organ_id_ IN
  152. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  153. #{organId}
  154. </foreach>
  155. </if>
  156. <if test="startMonth!=null and startMonth!=''">
  157. AND month_&gt;=#{startMonth}
  158. </if>
  159. <if test="endMonth!=null and endMonth!=''">
  160. AND month_&lt;=#{endMonth}
  161. </if>
  162. </where>
  163. </select>
  164. <select id="getVipCourseDataList" resultMap="IndexBaseMonthData">
  165. SELECT
  166. month_,
  167. organ_id_,
  168. data_type_,
  169. extend_info_
  170. FROM index_base_month_data
  171. FORCE INDEX(data_type_, month_)
  172. <where>
  173. <if test="dataTypes!=null and dataTypes.size()>0">
  174. AND data_type_ IN
  175. <foreach collection="dataTypes" item="dataType" open="(" close=")" separator=",">
  176. #{dataType}
  177. </foreach>
  178. </if>
  179. <if test="organIds!=null and organIds.size()>0">
  180. AND organ_id_ IN
  181. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  182. #{organId}
  183. </foreach>
  184. </if>
  185. <if test="startMonth!=null and startMonth!=''">
  186. AND month_&gt;=#{startMonth}
  187. </if>
  188. <if test="endMonth!=null and endMonth!=''">
  189. AND month_&lt;=#{endMonth}
  190. </if>
  191. AND extend_info_ IS NOT NULL
  192. </where>
  193. </select>
  194. <select id="getWithDayAndDataType" resultMap="IndexBaseMonthData">
  195. SELECT
  196. *
  197. FROM index_base_month_data
  198. WHERE 1=1
  199. AND data_type_ = #{dataType}
  200. AND month_&gt;=#{day}
  201. </select>
  202. <select id="getStudentSignUpData" resultMap="IndexBaseMonthData">
  203. SELECT
  204. organ_id_,
  205. #{dayStr} month_,
  206. COUNT( id_ ) total_num_,
  207. COUNT(CASE WHEN password_ IS NOT NULL THEN id_ ELSE NULL END) activate_num_,
  208. TRUNCATE(COUNT(CASE WHEN password_ IS NOT NULL THEN id_ ELSE NULL END)/COUNT( id_ )*100, 2) percent_
  209. FROM
  210. ((
  211. SELECT DISTINCT
  212. sr.user_id_
  213. FROM
  214. student_registration sr
  215. LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
  216. WHERE
  217. mg.status_ IN ( 'PREPARE', 'PROGRESS' )
  218. AND sr.music_group_status_ = 'NORMAL'
  219. AND DATE_FORMAT(sr.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  220. ) UNION ALL
  221. (
  222. SELECT DISTINCT
  223. cssp.user_id_
  224. FROM
  225. course_schedule_student_payment cssp
  226. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  227. WHERE
  228. cs.del_flag_ = 0 AND cs.pre_course_flag_ = 0
  229. AND ( cs.is_lock_ = 0 OR cs.is_lock_ IS NULL )
  230. AND ( cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_ )
  231. AND cssp.group_type_ IN ('VIP', 'PRACTICE')
  232. AND cs.organ_id_ IS NOT NULL
  233. AND DATE_FORMAT(cssp.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  234. AND cs.class_date_ &gt;= #{courseStartDay}
  235. )) u
  236. LEFT JOIN sys_user su ON u.user_id_ = su.id_
  237. WHERE
  238. del_flag_=0
  239. AND organ_id_ IS NOT NULL
  240. AND user_type_ LIKE '%STUDENT%'
  241. GROUP BY organ_id_
  242. ORDER BY organ_id_;
  243. </select>
  244. <select id="getStudentRegistrationData" resultMap="IndexBaseMonthData">
  245. SELECT
  246. su.organ_id_,
  247. #{dayStr} month_,
  248. COUNT( DISTINCT stu.user_id_ ) total_num_,
  249. COUNT( DISTINCT stu.user_id_ ) activate_num_,
  250. COUNT( DISTINCT stu.user_id_ ) percent_
  251. FROM
  252. student stu
  253. LEFT JOIN sys_user su ON stu.user_id_=su.id_
  254. WHERE
  255. su.del_flag_=0
  256. AND su.organ_id_ IS NOT NULL
  257. AND su.user_type_ LIKE '%STUDENT%'
  258. AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  259. GROUP BY organ_id_
  260. ORDER BY organ_id_;
  261. </select>
  262. <select id="getAddStudentRegistrationData" resultMap="IndexBaseMonthData">
  263. SELECT
  264. su.organ_id_,
  265. #{dayStr} month_,
  266. COUNT( DISTINCT stu.user_id_ ) total_num_,
  267. COUNT( DISTINCT stu.user_id_ ) activate_num_,
  268. COUNT( DISTINCT stu.user_id_ ) percent_
  269. FROM
  270. student stu
  271. LEFT JOIN sys_user su ON stu.user_id_=su.id_
  272. WHERE
  273. su.del_flag_=0
  274. AND su.organ_id_ IS NOT NULL
  275. AND su.user_type_ LIKE '%STUDENT%'
  276. AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')=#{dayStr}
  277. GROUP BY organ_id_
  278. ORDER BY organ_id_;
  279. </select>
  280. <select id="getChargeStudentChangeData" resultMap="IndexBaseMonthData">
  281. SELECT
  282. su.organ_id_,
  283. #{dayStr} month_,
  284. COUNT( DISTINCT stu.user_id_ ) total_num_,
  285. COUNT( DISTINCT (CASE WHEN DATE_FORMAT( spo.create_time_, '%Y-%m-%d' ) &lt;= #{dayStr} THEN spo.user_id_ ELSE NULL END) ) activate_num_,
  286. TRUNCATE(COUNT(DISTINCT (CASE WHEN DATE_FORMAT( spo.create_time_, '%Y-%m-%d' ) &lt;= #{dayStr} THEN spo.user_id_ ELSE NULL END))/COUNT(DISTINCT stu.user_id_)*100, 2) percent_
  287. FROM
  288. student stu
  289. LEFT JOIN sys_user su ON stu.user_id_=su.id_
  290. LEFT JOIN student_payment_order spo ON stu.user_id_=spo.user_id_ AND status_='SUCCESS' AND actual_amount_>0
  291. WHERE
  292. su.del_flag_=0
  293. AND su.organ_id_ IS NOT NULL
  294. AND su.user_type_ LIKE '%STUDENT%'
  295. AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  296. GROUP BY organ_id_
  297. ORDER BY organ_id_;
  298. </select>
  299. <select id="getHomeworkData" resultMap="IndexBaseMonthData">
  300. SELECT
  301. su.organ_id_,
  302. sees.monday_ month_,
  303. <choose>
  304. <when test="type == 'submit'">
  305. SUM(sees.actual_exercises_num_) total_num_,
  306. SUM(sees.exercises_reply_num_) activate_num_,
  307. TRUNCATE(SUM(sees.exercises_reply_num_)/SUM(sees.actual_exercises_num_)*100, 2) percent_
  308. </when>
  309. <when test="type == 'comment'">
  310. SUM(sees.exercises_reply_num_) total_num_,
  311. SUM(sees.exercises_message_num_) activate_num_,
  312. TRUNCATE(SUM(sees.exercises_message_num_)/SUM(sees.exercises_reply_num_)*100, 2) percent_
  313. </when>
  314. <otherwise>
  315. SUM(sees.expect_exercises_num_-sees.not_over_course_num_) total_num_,
  316. SUM(sees.actual_exercises_num_) activate_num_,
  317. TRUNCATE(SUM(sees.actual_exercises_num_)/SUM(sees.expect_exercises_num_-sees.not_over_course_num_)*100, 2) percent_
  318. </otherwise>
  319. </choose>
  320. FROM student_extracurricular_exercises_situation_ sees
  321. LEFT JOIN sys_user su ON sees.student_id_=su.id_
  322. LEFT JOIN teacher tea ON sees.teacher_id_=tea.id_
  323. WHERE su.del_flag_=0
  324. AND tea.job_nature_='FULL_TIME'
  325. AND su.organ_id_ IS NOT NULL
  326. AND DATE_FORMAT(sees.monday_, '%Y-%m-%d')&lt;=#{dayStr}
  327. AND DATE_FORMAT(sees.sunday_, '%Y-%m-%d')&gt;=#{dayStr}
  328. GROUP BY su.organ_id_
  329. ORDER BY su.organ_id_
  330. </select>
  331. <select id="getSchoolData" resultMap="IndexBaseMonthData">
  332. SELECT
  333. mg.organ_id_,
  334. #{dayStr} month_,
  335. COUNT( DISTINCT mg.cooperation_organ_id_ ) total_num_,
  336. COUNT( DISTINCT mg.cooperation_organ_id_ ) activate_num_,
  337. COUNT( DISTINCT mg.cooperation_organ_id_ ) percent_
  338. FROM
  339. music_group mg
  340. WHERE
  341. mg.del_flag_ = 0
  342. AND mg.organ_id_ IS NOT NULL
  343. AND mg.status_ = 'PROGRESS'
  344. AND DATE_FORMAT(mg.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  345. GROUP BY
  346. mg.organ_id_
  347. ORDER BY
  348. mg.organ_id_;
  349. </select>
  350. <select id="getMusicData" resultMap="IndexBaseMonthData">
  351. SELECT
  352. organ_id_,
  353. #{dayStr} month_,
  354. COUNT( id_ ) total_num_,
  355. COUNT( id_ ) activate_num_,
  356. COUNT( id_ ) percent_
  357. FROM
  358. music_group
  359. WHERE
  360. del_flag_ = 0
  361. AND status_ = 'PROGRESS'
  362. AND organ_id_ IS NOT NULL
  363. <if test="dayStr!=null and dayStr!=''">
  364. AND DATE_FORMAT(create_time_, '%Y-%m-%d') &lt;= #{dayStr}
  365. </if>
  366. GROUP BY
  367. organ_id_
  368. ORDER BY
  369. organ_id_;
  370. </select>
  371. <select id="getMusicStudentData" resultMap="IndexBaseMonthData">
  372. SELECT
  373. mg.organ_id_,
  374. #{dayStr} month_,
  375. COUNT( DISTINCT sr.user_id_ ) total_num_,
  376. COUNT( DISTINCT sr.user_id_ ) activate_num_,
  377. COUNT( DISTINCT sr.user_id_ ) percent_
  378. FROM student_registration sr
  379. LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
  380. WHERE
  381. mg.del_flag_ = 0
  382. AND mg.organ_id_ IS NOT NULL
  383. AND mg.status_ = 'PROGRESS'
  384. <if test="type==null">
  385. AND sr.music_group_status_='NORMAL'
  386. </if>
  387. <if test="type!=null and type=='QUIT'">
  388. AND sr.music_group_status_='QUIT'
  389. AND DATE_FORMAT(sr.create_time_, '%Y-%m') &gt;= CONCAT(DATE_FORMAT(NOW(), '%Y'), '-01')
  390. </if>
  391. <if test="type!=null and type=='ADD'">
  392. AND sr.music_group_status_='NORMAL'
  393. AND DATE_FORMAT(sr.create_time_, '%Y-%m') &gt;= CONCAT(DATE_FORMAT(NOW(), '%Y'), '-01')
  394. </if>
  395. <if test="dayStr!=null and dayStr!=''">
  396. AND DATE_FORMAT(sr.create_time_, '%Y-%m-%d') &lt;= #{dayStr}
  397. </if>
  398. GROUP BY
  399. mg.organ_id_
  400. ORDER BY
  401. mg.organ_id_;
  402. </select>
  403. <select id="getTeacherData" resultMap="IndexBaseMonthData">
  404. SELECT
  405. t.organ_id_,
  406. #{dayStr} month_,
  407. COUNT( t.id_ ) total_num_,
  408. COUNT( t.id_ ) activate_num_,
  409. COUNT( t.id_ ) percent_
  410. FROM
  411. teacher t
  412. LEFT JOIN sys_user su ON su.id_ = t.id_
  413. WHERE
  414. su.del_flag_ = 0
  415. AND (t.demission_date_ IS NULl OR DATE_FORMAT(t.demission_date_, '%Y-%m-%d') &gt; #{dayStr})
  416. <if test="isDemission==null">
  417. AND su.lock_flag_ = 0
  418. </if>
  419. <if test="isDemission!=null">
  420. AND (su.lock_flag_ = 1 OR t.demission_date_&lt;NOW())
  421. </if>
  422. AND t.organ_id_ IS NOT NULL
  423. <if test="jobNature!=null">
  424. AND t.job_nature_ = #{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  425. </if>
  426. <if test="dayStr!=null and dayStr!=''">
  427. AND DATE_FORMAT(t.create_time_, '%Y-%m-%d') &lt;= #{dayStr}
  428. </if>
  429. GROUP BY
  430. t.organ_id_
  431. ORDER BY
  432. t.organ_id_;
  433. </select>
  434. <select id="getGroupCourseData" resultMap="IndexBaseMonthData">
  435. SELECT
  436. m.organ_id_,
  437. #{dayStr} month_,
  438. COUNT( m.id_ ) total_num_,
  439. COUNT( m.id_ ) activate_num_,
  440. COUNT( m.id_ ) percent_
  441. FROM
  442. course_schedule m
  443. WHERE
  444. m.del_flag_ = 0
  445. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  446. AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  447. AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
  448. AND NOT EXISTS (SELECT id_ FROM practice_group WHERE m.group_type_='PRACTICE' AND m.music_group_id_=id_ AND type_='TRIAL')
  449. AND m.organ_id_ IS NOT NULL AND m.pre_course_flag_ = 0
  450. <if test="groupType!=null">
  451. AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  452. </if>
  453. <if test="dayStr!=null and dayStr!=''">
  454. AND m.class_date_ &gt;= #{dayStr}
  455. </if>
  456. GROUP BY
  457. m.organ_id_
  458. ORDER BY
  459. m.organ_id_;
  460. </select>
  461. <select id="getGroupSurplusCourseData" resultMap="IndexBaseMonthData">
  462. SELECT
  463. m.organ_id_,
  464. #{dayStr} month_,
  465. COUNT( m.id_ ) total_num_,
  466. COUNT( m.id_ ) activate_num_,
  467. COUNT( m.id_ ) percent_
  468. FROM
  469. course_schedule m
  470. WHERE
  471. m.del_flag_ = 0
  472. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  473. AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  474. AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
  475. AND NOT EXISTS (SELECT id_ FROM practice_group WHERE m.group_type_='PRACTICE' AND m.music_group_id_=id_ AND type_='TRIAL')
  476. AND m.organ_id_ IS NOT NULL AND m.pre_course_flag_ = 0
  477. <if test="groupType!=null">
  478. AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  479. </if>
  480. <if test="dayStr!=null and dayStr!=''">
  481. AND m.class_date_ &lt;= #{dayStr}
  482. </if>
  483. GROUP BY m.organ_id_
  484. ORDER BY m.organ_id_;
  485. </select>
  486. <select id="getGroupCourseDataWithGroup" resultMap="IndexBaseMonthData">
  487. SELECT
  488. m.organ_id_,
  489. m.class_date_ month_,
  490. COUNT( m.id_ ) total_num_,
  491. COUNT( m.id_ ) activate_num_,
  492. COUNT( m.id_ ) percent_
  493. FROM
  494. course_schedule m
  495. WHERE
  496. m.del_flag_ = 0
  497. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  498. AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
  499. AND NOT EXISTS (SELECT id_ FROM practice_group WHERE m.group_type_='PRACTICE' AND m.music_group_id_=id_ AND type_='TRIAL')
  500. AND m.organ_id_ IS NOT NULL AND m.pre_course_flag_ = 0
  501. <if test="groupType!=null">
  502. AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  503. </if>
  504. <if test="dayStr!=null and dayStr!=''">
  505. AND m.class_date_ = #{dayStr}
  506. </if>
  507. <if test="startDate!=null and endDate!=''">
  508. AND m.class_date_ BETWEEN #{startDate} AND #{endDate}
  509. </if>
  510. <if test="teachMode!=null">
  511. AND m.teach_mode_ = #{teachMode, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  512. </if>
  513. <if test="organIds!=null and organIds.size()>0">
  514. AND m.organ_id_ IN
  515. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  516. #{organId}
  517. </foreach>
  518. </if>
  519. <if test="dayStr!=null and dayStr!=''">
  520. GROUP BY m.organ_id_
  521. </if>
  522. <if test="startDate!=null and endDate!=''">
  523. GROUP BY m.class_date_
  524. </if>
  525. ORDER BY
  526. m.organ_id_;
  527. </select>
  528. <select id="getVipGroupCategoryCourseData" resultType="com.ym.mec.biz.dal.dto.OrganVipGroupCategoryCourseNumDto">
  529. SELECT
  530. m.organ_id_ organId,
  531. vgc.name_ categoryName,
  532. COUNT( m.id_ ) courseNum
  533. FROM
  534. course_schedule m
  535. LEFT JOIN vip_group vg ON m.music_group_id_=vg.id_
  536. LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
  537. WHERE
  538. m.del_flag_ = 0
  539. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  540. AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
  541. AND m.organ_id_ IS NOT NULL
  542. <if test="groupType!=null">
  543. AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  544. </if>
  545. <if test="dayStr!=null and dayStr!=''">
  546. AND m.class_date_ = #{dayStr}
  547. </if>
  548. <if test="startDate!=null and endDate!=null">
  549. AND m.class_date_ BETWEEN #{startDate} AND #{endDate}
  550. </if>
  551. <if test="teachMode!=null">
  552. AND m.teach_mode_ = #{teachMode, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  553. </if>
  554. <if test="organIds!=null and organIds.size()>0">
  555. AND m.organ_id_ IN
  556. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  557. #{organId}
  558. </foreach>
  559. </if>
  560. GROUP BY
  561. m.organ_id_,vgc.name_
  562. ORDER BY
  563. m.organ_id_;
  564. </select>
  565. <select id="getOtherStudentData" resultMap="IndexBaseMonthData">
  566. SELECT
  567. su.organ_id_,
  568. #{dayStr} month_,
  569. COUNT( DISTINCT s.user_id_ ) total_num_,
  570. COUNT( DISTINCT s.user_id_ ) activate_num_,
  571. COUNT( DISTINCT s.user_id_ ) percent_
  572. FROM
  573. sys_user su
  574. LEFT JOIN course_schedule_student_payment s ON su.id_=s.user_id_
  575. LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
  576. WHERE
  577. m.del_flag_ = 0
  578. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  579. AND su.organ_id_ IS NOT NULL
  580. AND m.group_type_ IN ('VIP', 'PRACTICE')
  581. AND m.status_ = 'NOT_START'
  582. <if test="dayStr!=null and dayStr!=''">
  583. AND (DATE_FORMAT(s.create_time_, '%Y-%m-%d') &lt;= #{dayStr} OR YEAR(m.create_time_)=3000)
  584. </if>
  585. GROUP BY
  586. su.organ_id_
  587. ORDER BY
  588. su.organ_id_;
  589. </select>
  590. <select id="getVipPracticeAddStudentData" resultMap="IndexBaseMonthData">
  591. SELECT
  592. su.organ_id_,
  593. #{dayStr} month_,
  594. COUNT( DISTINCT s.user_id_ ) total_num_,
  595. COUNT( DISTINCT s.user_id_ ) activate_num_,
  596. COUNT( DISTINCT s.user_id_ ) percent_
  597. FROM
  598. sys_user su
  599. LEFT JOIN course_schedule_student_payment s ON su.id_=s.user_id_
  600. LEFT JOIN course_schedule_student_payment cssp1 ON s.user_id_=cssp1.user_id_ AND cssp1.create_time_&lt;#{dayStr}
  601. LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
  602. WHERE
  603. m.del_flag_ = 0
  604. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  605. AND cssp1.id_ IS NULL
  606. AND su.organ_id_ IS NOT NULL
  607. AND m.group_type_ IN ('VIP', 'PRACTICE')
  608. <if test="dayStr!=null and dayStr!=''">
  609. AND DATE_FORMAT(s.create_time_, '%Y-%m-%d') = #{dayStr}
  610. </if>
  611. GROUP BY su.organ_id_
  612. ORDER BY su.organ_id_;
  613. </select>
  614. <select id="getStudentConversionData" resultMap="IndexBaseMonthData">
  615. SELECT
  616. cs.organ_id_,
  617. #{dayStr} month_,
  618. COUNT( DISTINCT m.user_id_ ) total_num_,
  619. COUNT( DISTINCT m.user_id_ ) activate_num_,
  620. COUNT( DISTINCT m.user_id_ ) percent_
  621. FROM
  622. course_schedule_student_payment m
  623. LEFT JOIN course_schedule cs ON m.course_schedule_id_=cs.id_
  624. LEFT JOIN practice_group pg ON m.music_group_id_=pg.id_ AND m.group_type_='PRACTICE'
  625. WHERE
  626. (cs.del_flag_ IS NULL OR cs.del_flag_=0)
  627. AND cs.organ_id_ IS NOT NULL
  628. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
  629. AND m.group_type_ IN ('VIP', 'PRACTICE')
  630. AND (pg.id_ IS NULL OR pg.type_='CHARGE')
  631. AND m.user_id_ IN
  632. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  633. #{studentId}
  634. </foreach>
  635. AND DATE_FORMAT(m.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  636. GROUP BY
  637. cs.organ_id_
  638. ORDER BY
  639. cs.organ_id_;
  640. </select>
  641. <select id="getMusicGroupPreRegistrationStudentData" resultMap="IndexBaseMonthData">
  642. SELECT
  643. mg.organ_id_,
  644. #{dayStr} month_,
  645. COUNT( DISTINCT spr.user_id_ ) total_num_,
  646. COUNT( DISTINCT spr.user_id_ ) activate_num_,
  647. COUNT( DISTINCT spr.user_id_ ) percent_
  648. FROM
  649. student_pre_registration spr
  650. LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
  651. WHERE
  652. mg.del_flag_ = 0
  653. AND mg.organ_id_ IS NOT NULL
  654. AND mg.status_ = 'PROGRESS'
  655. AND DATE_FORMAT( spr.create_time_, '%Y-%m-%d' ) &lt;= #{dayStr}
  656. GROUP BY
  657. mg.organ_id_
  658. ORDER BY
  659. mg.organ_id_;
  660. </select>
  661. <select id="getMusicGroupStudentFromPreData" resultMap="IndexBaseMonthData">
  662. SELECT
  663. mg.organ_id_,
  664. #{dayStr} month_,
  665. COUNT( DISTINCT sr.user_id_ ) total_num_,
  666. COUNT( DISTINCT sr.user_id_ ) activate_num_,
  667. COUNT( DISTINCT sr.user_id_ ) percent_
  668. FROM
  669. student_registration sr
  670. LEFT JOIN student_pre_registration spr ON sr.user_id_ = spr.user_id_ AND sr.music_group_id_ = spr.music_group_id_
  671. LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
  672. WHERE
  673. mg.del_flag_ = 0
  674. AND mg.organ_id_ IS NOT NULL
  675. AND mg.status_ = 'PROGRESS'
  676. <if test="paymentStatus==null">
  677. AND sr.music_group_status_ IN ('APPLY', 'NORMAL')
  678. </if>
  679. <if test="paymentStatus!=null">
  680. AND sr.music_group_status_ IN ('NORMAL')
  681. AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  682. </if>
  683. AND DATE_FORMAT( sr.create_time_, '%Y-%m-%d' ) &lt;= #{dayStr}
  684. GROUP BY
  685. mg.organ_id_
  686. ORDER BY
  687. mg.organ_id_;
  688. </select>
  689. <select id="getMusicGroupStudentIdFromPre" resultType="int">
  690. SELECT
  691. sr.user_id_
  692. FROM
  693. student_registration sr
  694. LEFT JOIN student_pre_registration spr ON sr.user_id_ = spr.user_id_ AND sr.music_group_id_ = spr.music_group_id_
  695. LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
  696. WHERE
  697. mg.del_flag_ = 0
  698. AND mg.organ_id_ IS NOT NULL
  699. AND mg.status_ = 'PROGRESS'
  700. <if test="paymentStatus==null">
  701. AND sr.music_group_status_ IN ('APPLY', 'NORMAL')
  702. </if>
  703. <if test="paymentStatus!=null">
  704. AND sr.music_group_status_ IN ('NORMAL')
  705. AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  706. </if>
  707. AND DATE_FORMAT( sr.create_time_, '%Y-%m-%d' ) &lt;= #{dayStr}
  708. </select>
  709. <select id="countLessThenThreeClassGroupNum" resultType="int">
  710. SELECT COUNT(t.id_) FROM (
  711. SELECT cg.id_ FROM
  712. class_group cg
  713. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  714. LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
  715. LEFT JOIN course_schedule cs ON cs.class_group_id_=cg.id_
  716. WHERE
  717. cg.type_ IN ('HIGH', 'HIGH_ONLINE')
  718. AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0 AND cs.pre_course_flag_ = 0
  719. AND cs.del_flag_=0
  720. AND cs.status_='NOT_START'
  721. AND ( cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_ )
  722. <if test="educationUserId != null">
  723. AND mg.educational_teacher_id_ = #{educationUserId}
  724. </if>
  725. <if test="organIds!=null and organIds.size()>0">
  726. AND mg.organ_id_ IN
  727. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  728. #{organId}
  729. </foreach>
  730. </if>
  731. GROUP BY cg.id_
  732. HAVING
  733. COUNT(DISTINCT CASE WHEN cgsm.status_ = 'NORMAL' THEN cgsm.user_id_ ELSE NULL END) &lt; 3
  734. ) t
  735. </select>
  736. <select id="countLessThenThreeClassOrganGroupNum" resultType="map">
  737. SELECT t.organ_id_ AS 'key',
  738. COUNT(t.id_) AS 'value'
  739. FROM (
  740. SELECT mg.organ_id_,cg.id_ FROM
  741. class_group cg
  742. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  743. LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
  744. LEFT JOIN course_schedule cs ON cs.class_group_id_=cg.id_
  745. WHERE
  746. cg.type_ IN ('HIGH', 'HIGH_ONLINE') AND cs.pre_course_flag_ = 0
  747. AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0
  748. AND cs.del_flag_=0
  749. AND cs.status_='NOT_START'
  750. AND ( cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_ )
  751. <if test="educationUserId != null">
  752. AND mg.educational_teacher_id_ = #{educationUserId}
  753. </if>
  754. <if test="organIds!=null and organIds.size()>0">
  755. AND mg.organ_id_ IN
  756. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  757. #{organId}
  758. </foreach>
  759. </if>
  760. GROUP BY cg.id_
  761. HAVING
  762. COUNT(DISTINCT CASE WHEN cgsm.status_ = 'NORMAL' THEN cgsm.user_id_ ELSE NULL END) &lt; 3
  763. ) t GROUP BY t.organ_id_
  764. </select>
  765. <select id="getLessThenThreeMusicGroup" resultType="java.lang.String">
  766. SELECT cg.music_group_id_ FROM
  767. class_group cg
  768. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  769. LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
  770. WHERE
  771. cg.type_ IN ('HIGH_ONLINE')
  772. AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0
  773. <if test="organIds!=null and organIds.size()>0">
  774. AND mg.organ_id_ IN
  775. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  776. #{organId}
  777. </foreach>
  778. </if>
  779. GROUP BY cg.id_
  780. HAVING
  781. COUNT(CASE WHEN cgsm.status_ = 'NORMAL' THEN 1 ELSE NULL END) &lt; 3
  782. </select>
  783. <select id="countNoPaymentStudentNum" resultType="int">
  784. SELECT
  785. COUNT(DISTINCT mgpc.music_group_id_,mgpcd.user_id_)
  786. FROM
  787. music_group_payment_calender_detail mgpcd
  788. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  789. LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
  790. LEFT JOIN student_registration sr ON sr.music_group_id_ = mgpc.music_group_id_ AND mgpcd.user_id_ = sr.user_id_
  791. WHERE
  792. mg.status_ = 'PROGRESS'
  793. AND ((mgpc.member_rank_setting_id_ IS NOT NULL AND (sr.membership_end_time_ &lt; NOW() OR sr.membership_end_time_ IS NULL)) OR mgpc.member_rank_setting_id_ IS NULL)
  794. <if test="noPaymentType==null or noPaymentType==0">
  795. AND DATE_FORMAT(NOW(),'%Y-%m-%d') > DATE_FORMAT(mgpc.deadline_payment_date_,'%Y-%m-%d')
  796. </if>
  797. <if test="noPaymentType!=null and noPaymentType==1">
  798. AND DATE_FORMAT(NOW(),'%Y-%m-%d') BETWEEN DATE_FORMAT(mgpc.start_payment_date_,'%Y-%m-%d') AND DATE_FORMAT(mgpc.deadline_payment_date_,'%Y-%m-%d')
  799. </if>
  800. AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
  801. AND (mgpcd.expect_amount_ + mgpcd.expect_member_amount_) > 0
  802. <if test="educationUserId != null">
  803. AND mg.educational_teacher_id_ = #{educationUserId}
  804. </if>
  805. <if test="organIds!=null and organIds.size()>0">
  806. AND mg.organ_id_ IN
  807. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  808. #{organId}
  809. </foreach>
  810. </if>
  811. </select>
  812. <select id="countOrganNoPaymentStudentNum" resultType="map">
  813. SELECT
  814. mg.organ_id_ AS 'key',
  815. COUNT(DISTINCT mgpc.music_group_id_,mgpcd.user_id_) AS 'value'
  816. FROM
  817. music_group_payment_calender_detail mgpcd
  818. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  819. LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
  820. WHERE
  821. mg.status_ = 'PROGRESS'
  822. AND DATE_FORMAT(NOW(),'%Y-%m-%d') > mgpc.deadline_payment_date_
  823. AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpcd.expect_amount_ > 0 AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
  824. <if test="educationUserId != null">
  825. AND mg.educational_teacher_id_ = #{educationUserId}
  826. </if>
  827. <if test="organIds!=null and organIds.size()>0">
  828. AND mg.organ_id_ IN
  829. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  830. #{organId}
  831. </foreach>
  832. </if>
  833. GROUP BY mg.organ_id_
  834. </select>
  835. <select id="getNoPaymentMusicGroup" resultType="java.lang.String">
  836. SELECT
  837. DISTINCT mg.id_
  838. FROM
  839. music_group_payment_calender_detail mgpcd
  840. LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
  841. LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
  842. WHERE
  843. mg.status_ = 'PROGRESS'
  844. AND DATE_FORMAT(NOW(),'%Y-%m-%d') >= DATE_FORMAT(mgpc.payment_valid_start_date_,'%Y-%m-%d')
  845. AND mgpcd.payment_status_ = 'NON_PAYMENT'
  846. <if test="educationUserId != null">
  847. AND mg.educational_teacher_id_ = #{educationUserId}
  848. </if>
  849. <if test="organIds!=null and organIds.size()>0">
  850. AND mg.organ_id_ IN
  851. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  852. #{organId}
  853. </foreach>
  854. </if>
  855. </select>
  856. <select id="queryApplyForQuitGroupNum" resultType="java.lang.Long">
  857. SELECT mgq.id_ FROM music_group_quit mgq
  858. LEFT JOIN music_group mg ON mgq.music_group_id_=mg.id_
  859. WHERE mg.status_='PROGRESS'
  860. AND mgq.status_='PROCESSING'
  861. <if test="educationUserId != null">
  862. AND mg.educational_teacher_id_ = #{educationUserId}
  863. </if>
  864. <if test="organIds!=null and organIds.size() > 0">
  865. AND mg.organ_id_ IN
  866. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  867. #{organId}
  868. </foreach>
  869. </if>
  870. </select>
  871. <select id="queryOrganApplyForQuitGroupNum" resultType="map">
  872. SELECT
  873. mg.organ_id_ AS 'key',
  874. COUNT(mgq.id_) AS 'value'
  875. FROM music_group_quit mgq
  876. LEFT JOIN music_group mg ON mgq.music_group_id_=mg.id_
  877. WHERE mg.status_='PROGRESS'
  878. AND mgq.status_='PROCESSING'
  879. <if test="educationUserId != null">
  880. AND mg.educational_teacher_id_ = #{educationUserId}
  881. </if>
  882. <if test="organIds!=null and organIds.size() > 0">
  883. AND mg.organ_id_ IN
  884. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  885. #{organId}
  886. </foreach>
  887. </if>
  888. GROUP BY mg.organ_id_
  889. </select>
  890. <select id="queryStudentAttendanceInfo" resultType="int">
  891. SELECT
  892. COUNT(DISTINCT cssp.id_)
  893. FROM
  894. course_schedule_student_payment cssp
  895. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  896. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND sa.user_id_ = cssp.user_id_
  897. LEFT JOIN student_visit sv ON cssp.id_ = sv.object_id_
  898. WHERE
  899. cs.status_ = 'OVER' AND sv.id_ IS NULL AND cs.del_flag_ = 0 AND cs.class_date_ >= #{startTime} AND cs.class_date_ &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  900. AND cssp.group_type_ IN ('MUSIC','PRACTICE','VIP') AND cs.pre_course_flag_ = 0
  901. <if test="type!=null and type=='LEAVE'">
  902. AND sa.status_ = 'LEAVE'
  903. </if>
  904. <if test="type!=null and type=='TRUANT'">
  905. AND (sa.status_ = 'TRUANT' OR sa.id_ IS NULL) AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
  906. </if>
  907. <if test="organIds!=null and organIds.size()>0">
  908. AND cs.organ_id_ IN
  909. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  910. #{organId}
  911. </foreach>
  912. </if>
  913. </select>
  914. <select id="getCourseTimeError" resultType="int">
  915. SELECT COUNT(cs.id_) FROM course_schedule cs
  916. WHERE cs.status_ = 'NOT_START' AND cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND (cs.start_class_time_ &lt; #{courseStartTimeError} OR cs.end_class_time_ > #{courseEndTimeError})
  917. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cs.pre_course_flag_ = 0
  918. <if test="classGroupIds != null and classGroupIds.size() > 0">
  919. AND cs.class_group_id_ IN
  920. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  921. #{classGroupId}
  922. </foreach>
  923. </if>
  924. <if test="organIds != null and organIds.size()>0">
  925. AND cs.organ_id_ IN
  926. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  927. #{organId}
  928. </foreach>
  929. </if>
  930. </select>
  931. <select id="getOrganCourseTimeError" resultType="map">
  932. SELECT
  933. cs.organ_id_ AS 'key',
  934. COUNT(cs.id_) AS 'value'
  935. FROM course_schedule cs
  936. WHERE cs.status_ = 'NOT_START' AND cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.start_class_time_ &lt; '06:00:00'
  937. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cs.pre_course_flag_ = 0
  938. <if test="classGroupIds != null and classGroupIds.size() > 0">
  939. AND cs.class_group_id_ IN
  940. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  941. #{classGroupId}
  942. </foreach>
  943. </if>
  944. <if test="organIds != null and organIds.size()>0">
  945. AND cs.organ_id_ IN
  946. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  947. #{organId}
  948. </foreach>
  949. </if>
  950. GROUP BY cs.organ_id_
  951. </select>
  952. <select id="getAttendanceError" resultType="int">
  953. SELECT COUNT(DISTINCT c.id_) FROM (SELECT cs.id_ FROM course_schedule cs
  954. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  955. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  956. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
  957. WHERE ta.teacher_id_ = cs.actual_teacher_id_ AND cs.pre_course_flag_ = 0
  958. AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_ >= '2021-02-01'
  959. AND (((ta.sign_in_status_ = 0 OR ta.sign_in_status_ IS NULL OR ta.sign_out_status_ = 0 OR ta.sign_out_status_ IS NULL) AND ta.dispose_content_ IS NULL) OR (sa.id_ IS NULL OR (sa.status_ = 'TRUANT' AND sa.visit_flag_ = 0)))
  960. AND ((ta.sign_in_status_ IS NULL AND ta.sign_out_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NULL AND ta.sign_in_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NOT NULL AND ta.sign_in_status_ IS NOT NULL))
  961. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cssp.id_ IS NOT NULL
  962. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  963. <if test="classGroupIds != null and classGroupIds.size() > 0">
  964. AND cs.class_group_id_ IN
  965. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  966. #{classGroupId}
  967. </foreach>
  968. </if>
  969. <if test="organIds != null and organIds.size()>0">
  970. AND cs.organ_id_ IN
  971. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  972. #{organId}
  973. </foreach>
  974. </if>
  975. GROUP BY cs.id_) c
  976. </select>
  977. <select id="getOrganAttendanceError" resultType="map">
  978. SELECT
  979. c.organ_id_ AS 'key',
  980. COUNT(DISTINCT c.id_) AS 'value'
  981. FROM (SELECT cs.organ_id_,cs.id_ FROM course_schedule cs
  982. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  983. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  984. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
  985. WHERE ta.teacher_id_ = cs.actual_teacher_id_
  986. AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_ >= '2021-02-01' AND cs.pre_course_flag_ = 0
  987. AND (((ta.sign_in_status_ = 0 OR ta.sign_in_status_ IS NULL OR ta.sign_out_status_ = 0 OR ta.sign_out_status_ IS NULL) AND ta.dispose_content_ IS NULL) OR (sa.id_ IS NULL OR (sa.status_ = 'TRUANT' AND sa.visit_flag_ = 0)))
  988. AND ((ta.sign_in_status_ IS NULL AND ta.sign_out_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NULL AND ta.sign_in_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NOT NULL AND ta.sign_in_status_ IS NOT NULL))
  989. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cssp.id_ IS NOT NULL
  990. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  991. <if test="classGroupIds != null and classGroupIds.size() > 0">
  992. AND cs.class_group_id_ IN
  993. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  994. #{classGroupId}
  995. </foreach>
  996. </if>
  997. <if test="organIds != null and organIds.size()>0">
  998. AND cs.organ_id_ IN
  999. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1000. #{organId}
  1001. </foreach>
  1002. </if>
  1003. GROUP BY cs.id_) c GROUP BY c.organ_id_
  1004. </select>
  1005. <select id="getNoAttendance" resultType="int">
  1006. SELECT COUNT(DISTINCT cs.id_) FROM course_schedule cs
  1007. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  1008. WHERE ta.teacher_id_ = cs.actual_teacher_id_
  1009. AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_>='2021-02-01' AND cs.pre_course_flag_ = 0
  1010. AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.dispose_content_ IS NULL
  1011. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
  1012. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  1013. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1014. AND cs.class_group_id_ IN
  1015. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1016. #{classGroupId}
  1017. </foreach>
  1018. </if>
  1019. <if test="organIds!=null and organIds.size() > 0">
  1020. AND cs.organ_id_ IN
  1021. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1022. #{organId}
  1023. </foreach>
  1024. </if>
  1025. </select>
  1026. <select id="getOrganNoAttendance" resultType="map">
  1027. SELECT
  1028. cs.organ_id_ AS 'key',
  1029. COUNT(DISTINCT cs.id_) AS 'value'
  1030. FROM course_schedule cs
  1031. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  1032. WHERE ta.teacher_id_ = cs.actual_teacher_id_
  1033. AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_>='2021-02-01' AND cs.pre_course_flag_ = 0
  1034. AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.dispose_content_ IS NULL
  1035. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
  1036. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  1037. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1038. AND cs.class_group_id_ IN
  1039. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1040. #{classGroupId}
  1041. </foreach>
  1042. </if>
  1043. <if test="organIds!=null and organIds.size() > 0">
  1044. AND cs.organ_id_ IN
  1045. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1046. #{organId}
  1047. </foreach>
  1048. </if>
  1049. GROUP BY cs.organ_id_
  1050. </select>
  1051. <select id="queryTeacherLeave" resultType="int">
  1052. SELECT COUNT(DISTINCT tlr.id_) FROM teacher_leave_record tlr
  1053. LEFT JOIN teacher t ON t.id_ = tlr.user_id_
  1054. WHERE tlr.status_ = 'ING' AND DATE_FORMAT( tlr.create_time_, '%Y-%m-%d' ) >= #{startTime}
  1055. <if test="organIdsStr != null and organIdsStr != ''">
  1056. AND FIND_IN_SET(t.organ_id_,#{organIdsStr})
  1057. </if>
  1058. </select>
  1059. <select id="queryLowTeacherSalary" resultType="int">
  1060. SELECT COUNT(DISTINCT tcs.user_id_) FROM teacher_course_statistics tcs
  1061. LEFT JOIN teacher t ON t.id_ = tcs.user_id_
  1062. LEFT JOIN sys_user su ON su.id_ = tcs.user_id_
  1063. WHERE su.lock_flag_ = 0 AND su.del_flag_ = 0 AND t.job_nature_ = 'FULL_TIME' AND t.demission_date_ IS NULL
  1064. AND t.is_settlement_salary_ = 1
  1065. AND DATE_FORMAT(tcs.month_,'%Y-%m') = #{monthStr} AND tcs.low_salary = 1
  1066. <if test="organIdsStr != null and organIdsStr != ''">
  1067. AND FIND_IN_SET(tcs.organ_id_,#{organIdsStr})
  1068. </if>
  1069. </select>
  1070. <select id="queryOrganLowTeacherSalary" resultType="map">
  1071. SELECT
  1072. tcs.organ_id_ AS 'key',
  1073. COUNT(DISTINCT tcs.user_id_) AS 'value'
  1074. FROM teacher_course_statistics tcs
  1075. LEFT JOIN teacher t ON t.id_ = tcs.user_id_
  1076. LEFT JOIN sys_user su ON su.id_ = tcs.user_id_
  1077. WHERE su.lock_flag_ = 0 AND su.del_flag_ = 0 AND t.job_nature_ = 'FULL_TIME' AND t.demission_date_ IS NULL
  1078. AND t.is_settlement_salary_ = 1
  1079. AND DATE_FORMAT(tcs.month_,'%Y-%m') = #{monthStr} AND tcs.low_salary = 1
  1080. <if test="organIdsStr != null and organIdsStr != ''">
  1081. AND FIND_IN_SET(tcs.organ_id_,#{organIdsStr})
  1082. </if>
  1083. GROUP BY tcs.organ_id_
  1084. </select>
  1085. <select id="queryInspectionItem" resultType="int">
  1086. SELECT COUNT(DISTINCT ii.id_) FROM inspection_item ii
  1087. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1088. WHERE ii.times_ > planned_times_ AND ii.item_ = 'INSPECT' AND ii.memo_ =''
  1089. AND DATE_FORMAT(i.month_,'%Y-%m-%d') >= #{startTime}
  1090. <if test="organIdsStr != null and organIdsStr != ''">
  1091. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1092. </if>
  1093. <if test="userId != null">
  1094. AND ii.user_id_ = #{userId}
  1095. </if>
  1096. </select>
  1097. <select id="queryOrganInspectionItem" resultType="map">
  1098. SELECT
  1099. ii.organ_id_ AS 'key',
  1100. COUNT(DISTINCT ii.id_) AS 'value'
  1101. FROM inspection_item ii
  1102. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1103. WHERE ii.times_ > planned_times_ AND ii.item_ = 'INSPECT' AND ii.memo_ =''
  1104. AND DATE_FORMAT(i.month_,'%Y-%m-%d') >= #{startTime}
  1105. <if test="organIdsStr != null and organIdsStr != ''">
  1106. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1107. </if>
  1108. <if test="userId != null">
  1109. AND ii.user_id_ = #{userId}
  1110. </if>
  1111. GROUP BY ii.organ_id_
  1112. </select>
  1113. <select id="queryInspectionItemPlan" resultType="int">
  1114. SELECT COUNT(DISTINCT iip.id_) FROM inspection_item_plan iip
  1115. WHERE iip.status_ = 0 AND iip.memo_ = '' AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') &lt; DATE_FORMAT(NOW(),'%Y-%m-%d')
  1116. AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') >= #{startTime} AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  1117. <if test="organIdsStr != null and organIdsStr != ''">
  1118. AND FIND_IN_SET(iip.organ_id_,#{organIdsStr})
  1119. </if>
  1120. </select>
  1121. <select id="queryOrganInspectionItemPlan" resultType="map">
  1122. SELECT
  1123. iip.organ_id_ AS 'key',
  1124. COUNT(DISTINCT iip.id_) AS 'value'
  1125. FROM inspection_item_plan iip
  1126. WHERE iip.status_ = 0 AND iip.memo_ = '' AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') &lt; DATE_FORMAT(NOW(),'%Y-%m-%d')
  1127. AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') >= #{startTime} AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  1128. <if test="organIdsStr != null and organIdsStr != ''">
  1129. AND FIND_IN_SET(iip.organ_id_,#{organIdsStr})
  1130. </if>
  1131. GROUP BY iip.organ_id_
  1132. </select>
  1133. <select id="queryStudentVisit" resultType="int">
  1134. SELECT COUNT(DISTINCT ii.id_) FROM inspection_item ii
  1135. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1136. WHERE ii.item_ = 'VISIT' AND ii.memo_ =''
  1137. AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
  1138. WHERE sv.teacher_id_ = ii.user_id_ AND DATE_FORMAT(i.month_,'%Y-%m') = DATE_FORMAT(sv.visit_time_,'%Y-%m'))
  1139. AND i.month_ >= #{startTime} AND i.month_ &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  1140. <if test="organIdsStr != null and organIdsStr != ''">
  1141. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1142. </if>
  1143. <if test="userId != null">
  1144. AND ii.user_id_ = #{userId}
  1145. </if>
  1146. </select>
  1147. <select id="queryOrganStudentVisit" resultType="map">
  1148. SELECT
  1149. ii.organ_id_ AS 'key',
  1150. COUNT(DISTINCT ii.id_) AS 'value'
  1151. FROM inspection_item ii
  1152. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1153. WHERE ii.item_ = 'VISIT' AND ii.memo_ =''
  1154. AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
  1155. WHERE sv.teacher_id_ = ii.user_id_ AND DATE_FORMAT(i.month_,'%Y-%m') = DATE_FORMAT(sv.visit_time_,'%Y-%m'))
  1156. AND i.month_ >= #{startTime} AND i.month_ &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  1157. <if test="organIdsStr != null and organIdsStr != ''">
  1158. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1159. </if>
  1160. <if test="userId != null">
  1161. AND ii.user_id_ = #{userId}
  1162. </if>
  1163. GROUP BY ii.organ_id_
  1164. </select>
  1165. <select id="queryErrInspection" resultType="int">
  1166. SELECT
  1167. COUNT(id_)
  1168. FROM
  1169. inspection_item_plan
  1170. WHERE
  1171. conclusion_status_ = 1 AND memo_ = '' AND DATE_FORMAT(plan_start_,'%Y-%m-%d') >= #{startTime}
  1172. <if test="organIds!=null and organIds.size()>0">
  1173. AND organ_id_ IN
  1174. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1175. #{organId}
  1176. </foreach>
  1177. </if>
  1178. </select>
  1179. <select id="queryOrganErrInspection" resultType="map">
  1180. SELECT
  1181. organ_id_ AS 'key',
  1182. COUNT(id_) AS 'value'
  1183. FROM
  1184. inspection_item_plan
  1185. WHERE
  1186. conclusion_status_ = 1 AND memo_ = '' AND DATE_FORMAT(plan_start_,'%Y-%m-%d') >= #{startTime}
  1187. <if test="organIds!=null and organIds.size()>0">
  1188. AND organ_id_ IN
  1189. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1190. #{organId}
  1191. </foreach>
  1192. </if>
  1193. GROUP BY organ_id_
  1194. </select>
  1195. <select id="getNoClassMusicGroupStudentInfo" resultType="com.ym.mec.biz.dal.entity.IndexErrInfoDto">
  1196. SELECT
  1197. 'NO_CLASS_MUSIC_GROUP_STUDENT_INFO' errorType,
  1198. COUNT( DISTINCT sr.music_group_id_ ) num,
  1199. COUNT( sr.user_id_ ) num2
  1200. FROM
  1201. student_registration sr
  1202. LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
  1203. LEFT JOIN `subject` sub ON sr.actual_subject_id_=sub.id_
  1204. LEFT JOIN class_group_student_mapper cgsm ON cgsm.group_type_='MUSIC' AND cgsm.music_group_id_=sr.music_group_id_ AND cgsm.user_id_=sr.user_id_ AND cgsm.status_='NORMAL'
  1205. WHERE
  1206. sr.music_group_status_ = 'NORMAL'
  1207. AND mg.status_ = 'PROGRESS'
  1208. AND cgsm.id_ IS NULL
  1209. AND sub.parent_subject_id_!=24
  1210. <if test="educationUserId != null">
  1211. AND mg.educational_teacher_id_ = #{educationUserId}
  1212. </if>
  1213. <if test="organIds!=null and organIds.size()>0">
  1214. AND mg.organ_id_ IN
  1215. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1216. #{organId}
  1217. </foreach>
  1218. </if>
  1219. </select>
  1220. <select id="getOrganNoClassMusicGroupStudentNum" resultType="map">
  1221. SELECT
  1222. mg.organ_id_ AS 'key',
  1223. COUNT( sr.user_id_ ) AS 'value'
  1224. FROM
  1225. student_registration sr
  1226. LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
  1227. LEFT JOIN `subject` sub ON sr.actual_subject_id_=sub.id_
  1228. LEFT JOIN class_group_student_mapper cgsm ON cgsm.group_type_='MUSIC' AND cgsm.music_group_id_=sr.music_group_id_ AND cgsm.user_id_=sr.user_id_ AND cgsm.status_='NORMAL'
  1229. WHERE
  1230. sr.music_group_status_ = 'NORMAL'
  1231. AND mg.status_ = 'PROGRESS'
  1232. AND cgsm.id_ IS NULL
  1233. AND sub.parent_subject_id_!=24
  1234. <if test="educationUserId != null">
  1235. AND mg.educational_teacher_id_ = #{educationUserId}
  1236. </if>
  1237. <if test="organIds!=null and organIds.size()>0">
  1238. AND mg.organ_id_ IN
  1239. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1240. #{organId}
  1241. </foreach>
  1242. </if>
  1243. GROUP BY mg.organ_id_
  1244. </select>
  1245. <select id="getFinancePayData" resultMap="IndexBaseMonthData">
  1246. SELECT SUM(fe.amount_) total_num_,SUM(fe.amount_) activate_num_,SUM(fe.amount_) percent_,fe.organ_id_,#{dayStr} month_ FROM financial_expenditure fe
  1247. WHERE DATE_FORMAT(fe.create_time_,'%Y-%m-%d') = #{dayStr}
  1248. AND del_flag_ = 0 GROUP BY fe.organ_id_
  1249. </select>
  1250. <select id="getFinanceBalanceData" resultMap="IndexBaseMonthData">
  1251. SELECT spo.organ_id_,SUM(spo.balance_payment_amount_) total_num_,
  1252. SUM(spo.balance_payment_amount_) activate_num_,
  1253. SUM(spo.balance_payment_amount_) percent_,#{dayStr} month_
  1254. FROM student_payment_order spo
  1255. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr}
  1256. GROUP BY spo.organ_id_
  1257. </select>
  1258. <select id="getFinanceActualData" resultMap="IndexBaseMonthData">
  1259. SELECT spo.organ_id_,SUM(spo.actual_amount_) total_num_,
  1260. SUM(spo.actual_amount_) activate_num_,
  1261. SUM(spo.actual_amount_) percent_,#{dayStr} month_
  1262. FROM student_payment_order spo
  1263. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr}
  1264. GROUP BY spo.organ_id_
  1265. </select>
  1266. <select id="getFinancePayDataWithTimely" resultMap="IndexBaseMonthData">
  1267. SELECT SUM(fe.amount_) total_num_,SUM(fe.amount_) activate_num_,SUM(fe.amount_) percent_,fe.organ_id_,DATE_FORMAT(fe.create_time_,'%Y-%m-%d') month_
  1268. FROM financial_expenditure fe
  1269. WHERE DATE_FORMAT(fe.create_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1270. AND del_flag_ = 0
  1271. <if test="organIds!=null and organIds.size()>0">
  1272. AND fe.organ_id_ IN
  1273. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1274. #{organId}
  1275. </foreach>
  1276. </if>
  1277. GROUP BY DATE_FORMAT(fe.create_time_,'%Y-%m-%d')
  1278. </select>
  1279. <select id="getFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
  1280. SELECT spo.organ_id_,SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
  1281. SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
  1282. SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1283. FROM student_payment_order spo
  1284. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1285. <if test="organIds!=null and organIds.size()>0">
  1286. AND spo.organ_id_ IN
  1287. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1288. #{organId}
  1289. </foreach>
  1290. </if>
  1291. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1292. </select>
  1293. <select id="getFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
  1294. SELECT spo.organ_id_,SUM(spo.actual_amount_) total_num_,
  1295. SUM(spo.actual_amount_) activate_num_,
  1296. SUM(spo.actual_amount_) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1297. FROM student_payment_order spo
  1298. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1299. <if test="organIds!=null and organIds.size()>0">
  1300. AND spo.organ_id_ IN
  1301. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1302. #{organId}
  1303. </foreach>
  1304. </if>
  1305. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1306. </select>
  1307. <select id="getTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
  1308. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1309. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
  1310. SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1311. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
  1312. SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1313. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1314. FROM student_payment_order spo
  1315. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1316. <if test="organIds!=null and organIds.size()>0">
  1317. AND spo.organ_id_ IN
  1318. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1319. #{organId}
  1320. </foreach>
  1321. </if>
  1322. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1323. </select>
  1324. <select id="getTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1325. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1326. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
  1327. SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1328. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
  1329. SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1330. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1331. FROM student_payment_order spo
  1332. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1333. <if test="orderType != null">
  1334. AND FIND_IN_SET(spo.type_,#{orderType})
  1335. </if>
  1336. <if test="notOrderType != null">
  1337. AND spo.type_ NOT IN
  1338. <foreach collection="notOrderType" open="(" close=")" item="item" separator=",">
  1339. #{item}
  1340. </foreach>
  1341. </if>
  1342. <if test="organIds!=null and organIds.size()>0">
  1343. AND spo.organ_id_ IN
  1344. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1345. #{organId}
  1346. </foreach>
  1347. </if>
  1348. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1349. </select>
  1350. <select id="getVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1351. SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_ FROM (
  1352. SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1353. FROM student_payment_order spo
  1354. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1355. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1356. AND spo.type_ = 'DEGREE' AND spod.type_ IN ('THEORY_COURSE','VIP')
  1357. <if test="organIds!=null and organIds.size()>0">
  1358. AND spo.organ_id_ IN
  1359. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1360. #{organId}
  1361. </foreach>
  1362. </if>
  1363. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1364. UNION ALL
  1365. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1366. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
  1367. ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1368. FROM student_payment_order spo
  1369. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1370. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  1371. <if test="organIds!=null and organIds.size()>0">
  1372. AND spo.organ_id_ IN
  1373. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1374. #{organId}
  1375. </foreach>
  1376. </if>
  1377. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1378. )c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d')
  1379. </select>
  1380. <select id="getOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1381. SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_,c.type_ order_type_ FROM (
  1382. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1383. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
  1384. ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
  1385. FROM student_payment_order spo
  1386. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1387. AND spo.type_ NOT IN ('APPLY','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
  1388. <if test="organIds!=null and organIds.size()>0">
  1389. AND spo.organ_id_ IN
  1390. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1391. #{organId}
  1392. </foreach>
  1393. </if>
  1394. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d'),spo.type_
  1395. UNION ALL
  1396. SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
  1397. FROM student_payment_order spo
  1398. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1399. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1400. AND spo.type_ = 'DEGREE' AND spod.type_ = 'DEGREE_REGISTRATION'
  1401. <if test="organIds!=null and organIds.size()>0">
  1402. AND spo.organ_id_ IN
  1403. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1404. #{organId}
  1405. </foreach>
  1406. </if>
  1407. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d'),spo.type_
  1408. )c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d'),c.type_
  1409. </select>
  1410. <sql id="queryTeacherServeInfoCondition">
  1411. <where>
  1412. <if test="organIds!=null and organIds.size()>0">
  1413. AND tea.organ_id_ IN
  1414. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1415. #{organId}
  1416. </foreach>
  1417. </if>
  1418. <if test="monday!=null and monday!='' and sunday!=null and sunday!=''">
  1419. AND sees.monday_ BETWEEN #{monday} AND #{sunday}
  1420. </if>
  1421. <if test="teacherId!=null">
  1422. AND sees.teacher_id_ = #{teacherId}
  1423. </if>
  1424. <if test="reminded!=null and reminded==0">
  1425. AND NOT EXISTS (SELECT id_ FROM teacher_remind WHERE teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
  1426. </if>
  1427. <if test="reminded!=null and reminded==1">
  1428. AND EXISTS (SELECT id_ FROM teacher_remind WHERE teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
  1429. </if>
  1430. <if test="operatorId!=null">
  1431. AND EXISTS (SELECT id_ FROM teacher_remind WHERE operator_id_=#{operatorId} AND teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
  1432. </if>
  1433. <if test="jobNature!=null">
  1434. AND tea.job_nature_=#{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  1435. </if>
  1436. </where>
  1437. </sql>
  1438. <select id="countOrganTeacherServeInfo" resultType="map">
  1439. SELECT
  1440. e.organ_id_ AS 'key',
  1441. COUNT(1) AS 'value'
  1442. FROM (
  1443. SELECT
  1444. tea.organ_id_,
  1445. sees.id_
  1446. FROM
  1447. student_extracurricular_exercises_situation_ sees
  1448. LEFT JOIN teacher tea ON tea.id_=sees.teacher_id_
  1449. <if test="unDone!=null and unDone==1">
  1450. LEFT JOIN teacher_remind tm ON sees.monday_=tm.monday_ AND sees.teacher_id_=tm.teacher_id_
  1451. </if>
  1452. <include refid="queryTeacherServeInfoCondition" />
  1453. GROUP BY sees.monday_,sees.sunday_,sees.teacher_id_
  1454. <if test="unDone!=null">
  1455. HAVING
  1456. <if test="unDone==1">
  1457. SUM( sees.expect_exercises_num_-sees.not_over_course_num_ ) &gt; SUM( sees.actual_exercises_num_ )
  1458. </if>
  1459. <if test="unDone==0">
  1460. SUM( sees.expect_exercises_num_-sees.not_over_course_num_ ) &lt;= SUM( sees.actual_exercises_num_ )
  1461. </if>
  1462. </if>
  1463. ORDER BY sees.monday_,sees.sunday_,sees.teacher_id_
  1464. ) e GROUP BY e.organ_id_
  1465. </select>
  1466. <select id="countStudentErrorLeave" resultType="java.lang.Integer">
  1467. SELECT COUNT(DISTINCT c.user_id_) FROM (
  1468. SELECT sa.user_id_ FROM student_attendance sa
  1469. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1470. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{format} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1471. <if test="organIdList != null and organIdList.size > 0">
  1472. AND cs.organ_id_ IN
  1473. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  1474. #{item}
  1475. </foreach>
  1476. </if>
  1477. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1478. AND cs.class_group_id_ IN
  1479. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1480. #{classGroupId}
  1481. </foreach>
  1482. </if>
  1483. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1484. HAVING COUNT(sa.id_) >= #{studentErrorLeaveNum} AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_)) c
  1485. </select>
  1486. <select id="countOrganStudentErrorLeave" resultType="map">
  1487. SELECT c.organ_id_ 'key',COUNT(c.user_id_) 'value' FROM (
  1488. SELECT sa.user_id_,cs.organ_id_ FROM student_attendance sa
  1489. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1490. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= '2021-11' AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1491. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1492. AND cs.class_group_id_ IN
  1493. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1494. #{classGroupId}
  1495. </foreach>
  1496. </if>
  1497. <if test="organIds != null and organIds.size > 0">
  1498. AND cs.organ_id_ IN
  1499. <foreach collection="organIds" open="(" close=")" item="item" separator=",">
  1500. #{item}
  1501. </foreach>
  1502. </if>
  1503. GROUP BY sa.user_id_
  1504. HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_))c
  1505. GROUP BY c.organ_id_
  1506. </select>
  1507. <select id="countStudentErrorLeave1" resultType="java.lang.Integer">
  1508. SELECT COUNT(DISTINCT c.user_id_) FROM (
  1509. SELECT sa.user_id_ FROM student_attendance sa
  1510. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1511. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1512. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1513. <if test="organId != null">
  1514. AND FIND_IN_SET(cs.organ_id_,#{organId})
  1515. </if>
  1516. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1517. AND cs.class_group_id_ IN
  1518. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1519. #{classGroupId}
  1520. </foreach>
  1521. </if>
  1522. <if test="search != null and search != ''">
  1523. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1524. </if>
  1525. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1526. HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_)) c
  1527. </select>
  1528. <resultMap id="StudentErrorLeaveDto" type="com.ym.mec.biz.dal.dto.StudentErrorLeaveDto">
  1529. <result property="currentNum" column="current_num_"/>
  1530. <result property="totalNum" column="total_num_"/>
  1531. <result property="userId" column="user_id_"/>
  1532. <result property="studentName" column="username_"/>
  1533. <result property="phone" column="phone_"/>
  1534. <result property="organId" column="organ_id_"/>
  1535. <result property="organName" column="organ_name_"/>
  1536. </resultMap>
  1537. <select id="queryStudentErrorLeave" resultMap="StudentErrorLeaveDto">
  1538. SELECT organ_id_,organ_name_,user_id_,username_,phone_,current_num_,class_date_
  1539. FROM (SELECT cs.organ_id_,o.name_ organ_name_,sa.user_id_,su.username_,su.phone_,
  1540. COUNT(sa.id_) current_num_,cs.class_date_
  1541. FROM student_attendance sa
  1542. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1543. LEFT JOIN organization o ON o.id_ = cs.organ_id_
  1544. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1545. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1546. <if test="organId != null">
  1547. AND FIND_IN_SET(cs.organ_id_,#{organId})
  1548. </if>
  1549. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1550. AND cs.class_group_id_ IN
  1551. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1552. #{classGroupId}
  1553. </foreach>
  1554. </if>
  1555. <if test="search != null and search != ''">
  1556. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1557. </if>
  1558. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m') HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_) ORDER BY cs.class_date_ DESC)c
  1559. GROUP BY c.user_id_
  1560. <include refid="global.limit"/>
  1561. </select>
  1562. <select id="countStudentLeaveCourseList" resultType="java.lang.Integer">
  1563. SELECT COUNT(sa.id_)
  1564. FROM student_attendance sa
  1565. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1566. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  1567. <include refid="queryStudentLeaveCourseListSql"/>
  1568. </select>
  1569. <sql id="queryStudentLeaveCourseListSql">
  1570. <where>
  1571. sa.user_id_ = #{userId} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1572. <if test="search != null and search != ''">
  1573. AND (cs.id_ = #{search} OR cs.actual_teacher_id_ = #{search} OR su.real_name_ LIKE CONCAT('%',#{search},'%'))
  1574. </if>
  1575. <if test="leaveVisitFlag != null">
  1576. AND sa.leave_visit_flag_ = #{leaveVisitFlag}
  1577. </if>
  1578. <if test="courseType != null">
  1579. AND cs.type_ = #{courseType}
  1580. </if>
  1581. </where>
  1582. </sql>
  1583. <resultMap id="StudentLeaveCourseDto" type="com.ym.mec.biz.dal.dto.StudentLeaveCourseDto">
  1584. <result property="leaveVisitFlag" column="leave_visit_flag_"/>
  1585. <result property="classDate" column="class_date_"/>
  1586. <result property="startClassTime" column="start_class_time_"/>
  1587. <result property="endClassTime" column="end_class_time_"/>
  1588. <result property="teacherName" column="teacher_name_"/>
  1589. <result property="actualTeacherId" column="actual_teacher_id_"/>
  1590. <result property="courseScheduleId" column="course_schedule_id_"/>
  1591. <result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1592. <result property="courseScheduleType" column="type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1593. <result property="courseName" column="name_"/>
  1594. <result property="groupId" column="music_group_id_"/>
  1595. </resultMap>
  1596. <select id="queryStudentLeaveCourseList" resultMap="StudentLeaveCourseDto">
  1597. SELECT sa.leave_visit_flag_,cs.class_date_,cs.start_class_time_,
  1598. cs.end_class_time_,su.real_name_ teacher_name_,cs.actual_teacher_id_,
  1599. sa.course_schedule_id_,cs.group_type_,cs.type_,cs.name_,cs.music_group_id_
  1600. FROM student_attendance sa
  1601. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1602. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  1603. <include refid="queryStudentLeaveCourseListSql"/>
  1604. ORDER BY cs.class_date_ DESC,cs.start_class_time_ DESC
  1605. <include refid="global.limit"/>
  1606. </select>
  1607. <select id="getStudentErrorLeaveNumMap" resultType="java.util.Map">
  1608. SELECT user_id_ 'key',SUM(total_num_) 'value'
  1609. FROM (SELECT sa.user_id_,COUNT(sa.id_) total_num_
  1610. FROM student_attendance sa
  1611. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1612. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1613. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{totalMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1614. <if test="organId != null">
  1615. AND FIND_IN_SET(cs.organ_id_,#{organId})
  1616. </if>
  1617. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1618. AND cs.class_group_id_ IN
  1619. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1620. #{classGroupId}
  1621. </foreach>
  1622. </if>
  1623. <if test="search != null and search != ''">
  1624. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1625. </if>
  1626. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m') HAVING COUNT(sa.id_) >= #{studentErrorLeaveNum} AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_) ORDER BY cs.class_date_ DESC)c
  1627. GROUP BY c.user_id_
  1628. </select>
  1629. <select id="getOrgansStudentNumData" resultMap="IndexBaseMonthData">
  1630. SELECT
  1631. t.organ_id_,
  1632. #{dayStr} month_,
  1633. COUNT( DISTINCT t.user_id_ ) total_num_,
  1634. COUNT( DISTINCT t.user_id_ ) activate_num_,
  1635. COUNT( DISTINCT t.user_id_ ) percent_
  1636. FROM((
  1637. SELECT
  1638. su.organ_id_,
  1639. sr.user_id_
  1640. FROM
  1641. student_registration sr
  1642. LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
  1643. LEFT JOIN sys_user su ON sr.user_id_ = su.id_
  1644. WHERE
  1645. su.del_flag_ = 0
  1646. AND mg.status_='PROGRESS'
  1647. AND sr.music_group_status_ = 'NORMAL'
  1648. <if test="dayStr!=null and dayStr!=''">
  1649. AND DATE(sr.create_time_)&lt;= #{dayStr}
  1650. </if>)
  1651. UNION ALL
  1652. (
  1653. SELECT
  1654. su.organ_id_,
  1655. cssp.user_id_
  1656. FROM
  1657. course_schedule_student_payment cssp
  1658. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  1659. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  1660. WHERE
  1661. cssp.group_type_ IN ( 'VIP', 'PRACTICE' )
  1662. AND cs.status_ = 'NOT_START'
  1663. AND su.del_flag_ = 0
  1664. <if test="dayStr!=null and dayStr!=''">
  1665. AND DATE(cssp.create_time_)&lt;= #{dayStr}
  1666. </if>)) t
  1667. WHERE t.user_id_ NOT IN (SELECT user_id_ FROM student WHERE subject_id_list_ REGEXP '21|25|26|27|28|29')
  1668. GROUP BY t.organ_id_
  1669. </select>
  1670. <select id="getMemberStudentNumData" resultMap="IndexBaseMonthData">
  1671. SELECT
  1672. su.organ_id_,
  1673. #{dayStr} month_,
  1674. COUNT(DISTINCT cto.student_id_) total_num_,
  1675. COUNT(DISTINCT cto.student_id_) activate_num_,
  1676. COUNT(DISTINCT cto.student_id_) percent_
  1677. FROM cloud_teacher_order cto
  1678. LEFT JOIN sys_user su ON cto.student_id_=su.id_
  1679. WHERE su.del_flag_=0 AND cto.status_ IN (1,2)
  1680. <if test="dayStr!=null and dayStr!=''">
  1681. AND DATE(cto.create_time_)&lt;= #{dayStr}
  1682. </if>
  1683. GROUP BY su.organ_id_
  1684. </select>
  1685. <select id="getNewMemberStudentNumData" resultMap="IndexBaseMonthData">
  1686. SELECT
  1687. su.organ_id_,
  1688. #{dayStr} month_,
  1689. COUNT(DISTINCT cto.student_id_) total_num_,
  1690. COUNT(DISTINCT cto.student_id_) activate_num_,
  1691. COUNT(DISTINCT cto.student_id_) percent_
  1692. FROM cloud_teacher_order cto
  1693. LEFT JOIN sys_user su ON cto.student_id_=su.id_
  1694. WHERE su.del_flag_=0 AND cto.status_ IN (1,2)
  1695. <if test="dayStr!=null and dayStr!=''">
  1696. AND DATE(cto.create_time_)= #{dayStr}
  1697. </if>
  1698. GROUP BY su.organ_id_
  1699. </select>
  1700. <select id="getExperienceMemberStudentNumData" resultMap="IndexBaseMonthData">
  1701. SELECT
  1702. su.organ_id_,
  1703. #{dayStr} month_,
  1704. COUNT(DISTINCT stu.user_id_) total_num_,
  1705. COUNT(DISTINCT stu.user_id_) activate_num_,
  1706. COUNT(DISTINCT stu.user_id_) percent_
  1707. FROM student stu
  1708. LEFT JOIN cloud_teacher_order cto ON stu.user_id_=cto.student_id_
  1709. LEFT JOIN sys_user su ON su.id_=stu.user_id_
  1710. WHERE su.del_flag_=0 AND stu.experience_member_rank_setting_id_ IS NOT NULL AND (cto.id_ IS NULL OR cto.status_ NOT IN (1, 2))
  1711. <if test="dayStr!=null and dayStr!=''">
  1712. AND DATE(stu.experience_membership_start_time_)&lt;= #{dayStr}
  1713. </if>
  1714. GROUP BY su.organ_id_
  1715. </select>
  1716. <select id="getCloudStudyDayUseStudentNumData" resultMap="IndexBaseMonthData">
  1717. SELECT
  1718. su.organ_id_,
  1719. #{dayStr} month_,
  1720. COUNT(DISTINCT smcr.user_id_) total_num_,
  1721. COUNT(DISTINCT smcr.user_id_) activate_num_,
  1722. COUNT(DISTINCT smcr.user_id_) percent_
  1723. FROM sys_music_compare_record smcr
  1724. LEFT JOIN sys_user su ON smcr.user_id_=su.id_
  1725. LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
  1726. WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL
  1727. <if test="dayStr!=null and dayStr!=''">
  1728. AND DATE(smcr.create_time_)= #{dayStr}
  1729. </if>
  1730. GROUP BY su.organ_id_
  1731. </select>
  1732. <select id="getCloudStudyLivelyStudentNumData" resultMap="IndexBaseMonthData">
  1733. SELECT
  1734. t.organ_id_,
  1735. #{dayStr} month_,
  1736. COUNT(user_id_) total_num_,
  1737. COUNT(user_id_) activate_num_,
  1738. COUNT(user_id_) percent_
  1739. FROM (SELECT
  1740. su.organ_id_,
  1741. smcr.user_id_,
  1742. COUNT(DISTINCT(CASE WHEN DATEDIFF(NOW(), smcr.create_time_)&lt;=15 THEN DATE_FORMAT(smcr.create_time_, '%Y-%m-%d') ELSE NULL END)) days
  1743. FROM sys_music_compare_record smcr
  1744. LEFT JOIN sys_user su ON smcr.user_id_=su.id_
  1745. LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
  1746. WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL
  1747. <if test="dayStr!=null and dayStr!=''">
  1748. AND DATE(smcr.create_time_) &lt;= #{dayStr}
  1749. </if>
  1750. GROUP BY smcr.user_id_) t WHERE t.days>=5
  1751. GROUP BY t.organ_id_
  1752. </select>
  1753. <select id="getCloudStudyNewStudentNumData" resultMap="IndexBaseMonthData">
  1754. SELECT
  1755. organ_id_,
  1756. #{dayStr} month_,
  1757. COUNT( DISTINCT user_id_ ) total_num_,
  1758. COUNT( DISTINCT user_id_ ) activate_num_,
  1759. COUNT( DISTINCT user_id_ ) percent_
  1760. FROM
  1761. (
  1762. SELECT
  1763. su.organ_id_,
  1764. smcr.user_id_
  1765. FROM
  1766. sys_music_compare_record smcr
  1767. LEFT JOIN sys_user su ON smcr.user_id_ = su.id_
  1768. WHERE su.del_flag_ = 0
  1769. GROUP BY user_id_
  1770. HAVING MIN(DATE( smcr.create_time_ ))= #{dayStr}) t
  1771. GROUP BY t.organ_id_
  1772. </select>
  1773. <resultMap id="CloudTeacherActiveTargetDto" type="com.ym.mec.biz.dal.dto.CloudTeacherActiveTargetDto">
  1774. <result property="organId" column="organ_id_"/>
  1775. <result property="organName" column="organ_name_"/>
  1776. <result property="totalNum" column="total_num_"/>
  1777. <result property="buyAmount" column="buy_amount_"/>
  1778. <result property="buyNum" column="buy_num_"/>
  1779. <result property="targetAmount" column="target_amount_"/>
  1780. <result property="targetNum" column="target_num_"/>
  1781. </resultMap>
  1782. <select id="countCloudTeacherActive" resultMap="CloudTeacherActiveTargetDto">
  1783. SELECT o.name_ organ_name_,o.id_ organ_id_,CASE WHEN SUM(cto.amount_) IS NULL THEN 0 ELSE SUM(cto.amount_) END buy_amount_,
  1784. COUNT(DISTINCT cto.student_id_) buy_num_
  1785. FROM student s
  1786. LEFT JOIN cloud_teacher_order cto ON cto.student_id_ = s.user_id_ AND cto.status_ != 0 AND cto.active_remark_ = '202109'
  1787. LEFT JOIN sys_user su ON su.id_ = s.user_id_
  1788. LEFT JOIN organization o ON o.id_ = su.organ_id_
  1789. WHERE 1=1
  1790. <if test="organIdList != null and organIdList.size > 0">
  1791. AND su.organ_id_ IN
  1792. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  1793. #{item}
  1794. </foreach>
  1795. </if>
  1796. GROUP BY su.organ_id_
  1797. </select>
  1798. <select id="countTotalStudentNum" resultType="java.util.Map">
  1799. SELECT su.organ_id_ 'key',COUNT(DISTINCT s.user_id_) 'value' FROM student s
  1800. LEFT JOIN sys_user su ON su.id_ = s.user_id_
  1801. WHERE s.count_flag_ = 1
  1802. GROUP BY su.organ_id_
  1803. </select>
  1804. </mapper>