IndexBaseMonthDataMapper.xml 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164
  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="organ_name_" property="organName" />
  14. <result column="total_num_" property="totalNum" />
  15. <result column="activate_num_" property="activateNum" />
  16. <result column="percent_" property="percent" />
  17. <result column="data_type_" property="dataType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  18. <result column="extend_info_" property="extendInfo"/>
  19. <result column="order_type_" property="orderType"/>
  20. <result column="create_time_" property="createTime" />
  21. <result column="update_time_" property="updateTime" />
  22. <result column="tenant_id_" property="tenantId" />
  23. </resultMap>
  24. <!-- 根据主键查询一条记录 -->
  25. <select id="get" resultMap="IndexBaseMonthData" >
  26. SELECT * FROM index_base_month_data WHERE id_ = #{id}
  27. </select>
  28. <!-- 全查询 -->
  29. <select id="findAll" resultMap="IndexBaseMonthData">
  30. SELECT * FROM index_base_month_data where tenant_id_ = #{tenantId} ORDER BY id_
  31. </select>
  32. <select id="getOrganDataWithDayAndDataType" resultMap="IndexBaseMonthData">
  33. SELECT * FROM index_base_month_data WHERE organ_id_=#{organId} AND month_ = #{day}
  34. AND data_type_=#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} ORDER BY month_ DESC LIMIT 1;
  35. </select>
  36. <!-- 向数据库增加一条记录 -->
  37. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  38. <!--
  39. <selectKey resultClass="int" keyProperty="id" >
  40. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  41. </selectKey>
  42. -->
  43. INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,extend_info_,create_time_,update_time_,tenant_id_)
  44. VALUES(#{month},#{organId},#{totalNum},#{activateNum},#{percent},#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{extendInfo},NOW(),NOW(),#{tenantId})
  45. </insert>
  46. <insert id="batchInsertWithDataType" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  47. INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,extend_info_,create_time_,update_time_,tenant_id_)
  48. VALUES
  49. <foreach collection="datas" item="data" separator=",">
  50. (#{data.month},#{data.organId},#{data.totalNum},#{data.activateNum},#{data.percent},
  51. #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.extendInfo},NOW(),NOW(),#{data.tenantId})
  52. </foreach>
  53. </insert>
  54. <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  55. INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,extend_info_,create_time_,update_time_,tenant_id_)
  56. VALUES
  57. <foreach collection="datas" item="data" separator=",">
  58. (#{data.month},#{data.organId},#{data.totalNum},#{data.activateNum},#{data.percent},
  59. #{data.dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.extendInfo},NOW(),NOW(),#{tenantId})
  60. </foreach>
  61. </insert>
  62. <!-- 根据主键查询一条记录 -->
  63. <update id="update" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData">
  64. UPDATE index_base_month_data
  65. <set>
  66. <if test="organId != null">
  67. organ_id_ = #{organId},
  68. </if>
  69. <if test="id != null">
  70. id_ = #{id},
  71. </if>
  72. <if test="activateNum != null">
  73. activate_num_ = #{activateNum},
  74. </if>
  75. <if test="totalNum != null">
  76. total_num_ = #{totalNum},
  77. </if>
  78. <if test="percent != null">
  79. percent_ = #{percent},
  80. </if>
  81. <if test="month != null">
  82. month_ = #{month},
  83. </if>
  84. <if test="dataType != null">
  85. data_type_ = #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  86. </if>
  87. <if test="extendInfo != null">
  88. extend_info_ = #{extendInfo},
  89. </if>
  90. update_time_ = NOW()
  91. </set>
  92. WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  93. </update>
  94. <!-- 根据主键删除一条记录 -->
  95. <delete id="delete" >
  96. DELETE FROM index_base_month_data WHERE id_ = #{id}
  97. </delete>
  98. <delete id="deleteWithMonthAndType">
  99. DELETE FROM index_base_month_data
  100. WHERE tenant_id_ = #{tenantId} AND month_ IN
  101. <foreach collection="months" item="month" open="(" close=")" separator=",">
  102. #{month}
  103. </foreach>
  104. <if test="dataType!=null">
  105. AND data_type_=#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  106. </if>
  107. </delete>
  108. <!-- 分页查询 -->
  109. <select id="queryPage" resultMap="IndexBaseMonthData" parameterType="map">
  110. SELECT * FROM index_base_month_data where tenant_id_ = #{tenantId} ORDER BY id_ <include refid="global.limit"/>
  111. </select>
  112. <!-- 查询当前表的总记录数 -->
  113. <select id="queryCount" resultType="int">
  114. SELECT COUNT(*) FROM index_base_month_data where tenant_id_ = #{tenantId}
  115. </select>
  116. <select id="getIndexBaseData" resultMap="IndexBaseMonthData">
  117. SELECT
  118. month_,data_type_,SUM(total_num_) total_num_,SUM(activate_num_) activate_num_,SUM(percent_) percent_
  119. FROM index_base_month_data
  120. <where>
  121. tenant_id_ = #{tenantId}
  122. <if test="dataTypes!=null and dataTypes.size()>0">
  123. AND data_type_ IN
  124. <foreach collection="dataTypes" item="dataType" open="(" close=")" separator=",">
  125. #{dataType}
  126. </foreach>
  127. </if>
  128. <if test="organIds!=null and organIds.size()>0">
  129. AND organ_id_ IN
  130. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  131. #{organId}
  132. </foreach>
  133. </if>
  134. <if test="startMonth!=null and startMonth!=''">
  135. AND month_ BETWEEN #{startMonth} AND #{endMonth}
  136. </if>
  137. </where>
  138. GROUP BY month_,data_type_
  139. </select>
  140. <select id="getAllIndexBaseData" resultMap="IndexBaseMonthData">
  141. SELECT
  142. *
  143. FROM index_base_month_data
  144. <where>
  145. tenant_id_ = #{tenantId}
  146. <if test="dataTypes!=null and dataTypes.size()>0">
  147. AND data_type_ IN
  148. <foreach collection="dataTypes" item="dataType" open="(" close=")" separator=",">
  149. #{dataType}
  150. </foreach>
  151. </if>
  152. <if test="organIds!=null and organIds.size()>0">
  153. AND organ_id_ IN
  154. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  155. #{organId}
  156. </foreach>
  157. </if>
  158. <if test="startMonth!=null and startMonth!=''">
  159. AND month_&gt;=#{startMonth}
  160. </if>
  161. <if test="endMonth!=null and endMonth!=''">
  162. AND month_&lt;=#{endMonth}
  163. </if>
  164. </where>
  165. </select>
  166. <select id="getVipCourseDataList" resultMap="IndexBaseMonthData">
  167. SELECT
  168. month_,
  169. organ_id_,
  170. data_type_,
  171. extend_info_
  172. FROM index_base_month_data
  173. FORCE INDEX(data_type_, month_)
  174. <where>
  175. tenant_id_ = #{tenantId}
  176. <if test="dataTypes!=null and dataTypes.size()>0">
  177. AND data_type_ IN
  178. <foreach collection="dataTypes" item="dataType" open="(" close=")" separator=",">
  179. #{dataType}
  180. </foreach>
  181. </if>
  182. <if test="organIds!=null and organIds.size()>0">
  183. AND organ_id_ IN
  184. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  185. #{organId}
  186. </foreach>
  187. </if>
  188. <if test="startMonth!=null and startMonth!=''">
  189. AND month_ BETWEEN #{startMonth} AND #{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 tenant_id_ = #{tenantId}
  199. AND data_type_ = #{dataType}
  200. AND month_&gt;=#{day}
  201. </select>
  202. <select id="getStudentSignUpData" resultMap="IndexBaseMonthData">
  203. SELECT
  204. su.organ_id_,su.tenant_id_,
  205. #{dayStr} month_,
  206. COUNT( su.id_ ) total_num_,
  207. COUNT(CASE WHEN su.password_ IS NOT NULL THEN su.id_ ELSE NULL END) activate_num_,
  208. TRUNCATE(COUNT(CASE WHEN su.password_ IS NOT NULL THEN su.id_ ELSE NULL END)/COUNT( su.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' ) and sr.tenant_id_ = #{tenantId}
  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 and cs.tenant_id_ = #{tenantId} AND cs.is_lock_ = 0
  229. AND ( cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_ )
  230. AND cssp.group_type_ IN ('VIP', 'PRACTICE')
  231. AND DATE_FORMAT(cssp.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  232. AND cs.class_date_ &gt;= #{courseStartDay}
  233. )) u
  234. LEFT JOIN student st ON u.user_id_ = st.user_id_
  235. LEFT JOIN sys_user su ON st.user_id_ = su.id_
  236. WHERE
  237. su.del_flag_ = '0' and su.tenant_id_ = #{tenantId}
  238. GROUP BY su.organ_id_
  239. ORDER BY su.organ_id_;
  240. </select>
  241. <select id="getStudentRegistrationData" resultMap="IndexBaseMonthData">
  242. SELECT
  243. su.organ_id_,su.tenant_id_,
  244. #{dayStr} month_,
  245. COUNT( DISTINCT stu.user_id_ ) total_num_,
  246. COUNT( DISTINCT stu.user_id_ ) activate_num_,
  247. COUNT( DISTINCT stu.user_id_ ) percent_
  248. FROM
  249. student stu
  250. LEFT JOIN sys_user su ON stu.user_id_=su.id_
  251. WHERE
  252. su.del_flag_='0' and su.tenant_id_ = #{tenantId}
  253. AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  254. GROUP BY su.organ_id_
  255. ORDER BY su.organ_id_;
  256. </select>
  257. <select id="getAddStudentRegistrationData" resultMap="IndexBaseMonthData">
  258. SELECT
  259. su.organ_id_,stu.tenant_id_,
  260. #{dayStr} month_,
  261. COUNT( DISTINCT stu.user_id_ ) total_num_,
  262. COUNT( DISTINCT stu.user_id_ ) activate_num_,
  263. COUNT( DISTINCT stu.user_id_ ) percent_
  264. FROM
  265. student stu
  266. LEFT JOIN sys_user su ON stu.user_id_=su.id_
  267. WHERE su.del_flag_='0' and su.tenant_id_ = #{tenantId}
  268. AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')=#{dayStr}
  269. GROUP BY su.organ_id_
  270. ORDER BY su.organ_id_;
  271. </select>
  272. <select id="getChargeStudentChangeData" resultMap="IndexBaseMonthData">
  273. SELECT
  274. su.organ_id_,su.tenant_id_,
  275. #{dayStr} month_,
  276. COUNT( DISTINCT stu.user_id_ ) total_num_,
  277. COUNT( DISTINCT (CASE WHEN DATE_FORMAT( spo.create_time_, '%Y-%m-%d' ) &lt;= #{dayStr} THEN spo.user_id_ ELSE NULL END) ) activate_num_,
  278. 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_
  279. FROM
  280. student stu
  281. LEFT JOIN sys_user su ON stu.user_id_=su.id_
  282. LEFT JOIN student_payment_order spo ON stu.user_id_=spo.user_id_ AND status_='SUCCESS' AND actual_amount_>0
  283. WHERE
  284. su.del_flag_='0' and su.tenant_id_ = #{tenantId}
  285. AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  286. GROUP BY su.organ_id_
  287. ORDER BY su.organ_id_;
  288. </select>
  289. <select id="getHomeworkData" resultMap="IndexBaseMonthData">
  290. SELECT
  291. su.organ_id_,su.tenant_id_,
  292. sees.monday_ month_,
  293. <choose>
  294. <when test="type == 'submit'">
  295. SUM(sees.actual_exercises_num_) total_num_,
  296. SUM(sees.exercises_reply_num_) activate_num_,
  297. TRUNCATE(SUM(sees.exercises_reply_num_)/SUM(sees.actual_exercises_num_)*100, 2) percent_
  298. </when>
  299. <when test="type == 'comment'">
  300. SUM(sees.exercises_reply_num_) total_num_,
  301. SUM(sees.exercises_message_num_) activate_num_,
  302. TRUNCATE(SUM(sees.exercises_message_num_)/SUM(sees.exercises_reply_num_)*100, 2) percent_
  303. </when>
  304. <otherwise>
  305. SUM(sees.expect_exercises_num_-sees.not_over_course_num_) total_num_,
  306. SUM(sees.actual_exercises_num_) activate_num_,
  307. TRUNCATE(SUM(sees.actual_exercises_num_)/SUM(sees.expect_exercises_num_-sees.not_over_course_num_)*100, 2) percent_
  308. </otherwise>
  309. </choose>
  310. FROM student_extracurricular_exercises_situation_ sees
  311. LEFT JOIN sys_user su ON sees.student_id_=su.id_
  312. LEFT JOIN teacher tea ON sees.teacher_id_=tea.id_
  313. WHERE su.del_flag_='0' and sees.tenant_id_ = #{tenantId}
  314. AND tea.job_nature_='FULL_TIME'
  315. AND su.organ_id_ IS NOT NULL
  316. AND DATE_FORMAT(sees.monday_, '%Y-%m-%d')&lt;=#{dayStr}
  317. AND DATE_FORMAT(sees.sunday_, '%Y-%m-%d')&gt;=#{dayStr}
  318. GROUP BY su.organ_id_
  319. ORDER BY su.organ_id_
  320. </select>
  321. <select id="getSchoolData" resultMap="IndexBaseMonthData">
  322. SELECT
  323. mg.organ_id_,mg.tenant_id_,
  324. #{dayStr} month_,
  325. COUNT( DISTINCT mg.cooperation_organ_id_ ) total_num_,
  326. COUNT( DISTINCT mg.cooperation_organ_id_ ) activate_num_,
  327. COUNT( DISTINCT mg.cooperation_organ_id_ ) percent_
  328. FROM
  329. music_group mg
  330. WHERE
  331. mg.del_flag_ = 0 and mg.tenant_id_ = #{tenantId}
  332. AND mg.organ_id_ IS NOT NULL
  333. AND mg.status_ = 'PROGRESS'
  334. AND DATE_FORMAT(mg.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  335. GROUP BY
  336. mg.organ_id_
  337. ORDER BY
  338. mg.organ_id_;
  339. </select>
  340. <select id="getMusicData" resultMap="IndexBaseMonthData">
  341. SELECT
  342. organ_id_,tenant_id_,
  343. #{dayStr} month_,
  344. COUNT( id_ ) total_num_,
  345. COUNT( id_ ) activate_num_,
  346. COUNT( id_ ) percent_
  347. FROM
  348. music_group
  349. WHERE
  350. del_flag_ = 0 and tenant_id_ = #{tenantId}
  351. AND status_ = 'PROGRESS'
  352. AND organ_id_ IS NOT NULL
  353. <if test="dayStr!=null and dayStr!=''">
  354. AND DATE_FORMAT(create_time_, '%Y-%m-%d') &lt;= #{dayStr}
  355. </if>
  356. GROUP BY
  357. organ_id_
  358. ORDER BY
  359. organ_id_;
  360. </select>
  361. <select id="getMusicStudentData" resultMap="IndexBaseMonthData">
  362. SELECT
  363. mg.organ_id_,sr.tenant_id_,
  364. #{dayStr} month_,
  365. COUNT( DISTINCT sr.user_id_ ) total_num_,
  366. COUNT( DISTINCT sr.user_id_ ) activate_num_,
  367. COUNT( DISTINCT sr.user_id_ ) percent_
  368. FROM student_registration sr
  369. LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
  370. WHERE
  371. mg.del_flag_ = 0 and mg.tenant_id_ = #{tenantId}
  372. AND mg.organ_id_ IS NOT NULL
  373. AND mg.status_ = 'PROGRESS'
  374. <if test="type==null">
  375. AND sr.music_group_status_='NORMAL'
  376. </if>
  377. <if test="type!=null and type=='QUIT'">
  378. AND sr.music_group_status_='QUIT'
  379. AND DATE_FORMAT(sr.create_time_, '%Y-%m') &gt;= CONCAT(DATE_FORMAT(NOW(), '%Y'), '-01')
  380. </if>
  381. <if test="type!=null and type=='ADD'">
  382. AND sr.music_group_status_='NORMAL'
  383. AND DATE_FORMAT(sr.create_time_, '%Y-%m') &gt;= CONCAT(DATE_FORMAT(NOW(), '%Y'), '-01')
  384. </if>
  385. <if test="dayStr!=null and dayStr!=''">
  386. AND DATE_FORMAT(sr.create_time_, '%Y-%m-%d') &lt;= #{dayStr}
  387. </if>
  388. GROUP BY
  389. mg.organ_id_
  390. ORDER BY
  391. mg.organ_id_;
  392. </select>
  393. <select id="getTeacherData" resultMap="IndexBaseMonthData">
  394. SELECT
  395. t.organ_id_,t.tenant_id_,
  396. #{dayStr} month_,
  397. COUNT( t.id_ ) total_num_,
  398. COUNT( t.id_ ) activate_num_,
  399. COUNT( t.id_ ) percent_
  400. FROM
  401. teacher t
  402. LEFT JOIN sys_user su ON su.id_ = t.id_
  403. WHERE
  404. su.del_flag_ = '0' and t.tenant_id_ = #{tenantId}
  405. AND (t.demission_date_ IS NULl OR DATE_FORMAT(t.demission_date_, '%Y-%m-%d') &gt; #{dayStr})
  406. <if test="isDemission==null">
  407. AND su.lock_flag_ = 0
  408. </if>
  409. <if test="isDemission!=null">
  410. AND (su.lock_flag_ = 1 OR t.demission_date_&lt;NOW())
  411. </if>
  412. AND t.organ_id_ IS NOT NULL
  413. <if test="jobNature!=null">
  414. AND t.job_nature_ = #{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  415. </if>
  416. <if test="dayStr!=null and dayStr!=''">
  417. AND DATE_FORMAT(t.create_time_, '%Y-%m-%d') &lt;= #{dayStr}
  418. </if>
  419. GROUP BY
  420. t.organ_id_
  421. ORDER BY
  422. t.organ_id_;
  423. </select>
  424. <select id="getGroupCourseData" resultMap="IndexBaseMonthData">
  425. SELECT
  426. m.organ_id_,m.tenant_id_,
  427. #{dayStr} month_,
  428. COUNT( m.id_ ) total_num_,
  429. COUNT( m.id_ ) activate_num_,
  430. COUNT( m.id_ ) percent_
  431. FROM
  432. course_schedule m
  433. WHERE
  434. m.del_flag_ = 0
  435. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  436. AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  437. AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
  438. AND NOT EXISTS (SELECT id_ FROM practice_group WHERE m.group_type_='PRACTICE' AND m.music_group_id_=id_ AND type_='TRIAL')
  439. AND m.organ_id_ IS NOT NULL AND m.pre_course_flag_ != 1 and m.tenant_id_ = #{tenantId}
  440. <if test="groupType!=null">
  441. AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  442. </if>
  443. <if test="dayStr!=null and dayStr!=''">
  444. AND m.class_date_ &gt;= #{dayStr}
  445. </if>
  446. GROUP BY
  447. m.organ_id_
  448. ORDER BY
  449. m.organ_id_;
  450. </select>
  451. <select id="getGroupSurplusCourseData" resultMap="IndexBaseMonthData">
  452. SELECT
  453. m.organ_id_,m.tenant_id_,
  454. #{dayStr} month_,
  455. COUNT( m.id_ ) total_num_,
  456. COUNT( m.id_ ) activate_num_,
  457. COUNT( m.id_ ) percent_
  458. FROM
  459. course_schedule m
  460. WHERE
  461. m.del_flag_ = 0 and m.tenant_id_ = #{tenantId}
  462. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  463. AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  464. AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
  465. AND NOT EXISTS (SELECT id_ FROM practice_group WHERE m.group_type_='PRACTICE' AND m.music_group_id_=id_ AND type_='TRIAL')
  466. AND m.organ_id_ IS NOT NULL AND m.pre_course_flag_ != 1
  467. <if test="groupType!=null">
  468. AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  469. </if>
  470. <if test="dayStr!=null and dayStr!=''">
  471. AND m.class_date_ &lt;= #{dayStr}
  472. </if>
  473. GROUP BY m.organ_id_
  474. ORDER BY m.organ_id_;
  475. </select>
  476. <select id="getGroupCourseDataWithGroup" resultMap="IndexBaseMonthData">
  477. SELECT
  478. m.organ_id_,m.tenant_id_,
  479. m.class_date_ month_,
  480. COUNT( m.id_ ) total_num_,
  481. COUNT( m.id_ ) activate_num_,
  482. COUNT( m.id_ ) percent_
  483. FROM
  484. course_schedule m
  485. WHERE
  486. m.del_flag_ = 0 and m.tenant_id_ = #{tenantId}
  487. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  488. AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
  489. AND NOT EXISTS (SELECT id_ FROM practice_group WHERE m.group_type_='PRACTICE' AND m.music_group_id_=id_ AND type_='TRIAL')
  490. AND m.organ_id_ IS NOT NULL AND m.pre_course_flag_ != 1
  491. <if test="groupType!=null">
  492. AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  493. </if>
  494. <if test="dayStr!=null and dayStr!=''">
  495. AND m.class_date_ = #{dayStr}
  496. </if>
  497. <if test="startDate!=null and endDate!=''">
  498. AND m.class_date_ BETWEEN #{startDate} AND #{endDate}
  499. </if>
  500. <if test="teachMode!=null">
  501. AND m.teach_mode_ = #{teachMode, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  502. </if>
  503. <if test="organIds!=null and organIds.size()>0">
  504. AND m.organ_id_ IN
  505. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  506. #{organId}
  507. </foreach>
  508. </if>
  509. <if test="dayStr!=null and dayStr!=''">
  510. GROUP BY m.organ_id_
  511. </if>
  512. <if test="startDate!=null and endDate!=''">
  513. GROUP BY m.class_date_
  514. </if>
  515. ORDER BY
  516. m.organ_id_;
  517. </select>
  518. <select id="getVipGroupCategoryCourseData" resultType="com.ym.mec.biz.dal.dto.OrganVipGroupCategoryCourseNumDto">
  519. SELECT
  520. m.organ_id_ organId,
  521. vgc.name_ categoryName,
  522. COUNT( m.id_ ) courseNum
  523. FROM
  524. course_schedule m
  525. LEFT JOIN vip_group vg ON m.music_group_id_=vg.id_
  526. LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
  527. WHERE
  528. m.del_flag_ = 0 and m.tenant_id_ = #{tenantId}
  529. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  530. AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
  531. AND m.organ_id_ IS NOT NULL
  532. <if test="groupType!=null">
  533. AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  534. </if>
  535. <if test="dayStr!=null and dayStr!=''">
  536. AND m.class_date_ = #{dayStr}
  537. </if>
  538. <if test="startDate!=null and endDate!=null">
  539. AND m.class_date_ BETWEEN #{startDate} AND #{endDate}
  540. </if>
  541. <if test="teachMode!=null">
  542. AND m.teach_mode_ = #{teachMode, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  543. </if>
  544. <if test="organIds!=null and organIds.size()>0">
  545. AND m.organ_id_ IN
  546. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  547. #{organId}
  548. </foreach>
  549. </if>
  550. GROUP BY
  551. m.organ_id_,vgc.name_
  552. ORDER BY
  553. m.organ_id_;
  554. </select>
  555. <select id="getOtherStudentData" resultMap="IndexBaseMonthData">
  556. SELECT
  557. su.organ_id_,su.tenant_id_,
  558. #{dayStr} month_,
  559. COUNT( DISTINCT s.user_id_ ) total_num_,
  560. COUNT( DISTINCT s.user_id_ ) activate_num_,
  561. COUNT( DISTINCT s.user_id_ ) percent_
  562. FROM
  563. sys_user su
  564. LEFT JOIN course_schedule_student_payment s ON su.id_=s.user_id_
  565. LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
  566. WHERE
  567. m.del_flag_ = 0 and m.tenant_id_ = #{tenantId}
  568. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  569. AND su.organ_id_ IS NOT NULL
  570. AND m.group_type_ IN ('VIP', 'PRACTICE')
  571. AND m.status_ = 'NOT_START'
  572. <if test="dayStr!=null and dayStr!=''">
  573. AND (DATE_FORMAT(s.create_time_, '%Y-%m-%d') &lt;= #{dayStr} OR YEAR(m.create_time_)=3000)
  574. </if>
  575. GROUP BY
  576. su.organ_id_
  577. ORDER BY
  578. su.organ_id_;
  579. </select>
  580. <select id="getVipPracticeAddStudentData" resultMap="IndexBaseMonthData">
  581. SELECT
  582. su.organ_id_,su.tenant_id_,
  583. #{dayStr} month_,
  584. COUNT( DISTINCT s.user_id_ ) total_num_,
  585. COUNT( DISTINCT s.user_id_ ) activate_num_,
  586. COUNT( DISTINCT s.user_id_ ) percent_
  587. FROM
  588. sys_user su
  589. LEFT JOIN course_schedule_student_payment s ON su.id_=s.user_id_
  590. LEFT JOIN course_schedule_student_payment cssp1 ON s.user_id_=cssp1.user_id_ AND cssp1.create_time_&lt;#{dayStr}
  591. LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
  592. WHERE
  593. m.del_flag_ = 0 and m.tenant_id_ = #{tenantId}
  594. AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
  595. AND cssp1.id_ IS NULL
  596. AND su.organ_id_ IS NOT NULL
  597. AND m.group_type_ IN ('VIP', 'PRACTICE')
  598. <if test="dayStr!=null and dayStr!=''">
  599. AND DATE_FORMAT(s.create_time_, '%Y-%m-%d') = #{dayStr}
  600. </if>
  601. GROUP BY su.organ_id_
  602. ORDER BY su.organ_id_;
  603. </select>
  604. <select id="getStudentConversionData" resultMap="IndexBaseMonthData">
  605. SELECT
  606. cs.organ_id_,
  607. #{dayStr} month_,
  608. COUNT( DISTINCT m.user_id_ ) total_num_,
  609. COUNT( DISTINCT m.user_id_ ) activate_num_,
  610. COUNT( DISTINCT m.user_id_ ) percent_
  611. FROM
  612. course_schedule_student_payment m
  613. LEFT JOIN course_schedule cs ON m.course_schedule_id_=cs.id_
  614. LEFT JOIN practice_group pg ON m.music_group_id_=pg.id_ AND m.group_type_='PRACTICE'
  615. WHERE
  616. cs.del_flag_ = '0'
  617. AND cs.organ_id_ IS NOT NULL and cs.tenant_id_ = #{tenantId}
  618. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
  619. AND m.group_type_ IN ('VIP', 'PRACTICE')
  620. AND (pg.id_ IS NULL OR pg.type_='CHARGE')
  621. AND m.user_id_ IN
  622. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  623. #{studentId}
  624. </foreach>
  625. AND DATE_FORMAT(m.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
  626. GROUP BY
  627. cs.organ_id_
  628. ORDER BY
  629. cs.organ_id_;
  630. </select>
  631. <select id="getMusicGroupPreRegistrationStudentData" resultMap="IndexBaseMonthData">
  632. SELECT
  633. mg.organ_id_,
  634. #{dayStr} month_,
  635. COUNT( DISTINCT spr.user_id_ ) total_num_,
  636. COUNT( DISTINCT spr.user_id_ ) activate_num_,
  637. COUNT( DISTINCT spr.user_id_ ) percent_
  638. FROM
  639. student_pre_registration spr
  640. LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
  641. WHERE
  642. mg.del_flag_ = 0 and mg.tenant_id_ = #{tenantId}
  643. AND mg.organ_id_ IS NOT NULL
  644. AND mg.status_ = 'PROGRESS'
  645. AND DATE_FORMAT( spr.create_time_, '%Y-%m-%d' ) &lt;= #{dayStr}
  646. GROUP BY
  647. mg.organ_id_
  648. ORDER BY
  649. mg.organ_id_;
  650. </select>
  651. <select id="getMusicGroupStudentFromPreData" resultMap="IndexBaseMonthData">
  652. SELECT
  653. mg.organ_id_,
  654. #{dayStr} month_,
  655. COUNT( DISTINCT sr.user_id_ ) total_num_,
  656. COUNT( DISTINCT sr.user_id_ ) activate_num_,
  657. COUNT( DISTINCT sr.user_id_ ) percent_
  658. FROM
  659. student_registration sr
  660. LEFT JOIN student_pre_registration spr ON sr.user_id_ = spr.user_id_ AND sr.music_group_id_ = spr.music_group_id_
  661. LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
  662. WHERE
  663. mg.del_flag_ = 0 and mg.tenant_id_ = #{tenantId}
  664. AND mg.organ_id_ IS NOT NULL
  665. AND mg.status_ = 'PROGRESS'
  666. <if test="paymentStatus==null">
  667. AND sr.music_group_status_ IN ('APPLY', 'NORMAL')
  668. </if>
  669. <if test="paymentStatus!=null">
  670. AND sr.music_group_status_ IN ('NORMAL')
  671. AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  672. </if>
  673. AND DATE_FORMAT( sr.create_time_, '%Y-%m-%d' ) &lt;= #{dayStr}
  674. GROUP BY
  675. mg.organ_id_
  676. ORDER BY
  677. mg.organ_id_;
  678. </select>
  679. <select id="getMusicGroupStudentIdFromPre" resultType="int">
  680. SELECT
  681. sr.user_id_
  682. FROM
  683. student_registration sr
  684. LEFT JOIN student_pre_registration spr ON sr.user_id_ = spr.user_id_ AND sr.music_group_id_ = spr.music_group_id_
  685. LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
  686. WHERE
  687. mg.del_flag_ = 0 and mg.tenant_id_ = #{tenantId}
  688. AND mg.organ_id_ IS NOT NULL
  689. AND mg.status_ = 'PROGRESS'
  690. <if test="paymentStatus==null">
  691. AND sr.music_group_status_ IN ('APPLY', 'NORMAL')
  692. </if>
  693. <if test="paymentStatus!=null">
  694. AND sr.music_group_status_ IN ('NORMAL')
  695. AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  696. </if>
  697. AND DATE_FORMAT( sr.create_time_, '%Y-%m-%d' ) &lt;= #{dayStr}
  698. </select>
  699. <select id="countLessThenThreeClassGroupNum" resultType="int">
  700. SELECT COUNT(t.id_) FROM (
  701. SELECT cg.id_ FROM
  702. class_group cg
  703. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  704. LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
  705. LEFT JOIN course_schedule cs ON cs.class_group_id_=cg.id_
  706. WHERE
  707. cg.type_ IN ('HIGH', 'HIGH_ONLINE') and cg.tenant_id_ = #{tenantId}
  708. AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0 AND cs.pre_course_flag_ != 1
  709. AND cs.del_flag_ = '0'
  710. AND cs.status_='NOT_START'
  711. AND ( cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_ )
  712. <if test="hasDesc != null and hasDesc == true">
  713. AND cg.desc_ IS NOT NULL
  714. </if>
  715. <if test="hasDesc != null and hasDesc == false">
  716. AND cg.desc_ IS NULL
  717. </if>
  718. <if test="educationUserId != null">
  719. AND mg.educational_teacher_id_ = #{educationUserId}
  720. </if>
  721. <if test="organIds!=null and organIds.size()>0">
  722. AND mg.organ_id_ IN
  723. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  724. #{organId}
  725. </foreach>
  726. </if>
  727. GROUP BY cg.id_
  728. HAVING
  729. COUNT(DISTINCT CASE WHEN cgsm.status_ = 'NORMAL' THEN cgsm.user_id_ ELSE NULL END) &lt; 3
  730. ) t
  731. </select>
  732. <select id="countLessThenThreeClassOrganGroupNum" resultType="map">
  733. SELECT t.organ_id_ AS 'key',
  734. COUNT(t.id_) AS 'value'
  735. FROM (
  736. SELECT mg.organ_id_,cg.id_ FROM
  737. class_group cg
  738. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  739. LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
  740. LEFT JOIN course_schedule cs ON cs.class_group_id_=cg.id_
  741. WHERE
  742. cg.type_ IN ('HIGH', 'HIGH_ONLINE') AND cs.pre_course_flag_ != 1 and cg.tenant_id_ = #{tenantId}
  743. AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0
  744. AND cs.del_flag_ = '0'
  745. AND cs.status_='NOT_START'
  746. AND ( cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_ )
  747. <if test="educationUserId != null">
  748. AND mg.educational_teacher_id_ = #{educationUserId}
  749. </if>
  750. <if test="organIds!=null and organIds.size()>0">
  751. AND mg.organ_id_ IN
  752. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  753. #{organId}
  754. </foreach>
  755. </if>
  756. GROUP BY cg.id_
  757. HAVING
  758. COUNT(DISTINCT CASE WHEN cgsm.status_ = 'NORMAL' THEN cgsm.user_id_ ELSE NULL END) &lt; 3
  759. ) t GROUP BY t.organ_id_
  760. </select>
  761. <select id="getLessThenThreeMusicGroup" resultType="java.lang.String">
  762. SELECT cg.music_group_id_ FROM
  763. class_group cg
  764. LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
  765. LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
  766. WHERE
  767. cg.type_ IN ('HIGH_ONLINE') and cg.tenant_id_ = #{tenantId}
  768. AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0
  769. <if test="organIds!=null and organIds.size()>0">
  770. AND mg.organ_id_ IN
  771. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  772. #{organId}
  773. </foreach>
  774. </if>
  775. GROUP BY cg.id_
  776. HAVING
  777. COUNT(CASE WHEN cgsm.status_ = 'NORMAL' THEN 1 ELSE NULL END) &lt; 3
  778. </select>
  779. <select id="countNoPaymentStudentNum" resultType="int">
  780. SELECT
  781. COUNT(DISTINCT mgpc.music_group_id_,mgpcd.user_id_)
  782. FROM
  783. music_group_payment_calender_detail mgpcd
  784. <if test="hasCourse != null">
  785. LEFT JOIN (select user_id_,SUM(used_course_minutes_) used_course_minutes_,music_group_payment_calender_id_ from music_group_payment_student_course_detail group by music_group_payment_calender_id_,user_id_) mgpsc
  786. ON mgpsc.music_group_payment_calender_id_ = mgpcd.music_group_payment_calender_id_ and mgpcd.user_id_ = mgpsc.user_id_
  787. </if>
  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' and mg.tenant_id_ = #{tenantId}
  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. AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
  795. AND mgpc.current_total_amount_ > 0
  796. <if test="hasCourse != null and hasCourse == true">
  797. AND mgpsc.used_course_minutes_ > 0
  798. </if>
  799. <if test="hasCourse != null and hasCourse == false">
  800. AND mgpsc.used_course_minutes_ = 0
  801. </if>
  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' and mg.tenant_id_ = #{tenantId}
  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' and mg.tenant_id_ = #{tenantId}
  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' and mgq.tenant_id_ = #{tenantId}
  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' and mgq.tenant_id_ = #{tenantId}
  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_ != 1 and cssp.tenant_id_ = #{tenantId}
  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_ != 1 and cs.tenant_id_ = #{tenantId}
  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_ != 1 and cs.tenant_id_ = #{tenantId}
  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="getTeacherAttendanceError" 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. WHERE ta.teacher_id_ = cs.actual_teacher_id_ AND cs.pre_course_flag_ != 1 and cs.tenant_id_ = #{tenantId}
  957. AND cs.status_ = 'OVER' AND cs.del_flag_ = '0' AND cs.class_date_ >= #{startTime}
  958. 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)
  959. AND ta.complaints_content_ IS NULL AND ta.dispose_content_ IS NULL)
  960. AND (ta.sign_out_status_ IS NOT NULL OR 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="getStudentAttendanceError" resultType="int">
  978. SELECT COUNT(DISTINCT c.id_) FROM (SELECT cs.id_ FROM course_schedule cs
  979. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  980. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  981. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
  982. WHERE cs.pre_course_flag_ != 1 AND cs.status_ = 'OVER' AND cs.del_flag_ = '0' AND cs.class_date_ >= #{startTime}
  983. AND (sa.id_ IS NULL OR (sa.status_ = 'TRUANT' AND sa.visit_flag_ = 0)) AND cssp.id_ IS NOT NULL
  984. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  985. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
  986. AND (ta.sign_out_status_ IS NOT NULL OR ta.sign_in_status_ IS NOT NULL)
  987. <if test="classGroupIds != null and classGroupIds.size() > 0">
  988. AND cs.class_group_id_ IN
  989. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  990. #{classGroupId}
  991. </foreach>
  992. </if>
  993. <if test="organIds != null and organIds.size()>0">
  994. AND cs.organ_id_ IN
  995. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  996. #{organId}
  997. </foreach>
  998. </if>
  999. GROUP BY cs.id_) c
  1000. </select>
  1001. <select id="getOrganAttendanceError" resultType="map">
  1002. SELECT
  1003. c.organ_id_ AS 'key',
  1004. COUNT(DISTINCT c.id_) AS 'value'
  1005. FROM (SELECT cs.organ_id_,cs.id_ FROM course_schedule cs
  1006. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  1007. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  1008. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
  1009. WHERE ta.teacher_id_ = cs.actual_teacher_id_ and cs.tenant_id_ = #{tenantId}
  1010. AND cs.status_ = 'OVER' AND cs.del_flag_ = '0' AND cs.class_date_ >= #{startTime} AND cs.pre_course_flag_ != 1
  1011. 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)))
  1012. AND (ta.sign_out_status_ IS NOT NULL OR ta.sign_in_status_ IS NOT NULL)
  1013. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cssp.id_ IS NOT NULL
  1014. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  1015. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1016. AND cs.class_group_id_ IN
  1017. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1018. #{classGroupId}
  1019. </foreach>
  1020. </if>
  1021. <if test="organIds != null and organIds.size()>0">
  1022. AND cs.organ_id_ IN
  1023. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1024. #{organId}
  1025. </foreach>
  1026. </if>
  1027. GROUP BY cs.id_) c GROUP BY c.organ_id_
  1028. </select>
  1029. <select id="getNoAttendance" resultType="int">
  1030. SELECT COUNT(DISTINCT cs.id_) 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_ and cs.tenant_id_ = #{tenantId}
  1033. AND cs.status_ = 'OVER' AND cs.del_flag_ = '0' AND cs.class_date_>=#{startTime} AND cs.pre_course_flag_ != 1
  1034. AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.complaints_content_ 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. </select>
  1050. <select id="getOrganNoAttendance" resultType="map">
  1051. SELECT
  1052. cs.organ_id_ AS 'key',
  1053. COUNT(DISTINCT cs.id_) AS 'value'
  1054. FROM course_schedule cs
  1055. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  1056. WHERE ta.teacher_id_ = cs.actual_teacher_id_ and cs.tenant_id_ = #{tenantId}
  1057. AND cs.status_ = 'OVER' AND cs.del_flag_ = '0' AND cs.class_date_>=#{startTime} AND cs.pre_course_flag_ != 1
  1058. AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.dispose_content_ IS NULL
  1059. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
  1060. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  1061. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1062. AND cs.class_group_id_ IN
  1063. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1064. #{classGroupId}
  1065. </foreach>
  1066. </if>
  1067. <if test="organIds!=null and organIds.size() > 0">
  1068. AND cs.organ_id_ IN
  1069. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1070. #{organId}
  1071. </foreach>
  1072. </if>
  1073. GROUP BY cs.organ_id_
  1074. </select>
  1075. <select id="queryTeacherLeave" resultType="int">
  1076. SELECT COUNT(DISTINCT tlr.id_) FROM teacher_leave_record tlr
  1077. LEFT JOIN teacher t ON t.id_ = tlr.user_id_
  1078. WHERE tlr.status_ = 'ING' AND DATE_FORMAT( tlr.create_time_, '%Y-%m-%d' ) >= #{startTime} and tlr.tenant_id_ = #{tenantId}
  1079. <if test="organIdsStr != null and organIdsStr != ''">
  1080. AND FIND_IN_SET(t.organ_id_,#{organIdsStr})
  1081. </if>
  1082. </select>
  1083. <select id="queryLowTeacherSalary" resultType="int">
  1084. SELECT COUNT(DISTINCT tcs.user_id_) FROM teacher_course_statistics tcs
  1085. LEFT JOIN teacher t ON t.id_ = tcs.user_id_
  1086. LEFT JOIN sys_user su ON su.id_ = tcs.user_id_
  1087. WHERE su.lock_flag_ = 0 AND su.del_flag_ = '0' AND t.job_nature_ = 'FULL_TIME' AND t.demission_date_ IS NULL
  1088. AND t.is_settlement_salary_ = 1 and t.tenant_id_ = #{tenantId}
  1089. AND DATE_FORMAT(tcs.month_,'%Y-%m') = #{monthStr} AND tcs.low_salary = 1
  1090. <if test="organIdsStr != null and organIdsStr != ''">
  1091. AND FIND_IN_SET(tcs.organ_id_,#{organIdsStr})
  1092. </if>
  1093. </select>
  1094. <select id="queryOrganLowTeacherSalary" resultType="map">
  1095. SELECT
  1096. tcs.organ_id_ AS 'key',
  1097. COUNT(DISTINCT tcs.user_id_) AS 'value'
  1098. FROM teacher_course_statistics tcs
  1099. LEFT JOIN teacher t ON t.id_ = tcs.user_id_
  1100. LEFT JOIN sys_user su ON su.id_ = tcs.user_id_
  1101. WHERE su.lock_flag_ = 0 AND su.del_flag_ = '0' AND t.job_nature_ = 'FULL_TIME' AND t.demission_date_ IS NULL
  1102. AND t.is_settlement_salary_ = 1 and t.tenant_id_ = #{tenantId}
  1103. AND DATE_FORMAT(tcs.month_,'%Y-%m') = #{monthStr} AND tcs.low_salary = 1
  1104. <if test="organIdsStr != null and organIdsStr != ''">
  1105. AND FIND_IN_SET(tcs.organ_id_,#{organIdsStr})
  1106. </if>
  1107. GROUP BY tcs.organ_id_
  1108. </select>
  1109. <select id="queryInspectionItem" resultType="int">
  1110. SELECT COUNT(DISTINCT ii.id_) FROM inspection_item ii
  1111. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1112. WHERE ii.times_ > planned_times_ AND ii.item_ = 'INSPECT' AND ii.memo_ ='' and ii.tenant_id_ = #{tenantId}
  1113. AND DATE_FORMAT(i.month_,'%Y-%m-%d') >= #{startTime}
  1114. <if test="organIdsStr != null and organIdsStr != ''">
  1115. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1116. </if>
  1117. <if test="userId != null">
  1118. AND ii.user_id_ = #{userId}
  1119. </if>
  1120. </select>
  1121. <select id="queryOrganInspectionItem" resultType="map">
  1122. SELECT
  1123. ii.organ_id_ AS 'key',
  1124. COUNT(DISTINCT ii.id_) AS 'value'
  1125. FROM inspection_item ii
  1126. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1127. WHERE ii.times_ > planned_times_ AND ii.item_ = 'INSPECT' AND ii.memo_ ='' and ii.tenant_id_ = #{tenantId}
  1128. AND DATE_FORMAT(i.month_,'%Y-%m-%d') >= #{startTime}
  1129. <if test="organIdsStr != null and organIdsStr != ''">
  1130. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1131. </if>
  1132. <if test="userId != null">
  1133. AND ii.user_id_ = #{userId}
  1134. </if>
  1135. GROUP BY ii.organ_id_
  1136. </select>
  1137. <select id="queryInspectionItemPlan" resultType="int">
  1138. SELECT COUNT(DISTINCT iip.id_) FROM inspection_item_plan iip
  1139. WHERE iip.status_ = 0 AND iip.memo_ = '' AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') &lt; DATE_FORMAT(NOW(),'%Y-%m-%d') and iip.tenant_id_ = #{tenantId}
  1140. 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')
  1141. <if test="organIdsStr != null and organIdsStr != ''">
  1142. AND FIND_IN_SET(iip.organ_id_,#{organIdsStr})
  1143. </if>
  1144. </select>
  1145. <select id="queryOrganInspectionItemPlan" resultType="map">
  1146. SELECT
  1147. iip.organ_id_ AS 'key',
  1148. COUNT(DISTINCT iip.id_) AS 'value'
  1149. FROM inspection_item_plan iip
  1150. WHERE iip.status_ = 0 AND iip.memo_ = '' AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') &lt; DATE_FORMAT(NOW(),'%Y-%m-%d') and iip.tenant_id_ = #{tenantId}
  1151. 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')
  1152. <if test="organIdsStr != null and organIdsStr != ''">
  1153. AND FIND_IN_SET(iip.organ_id_,#{organIdsStr})
  1154. </if>
  1155. GROUP BY iip.organ_id_
  1156. </select>
  1157. <select id="queryStudentVisit" resultType="int">
  1158. SELECT COUNT(DISTINCT ii.id_) FROM inspection_item ii
  1159. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1160. WHERE ii.item_ = 'VISIT' AND ii.memo_ ='' and ii.tenant_id_ = #{tenantId}
  1161. AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
  1162. WHERE sv.teacher_id_ = ii.user_id_ AND DATE_FORMAT(i.month_,'%Y-%m') = DATE_FORMAT(sv.visit_time_,'%Y-%m'))
  1163. AND i.month_ >= #{startTime} AND i.month_ &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  1164. <if test="organIdsStr != null and organIdsStr != ''">
  1165. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1166. </if>
  1167. <if test="userId != null">
  1168. AND ii.user_id_ = #{userId}
  1169. </if>
  1170. </select>
  1171. <select id="queryOrganStudentVisit" resultType="map">
  1172. SELECT
  1173. ii.organ_id_ AS 'key',
  1174. COUNT(DISTINCT ii.id_) AS 'value'
  1175. FROM inspection_item ii
  1176. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1177. WHERE ii.item_ = 'VISIT' AND ii.memo_ =''
  1178. AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
  1179. WHERE sv.teacher_id_ = ii.user_id_ AND DATE_FORMAT(i.month_,'%Y-%m') = DATE_FORMAT(sv.visit_time_,'%Y-%m')) and ii.tenant_id_ = #{tenantId}
  1180. AND i.month_ >= #{startTime} AND i.month_ &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  1181. <if test="organIdsStr != null and organIdsStr != ''">
  1182. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1183. </if>
  1184. <if test="userId != null">
  1185. AND ii.user_id_ = #{userId}
  1186. </if>
  1187. GROUP BY ii.organ_id_
  1188. </select>
  1189. <select id="queryErrInspection" resultType="int">
  1190. SELECT
  1191. COUNT(id_)
  1192. FROM
  1193. inspection_item_plan
  1194. WHERE
  1195. conclusion_status_ = 1 AND memo_ = '' AND DATE_FORMAT(plan_start_,'%Y-%m-%d') >= #{startTime} and tenant_id_ = #{tenantId}
  1196. <if test="organIds!=null and organIds.size()>0">
  1197. AND organ_id_ IN
  1198. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1199. #{organId}
  1200. </foreach>
  1201. </if>
  1202. </select>
  1203. <select id="queryOrganErrInspection" resultType="map">
  1204. SELECT
  1205. organ_id_ AS 'key',
  1206. COUNT(id_) AS 'value'
  1207. FROM
  1208. inspection_item_plan
  1209. WHERE
  1210. conclusion_status_ = 1 AND memo_ = '' AND DATE_FORMAT(plan_start_,'%Y-%m-%d') >= #{startTime} and tenant_id_ = #{tenantId}
  1211. <if test="organIds!=null and organIds.size()>0">
  1212. AND organ_id_ IN
  1213. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1214. #{organId}
  1215. </foreach>
  1216. </if>
  1217. GROUP BY organ_id_
  1218. </select>
  1219. <select id="getNoClassMusicGroupStudentInfo" resultType="com.ym.mec.biz.dal.entity.IndexErrInfoDto">
  1220. SELECT
  1221. 'NO_CLASS_MUSIC_GROUP_STUDENT_INFO' errorType,
  1222. COUNT( DISTINCT sr.music_group_id_ ) num,
  1223. COUNT( sr.user_id_ ) num2
  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' and sr.tenant_id_ = #{tenantId}
  1231. AND mg.status_ = 'PROGRESS'
  1232. AND cgsm.id_ IS NULL
  1233. AND sub.parent_subject_id_ != 24
  1234. <if test="hasCourse != null and hasCourse == true">
  1235. AND NOW() >= mg.first_course_start_time_
  1236. </if>
  1237. <if test="hasCourse != null and hasCourse == false">
  1238. AND (NOW() &lt; mg.first_course_start_time_ OR mg.first_course_start_time_ IS NULL)
  1239. </if>
  1240. <if test="educationUserId != null">
  1241. AND mg.educational_teacher_id_ = #{educationUserId}
  1242. </if>
  1243. <if test="organIds!=null and organIds.size()>0">
  1244. AND mg.organ_id_ IN
  1245. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1246. #{organId}
  1247. </foreach>
  1248. </if>
  1249. </select>
  1250. <select id="getOrganNoClassMusicGroupStudentNum" resultType="map">
  1251. SELECT
  1252. mg.organ_id_ AS 'key',
  1253. COUNT( sr.user_id_ ) AS 'value'
  1254. FROM
  1255. student_registration sr
  1256. LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
  1257. LEFT JOIN `subject` sub ON sr.actual_subject_id_=sub.id_
  1258. 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'
  1259. WHERE
  1260. sr.music_group_status_ = 'NORMAL' and sr.tenant_id_ = #{tenantId}
  1261. AND mg.status_ = 'PROGRESS'
  1262. AND cgsm.id_ IS NULL
  1263. AND sub.parent_subject_id_!=24
  1264. <if test="educationUserId != null">
  1265. AND mg.educational_teacher_id_ = #{educationUserId}
  1266. </if>
  1267. <if test="organIds!=null and organIds.size()>0">
  1268. AND mg.organ_id_ IN
  1269. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1270. #{organId}
  1271. </foreach>
  1272. </if>
  1273. GROUP BY mg.organ_id_
  1274. </select>
  1275. <select id="getFinancePayData" resultMap="IndexBaseMonthData">
  1276. SELECT SUM(fe.amount_) total_num_,SUM(fe.amount_) activate_num_,SUM(fe.amount_) percent_,fe.organ_id_,#{dayStr} month_ FROM financial_expenditure fe
  1277. WHERE DATE_FORMAT(fe.create_time_,'%Y-%m-%d') = #{dayStr} and fe.tenant_id_ = #{tenantId}
  1278. AND del_flag_ = 0 GROUP BY fe.organ_id_
  1279. </select>
  1280. <select id="getFinanceBalanceData" resultMap="IndexBaseMonthData">
  1281. SELECT spo.organ_id_,SUM(spo.balance_payment_amount_) total_num_,
  1282. SUM(spo.balance_payment_amount_) activate_num_,
  1283. SUM(spo.balance_payment_amount_) percent_,#{dayStr} month_
  1284. FROM student_payment_order spo
  1285. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr} and spo.tenant_id_ = #{tenantId}
  1286. GROUP BY spo.organ_id_
  1287. </select>
  1288. <select id="getFinanceActualData" resultMap="IndexBaseMonthData">
  1289. SELECT spo.organ_id_,SUM(spo.actual_amount_) total_num_,
  1290. SUM(spo.actual_amount_) activate_num_,
  1291. SUM(spo.actual_amount_) percent_,#{dayStr} month_
  1292. FROM student_payment_order spo
  1293. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr} and spo.tenant_id_ = #{tenantId}
  1294. GROUP BY spo.organ_id_
  1295. </select>
  1296. <select id="getFinancePayDataWithTimely" resultMap="IndexBaseMonthData">
  1297. 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_
  1298. FROM financial_expenditure fe
  1299. WHERE DATE_FORMAT(fe.create_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and fe.tenant_id_ = #{tenantId}
  1300. AND del_flag_ = 0
  1301. <if test="organIds!=null and organIds.size()>0">
  1302. AND fe.organ_id_ IN
  1303. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1304. #{organId}
  1305. </foreach>
  1306. </if>
  1307. GROUP BY DATE_FORMAT(fe.create_time_,'%Y-%m-%d')
  1308. </select>
  1309. <select id="getOrganFinancePayDataWithTimely" resultMap="IndexBaseMonthData">
  1310. SELECT SUM(fe.amount_) percent_,o.id_ organ_id_,o.name_ organ_name_
  1311. FROM organization o
  1312. LEFT JOIN financial_expenditure fe ON o.id_ = fe.organ_id_ AND fe.tenant_id_ = o.tenant_id_
  1313. AND DATE_FORMAT(fe.create_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} AND fe.del_flag_ = 0
  1314. WHERE o.tenant_id_ = #{tenantId}
  1315. <if test="organIds!=null and organIds.size()>0">
  1316. AND o.id_ IN
  1317. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1318. #{organId}
  1319. </foreach>
  1320. </if>
  1321. GROUP BY o.id_ ORDER BY percent_ DESC
  1322. </select>
  1323. <select id="getFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
  1324. SELECT spo.organ_id_,SUM(IFNULL(spo.balance_payment_amount_,0)) total_num_,
  1325. SUM(IFNULL(spo.balance_payment_amount_,0)) activate_num_,
  1326. SUM(IFNULL(spo.balance_payment_amount_,0)) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1327. FROM student_payment_order spo
  1328. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1329. <if test="organIds!=null and organIds.size()>0">
  1330. AND spo.organ_id_ IN
  1331. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1332. #{organId}
  1333. </foreach>
  1334. </if>
  1335. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1336. </select>
  1337. <select id="getOrganFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
  1338. SELECT SUM(IFNULL(spo.balance_payment_amount_,0)) percent_,spo.organ_id_
  1339. FROM student_payment_order spo
  1340. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
  1341. AND spo.tenant_id_ = #{tenantId}
  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 spo.organ_id_ ORDER BY percent_ DESC
  1349. </select>
  1350. <select id="getFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
  1351. SELECT spo.organ_id_,SUM(spo.actual_amount_) total_num_,
  1352. SUM(spo.actual_amount_) activate_num_,
  1353. SUM(spo.actual_amount_) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1354. FROM student_payment_order spo
  1355. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1356. <if test="organIds!=null and organIds.size()>0">
  1357. AND spo.organ_id_ IN
  1358. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1359. #{organId}
  1360. </foreach>
  1361. </if>
  1362. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1363. </select>
  1364. <select id="getOrganFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
  1365. SELECT SUM(spo.actual_amount_) percent_,spo.organ_id_
  1366. FROM student_payment_order spo
  1367. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
  1368. AND spo.tenant_id_ = #{tenantId}
  1369. <if test="organIds!=null and organIds.size()>0">
  1370. AND spo.organ_id_ IN
  1371. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1372. #{organId}
  1373. </foreach>
  1374. </if>
  1375. GROUP BY spo.organ_id_ ORDER BY percent_ DESC
  1376. </select>
  1377. <select id="getTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
  1378. SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_,
  1379. SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) activate_num_,
  1380. SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1381. FROM student_payment_order spo
  1382. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1383. <if test="organIds!=null and organIds.size()>0">
  1384. AND spo.organ_id_ IN
  1385. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1386. #{organId}
  1387. </foreach>
  1388. </if>
  1389. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1390. </select>
  1391. <select id="getOrganTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
  1392. SELECT SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_,spo.organ_id_
  1393. FROM student_payment_order spo
  1394. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
  1395. AND spo.tenant_id_ = #{tenantId}
  1396. <if test="organIds!=null and organIds.size()>0">
  1397. AND spo.organ_id_ IN
  1398. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1399. #{organId}
  1400. </foreach>
  1401. </if>
  1402. GROUP BY spo.organ_id_ ORDER BY percent_ DESC
  1403. </select>
  1404. <select id="getTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1405. SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_,
  1406. SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) activate_num_,
  1407. SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1408. FROM student_payment_order spo
  1409. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1410. <if test="orderType != null">
  1411. AND FIND_IN_SET(spo.type_,#{orderType})
  1412. </if>
  1413. <if test="organIds!=null and organIds.size()>0">
  1414. AND spo.organ_id_ IN
  1415. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1416. #{organId}
  1417. </foreach>
  1418. </if>
  1419. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1420. </select>
  1421. <select id="getOrganTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1422. SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_
  1423. FROM student_payment_order spo
  1424. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
  1425. <if test="orderType != null">
  1426. AND FIND_IN_SET(spo.type_,#{orderType})
  1427. </if>
  1428. AND spo.tenant_id_ = #{tenantId}
  1429. <if test="organIds!=null and organIds.size()>0">
  1430. AND spo.organ_id_ IN
  1431. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1432. #{organId}
  1433. </foreach>
  1434. </if>
  1435. GROUP BY spo.organ_id_ ORDER BY percent_ DESC
  1436. </select>
  1437. <select id="getVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1438. SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_ FROM (
  1439. SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1440. FROM student_payment_order spo
  1441. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1442. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1443. AND spo.type_ = 'DEGREE' AND spod.type_ IN ('THEORY_COURSE','VIP')
  1444. <if test="organIds!=null and organIds.size()>0">
  1445. AND spo.organ_id_ IN
  1446. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1447. #{organId}
  1448. </foreach>
  1449. </if>
  1450. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1451. UNION ALL
  1452. SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_
  1453. ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1454. FROM student_payment_order spo
  1455. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
  1456. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  1457. <if test="organIds!=null and organIds.size()>0">
  1458. AND spo.organ_id_ IN
  1459. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1460. #{organId}
  1461. </foreach>
  1462. </if>
  1463. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1464. )c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d')
  1465. </select>
  1466. <select id="getOrganVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1467. SELECT c.organ_id_,SUM(c.total_num_) percent_
  1468. FROM (SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) total_num_
  1469. FROM student_payment_order spo
  1470. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1471. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1472. AND spo.type_ = 'DEGREE' AND spod.type_ IN ('THEORY_COURSE','VIP')
  1473. <if test="organIds!=null and organIds.size()>0">
  1474. AND spo.organ_id_ IN
  1475. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1476. #{organId}
  1477. </foreach>
  1478. </if>
  1479. GROUP BY spo.organ_id_
  1480. UNION ALL
  1481. SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_
  1482. FROM student_payment_order spo
  1483. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
  1484. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  1485. <if test="organIds!=null and organIds.size()>0">
  1486. AND spo.organ_id_ IN
  1487. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1488. #{organId}
  1489. </foreach>
  1490. </if>
  1491. GROUP BY spo.organ_id_
  1492. )c
  1493. GROUP BY c.organ_id_ ORDER BY percent_ DESC
  1494. </select>
  1495. <select id="getOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1496. 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 (
  1497. SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_
  1498. ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
  1499. FROM student_payment_order spo
  1500. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1501. AND spo.type_ NOT IN ('APPLY','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
  1502. <if test="organIds!=null and organIds.size()>0">
  1503. AND spo.organ_id_ IN
  1504. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1505. #{organId}
  1506. </foreach>
  1507. </if>
  1508. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d'),spo.type_
  1509. UNION ALL
  1510. SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
  1511. FROM student_payment_order spo
  1512. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1513. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
  1514. AND spo.type_ = 'DEGREE' AND spod.type_ = 'DEGREE_REGISTRATION'
  1515. <if test="organIds!=null and organIds.size()>0">
  1516. AND spo.organ_id_ IN
  1517. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1518. #{organId}
  1519. </foreach>
  1520. </if>
  1521. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d'),spo.type_
  1522. )c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d'),c.type_
  1523. </select>
  1524. <select id="getOrganOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1525. SELECT c.organ_id_,SUM(c.total_num_) percent_
  1526. FROM (
  1527. SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_,spo.type_
  1528. FROM student_payment_order spo
  1529. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1530. AND spo.type_ NOT IN ('APPLY','ADD_STUDENT','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
  1531. <if test="organIds!=null and organIds.size()>0">
  1532. AND spo.organ_id_ IN
  1533. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1534. #{organId}
  1535. </foreach>
  1536. </if>
  1537. GROUP BY spo.organ_id_,spo.type_
  1538. UNION ALL
  1539. SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) total_num_,spo.type_
  1540. FROM student_payment_order spo
  1541. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1542. WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
  1543. AND spo.type_ = 'DEGREE' AND spod.type_ = 'DEGREE_REGISTRATION'
  1544. <if test="organIds!=null and organIds.size()>0">
  1545. AND spo.organ_id_ IN
  1546. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1547. #{organId}
  1548. </foreach>
  1549. </if>
  1550. GROUP BY spo.organ_id_,spo.type_
  1551. )c
  1552. GROUP BY c.organ_id_ ORDER BY percent_ DESC
  1553. </select>
  1554. <sql id="queryTeacherServeInfoCondition">
  1555. <where>
  1556. sees.tenant_id_ = #{tenantId}
  1557. <if test="organIds!=null and organIds.size()>0">
  1558. AND tea.organ_id_ IN
  1559. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1560. #{organId}
  1561. </foreach>
  1562. </if>
  1563. <if test="monday!=null and monday!='' and sunday!=null and sunday!=''">
  1564. AND sees.monday_ BETWEEN #{monday} AND #{sunday}
  1565. </if>
  1566. <if test="teacherId!=null">
  1567. AND sees.teacher_id_ = #{teacherId}
  1568. </if>
  1569. <if test="reminded!=null and reminded==0">
  1570. AND NOT EXISTS (SELECT id_ FROM teacher_remind WHERE teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
  1571. </if>
  1572. <if test="reminded!=null and reminded==1">
  1573. AND EXISTS (SELECT id_ FROM teacher_remind WHERE teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
  1574. </if>
  1575. <if test="operatorId!=null">
  1576. AND EXISTS (SELECT id_ FROM teacher_remind WHERE operator_id_=#{operatorId} AND teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
  1577. </if>
  1578. <if test="jobNature!=null">
  1579. AND tea.job_nature_=#{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  1580. </if>
  1581. </where>
  1582. </sql>
  1583. <select id="countOrganTeacherServeInfo" resultType="map">
  1584. SELECT
  1585. e.organ_id_ AS 'key',
  1586. COUNT(1) AS 'value'
  1587. FROM (
  1588. SELECT
  1589. tea.organ_id_,
  1590. sees.id_
  1591. FROM
  1592. student_extracurricular_exercises_situation_ sees
  1593. LEFT JOIN teacher tea ON tea.id_=sees.teacher_id_
  1594. <if test="unDone!=null and unDone==1">
  1595. LEFT JOIN teacher_remind tm ON sees.monday_=tm.monday_ AND sees.teacher_id_=tm.teacher_id_
  1596. </if>
  1597. <include refid="queryTeacherServeInfoCondition" />
  1598. GROUP BY sees.monday_,sees.sunday_,sees.teacher_id_
  1599. <if test="unDone!=null">
  1600. HAVING
  1601. <if test="unDone==1">
  1602. SUM( sees.expect_exercises_num_-sees.not_over_course_num_ ) &gt; SUM( sees.actual_exercises_num_ )
  1603. </if>
  1604. <if test="unDone==0">
  1605. SUM( sees.expect_exercises_num_-sees.not_over_course_num_ ) &lt;= SUM( sees.actual_exercises_num_ )
  1606. </if>
  1607. </if>
  1608. ORDER BY sees.monday_,sees.sunday_,sees.teacher_id_
  1609. ) e GROUP BY e.organ_id_
  1610. </select>
  1611. <select id="countStudentErrorLeave" resultType="java.lang.Integer">
  1612. SELECT COUNT(DISTINCT c.user_id_) FROM (
  1613. SELECT sa.user_id_ FROM student_attendance sa
  1614. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1615. WHERE cs.class_date_ BETWEEN #{firstDay} AND #{lastDay} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ != 1 and cs.tenant_id_ = #{tenantId}
  1616. <if test="organIdList != null and organIdList.size > 0">
  1617. AND cs.organ_id_ IN
  1618. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  1619. #{item}
  1620. </foreach>
  1621. </if>
  1622. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1623. AND cs.class_group_id_ IN
  1624. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1625. #{classGroupId}
  1626. </foreach>
  1627. </if>
  1628. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1629. HAVING COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) >= #{studentErrorLeaveNum}
  1630. AND COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) > SUM(sa.leave_visit_flag_)) c
  1631. </select>
  1632. <select id="countOrganStudentErrorLeave" resultType="map">
  1633. SELECT c.organ_id_ 'key',COUNT(c.user_id_) 'value' FROM (
  1634. SELECT sa.user_id_,cs.organ_id_ FROM student_attendance sa
  1635. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1636. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= '2021-11' AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ != 1 and cs.tenant_id_ = #{tenantId}
  1637. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1638. AND cs.class_group_id_ IN
  1639. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1640. #{classGroupId}
  1641. </foreach>
  1642. </if>
  1643. <if test="organIds != null and organIds.size > 0">
  1644. AND cs.organ_id_ IN
  1645. <foreach collection="organIds" open="(" close=")" item="item" separator=",">
  1646. #{item}
  1647. </foreach>
  1648. </if>
  1649. GROUP BY sa.user_id_
  1650. HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_))c
  1651. GROUP BY c.organ_id_
  1652. </select>
  1653. <select id="countStudentErrorLeave1" resultType="java.lang.Integer">
  1654. SELECT COUNT(DISTINCT c.user_id_) FROM (
  1655. SELECT sa.user_id_ FROM student_attendance sa
  1656. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1657. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1658. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') = #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ != 1 and cs.tenant_id_ = #{tenantId}
  1659. <if test="organIds != null">
  1660. AND FIND_IN_SET(cs.organ_id_,#{organIds})
  1661. </if>
  1662. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1663. AND cs.class_group_id_ IN
  1664. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1665. #{classGroupId}
  1666. </foreach>
  1667. </if>
  1668. <if test="search != null and search != ''">
  1669. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1670. </if>
  1671. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1672. HAVING COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) >= #{studentErrorLeaveNum}
  1673. AND COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) > SUM(sa.leave_visit_flag_)) c
  1674. </select>
  1675. <resultMap id="StudentErrorLeaveDto" type="com.ym.mec.biz.dal.dto.StudentErrorLeaveDto">
  1676. <result property="currentNum" column="current_num_"/>
  1677. <result property="totalNum" column="total_num_"/>
  1678. <result property="userId" column="user_id_"/>
  1679. <result property="studentName" column="username_"/>
  1680. <result property="phone" column="phone_"/>
  1681. <result property="organId" column="organ_id_"/>
  1682. <result property="organName" column="organ_name_"/>
  1683. <result property="courseNum" column="course_num_"/>
  1684. </resultMap>
  1685. <select id="queryStudentErrorLeave" resultMap="StudentErrorLeaveDto">
  1686. SELECT organ_id_,organ_name_,user_id_,username_,phone_,current_num_,class_date_,course_num_
  1687. FROM (SELECT cs.organ_id_,o.name_ organ_name_,sa.user_id_,su.username_,su.phone_,
  1688. COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) current_num_,cs.class_date_,COUNT(DISTINCT sa.course_schedule_id_) course_num_
  1689. FROM student_attendance sa
  1690. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1691. LEFT JOIN organization o ON o.id_ = cs.organ_id_
  1692. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1693. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') = #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ != 1 and cs.tenant_id_ = #{tenantId}
  1694. <if test="organIds != null">
  1695. AND FIND_IN_SET(cs.organ_id_,#{organIds})
  1696. </if>
  1697. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1698. AND cs.class_group_id_ IN
  1699. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1700. #{classGroupId}
  1701. </foreach>
  1702. </if>
  1703. <if test="search != null and search != ''">
  1704. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1705. </if>
  1706. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1707. HAVING COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) >= #{studentErrorLeaveNum}
  1708. AND COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) > SUM(sa.leave_visit_flag_) ORDER BY cs.class_date_ DESC)c
  1709. GROUP BY c.user_id_
  1710. <include refid="global.limit"/>
  1711. </select>
  1712. <select id="countStudentLeaveCourseList" resultType="java.lang.Integer">
  1713. SELECT COUNT(sa.id_)
  1714. FROM student_attendance sa
  1715. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1716. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  1717. <include refid="queryStudentLeaveCourseListSql"/>
  1718. </select>
  1719. <sql id="queryStudentLeaveCourseListSql">
  1720. <where>
  1721. sa.user_id_ = #{userId} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ != 1 and cs.tenant_id_ = #{tenantId}
  1722. <if test="search != null and search != ''">
  1723. AND (cs.id_ = #{search} OR cs.actual_teacher_id_ = #{search} OR su.real_name_ LIKE CONCAT('%',#{search},'%'))
  1724. </if>
  1725. <if test="leaveVisitFlag != null">
  1726. AND sa.leave_visit_flag_ = #{leaveVisitFlag}
  1727. </if>
  1728. <if test="courseType != null">
  1729. AND cs.type_ = #{courseType}
  1730. </if>
  1731. </where>
  1732. </sql>
  1733. <resultMap id="StudentLeaveCourseDto" type="com.ym.mec.biz.dal.dto.StudentLeaveCourseDto">
  1734. <result property="leaveVisitFlag" column="leave_visit_flag_"/>
  1735. <result property="classDate" column="class_date_"/>
  1736. <result property="startClassTime" column="start_class_time_"/>
  1737. <result property="endClassTime" column="end_class_time_"/>
  1738. <result property="teacherName" column="teacher_name_"/>
  1739. <result property="actualTeacherId" column="actual_teacher_id_"/>
  1740. <result property="courseScheduleId" column="course_schedule_id_"/>
  1741. <result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1742. <result property="courseScheduleType" column="type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1743. <result property="courseName" column="name_"/>
  1744. <result property="groupId" column="music_group_id_"/>
  1745. </resultMap>
  1746. <select id="queryStudentLeaveCourseList" resultMap="StudentLeaveCourseDto">
  1747. SELECT sa.leave_visit_flag_,cs.class_date_,cs.start_class_time_,
  1748. cs.end_class_time_,su.real_name_ teacher_name_,cs.actual_teacher_id_,
  1749. sa.course_schedule_id_,cs.group_type_,cs.type_,cs.name_,cs.music_group_id_
  1750. FROM student_attendance sa
  1751. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1752. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  1753. <include refid="queryStudentLeaveCourseListSql"/>
  1754. ORDER BY cs.class_date_ DESC,cs.start_class_time_ DESC
  1755. <include refid="global.limit"/>
  1756. </select>
  1757. <select id="getStudentErrorLeaveNumMap" resultType="java.util.Map">
  1758. SELECT user_id_ 'key',SUM(total_num_) 'value'
  1759. FROM (SELECT sa.user_id_,COUNT(DISTINCT DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) total_num_
  1760. FROM student_attendance sa
  1761. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1762. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1763. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') BETWEEN #{totalMonth} AND #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ != 1 and cs.tenant_id_ = #{tenantId}
  1764. <if test="organIds != null">
  1765. AND FIND_IN_SET(cs.organ_id_,#{organIds})
  1766. </if>
  1767. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1768. AND cs.class_group_id_ IN
  1769. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1770. #{classGroupId}
  1771. </foreach>
  1772. </if>
  1773. <if test="search != null and search != ''">
  1774. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1775. </if>
  1776. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1777. HAVING COUNT(DISTINCT DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) >= #{studentErrorLeaveNum} AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_) ORDER BY cs.class_date_ DESC)c
  1778. GROUP BY c.user_id_
  1779. </select>
  1780. <select id="getOrgansStudentNumData" resultMap="IndexBaseMonthData">
  1781. SELECT
  1782. t.organ_id_,t.tenant_id_,
  1783. #{dayStr} month_,
  1784. COUNT( DISTINCT t.user_id_ ) total_num_,
  1785. COUNT( DISTINCT t.user_id_ ) activate_num_,
  1786. COUNT( DISTINCT t.user_id_ ) percent_
  1787. FROM((
  1788. SELECT
  1789. su.organ_id_,sr.tenant_id_,
  1790. sr.user_id_
  1791. FROM
  1792. student_registration sr
  1793. LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
  1794. LEFT JOIN sys_user su ON sr.user_id_ = su.id_
  1795. WHERE
  1796. su.del_flag_ = '0' and sr.tenant_id_ = #{tenantId}
  1797. AND mg.status_='PROGRESS'
  1798. AND sr.music_group_status_ = 'NORMAL'
  1799. <if test="dayStr!=null and dayStr!=''">
  1800. AND DATE(sr.create_time_)&lt;= #{dayStr}
  1801. </if>)
  1802. UNION ALL
  1803. (
  1804. SELECT
  1805. su.organ_id_,cssp.tenant_id_,
  1806. cssp.user_id_
  1807. FROM
  1808. course_schedule_student_payment cssp
  1809. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  1810. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  1811. WHERE
  1812. cssp.group_type_ IN ( 'VIP', 'PRACTICE' ) and cssp.tenant_id_ = #{tenantId}
  1813. AND cs.status_ = 'NOT_START'
  1814. AND su.del_flag_ = '0'
  1815. <if test="dayStr!=null and dayStr!=''">
  1816. AND DATE(cssp.create_time_)&lt;= #{dayStr}
  1817. </if>)) t
  1818. WHERE t.user_id_ NOT IN (SELECT user_id_ FROM student WHERE subject_id_list_ REGEXP '21|25|26|27|28|29')
  1819. GROUP BY t.organ_id_
  1820. </select>
  1821. <select id="getMemberStudentNumData" resultMap="IndexBaseMonthData">
  1822. SELECT
  1823. su.organ_id_,cto.tenant_id_,
  1824. #{dayStr} month_,
  1825. COUNT(DISTINCT cto.student_id_) total_num_,
  1826. COUNT(DISTINCT cto.student_id_) activate_num_,
  1827. COUNT(DISTINCT cto.student_id_) percent_
  1828. FROM cloud_teacher_order cto
  1829. LEFT JOIN sys_user su ON cto.student_id_=su.id_
  1830. WHERE su.del_flag_='0' AND cto.status_ IN (1,2) and cto.tenant_id_ = #{tenantId}
  1831. <if test="dayStr!=null and dayStr!=''">
  1832. AND DATE(cto.create_time_)&lt;= #{dayStr}
  1833. </if>
  1834. GROUP BY su.organ_id_
  1835. </select>
  1836. <select id="getNewMemberStudentNumData" resultMap="IndexBaseMonthData">
  1837. SELECT
  1838. su.organ_id_,cto.tenant_id_,
  1839. #{dayStr} month_,
  1840. COUNT(DISTINCT cto.student_id_) total_num_,
  1841. COUNT(DISTINCT cto.student_id_) activate_num_,
  1842. COUNT(DISTINCT cto.student_id_) percent_
  1843. FROM cloud_teacher_order cto
  1844. LEFT JOIN sys_user su ON cto.student_id_=su.id_
  1845. WHERE su.del_flag_='0' AND cto.status_ IN (1,2) and cto.tenant_id_ = #{tenantId}
  1846. <if test="dayStr!=null and dayStr!=''">
  1847. AND DATE(cto.create_time_)= #{dayStr}
  1848. </if>
  1849. GROUP BY su.organ_id_
  1850. </select>
  1851. <select id="getExperienceMemberStudentNumData" resultMap="IndexBaseMonthData">
  1852. SELECT
  1853. su.organ_id_,stu.tenant_id_,
  1854. #{dayStr} month_,
  1855. COUNT(DISTINCT stu.user_id_) total_num_,
  1856. COUNT(DISTINCT stu.user_id_) activate_num_,
  1857. COUNT(DISTINCT stu.user_id_) percent_
  1858. FROM student stu
  1859. LEFT JOIN cloud_teacher_order cto ON stu.user_id_=cto.student_id_
  1860. LEFT JOIN sys_user su ON su.id_=stu.user_id_
  1861. 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)) and cto.tenant_id_ = #{tenantId}
  1862. <if test="dayStr!=null and dayStr!=''">
  1863. AND DATE(stu.experience_membership_start_time_)&lt;= #{dayStr}
  1864. </if>
  1865. GROUP BY su.organ_id_
  1866. </select>
  1867. <select id="getCloudStudyDayUseStudentNumData" resultMap="IndexBaseMonthData">
  1868. SELECT
  1869. su.organ_id_,smcr.tenant_id_,
  1870. #{dayStr} month_,
  1871. COUNT(DISTINCT smcr.user_id_) total_num_,
  1872. COUNT(DISTINCT smcr.user_id_) activate_num_,
  1873. COUNT(DISTINCT smcr.user_id_) percent_
  1874. FROM sys_music_compare_record smcr
  1875. LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
  1876. LEFT JOIN sys_user su ON stu.user_id_=su.id_
  1877. WHERE su.del_flag_='0' AND smcr.user_id_ = stu.user_id_ and smcr.tenant_id_ = #{tenantId}
  1878. <if test="dayStr!=null and dayStr!=''">
  1879. AND DATE(smcr.create_time_)= #{dayStr}
  1880. </if>
  1881. GROUP BY su.organ_id_
  1882. </select>
  1883. <select id="getCloudStudyLivelyStudentNumData" resultMap="IndexBaseMonthData">
  1884. SELECT
  1885. t.organ_id_,t.tenant_id_,
  1886. #{dayStr} month_,
  1887. COUNT(user_id_) total_num_,
  1888. COUNT(user_id_) activate_num_,
  1889. COUNT(user_id_) percent_
  1890. FROM (
  1891. SELECT su.organ_id_, su.tenant_id_, smcr.user_id_
  1892. , COUNT(DISTINCT DATE_FORMAT(smcr.create_time_, '%Y-%m-%d')) AS days
  1893. FROM sys_music_compare_record smcr
  1894. LEFT JOIN student stu ON smcr.user_id_ = stu.user_id_
  1895. LEFT JOIN sys_user su ON stu.user_id_ = su.id_
  1896. WHERE su.del_flag_ = '0' AND smcr.user_id_ = stu.user_id_
  1897. AND smcr.tenant_id_ = #{tenantId}
  1898. AND smcr.create_time_ >= CURDATE() - INTERVAL 15 DAY
  1899. GROUP BY smcr.user_id_
  1900. ) t WHERE t.days>=5
  1901. GROUP BY t.organ_id_
  1902. </select>
  1903. <select id="getCloudStudyNewStudentNumData" resultMap="IndexBaseMonthData">
  1904. SELECT
  1905. organ_id_,tenant_id_,
  1906. #{dayStr} month_,
  1907. COUNT( DISTINCT user_id_ ) total_num_,
  1908. COUNT( DISTINCT user_id_ ) activate_num_,
  1909. COUNT( DISTINCT user_id_ ) percent_
  1910. FROM
  1911. (
  1912. SELECT su.organ_id_, smcr.tenant_id_, smcr.user_id_
  1913. FROM sys_music_compare_record smcr
  1914. INNER JOIN sys_user su ON smcr.user_id_ = su.id_
  1915. WHERE su.del_flag_ = '0' AND smcr.tenant_id_ = #{tenantId}
  1916. AND smcr.create_time_ >= #{dayStr}
  1917. AND smcr.create_time_ &lt; DATE_ADD(#{dayStr}, INTERVAL 1 DAY)
  1918. GROUP BY smcr.user_id_) t
  1919. GROUP BY t.organ_id_
  1920. </select>
  1921. <resultMap id="CloudTeacherActiveTargetDto" type="com.ym.mec.biz.dal.dto.CloudTeacherActiveTargetDto">
  1922. <result property="organId" column="organ_id_"/>
  1923. <result property="organName" column="organ_name_"/>
  1924. <result property="totalNum" column="total_num_"/>
  1925. <result property="buyAmount" column="buy_amount_"/>
  1926. <result property="buyNum" column="buy_num_"/>
  1927. <result property="targetAmount" column="target_amount_"/>
  1928. <result property="targetNum" column="target_num_"/>
  1929. </resultMap>
  1930. <select id="countCloudTeacherActive" resultMap="CloudTeacherActiveTargetDto">
  1931. 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_,
  1932. COUNT(DISTINCT cto.student_id_) buy_num_
  1933. FROM student s
  1934. LEFT JOIN cloud_teacher_order cto ON cto.student_id_ = s.user_id_ AND cto.status_ != 0 AND cto.active_remark_ = '202109'
  1935. LEFT JOIN sys_user su ON su.id_ = s.user_id_
  1936. LEFT JOIN organization o ON o.id_ = su.organ_id_
  1937. WHERE s.tenant_id_ = #{tenantId}
  1938. <if test="organIdList != null and organIdList.size > 0">
  1939. AND su.organ_id_ IN
  1940. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  1941. #{item}
  1942. </foreach>
  1943. </if>
  1944. GROUP BY su.organ_id_
  1945. </select>
  1946. <select id="getStudentVipOrderNum" resultMap="IndexBaseMonthData">
  1947. SELECT spo.create_time_ month_,spo.organ_id_,
  1948. COUNT(DISTINCT spo.id_) total_num_,
  1949. 'STUDENT_VIP_ORDER_NUM' data_type_,spo.user_id_ extend_info_,spo.tenant_id_
  1950. FROM (SELECT id_,user_id_,organ_id_,activity_id_,music_group_id_,calender_id_,type_,group_type_,
  1951. DATE_FORMAT(create_time_,'%Y-%m-%d') create_time_,tenant_id_ FROM student_payment_order
  1952. WHERE status_ = 'SUCCESS' AND DATE_FORMAT(create_time_,'%Y-%m-%d') = #{dayStr} AND tenant_id_ = #{tenantId}) spo
  1953. LEFT JOIN student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
  1954. LEFT JOIN vip_group_activity vga ON FIND_IN_SET(vga.id_,spo.activity_id_)
  1955. LEFT JOIN vip_group_category vgc ON vgc.id_ = vga.vip_group_category_id_list_
  1956. LEFT JOIN vip_group vg ON vg.id_ = spo.music_group_id_
  1957. LEFT JOIN vip_group_category vgc1 ON vgc1.id_ = vg.vip_group_category_id_
  1958. LEFT JOIN music_group_payment_calender_activity mgpca ON mgpca.calender_id_ = spo.calender_id_
  1959. LEFT JOIN vip_group_activity vga1 ON vga1.id_ = mgpca.activity_id_
  1960. LEFT JOIN vip_group_category vgc2 ON vgc2.id_ = vga1.vip_group_category_id_list_
  1961. WHERE (spo.group_type_ = 'SPORADIC' AND spo.type_ = 'DEGREE_REGISTRATION' AND spod.type_ = 'DEGREE_REGISTRATION')
  1962. OR (spo.group_type_ = 'SPORADIC' AND spo.type_ = 'DOUBLE_ELEVEN2020') OR (spo.group_type_ = 'DEGREE' AND spod.type_ = 'VIP')
  1963. OR (spo.type_ = 'SMALL_CLASS_TO_BUY' AND vgc1.name_ != '小组课') OR (spo.group_type_ = 'MUSIC' AND spod.type_ = 'VIP' AND vgc2.name_ != '小组课')
  1964. OR (spo.type_ = 'DOUBLE_ELEVEN2021' AND vgc.name_ != '小组课')
  1965. GROUP BY spo.user_id_,spo.create_time_,spo.organ_id_;
  1966. </select>
  1967. <select id="getStudentTheoryOrderNum" resultMap="IndexBaseMonthData">
  1968. SELECT spo.create_time_ month_,spo.organ_id_,
  1969. COUNT(DISTINCT spo.id_) total_num_,
  1970. 'STUDENT_THEORY_ORDER_NUM' data_type_,spo.user_id_ extend_info_,spo.tenant_id_
  1971. FROM (SELECT id_,user_id_,organ_id_,activity_id_,music_group_id_,calender_id_,type_,group_type_,
  1972. DATE_FORMAT(create_time_,'%Y-%m-%d') create_time_,tenant_id_ FROM student_payment_order
  1973. WHERE status_ = 'SUCCESS' AND DATE_FORMAT(create_time_,'%Y-%m-%d') = #{dayStr} AND tenant_id_ = #{tenantId}) spo
  1974. LEFT JOIN student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
  1975. LEFT JOIN vip_group_activity vga ON FIND_IN_SET(vga.id_,spo.activity_id_)
  1976. LEFT JOIN vip_group_category vgc ON vgc.id_ = vga.vip_group_category_id_list_
  1977. LEFT JOIN vip_group vg ON vg.id_ = spo.music_group_id_
  1978. LEFT JOIN vip_group_category vgc1 ON vgc1.id_ = vg.vip_group_category_id_
  1979. LEFT JOIN music_group_payment_calender_activity mgpca ON mgpca.calender_id_ = spo.calender_id_
  1980. LEFT JOIN vip_group_activity vga1 ON vga1.id_ = mgpca.activity_id_
  1981. LEFT JOIN vip_group_category vgc2 ON vgc2.id_ = vga1.vip_group_category_id_list_
  1982. WHERE (spo.group_type_ = 'DEGREE' AND spod.type_ = 'THEORY_COURSE')
  1983. OR (spo.type_ = 'SMALL_CLASS_TO_BUY' AND vgc1.name_ = '小组课') OR (spo.group_type_ = 'MUSIC' AND spod.type_ = 'VIP' AND vgc2.name_ = '小组课')
  1984. OR (spo.type_ = 'DOUBLE_ELEVEN2021' AND vgc.name_ = '小组课')
  1985. GROUP BY spo.user_id_,spo.create_time_,spo.organ_id_;
  1986. </select>
  1987. <select id="getStudentPracticeOrderNum" resultMap="IndexBaseMonthData">
  1988. SELECT spo.create_time_ month_,spo.organ_id_,
  1989. COUNT(DISTINCT spo.id_) total_num_,
  1990. 'STUDENT_PRACTICE_ORDER_NUM' data_type_,spo.user_id_ extend_info_,spo.tenant_id_
  1991. FROM (SELECT id_,user_id_,organ_id_,activity_id_,music_group_id_,calender_id_,type_,group_type_,
  1992. DATE_FORMAT(create_time_,'%Y-%m-%d') create_time_,tenant_id_ FROM student_payment_order
  1993. WHERE status_ = 'SUCCESS' AND DATE_FORMAT(create_time_,'%Y-%m-%d') = #{dayStr} AND tenant_id_ = #{tenantId}) spo
  1994. LEFT JOIN student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
  1995. WHERE spo.type_ = 'PRACTICE_GROUP_BUY' OR spo.type_ = 'PRACTICE_GROUP_RENEW' OR (spo.group_type_ = 'MUSIC' AND spod.type_ = 'PRACTICE')
  1996. GROUP BY spo.user_id_,spo.create_time_,spo.organ_id_;
  1997. </select>
  1998. <select id="getCurrentCourseError" resultType="java.lang.Integer">
  1999. select COUNT(cs.user_id_) from (
  2000. select DISTINCT ss.user_id_ from student_statistics ss
  2001. left join course_schedule_student_payment cssp ON cssp.user_id_ = ss.user_id_
  2002. left join course_schedule cs ON cs.id_ = cssp.course_schedule_id_ AND DATE_FORMAT(cs.class_date_,'%Y-%m') = #{month} AND cssp.group_type_ = 'VIP'
  2003. where ss.no_schedule_num_ + ss.sub_course_num_ > 4 and
  2004. (((ss.no_schedule_num_ > 0 OR ss.sub_course_num_) AND ss.lately_year_course_consumer_ > 0 AND ss.last_visit_status_ IS NULL) OR ss.last_visit_status_ = 'NORMAL')
  2005. and ss.group_type_ = 'VIP'
  2006. <if test="organIdList != null and organIdList.size > 0">
  2007. AND cs.organ_id_ IN
  2008. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  2009. #{item}
  2010. </foreach>
  2011. </if>
  2012. group by ss.user_id_ having COUNT(distinct cs.id_) &lt; 4) cs
  2013. </select>
  2014. <select id="getWaitRenewInfo" resultType="java.lang.Integer">
  2015. select COUNT(ss.user_id_) from student_statistics ss
  2016. <if test="organIdList != null and organIdList.size > 0">
  2017. left join sys_user su ON su.id_ = ss.user_id_
  2018. </if>
  2019. where ss.group_type_ = 'VIP' AND ss.no_schedule_num_ + ss.sub_course_num_ &lt; 4
  2020. AND (ss.sub_course_num_ > 0 OR ss.no_schedule_num_ > 0) AND ss.lately_year_course_consumer_ > 0
  2021. <if test="organIdList != null and organIdList.size > 0">
  2022. AND su.organ_id_ IN
  2023. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  2024. #{item}
  2025. </foreach>
  2026. </if>
  2027. </select>
  2028. <select id="indexCoop" resultType="com.ym.mec.biz.dal.dto.DecimalMapDto">
  2029. SELECT cop.organ_id_ id,SUM(spo.expect_amount_) amount
  2030. FROM student_payment_order spo
  2031. left join (select sr.user_id_,mg.cooperation_organ_id_ organ_id_,co.name_ organ_name_ from
  2032. (select * from student_registration where id_ IN (select MAX(id_) from student_registration group by user_id_)) sr
  2033. left join music_group mg ON mg.id_ = sr.music_group_id_
  2034. left join cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
  2035. <where>
  2036. <if test="organIds != null and organIds.size > 0">
  2037. mg.organ_id_ IN
  2038. <foreach collection="organIds" open="(" close=")" item="organId" separator=",">
  2039. #{organId}
  2040. </foreach>
  2041. </if>
  2042. </where>
  2043. group by sr.user_id_,mg.cooperation_organ_id_) cop ON cop.user_id_ = spo.user_id_
  2044. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
  2045. AND cop.user_id_ = spo.user_id_
  2046. GROUP BY cop.organ_id_
  2047. </select>
  2048. <select id="indexImportCoop" resultType="com.ym.mec.biz.dal.dto.DecimalMapDto">
  2049. select co.id_ id,co.name_ name,spo.expect_amount_ amount from cooperation_organ co
  2050. left join (select music_group_id_,SUM(expect_amount_) expect_amount_ from student_payment_order where type_ = 'SCHOOL'
  2051. AND group_type_ = 'OUTORDER' AND status_ = 'SUCCESS' AND DATE_FORMAT(pay_time_,'%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
  2052. group by music_group_id_) spo ON co.id_ = spo.music_group_id_
  2053. where co.is_enable_ AND co.del_flag_ = 0
  2054. <if test="organIds != null and organIds.size > 0">
  2055. AND co.organ_id_ IN
  2056. <foreach collection="organIds" open="(" close=")" item="organId" separator=",">
  2057. #{organId}
  2058. </foreach>
  2059. </if>
  2060. group by co.id_
  2061. </select>
  2062. <select id="getSchoolPatrolError" resultType="com.ym.mec.biz.dal.entity.IndexErrInfoDto">
  2063. select count(cpe.id_) as num
  2064. from course_patrol_evaluation cpe
  2065. left join cooperation_organ co on co.id_ = cpe.cooperation_organ_id_
  2066. <where>
  2067. cpe.handle_status_ = false and cpe.evaluate_status_ = 'UNQUALIFIED'
  2068. <if test="organIdList != null and organIdList.size() != 0">
  2069. and co.organ_id_ in
  2070. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  2071. #{item}
  2072. </foreach>
  2073. </if>
  2074. <if test="tenantId != null">
  2075. and co.tenant_id_ = #{tenantId}
  2076. </if>
  2077. </where>
  2078. </select>
  2079. </mapper>