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