IndexBaseMonthDataMapper.xml 79 KB

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