IndexBaseMonthDataMapper.xml 50 KB

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