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