IndexBaseMonthDataMapper.xml 70 KB

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