IndexBaseMonthDataMapper.xml 51 KB

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