IndexBaseMonthDataMapper.xml 60 KB

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