IndexBaseMonthDataMapper.xml 88 KB

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