IndexBaseMonthDataMapper.xml 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171
  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.complaints_content_ IS NULL)
  975. AND (ta.sign_out_status_ IS NOT NULL OR 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 teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  995. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  996. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
  997. WHERE cs.pre_course_flag_ = 0 AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_ >= #{startTime}
  998. AND (sa.id_ IS NULL OR (sa.status_ = 'TRUANT' AND sa.visit_flag_ = 0)) AND cssp.id_ IS NOT NULL
  999. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  1000. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
  1001. AND (ta.sign_out_status_ IS NOT NULL OR ta.sign_in_status_ IS NOT NULL)
  1002. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1003. AND cs.class_group_id_ IN
  1004. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1005. #{classGroupId}
  1006. </foreach>
  1007. </if>
  1008. <if test="organIds != null and organIds.size()>0">
  1009. AND cs.organ_id_ IN
  1010. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1011. #{organId}
  1012. </foreach>
  1013. </if>
  1014. GROUP BY cs.id_) c
  1015. </select>
  1016. <select id="getOrganAttendanceError" resultType="map">
  1017. SELECT
  1018. c.organ_id_ AS 'key',
  1019. COUNT(DISTINCT c.id_) AS 'value'
  1020. FROM (SELECT cs.organ_id_,cs.id_ FROM course_schedule cs
  1021. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  1022. LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  1023. LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
  1024. WHERE ta.teacher_id_ = cs.actual_teacher_id_ and cs.tenant_id_ = #{tenantId}
  1025. AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_ >= #{startTime} AND cs.pre_course_flag_ = 0
  1026. 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)))
  1027. AND (ta.sign_out_status_ IS NOT NULL OR ta.sign_in_status_ IS NOT NULL)
  1028. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cssp.id_ IS NOT NULL
  1029. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  1030. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1031. AND cs.class_group_id_ IN
  1032. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1033. #{classGroupId}
  1034. </foreach>
  1035. </if>
  1036. <if test="organIds != null and organIds.size()>0">
  1037. AND cs.organ_id_ IN
  1038. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1039. #{organId}
  1040. </foreach>
  1041. </if>
  1042. GROUP BY cs.id_) c GROUP BY c.organ_id_
  1043. </select>
  1044. <select id="getNoAttendance" resultType="int">
  1045. SELECT COUNT(DISTINCT cs.id_) FROM course_schedule cs
  1046. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  1047. WHERE ta.teacher_id_ = cs.actual_teacher_id_ and cs.tenant_id_ = #{tenantId}
  1048. AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_>=#{startTime} AND cs.pre_course_flag_ = 0
  1049. AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.complaints_content_ IS NULL
  1050. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
  1051. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  1052. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1053. AND cs.class_group_id_ IN
  1054. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1055. #{classGroupId}
  1056. </foreach>
  1057. </if>
  1058. <if test="organIds!=null and organIds.size() > 0">
  1059. AND cs.organ_id_ IN
  1060. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1061. #{organId}
  1062. </foreach>
  1063. </if>
  1064. </select>
  1065. <select id="getOrganNoAttendance" resultType="map">
  1066. SELECT
  1067. cs.organ_id_ AS 'key',
  1068. COUNT(DISTINCT cs.id_) AS 'value'
  1069. FROM course_schedule cs
  1070. LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
  1071. WHERE ta.teacher_id_ = cs.actual_teacher_id_ and cs.tenant_id_ = #{tenantId}
  1072. AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_>=#{startTime} AND cs.pre_course_flag_ = 0
  1073. AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.dispose_content_ IS NULL
  1074. AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
  1075. AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
  1076. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1077. AND cs.class_group_id_ IN
  1078. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1079. #{classGroupId}
  1080. </foreach>
  1081. </if>
  1082. <if test="organIds!=null and organIds.size() > 0">
  1083. AND cs.organ_id_ IN
  1084. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1085. #{organId}
  1086. </foreach>
  1087. </if>
  1088. GROUP BY cs.organ_id_
  1089. </select>
  1090. <select id="queryTeacherLeave" resultType="int">
  1091. SELECT COUNT(DISTINCT tlr.id_) FROM teacher_leave_record tlr
  1092. LEFT JOIN teacher t ON t.id_ = tlr.user_id_
  1093. WHERE tlr.status_ = 'ING' AND DATE_FORMAT( tlr.create_time_, '%Y-%m-%d' ) >= #{startTime} and tlr.tenant_id_ = #{tenantId}
  1094. <if test="organIdsStr != null and organIdsStr != ''">
  1095. AND FIND_IN_SET(t.organ_id_,#{organIdsStr})
  1096. </if>
  1097. </select>
  1098. <select id="queryLowTeacherSalary" resultType="int">
  1099. SELECT COUNT(DISTINCT tcs.user_id_) FROM teacher_course_statistics tcs
  1100. LEFT JOIN teacher t ON t.id_ = tcs.user_id_
  1101. LEFT JOIN sys_user su ON su.id_ = tcs.user_id_
  1102. WHERE su.lock_flag_ = 0 AND su.del_flag_ = 0 AND t.job_nature_ = 'FULL_TIME' AND t.demission_date_ IS NULL
  1103. AND t.is_settlement_salary_ = 1 and t.tenant_id_ = #{tenantId}
  1104. AND DATE_FORMAT(tcs.month_,'%Y-%m') = #{monthStr} AND tcs.low_salary = 1
  1105. <if test="organIdsStr != null and organIdsStr != ''">
  1106. AND FIND_IN_SET(tcs.organ_id_,#{organIdsStr})
  1107. </if>
  1108. </select>
  1109. <select id="queryOrganLowTeacherSalary" resultType="map">
  1110. SELECT
  1111. tcs.organ_id_ AS 'key',
  1112. COUNT(DISTINCT tcs.user_id_) AS 'value'
  1113. FROM teacher_course_statistics tcs
  1114. LEFT JOIN teacher t ON t.id_ = tcs.user_id_
  1115. LEFT JOIN sys_user su ON su.id_ = tcs.user_id_
  1116. WHERE su.lock_flag_ = 0 AND su.del_flag_ = 0 AND t.job_nature_ = 'FULL_TIME' AND t.demission_date_ IS NULL
  1117. AND t.is_settlement_salary_ = 1 and t.tenant_id_ = #{tenantId}
  1118. AND DATE_FORMAT(tcs.month_,'%Y-%m') = #{monthStr} AND tcs.low_salary = 1
  1119. <if test="organIdsStr != null and organIdsStr != ''">
  1120. AND FIND_IN_SET(tcs.organ_id_,#{organIdsStr})
  1121. </if>
  1122. GROUP BY tcs.organ_id_
  1123. </select>
  1124. <select id="queryInspectionItem" resultType="int">
  1125. SELECT COUNT(DISTINCT ii.id_) FROM inspection_item ii
  1126. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1127. WHERE ii.times_ > planned_times_ AND ii.item_ = 'INSPECT' AND ii.memo_ ='' and ii.tenant_id_ = #{tenantId}
  1128. AND DATE_FORMAT(i.month_,'%Y-%m-%d') >= #{startTime}
  1129. <if test="organIdsStr != null and organIdsStr != ''">
  1130. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1131. </if>
  1132. <if test="userId != null">
  1133. AND ii.user_id_ = #{userId}
  1134. </if>
  1135. </select>
  1136. <select id="queryOrganInspectionItem" resultType="map">
  1137. SELECT
  1138. ii.organ_id_ AS 'key',
  1139. COUNT(DISTINCT ii.id_) AS 'value'
  1140. FROM inspection_item ii
  1141. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1142. WHERE ii.times_ > planned_times_ AND ii.item_ = 'INSPECT' AND ii.memo_ ='' and ii.tenant_id_ = #{tenantId}
  1143. AND DATE_FORMAT(i.month_,'%Y-%m-%d') >= #{startTime}
  1144. <if test="organIdsStr != null and organIdsStr != ''">
  1145. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1146. </if>
  1147. <if test="userId != null">
  1148. AND ii.user_id_ = #{userId}
  1149. </if>
  1150. GROUP BY ii.organ_id_
  1151. </select>
  1152. <select id="queryInspectionItemPlan" resultType="int">
  1153. SELECT COUNT(DISTINCT iip.id_) FROM inspection_item_plan iip
  1154. 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}
  1155. 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')
  1156. <if test="organIdsStr != null and organIdsStr != ''">
  1157. AND FIND_IN_SET(iip.organ_id_,#{organIdsStr})
  1158. </if>
  1159. </select>
  1160. <select id="queryOrganInspectionItemPlan" resultType="map">
  1161. SELECT
  1162. iip.organ_id_ AS 'key',
  1163. COUNT(DISTINCT iip.id_) AS 'value'
  1164. FROM inspection_item_plan iip
  1165. 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}
  1166. 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')
  1167. <if test="organIdsStr != null and organIdsStr != ''">
  1168. AND FIND_IN_SET(iip.organ_id_,#{organIdsStr})
  1169. </if>
  1170. GROUP BY iip.organ_id_
  1171. </select>
  1172. <select id="queryStudentVisit" resultType="int">
  1173. SELECT COUNT(DISTINCT ii.id_) FROM inspection_item ii
  1174. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1175. WHERE ii.item_ = 'VISIT' AND ii.memo_ ='' and ii.tenant_id_ = #{tenantId}
  1176. AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
  1177. WHERE sv.teacher_id_ = ii.user_id_ AND DATE_FORMAT(i.month_,'%Y-%m') = DATE_FORMAT(sv.visit_time_,'%Y-%m'))
  1178. AND i.month_ >= #{startTime} AND i.month_ &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  1179. <if test="organIdsStr != null and organIdsStr != ''">
  1180. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1181. </if>
  1182. <if test="userId != null">
  1183. AND ii.user_id_ = #{userId}
  1184. </if>
  1185. </select>
  1186. <select id="queryOrganStudentVisit" resultType="map">
  1187. SELECT
  1188. ii.organ_id_ AS 'key',
  1189. COUNT(DISTINCT ii.id_) AS 'value'
  1190. FROM inspection_item ii
  1191. LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
  1192. WHERE ii.item_ = 'VISIT' AND ii.memo_ =''
  1193. AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
  1194. 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}
  1195. AND i.month_ >= #{startTime} AND i.month_ &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d')
  1196. <if test="organIdsStr != null and organIdsStr != ''">
  1197. AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
  1198. </if>
  1199. <if test="userId != null">
  1200. AND ii.user_id_ = #{userId}
  1201. </if>
  1202. GROUP BY ii.organ_id_
  1203. </select>
  1204. <select id="queryErrInspection" resultType="int">
  1205. SELECT
  1206. COUNT(id_)
  1207. FROM
  1208. inspection_item_plan
  1209. WHERE
  1210. conclusion_status_ = 1 AND memo_ = '' AND DATE_FORMAT(plan_start_,'%Y-%m-%d') >= #{startTime} and tenant_id_ = #{tenantId}
  1211. <if test="organIds!=null and organIds.size()>0">
  1212. AND organ_id_ IN
  1213. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1214. #{organId}
  1215. </foreach>
  1216. </if>
  1217. </select>
  1218. <select id="queryOrganErrInspection" resultType="map">
  1219. SELECT
  1220. organ_id_ AS 'key',
  1221. COUNT(id_) AS 'value'
  1222. FROM
  1223. inspection_item_plan
  1224. WHERE
  1225. conclusion_status_ = 1 AND memo_ = '' AND DATE_FORMAT(plan_start_,'%Y-%m-%d') >= #{startTime} and tenant_id_ = #{tenantId}
  1226. <if test="organIds!=null and organIds.size()>0">
  1227. AND organ_id_ IN
  1228. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1229. #{organId}
  1230. </foreach>
  1231. </if>
  1232. GROUP BY organ_id_
  1233. </select>
  1234. <select id="getNoClassMusicGroupStudentInfo" resultType="com.ym.mec.biz.dal.entity.IndexErrInfoDto">
  1235. SELECT
  1236. 'NO_CLASS_MUSIC_GROUP_STUDENT_INFO' errorType,
  1237. COUNT( DISTINCT sr.music_group_id_ ) num,
  1238. COUNT( sr.user_id_ ) num2
  1239. FROM
  1240. student_registration sr
  1241. LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
  1242. LEFT JOIN `subject` sub ON sr.actual_subject_id_=sub.id_
  1243. 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'
  1244. WHERE
  1245. sr.music_group_status_ = 'NORMAL' and sr.tenant_id_ = #{tenantId}
  1246. AND mg.status_ = 'PROGRESS'
  1247. AND cgsm.id_ IS NULL
  1248. AND sub.parent_subject_id_ != 24
  1249. <if test="hasCourse != null and hasCourse == true">
  1250. AND NOW() >= mg.first_course_start_time_
  1251. </if>
  1252. <if test="hasCourse != null and hasCourse == false">
  1253. AND (NOW() &lt; mg.first_course_start_time_ OR mg.first_course_start_time_ IS NULL)
  1254. </if>
  1255. <if test="educationUserId != null">
  1256. AND mg.educational_teacher_id_ = #{educationUserId}
  1257. </if>
  1258. <if test="organIds!=null and organIds.size()>0">
  1259. AND mg.organ_id_ IN
  1260. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1261. #{organId}
  1262. </foreach>
  1263. </if>
  1264. </select>
  1265. <select id="getOrganNoClassMusicGroupStudentNum" resultType="map">
  1266. SELECT
  1267. mg.organ_id_ AS 'key',
  1268. COUNT( sr.user_id_ ) AS 'value'
  1269. FROM
  1270. student_registration sr
  1271. LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
  1272. LEFT JOIN `subject` sub ON sr.actual_subject_id_=sub.id_
  1273. 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'
  1274. WHERE
  1275. sr.music_group_status_ = 'NORMAL' and sr.tenant_id_ = #{tenantId}
  1276. AND mg.status_ = 'PROGRESS'
  1277. AND cgsm.id_ IS NULL
  1278. AND sub.parent_subject_id_!=24
  1279. <if test="educationUserId != null">
  1280. AND mg.educational_teacher_id_ = #{educationUserId}
  1281. </if>
  1282. <if test="organIds!=null and organIds.size()>0">
  1283. AND mg.organ_id_ IN
  1284. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1285. #{organId}
  1286. </foreach>
  1287. </if>
  1288. GROUP BY mg.organ_id_
  1289. </select>
  1290. <select id="getFinancePayData" resultMap="IndexBaseMonthData">
  1291. SELECT SUM(fe.amount_) total_num_,SUM(fe.amount_) activate_num_,SUM(fe.amount_) percent_,fe.organ_id_,#{dayStr} month_ FROM financial_expenditure fe
  1292. WHERE DATE_FORMAT(fe.create_time_,'%Y-%m-%d') = #{dayStr} and fe.tenant_id_ = #{tenantId}
  1293. AND del_flag_ = 0 GROUP BY fe.organ_id_
  1294. </select>
  1295. <select id="getFinanceBalanceData" resultMap="IndexBaseMonthData">
  1296. SELECT spo.organ_id_,SUM(spo.balance_payment_amount_) total_num_,
  1297. SUM(spo.balance_payment_amount_) activate_num_,
  1298. SUM(spo.balance_payment_amount_) percent_,#{dayStr} month_
  1299. FROM student_payment_order spo
  1300. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr} and spo.tenant_id_ = #{tenantId}
  1301. GROUP BY spo.organ_id_
  1302. </select>
  1303. <select id="getFinanceActualData" resultMap="IndexBaseMonthData">
  1304. SELECT spo.organ_id_,SUM(spo.actual_amount_) total_num_,
  1305. SUM(spo.actual_amount_) activate_num_,
  1306. SUM(spo.actual_amount_) percent_,#{dayStr} month_
  1307. FROM student_payment_order spo
  1308. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr} and spo.tenant_id_ = #{tenantId}
  1309. GROUP BY spo.organ_id_
  1310. </select>
  1311. <select id="getFinancePayDataWithTimely" resultMap="IndexBaseMonthData">
  1312. 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_
  1313. FROM financial_expenditure fe
  1314. WHERE DATE_FORMAT(fe.create_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and fe.tenant_id_ = #{tenantId}
  1315. AND del_flag_ = 0
  1316. <if test="organIds!=null and organIds.size()>0">
  1317. AND fe.organ_id_ IN
  1318. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1319. #{organId}
  1320. </foreach>
  1321. </if>
  1322. GROUP BY DATE_FORMAT(fe.create_time_,'%Y-%m-%d')
  1323. </select>
  1324. <select id="getOrganFinancePayDataWithTimely" resultMap="IndexBaseMonthData">
  1325. SELECT SUM(fe.amount_) percent_,o.id_ organ_id_,o.name_ organ_name_
  1326. FROM organization o
  1327. LEFT JOIN financial_expenditure fe ON o.id_ = fe.organ_id_ AND fe.tenant_id_ = o.tenant_id_
  1328. AND DATE_FORMAT(fe.create_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} AND fe.del_flag_ = 0
  1329. WHERE o.tenant_id_ = #{tenantId}
  1330. <if test="organIds!=null and organIds.size()>0">
  1331. AND o.id_ IN
  1332. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1333. #{organId}
  1334. </foreach>
  1335. </if>
  1336. GROUP BY o.id_ ORDER BY percent_ DESC
  1337. </select>
  1338. <select id="getFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
  1339. SELECT spo.organ_id_,SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
  1340. SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
  1341. 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_
  1342. FROM student_payment_order spo
  1343. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1344. <if test="organIds!=null and organIds.size()>0">
  1345. AND spo.organ_id_ IN
  1346. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1347. #{organId}
  1348. </foreach>
  1349. </if>
  1350. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1351. </select>
  1352. <select id="getOrganFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
  1353. SELECT SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,
  1354. o.id_ organ_id_,o.name_ organ_name_
  1355. FROM organization o
  1356. LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
  1357. AND spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1358. WHERE o.tenant_id_ = #{tenantId}
  1359. <if test="organIds!=null and organIds.size() > 0">
  1360. AND o.id_ IN
  1361. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1362. #{organId}
  1363. </foreach>
  1364. </if>
  1365. GROUP BY o.id_ ORDER BY percent_ DESC
  1366. </select>
  1367. <select id="getFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
  1368. SELECT spo.organ_id_,SUM(spo.actual_amount_) total_num_,
  1369. SUM(spo.actual_amount_) activate_num_,
  1370. SUM(spo.actual_amount_) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1371. FROM student_payment_order spo
  1372. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1373. <if test="organIds!=null and organIds.size()>0">
  1374. AND spo.organ_id_ IN
  1375. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1376. #{organId}
  1377. </foreach>
  1378. </if>
  1379. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1380. </select>
  1381. <select id="getOrganFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
  1382. SELECT SUM(spo.actual_amount_) percent_,o.id_ organ_id_,o.name_ organ_name_
  1383. FROM organization o
  1384. LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
  1385. AND spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1386. WHERE o.tenant_id_ = #{tenantId}
  1387. <if test="organIds!=null and organIds.size()>0">
  1388. AND o.id_ IN
  1389. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1390. #{organId}
  1391. </foreach>
  1392. </if>
  1393. GROUP BY o.id_ ORDER BY percent_ DESC
  1394. </select>
  1395. <select id="getTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
  1396. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1397. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
  1398. SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1399. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
  1400. SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1401. 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_
  1402. FROM student_payment_order spo
  1403. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1404. <if test="organIds!=null and organIds.size()>0">
  1405. AND spo.organ_id_ IN
  1406. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1407. #{organId}
  1408. </foreach>
  1409. </if>
  1410. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1411. </select>
  1412. <select id="getOrganTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
  1413. SELECT SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1414. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,
  1415. o.id_ organ_id_,o.name_ organ_name_
  1416. FROM organization o
  1417. LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
  1418. AND spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1419. WHERE o.tenant_id_ = #{tenantId}
  1420. <if test="organIds!=null and organIds.size()>0">
  1421. AND o.id_ IN
  1422. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1423. #{organId}
  1424. </foreach>
  1425. </if>
  1426. GROUP BY o.id_ ORDER BY percent_ DESC
  1427. </select>
  1428. <select id="getTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1429. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1430. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
  1431. SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1432. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
  1433. SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1434. 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_
  1435. FROM student_payment_order spo
  1436. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1437. <if test="orderType != null">
  1438. AND FIND_IN_SET(spo.type_,#{orderType})
  1439. </if>
  1440. <if test="notOrderType != null">
  1441. AND spo.type_ NOT IN
  1442. <foreach collection="notOrderType" open="(" close=")" item="item" separator=",">
  1443. #{item}
  1444. </foreach>
  1445. </if>
  1446. <if test="organIds!=null and organIds.size()>0">
  1447. AND spo.organ_id_ IN
  1448. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1449. #{organId}
  1450. </foreach>
  1451. </if>
  1452. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1453. </select>
  1454. <select id="getOrganTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1455. SELECT SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1456. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,
  1457. o.id_ organ_id_,o.name_ organ_name_
  1458. FROM organization o
  1459. LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
  1460. AND spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1461. <if test="orderType != null">
  1462. AND FIND_IN_SET(spo.type_,#{orderType})
  1463. </if>
  1464. <if test="notOrderType != null">
  1465. AND spo.type_ NOT IN
  1466. <foreach collection="notOrderType" open="(" close=")" item="item" separator=",">
  1467. #{item}
  1468. </foreach>
  1469. </if>
  1470. <if test="organIds!=null and organIds.size()>0">
  1471. AND spo.organ_id_ IN
  1472. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1473. #{organId}
  1474. </foreach>
  1475. </if>
  1476. WHERE o.tenant_id_ = #{tenantId}
  1477. <if test="organIds!=null and organIds.size()>0">
  1478. AND o.id_ IN
  1479. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1480. #{organId}
  1481. </foreach>
  1482. </if>
  1483. GROUP BY o.id_ ORDER BY percent_ DESC
  1484. </select>
  1485. <select id="getVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1486. SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_ FROM (
  1487. 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_
  1488. FROM student_payment_order spo
  1489. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1490. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1491. AND spo.type_ = 'DEGREE' AND spod.type_ IN ('THEORY_COURSE','VIP')
  1492. <if test="organIds!=null and organIds.size()>0">
  1493. AND spo.organ_id_ IN
  1494. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1495. #{organId}
  1496. </foreach>
  1497. </if>
  1498. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1499. UNION ALL
  1500. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1501. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
  1502. ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
  1503. FROM student_payment_order spo
  1504. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1505. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  1506. <if test="organIds!=null and organIds.size()>0">
  1507. AND spo.organ_id_ IN
  1508. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1509. #{organId}
  1510. </foreach>
  1511. </if>
  1512. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
  1513. )c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d')
  1514. </select>
  1515. <select id="getOrganVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1516. SELECT o.id_ organ_id_,o.name_ organ_name_,SUM(c.total_num_) percent_ FROM organization o
  1517. LEFT JOIN (SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_
  1518. FROM student_payment_order spo
  1519. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1520. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1521. AND spo.type_ = 'DEGREE' AND spod.type_ IN ('THEORY_COURSE','VIP')
  1522. <if test="organIds!=null and organIds.size()>0">
  1523. AND spo.organ_id_ IN
  1524. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1525. #{organId}
  1526. </foreach>
  1527. </if>
  1528. GROUP BY spo.organ_id_
  1529. UNION ALL
  1530. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1531. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
  1532. FROM student_payment_order spo
  1533. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1534. AND spo.type_ = 'SMALL_CLASS_TO_BUY'
  1535. <if test="organIds!=null and organIds.size()>0">
  1536. AND spo.organ_id_ IN
  1537. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1538. #{organId}
  1539. </foreach>
  1540. </if>
  1541. GROUP BY spo.organ_id_
  1542. )c ON c.organ_id_ = o.id_
  1543. WHERE o.tenant_id_ = #{tenantId}
  1544. <if test="organIds!=null and organIds.size()>0">
  1545. AND o.id_ IN
  1546. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1547. #{organId}
  1548. </foreach>
  1549. </if>
  1550. GROUP BY o.id_ ORDER BY percent_ DESC
  1551. </select>
  1552. <select id="getOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1553. 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 (
  1554. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1555. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
  1556. ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
  1557. FROM student_payment_order spo
  1558. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1559. AND spo.type_ NOT IN ('APPLY','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
  1560. <if test="organIds!=null and organIds.size()>0">
  1561. AND spo.organ_id_ IN
  1562. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1563. #{organId}
  1564. </foreach>
  1565. </if>
  1566. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d'),spo.type_
  1567. UNION ALL
  1568. 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_
  1569. FROM student_payment_order spo
  1570. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1571. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1572. AND spo.type_ = 'DEGREE' AND spod.type_ = 'DEGREE_REGISTRATION'
  1573. <if test="organIds!=null and organIds.size()>0">
  1574. AND spo.organ_id_ IN
  1575. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1576. #{organId}
  1577. </foreach>
  1578. </if>
  1579. GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d'),spo.type_
  1580. )c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d'),c.type_
  1581. </select>
  1582. <select id="getOrganOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
  1583. SELECT o.id_ organ_id_,o.name_ organ_name_,SUM(c.total_num_) percent_ FROM organization o
  1584. LEFT JOIN (
  1585. SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
  1586. CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,spo.type_
  1587. FROM student_payment_order spo
  1588. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
  1589. AND spo.type_ NOT IN ('APPLY','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
  1590. <if test="organIds!=null and organIds.size()>0">
  1591. AND spo.organ_id_ IN
  1592. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1593. #{organId}
  1594. </foreach>
  1595. </if>
  1596. GROUP BY spo.organ_id_,spo.type_
  1597. UNION ALL
  1598. SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,spo.type_
  1599. FROM student_payment_order spo
  1600. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  1601. WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
  1602. AND spo.type_ = 'DEGREE' AND spod.type_ = 'DEGREE_REGISTRATION'
  1603. <if test="organIds!=null and organIds.size()>0">
  1604. AND spo.organ_id_ IN
  1605. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1606. #{organId}
  1607. </foreach>
  1608. </if>
  1609. GROUP BY spo.organ_id_,spo.type_
  1610. )c ON c.organ_id_ = o.id_
  1611. WHERE o.tenant_id_ = #{tenantId}
  1612. <if test="organIds!=null and organIds.size()>0">
  1613. AND o.id_ IN
  1614. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1615. #{organId}
  1616. </foreach>
  1617. </if>
  1618. GROUP BY o.id_ ORDER BY percent_ DESC
  1619. </select>
  1620. <sql id="queryTeacherServeInfoCondition">
  1621. <where>
  1622. sees.tenant_id_ = #{tenantId}
  1623. <if test="organIds!=null and organIds.size()>0">
  1624. AND tea.organ_id_ IN
  1625. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  1626. #{organId}
  1627. </foreach>
  1628. </if>
  1629. <if test="monday!=null and monday!='' and sunday!=null and sunday!=''">
  1630. AND sees.monday_ BETWEEN #{monday} AND #{sunday}
  1631. </if>
  1632. <if test="teacherId!=null">
  1633. AND sees.teacher_id_ = #{teacherId}
  1634. </if>
  1635. <if test="reminded!=null and reminded==0">
  1636. AND NOT EXISTS (SELECT id_ FROM teacher_remind WHERE teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
  1637. </if>
  1638. <if test="reminded!=null and reminded==1">
  1639. AND EXISTS (SELECT id_ FROM teacher_remind WHERE teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
  1640. </if>
  1641. <if test="operatorId!=null">
  1642. AND EXISTS (SELECT id_ FROM teacher_remind WHERE operator_id_=#{operatorId} AND teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
  1643. </if>
  1644. <if test="jobNature!=null">
  1645. AND tea.job_nature_=#{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  1646. </if>
  1647. </where>
  1648. </sql>
  1649. <select id="countOrganTeacherServeInfo" resultType="map">
  1650. SELECT
  1651. e.organ_id_ AS 'key',
  1652. COUNT(1) AS 'value'
  1653. FROM (
  1654. SELECT
  1655. tea.organ_id_,
  1656. sees.id_
  1657. FROM
  1658. student_extracurricular_exercises_situation_ sees
  1659. LEFT JOIN teacher tea ON tea.id_=sees.teacher_id_
  1660. <if test="unDone!=null and unDone==1">
  1661. LEFT JOIN teacher_remind tm ON sees.monday_=tm.monday_ AND sees.teacher_id_=tm.teacher_id_
  1662. </if>
  1663. <include refid="queryTeacherServeInfoCondition" />
  1664. GROUP BY sees.monday_,sees.sunday_,sees.teacher_id_
  1665. <if test="unDone!=null">
  1666. HAVING
  1667. <if test="unDone==1">
  1668. SUM( sees.expect_exercises_num_-sees.not_over_course_num_ ) &gt; SUM( sees.actual_exercises_num_ )
  1669. </if>
  1670. <if test="unDone==0">
  1671. SUM( sees.expect_exercises_num_-sees.not_over_course_num_ ) &lt;= SUM( sees.actual_exercises_num_ )
  1672. </if>
  1673. </if>
  1674. ORDER BY sees.monday_,sees.sunday_,sees.teacher_id_
  1675. ) e GROUP BY e.organ_id_
  1676. </select>
  1677. <select id="countStudentErrorLeave" resultType="java.lang.Integer">
  1678. SELECT COUNT(DISTINCT c.user_id_) FROM (
  1679. SELECT sa.user_id_ FROM student_attendance sa
  1680. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1681. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') = #{format} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0 and cs.tenant_id_ = #{tenantId}
  1682. <if test="organIdList != null and organIdList.size > 0">
  1683. AND cs.organ_id_ IN
  1684. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  1685. #{item}
  1686. </foreach>
  1687. </if>
  1688. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1689. AND cs.class_group_id_ IN
  1690. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1691. #{classGroupId}
  1692. </foreach>
  1693. </if>
  1694. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1695. HAVING COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) >= #{studentErrorLeaveNum}
  1696. AND COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) > SUM(sa.leave_visit_flag_)) c
  1697. </select>
  1698. <select id="countOrganStudentErrorLeave" resultType="map">
  1699. SELECT c.organ_id_ 'key',COUNT(c.user_id_) 'value' FROM (
  1700. SELECT sa.user_id_,cs.organ_id_ FROM student_attendance sa
  1701. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1702. 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}
  1703. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1704. AND cs.class_group_id_ IN
  1705. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1706. #{classGroupId}
  1707. </foreach>
  1708. </if>
  1709. <if test="organIds != null and organIds.size > 0">
  1710. AND cs.organ_id_ IN
  1711. <foreach collection="organIds" open="(" close=")" item="item" separator=",">
  1712. #{item}
  1713. </foreach>
  1714. </if>
  1715. GROUP BY sa.user_id_
  1716. HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_))c
  1717. GROUP BY c.organ_id_
  1718. </select>
  1719. <select id="countStudentErrorLeave1" resultType="java.lang.Integer">
  1720. SELECT COUNT(DISTINCT c.user_id_) FROM (
  1721. SELECT sa.user_id_ FROM student_attendance sa
  1722. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1723. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1724. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') = #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0 and cs.tenant_id_ = #{tenantId}
  1725. <if test="organIds != null">
  1726. AND FIND_IN_SET(cs.organ_id_,#{organIds})
  1727. </if>
  1728. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1729. AND cs.class_group_id_ IN
  1730. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1731. #{classGroupId}
  1732. </foreach>
  1733. </if>
  1734. <if test="search != null and search != ''">
  1735. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1736. </if>
  1737. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1738. HAVING COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) >= #{studentErrorLeaveNum}
  1739. AND COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) > SUM(sa.leave_visit_flag_)) c
  1740. </select>
  1741. <resultMap id="StudentErrorLeaveDto" type="com.ym.mec.biz.dal.dto.StudentErrorLeaveDto">
  1742. <result property="currentNum" column="current_num_"/>
  1743. <result property="totalNum" column="total_num_"/>
  1744. <result property="userId" column="user_id_"/>
  1745. <result property="studentName" column="username_"/>
  1746. <result property="phone" column="phone_"/>
  1747. <result property="organId" column="organ_id_"/>
  1748. <result property="organName" column="organ_name_"/>
  1749. <result property="courseNum" column="course_num_"/>
  1750. </resultMap>
  1751. <select id="queryStudentErrorLeave" resultMap="StudentErrorLeaveDto">
  1752. SELECT organ_id_,organ_name_,user_id_,username_,phone_,current_num_,class_date_,course_num_
  1753. FROM (SELECT cs.organ_id_,o.name_ organ_name_,sa.user_id_,su.username_,su.phone_,
  1754. COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) current_num_,cs.class_date_,COUNT(DISTINCT sa.course_schedule_id_) course_num_
  1755. FROM student_attendance sa
  1756. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1757. LEFT JOIN organization o ON o.id_ = cs.organ_id_
  1758. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1759. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') = #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0 and cs.tenant_id_ = #{tenantId}
  1760. <if test="organIds != null">
  1761. AND FIND_IN_SET(cs.organ_id_,#{organIds})
  1762. </if>
  1763. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1764. AND cs.class_group_id_ IN
  1765. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1766. #{classGroupId}
  1767. </foreach>
  1768. </if>
  1769. <if test="search != null and search != ''">
  1770. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1771. </if>
  1772. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1773. HAVING COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) >= #{studentErrorLeaveNum}
  1774. AND COUNT(distinct DATE_FORMAT(cs.class_date_,'%Y-%m-%d')) > SUM(sa.leave_visit_flag_) ORDER BY cs.class_date_ DESC)c
  1775. GROUP BY c.user_id_
  1776. <include refid="global.limit"/>
  1777. </select>
  1778. <select id="countStudentLeaveCourseList" resultType="java.lang.Integer">
  1779. SELECT COUNT(sa.id_)
  1780. FROM student_attendance sa
  1781. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1782. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  1783. <include refid="queryStudentLeaveCourseListSql"/>
  1784. </select>
  1785. <sql id="queryStudentLeaveCourseListSql">
  1786. <where>
  1787. sa.user_id_ = #{userId} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0 and cs.tenant_id_ = #{tenantId}
  1788. <if test="search != null and search != ''">
  1789. AND (cs.id_ = #{search} OR cs.actual_teacher_id_ = #{search} OR su.real_name_ LIKE CONCAT('%',#{search},'%'))
  1790. </if>
  1791. <if test="leaveVisitFlag != null">
  1792. AND sa.leave_visit_flag_ = #{leaveVisitFlag}
  1793. </if>
  1794. <if test="courseType != null">
  1795. AND cs.type_ = #{courseType}
  1796. </if>
  1797. </where>
  1798. </sql>
  1799. <resultMap id="StudentLeaveCourseDto" type="com.ym.mec.biz.dal.dto.StudentLeaveCourseDto">
  1800. <result property="leaveVisitFlag" column="leave_visit_flag_"/>
  1801. <result property="classDate" column="class_date_"/>
  1802. <result property="startClassTime" column="start_class_time_"/>
  1803. <result property="endClassTime" column="end_class_time_"/>
  1804. <result property="teacherName" column="teacher_name_"/>
  1805. <result property="actualTeacherId" column="actual_teacher_id_"/>
  1806. <result property="courseScheduleId" column="course_schedule_id_"/>
  1807. <result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1808. <result property="courseScheduleType" column="type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1809. <result property="courseName" column="name_"/>
  1810. <result property="groupId" column="music_group_id_"/>
  1811. </resultMap>
  1812. <select id="queryStudentLeaveCourseList" resultMap="StudentLeaveCourseDto">
  1813. SELECT sa.leave_visit_flag_,cs.class_date_,cs.start_class_time_,
  1814. cs.end_class_time_,su.real_name_ teacher_name_,cs.actual_teacher_id_,
  1815. sa.course_schedule_id_,cs.group_type_,cs.type_,cs.name_,cs.music_group_id_
  1816. FROM student_attendance sa
  1817. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1818. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  1819. <include refid="queryStudentLeaveCourseListSql"/>
  1820. ORDER BY cs.class_date_ DESC,cs.start_class_time_ DESC
  1821. <include refid="global.limit"/>
  1822. </select>
  1823. <select id="getStudentErrorLeaveNumMap" resultType="java.util.Map">
  1824. SELECT user_id_ 'key',SUM(total_num_) 'value'
  1825. FROM (SELECT sa.user_id_,COUNT(sa.id_) total_num_
  1826. FROM student_attendance sa
  1827. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1828. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1829. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{totalMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0 and cs.tenant_id_ = #{tenantId}
  1830. <if test="organIds != null">
  1831. AND FIND_IN_SET(cs.organ_id_,#{organIds})
  1832. </if>
  1833. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1834. AND cs.class_group_id_ IN
  1835. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1836. #{classGroupId}
  1837. </foreach>
  1838. </if>
  1839. <if test="search != null and search != ''">
  1840. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1841. </if>
  1842. 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
  1843. GROUP BY c.user_id_
  1844. </select>
  1845. <select id="getOrgansStudentNumData" resultMap="IndexBaseMonthData">
  1846. SELECT
  1847. t.organ_id_,t.tenant_id_,
  1848. #{dayStr} month_,
  1849. COUNT( DISTINCT t.user_id_ ) total_num_,
  1850. COUNT( DISTINCT t.user_id_ ) activate_num_,
  1851. COUNT( DISTINCT t.user_id_ ) percent_
  1852. FROM((
  1853. SELECT
  1854. su.organ_id_,sr.tenant_id_,
  1855. sr.user_id_
  1856. FROM
  1857. student_registration sr
  1858. LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
  1859. LEFT JOIN sys_user su ON sr.user_id_ = su.id_
  1860. WHERE
  1861. su.del_flag_ = 0 and sr.tenant_id_ = #{tenantId}
  1862. AND mg.status_='PROGRESS'
  1863. AND sr.music_group_status_ = 'NORMAL'
  1864. <if test="dayStr!=null and dayStr!=''">
  1865. AND DATE(sr.create_time_)&lt;= #{dayStr}
  1866. </if>)
  1867. UNION ALL
  1868. (
  1869. SELECT
  1870. su.organ_id_,cssp.tenant_id_,
  1871. cssp.user_id_
  1872. FROM
  1873. course_schedule_student_payment cssp
  1874. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  1875. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  1876. WHERE
  1877. cssp.group_type_ IN ( 'VIP', 'PRACTICE' ) and cssp.tenant_id_ = #{tenantId}
  1878. AND cs.status_ = 'NOT_START'
  1879. AND su.del_flag_ = 0
  1880. <if test="dayStr!=null and dayStr!=''">
  1881. AND DATE(cssp.create_time_)&lt;= #{dayStr}
  1882. </if>)) t
  1883. WHERE t.user_id_ NOT IN (SELECT user_id_ FROM student WHERE subject_id_list_ REGEXP '21|25|26|27|28|29')
  1884. GROUP BY t.organ_id_
  1885. </select>
  1886. <select id="getMemberStudentNumData" resultMap="IndexBaseMonthData">
  1887. SELECT
  1888. su.organ_id_,cto.tenant_id_,
  1889. #{dayStr} month_,
  1890. COUNT(DISTINCT cto.student_id_) total_num_,
  1891. COUNT(DISTINCT cto.student_id_) activate_num_,
  1892. COUNT(DISTINCT cto.student_id_) percent_
  1893. FROM cloud_teacher_order cto
  1894. LEFT JOIN sys_user su ON cto.student_id_=su.id_
  1895. WHERE su.del_flag_=0 AND cto.status_ IN (1,2) and cto.tenant_id_ = #{tenantId}
  1896. <if test="dayStr!=null and dayStr!=''">
  1897. AND DATE(cto.create_time_)&lt;= #{dayStr}
  1898. </if>
  1899. GROUP BY su.organ_id_
  1900. </select>
  1901. <select id="getNewMemberStudentNumData" resultMap="IndexBaseMonthData">
  1902. SELECT
  1903. su.organ_id_,cto.tenant_id_,
  1904. #{dayStr} month_,
  1905. COUNT(DISTINCT cto.student_id_) total_num_,
  1906. COUNT(DISTINCT cto.student_id_) activate_num_,
  1907. COUNT(DISTINCT cto.student_id_) percent_
  1908. FROM cloud_teacher_order cto
  1909. LEFT JOIN sys_user su ON cto.student_id_=su.id_
  1910. WHERE su.del_flag_=0 AND cto.status_ IN (1,2) and cto.tenant_id_ = #{tenantId}
  1911. <if test="dayStr!=null and dayStr!=''">
  1912. AND DATE(cto.create_time_)= #{dayStr}
  1913. </if>
  1914. GROUP BY su.organ_id_
  1915. </select>
  1916. <select id="getExperienceMemberStudentNumData" resultMap="IndexBaseMonthData">
  1917. SELECT
  1918. su.organ_id_,stu.tenant_id_,
  1919. #{dayStr} month_,
  1920. COUNT(DISTINCT stu.user_id_) total_num_,
  1921. COUNT(DISTINCT stu.user_id_) activate_num_,
  1922. COUNT(DISTINCT stu.user_id_) percent_
  1923. FROM student stu
  1924. LEFT JOIN cloud_teacher_order cto ON stu.user_id_=cto.student_id_
  1925. LEFT JOIN sys_user su ON su.id_=stu.user_id_
  1926. 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}
  1927. <if test="dayStr!=null and dayStr!=''">
  1928. AND DATE(stu.experience_membership_start_time_)&lt;= #{dayStr}
  1929. </if>
  1930. GROUP BY su.organ_id_
  1931. </select>
  1932. <select id="getCloudStudyDayUseStudentNumData" resultMap="IndexBaseMonthData">
  1933. SELECT
  1934. su.organ_id_,smcr.tenant_id_,
  1935. #{dayStr} month_,
  1936. COUNT(DISTINCT smcr.user_id_) total_num_,
  1937. COUNT(DISTINCT smcr.user_id_) activate_num_,
  1938. COUNT(DISTINCT smcr.user_id_) percent_
  1939. FROM sys_music_compare_record smcr
  1940. LEFT JOIN sys_user su ON smcr.user_id_=su.id_
  1941. LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
  1942. WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL and smcr.tenant_id_ = #{tenantId}
  1943. <if test="dayStr!=null and dayStr!=''">
  1944. AND DATE(smcr.create_time_)= #{dayStr}
  1945. </if>
  1946. GROUP BY su.organ_id_
  1947. </select>
  1948. <select id="getCloudStudyLivelyStudentNumData" resultMap="IndexBaseMonthData">
  1949. SELECT
  1950. t.organ_id_,t.tenant_id_,
  1951. #{dayStr} month_,
  1952. COUNT(user_id_) total_num_,
  1953. COUNT(user_id_) activate_num_,
  1954. COUNT(user_id_) percent_
  1955. FROM (SELECT
  1956. su.organ_id_,su.tenant_id_,
  1957. smcr.user_id_,
  1958. COUNT(DISTINCT(CASE WHEN DATEDIFF(NOW(), smcr.create_time_)&lt;=15 THEN DATE_FORMAT(smcr.create_time_, '%Y-%m-%d') ELSE NULL END)) days
  1959. FROM sys_music_compare_record smcr
  1960. LEFT JOIN sys_user su ON smcr.user_id_=su.id_
  1961. LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
  1962. WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL and smcr.tenant_id_ = #{tenantId}
  1963. <if test="dayStr!=null and dayStr!=''">
  1964. AND DATE(smcr.create_time_) &lt;= #{dayStr}
  1965. </if>
  1966. GROUP BY smcr.user_id_) t WHERE t.days>=5
  1967. GROUP BY t.organ_id_
  1968. </select>
  1969. <select id="getCloudStudyNewStudentNumData" resultMap="IndexBaseMonthData">
  1970. SELECT
  1971. organ_id_,tenant_id_,
  1972. #{dayStr} month_,
  1973. COUNT( DISTINCT user_id_ ) total_num_,
  1974. COUNT( DISTINCT user_id_ ) activate_num_,
  1975. COUNT( DISTINCT user_id_ ) percent_
  1976. FROM
  1977. (
  1978. SELECT
  1979. su.organ_id_,smcr.tenant_id_,
  1980. smcr.user_id_
  1981. FROM
  1982. sys_music_compare_record smcr
  1983. LEFT JOIN sys_user su ON smcr.user_id_ = su.id_
  1984. WHERE su.del_flag_ = 0 and smcr.tenant_id_ = #{tenantId}
  1985. GROUP BY user_id_
  1986. HAVING MIN(DATE( smcr.create_time_ ))= #{dayStr}) t
  1987. GROUP BY t.organ_id_
  1988. </select>
  1989. <resultMap id="CloudTeacherActiveTargetDto" type="com.ym.mec.biz.dal.dto.CloudTeacherActiveTargetDto">
  1990. <result property="organId" column="organ_id_"/>
  1991. <result property="organName" column="organ_name_"/>
  1992. <result property="totalNum" column="total_num_"/>
  1993. <result property="buyAmount" column="buy_amount_"/>
  1994. <result property="buyNum" column="buy_num_"/>
  1995. <result property="targetAmount" column="target_amount_"/>
  1996. <result property="targetNum" column="target_num_"/>
  1997. </resultMap>
  1998. <select id="countCloudTeacherActive" resultMap="CloudTeacherActiveTargetDto">
  1999. 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_,
  2000. COUNT(DISTINCT cto.student_id_) buy_num_
  2001. FROM student s
  2002. LEFT JOIN cloud_teacher_order cto ON cto.student_id_ = s.user_id_ AND cto.status_ != 0 AND cto.active_remark_ = '202109'
  2003. LEFT JOIN sys_user su ON su.id_ = s.user_id_
  2004. LEFT JOIN organization o ON o.id_ = su.organ_id_
  2005. WHERE s.tenant_id_ = #{tenantId}
  2006. <if test="organIdList != null and organIdList.size > 0">
  2007. AND su.organ_id_ IN
  2008. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  2009. #{item}
  2010. </foreach>
  2011. </if>
  2012. GROUP BY su.organ_id_
  2013. </select>
  2014. <select id="getStudentVipOrderNum" resultMap="IndexBaseMonthData">
  2015. SELECT spo.create_time_ month_,spo.organ_id_,
  2016. COUNT(DISTINCT spo.id_) total_num_,
  2017. 'STUDENT_VIP_ORDER_NUM' data_type_,spo.user_id_ extend_info_,spo.tenant_id_
  2018. FROM (SELECT id_,user_id_,organ_id_,activity_id_,music_group_id_,calender_id_,type_,group_type_,
  2019. DATE_FORMAT(create_time_,'%Y-%m-%d') create_time_,tenant_id_ FROM student_payment_order
  2020. WHERE status_ = 'SUCCESS' AND DATE_FORMAT(create_time_,'%Y-%m-%d') = #{dayStr} AND tenant_id_ = #{tenantId}) spo
  2021. LEFT JOIN student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
  2022. LEFT JOIN vip_group_activity vga ON FIND_IN_SET(vga.id_,spo.activity_id_)
  2023. LEFT JOIN vip_group_category vgc ON vgc.id_ = vga.vip_group_category_id_list_
  2024. LEFT JOIN vip_group vg ON vg.id_ = spo.music_group_id_
  2025. LEFT JOIN vip_group_category vgc1 ON vgc1.id_ = vg.vip_group_category_id_
  2026. LEFT JOIN music_group_payment_calender_activity mgpca ON mgpca.calender_id_ = spo.calender_id_
  2027. LEFT JOIN vip_group_activity vga1 ON vga1.id_ = mgpca.activity_id_
  2028. LEFT JOIN vip_group_category vgc2 ON vgc2.id_ = vga1.vip_group_category_id_list_
  2029. WHERE (spo.group_type_ = 'SPORADIC' AND spo.type_ = 'DEGREE_REGISTRATION' AND spod.type_ = 'DEGREE_REGISTRATION')
  2030. OR (spo.group_type_ = 'SPORADIC' AND spo.type_ = 'DOUBLE_ELEVEN2020') OR (spo.group_type_ = 'DEGREE' AND spod.type_ = 'VIP')
  2031. OR (spo.type_ = 'SMALL_CLASS_TO_BUY' AND vgc1.name_ != '乐理课') OR (spo.group_type_ = 'MUSIC' AND spod.type_ = 'VIP' AND vgc2.name_ != '乐理课')
  2032. OR (spo.type_ = 'DOUBLE_ELEVEN2021' AND vgc.name_ != '乐理课')
  2033. GROUP BY spo.user_id_,spo.create_time_,spo.organ_id_;
  2034. </select>
  2035. <select id="getStudentTheoryOrderNum" resultMap="IndexBaseMonthData">
  2036. SELECT spo.create_time_ month_,spo.organ_id_,
  2037. COUNT(DISTINCT spo.id_) total_num_,
  2038. 'STUDENT_THEORY_ORDER_NUM' data_type_,spo.user_id_ extend_info_,spo.tenant_id_
  2039. FROM (SELECT id_,user_id_,organ_id_,activity_id_,music_group_id_,calender_id_,type_,group_type_,
  2040. DATE_FORMAT(create_time_,'%Y-%m-%d') create_time_,tenant_id_ FROM student_payment_order
  2041. WHERE status_ = 'SUCCESS' AND DATE_FORMAT(create_time_,'%Y-%m-%d') = #{dayStr} AND tenant_id_ = #{tenantId}) spo
  2042. LEFT JOIN student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
  2043. LEFT JOIN vip_group_activity vga ON FIND_IN_SET(vga.id_,spo.activity_id_)
  2044. LEFT JOIN vip_group_category vgc ON vgc.id_ = vga.vip_group_category_id_list_
  2045. LEFT JOIN vip_group vg ON vg.id_ = spo.music_group_id_
  2046. LEFT JOIN vip_group_category vgc1 ON vgc1.id_ = vg.vip_group_category_id_
  2047. LEFT JOIN music_group_payment_calender_activity mgpca ON mgpca.calender_id_ = spo.calender_id_
  2048. LEFT JOIN vip_group_activity vga1 ON vga1.id_ = mgpca.activity_id_
  2049. LEFT JOIN vip_group_category vgc2 ON vgc2.id_ = vga1.vip_group_category_id_list_
  2050. WHERE (spo.group_type_ = 'DEGREE' AND spod.type_ = 'THEORY_COURSE')
  2051. OR (spo.type_ = 'SMALL_CLASS_TO_BUY' AND vgc1.name_ = '乐理课') OR (spo.group_type_ = 'MUSIC' AND spod.type_ = 'VIP' AND vgc2.name_ = '乐理课')
  2052. OR (spo.type_ = 'DOUBLE_ELEVEN2021' AND vgc.name_ = '乐理课')
  2053. GROUP BY spo.user_id_,spo.create_time_,spo.organ_id_;
  2054. </select>
  2055. <select id="getStudentPracticeOrderNum" resultMap="IndexBaseMonthData">
  2056. SELECT spo.create_time_ month_,spo.organ_id_,
  2057. COUNT(DISTINCT spo.id_) total_num_,
  2058. 'STUDENT_PRACTICE_ORDER_NUM' data_type_,spo.user_id_ extend_info_,spo.tenant_id_
  2059. FROM (SELECT id_,user_id_,organ_id_,activity_id_,music_group_id_,calender_id_,type_,group_type_,
  2060. DATE_FORMAT(create_time_,'%Y-%m-%d') create_time_,tenant_id_ FROM student_payment_order
  2061. WHERE status_ = 'SUCCESS' AND DATE_FORMAT(create_time_,'%Y-%m-%d') = #{dayStr} AND tenant_id_ = #{tenantId}) spo
  2062. LEFT JOIN student_payment_order_detail spod ON spod.payment_order_id_ = spo.id_
  2063. WHERE spo.type_ = 'PRACTICE_GROUP_BUY' OR spo.type_ = 'PRACTICE_GROUP_RENEW' OR (spo.group_type_ = 'MUSIC' AND spod.type_ = 'PRACTICE')
  2064. GROUP BY spo.user_id_,spo.create_time_,spo.organ_id_;
  2065. </select>
  2066. <select id="getCurrentCourseError" resultType="java.lang.Integer">
  2067. select COUNT(ss.user_id_) from student_statistics ss
  2068. left join (select cssp.user_id_ from course_schedule cs
  2069. left join course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
  2070. where DATE_FORMAT(cs.class_date_,'%Y-%m') = #{month} AND cs.type_ = 'VIP' AND cssp.group_type_ = 'VIP' and cssp.user_id_ IS NOT NULL
  2071. <if test="organIdList != null and organIdList.size > 0">
  2072. AND cs.organ_id_ IN
  2073. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  2074. #{item}
  2075. </foreach>
  2076. </if>
  2077. group by cssp.user_id_ having COUNT(distinct cssp.course_schedule_id_) &lt; 4) cs ON cs.user_id_ = ss.user_id_
  2078. where ss.no_schedule_num_ + ss.sub_course_num_ > 4 and ss.group_type_ = 'VIP' AND cs.user_id_ = ss.user_id_;
  2079. </select>
  2080. <select id="getWaitRenewInfo" resultType="java.lang.Integer">
  2081. select COUNT(ss.user_id_) from student_statistics ss
  2082. <if test="organIdList != null and organIdList.size > 0">
  2083. left join sys_user su ON su.id_ = ss.user_id_
  2084. </if>
  2085. where ss.group_type_ = 'VIP' AND ss.no_schedule_num_ + ss.sub_course_num_ &lt; 4
  2086. AND (ss.sub_course_num_ > 0 OR ss.no_schedule_num_ > 0) AND ss.lately_year_course_consumer_ > 0
  2087. <if test="organIdList != null and organIdList.size > 0">
  2088. AND su.organ_id_ IN
  2089. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  2090. #{item}
  2091. </foreach>
  2092. </if>
  2093. </select>
  2094. </mapper>