IndexBaseMonthDataMapper.xml 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532
  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 AND cs.pre_course_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 AND m.pre_course_flag_ = 0
  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 AND m.pre_course_flag_ = 0
  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 AND m.pre_course_flag_ = 0
  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 AND cs.pre_course_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') AND cs.pre_course_flag_ = 0
  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') AND cs.pre_course_flag_ = 0
  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_) AND cs.pre_course_flag_ = 0
  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_) AND cs.pre_course_flag_ = 0
  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_ AND cs.pre_course_flag_ = 0
  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_in_status_ IS NULL OR ta.sign_out_status_ = 0 OR ta.sign_out_status_ IS NULL) AND ta.dispose_content_ IS NULL) OR (sa.id_ IS NULL OR (sa.status_ = 'TRUANT' AND sa.visit_flag_ = 0)))
  908. AND ((ta.sign_in_status_ IS NULL AND ta.sign_out_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NULL AND ta.sign_in_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NOT NULL AND ta.sign_in_status_ IS NOT NULL))
  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' AND cs.pre_course_flag_ = 0
  935. AND (((ta.sign_in_status_ = 0 OR ta.sign_in_status_ IS NULL OR ta.sign_out_status_ = 0 OR ta.sign_out_status_ IS NULL) AND ta.dispose_content_ IS NULL) OR (sa.id_ IS NULL OR (sa.status_ = 'TRUANT' AND sa.visit_flag_ = 0)))
  936. AND ((ta.sign_in_status_ IS NULL AND ta.sign_out_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NULL AND ta.sign_in_status_ IS NOT NULL) OR (ta.sign_out_status_ IS NOT NULL AND ta.sign_in_status_ IS NOT NULL))
  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' AND cs.pre_course_flag_ = 0
  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' AND cs.pre_course_flag_ = 0
  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. <select id="countStudentErrorLeave" resultType="java.lang.Integer">
  1329. SELECT COUNT(DISTINCT c.user_id_) FROM (
  1330. SELECT sa.user_id_ FROM student_attendance sa
  1331. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1332. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{format} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1333. <if test="organIdList != null and organIdList.size > 0">
  1334. AND cs.organ_id_ IN
  1335. <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
  1336. #{item}
  1337. </foreach>
  1338. </if>
  1339. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1340. AND cs.class_group_id_ IN
  1341. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1342. #{classGroupId}
  1343. </foreach>
  1344. </if>
  1345. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1346. HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_)) c
  1347. </select>
  1348. <select id="countStudentErrorLeave1" resultType="java.lang.Integer">
  1349. SELECT COUNT(DISTINCT c.user_id_) FROM (
  1350. SELECT sa.user_id_ FROM student_attendance sa
  1351. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1352. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1353. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1354. <if test="organId != null">
  1355. AND FIND_IN_SET(cs.organ_id_,#{organId})
  1356. </if>
  1357. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1358. AND cs.class_group_id_ IN
  1359. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1360. #{classGroupId}
  1361. </foreach>
  1362. </if>
  1363. <if test="search != null and search != ''">
  1364. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1365. </if>
  1366. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m')
  1367. HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_)) c
  1368. </select>
  1369. <resultMap id="StudentErrorLeaveDto" type="com.ym.mec.biz.dal.dto.StudentErrorLeaveDto">
  1370. <result property="currentNum" column="current_num_"/>
  1371. <result property="totalNum" column="total_num_"/>
  1372. <result property="userId" column="user_id_"/>
  1373. <result property="studentName" column="username_"/>
  1374. <result property="phone" column="phone_"/>
  1375. <result property="organId" column="organ_id_"/>
  1376. <result property="organName" column="organ_name_"/>
  1377. </resultMap>
  1378. <select id="queryStudentErrorLeave" resultMap="StudentErrorLeaveDto">
  1379. SELECT organ_id_,organ_name_,user_id_,username_,phone_,current_num_,class_date_
  1380. FROM (SELECT cs.organ_id_,o.name_ organ_name_,sa.user_id_,su.username_,su.phone_,
  1381. COUNT(sa.id_) current_num_,cs.class_date_
  1382. FROM student_attendance sa
  1383. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1384. LEFT JOIN organization o ON o.id_ = cs.organ_id_
  1385. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1386. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1387. <if test="organId != null">
  1388. AND FIND_IN_SET(cs.organ_id_,#{organId})
  1389. </if>
  1390. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1391. AND cs.class_group_id_ IN
  1392. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1393. #{classGroupId}
  1394. </foreach>
  1395. </if>
  1396. <if test="search != null and search != ''">
  1397. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1398. </if>
  1399. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m') HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_) ORDER BY cs.class_date_ DESC)c
  1400. GROUP BY c.user_id_
  1401. <include refid="global.limit"/>
  1402. </select>
  1403. <select id="countStudentLeaveCourseList" resultType="java.lang.Integer">
  1404. SELECT COUNT(sa.id_)
  1405. FROM student_attendance sa
  1406. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1407. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  1408. <include refid="queryStudentLeaveCourseListSql"/>
  1409. </select>
  1410. <sql id="queryStudentLeaveCourseListSql">
  1411. <where>
  1412. sa.user_id_ = #{userId} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1413. <if test="search != null and search != ''">
  1414. AND (cs.id_ = #{search} OR cs.actual_teacher_id_ = #{search} OR su.real_name_ LIKE CONCAT('%',#{search},'%'))
  1415. </if>
  1416. <if test="leaveVisitFlag != null">
  1417. AND sa.leave_visit_flag_ = #{leaveVisitFlag}
  1418. </if>
  1419. <if test="courseType != null">
  1420. AND cs.type_ = #{courseType}
  1421. </if>
  1422. </where>
  1423. </sql>
  1424. <resultMap id="StudentLeaveCourseDto" type="com.ym.mec.biz.dal.dto.StudentLeaveCourseDto">
  1425. <result property="leaveVisitFlag" column="leave_visit_flag_"/>
  1426. <result property="classDate" column="class_date_"/>
  1427. <result property="startClassTime" column="start_class_time_"/>
  1428. <result property="endClassTime" column="end_class_time_"/>
  1429. <result property="teacherName" column="teacher_name_"/>
  1430. <result property="actualTeacherId" column="actual_teacher_id_"/>
  1431. <result property="courseScheduleId" column="course_schedule_id_"/>
  1432. <result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1433. <result property="courseScheduleType" column="type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  1434. <result property="courseName" column="name_"/>
  1435. <result property="groupId" column="music_group_id_"/>
  1436. </resultMap>
  1437. <select id="queryStudentLeaveCourseList" resultMap="StudentLeaveCourseDto">
  1438. SELECT sa.leave_visit_flag_,cs.class_date_,cs.start_class_time_,
  1439. cs.end_class_time_,su.real_name_ teacher_name_,cs.actual_teacher_id_,
  1440. sa.course_schedule_id_,cs.group_type_,cs.type_,cs.name_,cs.music_group_id_
  1441. FROM student_attendance sa
  1442. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1443. LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
  1444. <include refid="queryStudentLeaveCourseListSql"/>
  1445. ORDER BY cs.class_date_ DESC,cs.start_class_time_ DESC
  1446. <include refid="global.limit"/>
  1447. </select>
  1448. <select id="getStudentErrorLeaveNumMap" resultType="java.util.Map">
  1449. SELECT user_id_ 'key',SUM(total_num_) 'value'
  1450. FROM (SELECT sa.user_id_,COUNT(sa.id_) total_num_
  1451. FROM student_attendance sa
  1452. LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
  1453. LEFT JOIN sys_user su ON su.id_ = sa.user_id_
  1454. WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{totalMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
  1455. <if test="organId != null">
  1456. AND FIND_IN_SET(cs.organ_id_,#{organId})
  1457. </if>
  1458. <if test="classGroupIds != null and classGroupIds.size() > 0">
  1459. AND cs.class_group_id_ IN
  1460. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  1461. #{classGroupId}
  1462. </foreach>
  1463. </if>
  1464. <if test="search != null and search != ''">
  1465. AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  1466. </if>
  1467. GROUP BY sa.user_id_,DATE_FORMAT(cs.class_date_,'%Y-%m') HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_) ORDER BY cs.class_date_ DESC)c
  1468. GROUP BY c.user_id_
  1469. </select>
  1470. </mapper>