IndexBaseMonthDataMapper.xml 64 KB

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