IndexBaseMonthDataMapper.xml 87 KB

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