IndexBaseMonthDataMapper.xml 91 KB

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