IndexBaseMonthDataMapper.xml 75 KB

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