IndexBaseMonthDataMapper.xml 90 KB

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