IndexBaseMonthDataMapper.xml 63 KB

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