IndexBaseMonthDataMapper.xml 46 KB

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