| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621 | 
							- <?xml version="1.0" encoding="UTF-8" ?>
 
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
- <!--
 
- 这个文件是自动生成的。
 
- 不要修改此文件。所有改动将在下次重新自动生成时丢失。
 
- -->
 
- <mapper namespace="com.ym.mec.biz.dal.dao.IndexBaseMonthDataDao">
 
- 	<resultMap type="com.ym.mec.biz.dal.entity.IndexBaseMonthData" id="IndexBaseMonthData">
 
- 		<result column="id_" property="id" />
 
- 		<result column="month_" property="month" />
 
- 		<result column="month_" property="monthStr" />
 
- 		<result column="organ_id_" property="organId" />
 
- 		<result column="total_num_" property="totalNum" />
 
- 		<result column="activate_num_" property="activateNum" />
 
- 		<result column="percent_" property="percent" />
 
- 		<result column="data_type_" property="dataType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 
- 		<result column="extend_info_" property="extendInfo"/>
 
- 		<result column="create_time_" property="createTime" />
 
- 		<result column="update_time_" property="updateTime" />
 
- 	</resultMap>
 
- 	<!-- 根据主键查询一条记录 -->
 
- 	<select id="get" resultMap="IndexBaseMonthData" >
 
- 		SELECT * FROM index_base_month_data WHERE id_ = #{id}
 
- 	</select>
 
- 	<!-- 全查询 -->
 
- 	<select id="findAll" resultMap="IndexBaseMonthData">
 
- 		SELECT * FROM index_base_month_data ORDER BY id_
 
- 	</select>
 
- 	<select id="getOrganDataWithDayAndDataType" resultMap="IndexBaseMonthData">
 
- 		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;
 
- 	</select>
 
- 	<!-- 向数据库增加一条记录 -->
 
- 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 
- 		<!--
 
- 		<selectKey resultClass="int" keyProperty="id" > 
 
- 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 
- 		</selectKey>
 
- 		-->
 
- 		INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,extend_info_,create_time_,update_time_)
 
- 		VALUES(#{month},#{organId},#{totalNum},#{activateNum},#{percent},#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{extendInfo},NOW(),NOW())
 
- 	</insert>
 
- 	<insert id="batchInsertWithDataType" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 
- 		INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,extend_info_,create_time_,update_time_)
 
- 		VALUES
 
- 		<foreach collection="datas" item="data" separator=",">
 
- 			(#{data.month},#{data.organId},#{data.totalNum},#{data.activateNum},#{data.percent},
 
- 			#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.extendInfo},NOW(),NOW())
 
- 		</foreach>
 
- 	</insert>
 
- 	<insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 
- 		INSERT INTO index_base_month_data (month_,organ_id_,total_num_,activate_num_,percent_,data_type_,extend_info_,create_time_,update_time_)
 
- 		VALUES
 
- 		<foreach collection="datas" item="data" separator=",">
 
- 			(#{data.month},#{data.organId},#{data.totalNum},#{data.activateNum},#{data.percent},
 
- 			#{data.dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.extendInfo},NOW(),NOW())
 
- 		</foreach>
 
- 	</insert>
 
- 	<!-- 根据主键查询一条记录 -->
 
- 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.IndexBaseMonthData">
 
- 		UPDATE index_base_month_data
 
- 		<set>
 
- 			<if test="organId != null">
 
- 				organ_id_ = #{organId},
 
- 			</if>
 
- 			<if test="id != null">
 
- 				id_ = #{id},
 
- 			</if>
 
- 			<if test="activateNum != null">
 
- 				activate_num_ = #{activateNum},
 
- 			</if>
 
- 			<if test="totalNum != null">
 
- 				total_num_ = #{totalNum},
 
- 			</if>
 
- 			<if test="percent != null">
 
- 				percent_ = #{percent},
 
- 			</if>
 
- 			<if test="month != null">
 
- 				month_ = #{month},
 
- 			</if>
 
- 			<if test="dataType != null">
 
- 				data_type_ = #{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 
- 			</if>
 
- 			<if test="extendInfo != null">
 
- 				extend_info_ = #{extendInfo},
 
- 			</if>
 
- 			update_time_ = NOW()
 
- 		</set>
 
- 		WHERE id_ = #{id}
 
- 	</update>
 
- 	<!-- 根据主键删除一条记录 -->
 
- 	<delete id="delete" >
 
- 		DELETE FROM index_base_month_data WHERE id_ = #{id}
 
- 	</delete>
 
- 	<delete id="deleteWithMonthAndType">
 
- 		DELETE FROM index_base_month_data
 
- 		WHERE DATE_FORMAT(month_, '%Y-%m-%d') IN
 
- 		<foreach collection="months" item="month" open="(" close=")" separator=",">
 
- 			#{month}
 
- 		</foreach>
 
- 		<if test="dataType!=null">
 
- 			AND data_type_=#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 		</if>
 
- 	</delete>
 
- 	<!-- 分页查询 -->
 
- 	<select id="queryPage" resultMap="IndexBaseMonthData" parameterType="map">
 
- 		SELECT * FROM index_base_month_data ORDER BY id_ <include refid="global.limit"/>
 
- 	</select>
 
- 	<!-- 查询当前表的总记录数 -->
 
- 	<select id="queryCount" resultType="int">
 
- 		SELECT COUNT(*) FROM index_base_month_data
 
- 	</select>
 
-     <select id="getIndexBaseData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			month_,data_type_,SUM(total_num_) total_num_,SUM(activate_num_) activate_num_,SUM(percent_) percent_
 
- 		FROM index_base_month_data
 
- 		<where>
 
- 			<if test="dataTypes!=null and dataTypes.size()>0">
 
- 				AND data_type_ IN
 
- 				<foreach collection="dataTypes" item="dataType" open="(" close=")" separator=",">
 
- 					#{dataType}
 
- 				</foreach>
 
- 			</if>
 
- 			<if test="organIds!=null and organIds.size()>0">
 
- 				AND organ_id_ IN
 
- 				<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 					#{organId}
 
- 				</foreach>
 
- 			</if>
 
- 			<if test="startMonth!=null and startMonth!=''">
 
- 				AND month_>=#{startMonth}
 
- 			</if>
 
- 			<if test="endMonth!=null and endMonth!=''">
 
- 				AND month_<=#{endMonth}
 
- 			</if>
 
- 		</where>
 
- 		GROUP BY month_,data_type_
 
- 	</select>
 
- 	<select id="getVipCourseDataList" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			month_,
 
- 			organ_id_,
 
- 			data_type_,
 
- 			extend_info_
 
- 		FROM index_base_month_data
 
- 		FORCE INDEX(data_type_, month_)
 
- 			<where>
 
- 				<if test="dataTypes!=null and dataTypes.size()>0">
 
- 					AND data_type_ IN
 
- 					<foreach collection="dataTypes" item="dataType" open="(" close=")" separator=",">
 
- 						#{dataType}
 
- 					</foreach>
 
- 				</if>
 
- 				<if test="organIds!=null and organIds.size()>0">
 
- 					AND organ_id_ IN
 
- 					<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 						#{organId}
 
- 					</foreach>
 
- 				</if>
 
- 				<if test="startMonth!=null and startMonth!=''">
 
- 					AND month_>=#{startMonth}
 
- 				</if>
 
- 				<if test="endMonth!=null and endMonth!=''">
 
- 					AND month_<=#{endMonth}
 
- 				</if>
 
- 				AND extend_info_ IS NOT NULL
 
- 			</where>
 
- 	</select>
 
- 	<select id="getWithDayAndDataType" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			*
 
- 		FROM index_base_month_data
 
- 		WHERE 1=1
 
- 			AND data_type_ = #{dataType}
 
- 			AND month_>=#{day}
 
- 	</select>
 
- 	<select id="getStudentSignUpData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( id_ ) total_num_,
 
- 			COUNT(CASE WHEN password_ IS NOT NULL THEN id_ ELSE NULL END) activate_num_,
 
- 			TRUNCATE(COUNT(CASE WHEN password_ IS NOT NULL THEN id_ ELSE NULL END)/COUNT( id_ )*100, 2) percent_
 
- 		FROM
 
- 			((
 
- 				 SELECT DISTINCT
 
- 					 sr.user_id_
 
- 				 FROM
 
- 					 student_registration sr
 
- 					LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
 
- 				 WHERE
 
- 					 mg.status_ IN ( 'PREPARE', 'PROGRESS' )
 
- 				   AND sr.music_group_status_ = 'NORMAL'
 
- 				   AND DATE_FORMAT(sr.create_time_, '%Y-%m-%d')<=#{dayStr}
 
- 			 ) UNION ALL
 
- 			(
 
- 			 SELECT DISTINCT
 
- 				 cssp.user_id_
 
- 			 FROM
 
- 				course_schedule_student_payment cssp
 
- 				LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
 
- 			 WHERE
 
- 				 cs.del_flag_ = 0 AND cs.pre_course_flag_ = 0
 
- 			   AND ( cs.is_lock_ = 0 OR cs.is_lock_ IS NULL )
 
- 			   AND ( cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_ )
 
- 			   AND cssp.group_type_ IN ('VIP', 'PRACTICE')
 
- 			   AND cs.organ_id_ IS NOT NULL
 
- 			   AND DATE_FORMAT(cssp.create_time_, '%Y-%m-%d')<=#{dayStr}
 
- 				AND cs.class_date_ >= #{courseStartDay}
 
- 			)) u
 
- 			LEFT JOIN sys_user su ON u.user_id_ = su.id_
 
- 		WHERE
 
- 			del_flag_=0
 
- 		  	AND organ_id_ IS NOT NULL
 
- 			AND user_type_ LIKE '%STUDENT%'
 
- 		GROUP BY organ_id_
 
- 		ORDER BY organ_id_;
 
- 	</select>
 
- 	<select id="getStudentRegistrationData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			su.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT stu.user_id_ ) total_num_,
 
- 			COUNT( DISTINCT stu.user_id_ ) activate_num_,
 
- 			COUNT( DISTINCT stu.user_id_ ) percent_
 
- 		FROM
 
- 			student stu
 
- 			LEFT JOIN sys_user su ON stu.user_id_=su.id_
 
- 		WHERE
 
- 			su.del_flag_=0
 
- 		  AND su.organ_id_ IS NOT NULL
 
- 		  AND su.user_type_ LIKE '%STUDENT%'
 
- 		  AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')<=#{dayStr}
 
- 		GROUP BY organ_id_
 
- 		ORDER BY organ_id_;
 
- 	</select>
 
- 	<select id="getAddStudentRegistrationData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			su.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT stu.user_id_ ) total_num_,
 
- 			COUNT( DISTINCT stu.user_id_ ) activate_num_,
 
- 			COUNT( DISTINCT stu.user_id_ ) percent_
 
- 		FROM
 
- 			student stu
 
- 			LEFT JOIN sys_user su ON stu.user_id_=su.id_
 
- 		WHERE
 
- 			su.del_flag_=0
 
- 		  AND su.organ_id_ IS NOT NULL
 
- 		  AND su.user_type_ LIKE '%STUDENT%'
 
- 		  AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')=#{dayStr}
 
- 		GROUP BY organ_id_
 
- 		ORDER BY organ_id_;
 
- 	</select>
 
- 	<select id="getChargeStudentChangeData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			su.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT stu.user_id_ ) total_num_,
 
- 			COUNT( DISTINCT (CASE WHEN DATE_FORMAT( spo.create_time_, '%Y-%m-%d' ) <= #{dayStr} THEN spo.user_id_ ELSE NULL END) ) activate_num_,
 
- 			TRUNCATE(COUNT(DISTINCT (CASE WHEN DATE_FORMAT( spo.create_time_, '%Y-%m-%d' ) <= #{dayStr} THEN spo.user_id_ ELSE NULL END))/COUNT(DISTINCT stu.user_id_)*100, 2) percent_
 
- 		FROM
 
- 			student stu
 
- 			LEFT JOIN sys_user su ON stu.user_id_=su.id_
 
- 			LEFT JOIN student_payment_order spo ON stu.user_id_=spo.user_id_ AND status_='SUCCESS' AND actual_amount_>0
 
- 		WHERE
 
- 			su.del_flag_=0
 
- 			  AND su.organ_id_ IS NOT NULL
 
- 			  AND su.user_type_ LIKE '%STUDENT%'
 
- 			  AND DATE_FORMAT(stu.create_time_, '%Y-%m-%d')<=#{dayStr}
 
- 		GROUP BY organ_id_
 
- 		ORDER BY organ_id_;
 
- 	</select>
 
- 	<select id="getHomeworkData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			su.organ_id_,
 
- 			sees.monday_ month_,
 
- 			<choose>
 
- 				<when test="type == 'submit'">
 
- 					SUM(sees.actual_exercises_num_) total_num_,
 
- 					SUM(sees.exercises_reply_num_) activate_num_,
 
- 					TRUNCATE(SUM(sees.exercises_reply_num_)/SUM(sees.actual_exercises_num_)*100, 2) percent_
 
- 				</when>
 
- 				<when test="type == 'comment'">
 
- 					SUM(sees.exercises_reply_num_) total_num_,
 
- 					SUM(sees.exercises_message_num_) activate_num_,
 
- 					TRUNCATE(SUM(sees.exercises_message_num_)/SUM(sees.exercises_reply_num_)*100, 2) percent_
 
- 				</when>
 
- 				<otherwise>
 
- 					SUM(sees.expect_exercises_num_-sees.not_over_course_num_) total_num_,
 
- 					SUM(sees.actual_exercises_num_) activate_num_,
 
- 					TRUNCATE(SUM(sees.actual_exercises_num_)/SUM(sees.expect_exercises_num_-sees.not_over_course_num_)*100, 2) percent_
 
- 				</otherwise>
 
- 			</choose>
 
- 		FROM student_extracurricular_exercises_situation_ sees
 
- 		LEFT JOIN sys_user su ON sees.student_id_=su.id_
 
- 		LEFT JOIN teacher tea ON sees.teacher_id_=tea.id_
 
- 		WHERE su.del_flag_=0
 
- 		  	AND tea.job_nature_='FULL_TIME'
 
- 			AND su.organ_id_ IS NOT NULL
 
- 			AND DATE_FORMAT(sees.monday_, '%Y-%m-%d')<=#{dayStr}
 
- 			AND DATE_FORMAT(sees.sunday_, '%Y-%m-%d')>=#{dayStr}
 
- 		GROUP BY su.organ_id_
 
- 		ORDER BY su.organ_id_
 
- 	</select>
 
- 	<select id="getSchoolData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			mg.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT mg.cooperation_organ_id_ ) total_num_,
 
- 			COUNT( DISTINCT mg.cooperation_organ_id_ ) activate_num_,
 
- 			COUNT( DISTINCT mg.cooperation_organ_id_ ) percent_
 
- 		FROM
 
- 			music_group mg
 
- 		WHERE
 
- 			mg.del_flag_ = 0
 
- 			AND mg.organ_id_ IS NOT NULL
 
- 			AND mg.status_ = 'PROGRESS'
 
- 			AND DATE_FORMAT(mg.create_time_, '%Y-%m-%d')<=#{dayStr}
 
- 		GROUP BY
 
- 			mg.organ_id_
 
- 		ORDER BY
 
- 			mg.organ_id_;
 
- 	</select>
 
- 	<select id="getMusicData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( id_ ) total_num_,
 
- 			COUNT( id_ ) activate_num_,
 
- 			COUNT( id_ ) percent_
 
- 		FROM
 
- 			music_group
 
- 		WHERE
 
- 			del_flag_ = 0
 
- 			AND status_ = 'PROGRESS'
 
- 			AND organ_id_ IS NOT NULL
 
- 			<if test="dayStr!=null and dayStr!=''">
 
- 				AND DATE_FORMAT(create_time_, '%Y-%m-%d') <= #{dayStr}
 
- 			</if>
 
- 		GROUP BY
 
- 			organ_id_
 
- 		ORDER BY
 
- 			organ_id_;
 
- 	</select>
 
- 	<select id="getMusicStudentData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			mg.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT sr.user_id_ ) total_num_,
 
- 			COUNT( DISTINCT sr.user_id_ ) activate_num_,
 
- 			COUNT( DISTINCT sr.user_id_ ) percent_
 
- 		FROM student_registration sr
 
- 			LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
 
- 		WHERE
 
- 			mg.del_flag_ = 0
 
- 		  	AND mg.organ_id_ IS NOT NULL
 
- 			AND mg.status_ = 'PROGRESS'
 
- 			<if test="type==null">
 
- 				AND sr.music_group_status_='NORMAL'
 
- 			</if>
 
- 			<if test="type!=null and type=='QUIT'">
 
- 				AND sr.music_group_status_='QUIT'
 
- 				AND DATE_FORMAT(sr.create_time_, '%Y-%m') >= CONCAT(DATE_FORMAT(NOW(), '%Y'), '-01')
 
- 			</if>
 
- 			<if test="type!=null and type=='ADD'">
 
- 				AND sr.music_group_status_='NORMAL'
 
- 				AND DATE_FORMAT(sr.create_time_, '%Y-%m') >= CONCAT(DATE_FORMAT(NOW(), '%Y'), '-01')
 
- 			</if>
 
- 			<if test="dayStr!=null and dayStr!=''">
 
- 				AND DATE_FORMAT(sr.create_time_, '%Y-%m-%d') <= #{dayStr}
 
- 			</if>
 
- 		GROUP BY
 
- 			mg.organ_id_
 
- 		ORDER BY
 
- 			mg.organ_id_;
 
- 	</select>
 
- 	<select id="getTeacherData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			t.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( t.id_ ) total_num_,
 
- 			COUNT( t.id_ ) activate_num_,
 
- 			COUNT( t.id_ ) percent_
 
- 		FROM
 
- 			teacher t
 
- 			LEFT JOIN sys_user su ON su.id_ = t.id_
 
- 		WHERE
 
- 			su.del_flag_ = 0
 
- 		  	AND (t.demission_date_ IS NULl OR DATE_FORMAT(t.demission_date_, '%Y-%m-%d') > #{dayStr})
 
- 		  	<if test="isDemission==null">
 
- 				AND su.lock_flag_ = 0
 
- 			</if>
 
- 		  	<if test="isDemission!=null">
 
- 				AND (su.lock_flag_ = 1 OR t.demission_date_<NOW())
 
- 			</if>
 
- 			AND t.organ_id_ IS NOT NULL
 
- 			<if test="jobNature!=null">
 
- 				AND t.job_nature_ = #{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 			</if>
 
- 			<if test="dayStr!=null and dayStr!=''">
 
- 				AND DATE_FORMAT(t.create_time_, '%Y-%m-%d') <= #{dayStr}
 
- 			</if>
 
- 		GROUP BY
 
- 			t.organ_id_
 
- 		ORDER BY
 
- 			t.organ_id_;
 
- 	</select>
 
- 	<select id="getGroupCourseData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			m.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( m.id_ ) total_num_,
 
- 			COUNT( m.id_ ) activate_num_,
 
- 			COUNT( m.id_ ) percent_
 
- 		FROM
 
- 			course_schedule m
 
- 		WHERE
 
- 			m.del_flag_ = 0
 
- 			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
 
- 		  	AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 			AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
 
- 			AND NOT EXISTS (SELECT id_ FROM practice_group WHERE m.group_type_='PRACTICE' AND m.music_group_id_=id_ AND type_='TRIAL')
 
- 			AND m.organ_id_ IS NOT NULL AND m.pre_course_flag_ = 0
 
- 			<if test="groupType!=null">
 
- 				AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 			</if>
 
- 			<if test="dayStr!=null and dayStr!=''">
 
- 				AND m.class_date_ >= #{dayStr}
 
- 			</if>
 
- 		GROUP BY
 
- 			m.organ_id_
 
- 		ORDER BY
 
- 			m.organ_id_;
 
- 	</select>
 
- 	<select id="getGroupSurplusCourseData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			m.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( m.id_ ) total_num_,
 
- 			COUNT( m.id_ ) activate_num_,
 
- 			COUNT( m.id_ ) percent_
 
- 		FROM
 
- 			course_schedule m
 
- 		WHERE
 
- 			m.del_flag_ = 0
 
- 			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
 
- 			AND m.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 			AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
 
- 			AND NOT EXISTS (SELECT id_ FROM practice_group WHERE m.group_type_='PRACTICE' AND m.music_group_id_=id_ AND type_='TRIAL')
 
- 			AND m.organ_id_ IS NOT NULL AND m.pre_course_flag_ = 0
 
- 			<if test="groupType!=null">
 
- 				AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 			</if>
 
- 			<if test="dayStr!=null and dayStr!=''">
 
- 				AND m.class_date_ <= #{dayStr}
 
- 			</if>
 
- 		GROUP BY m.organ_id_
 
- 		ORDER BY m.organ_id_;
 
- 	</select>
 
- 	<select id="getGroupCourseDataWithGroup" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 		m.organ_id_,
 
- 		#{dayStr} month_,
 
- 		COUNT( m.id_ ) total_num_,
 
- 		COUNT( m.id_ ) activate_num_,
 
- 		COUNT( m.id_ ) percent_
 
- 		FROM
 
- 		course_schedule m
 
- 		WHERE
 
- 		m.del_flag_ = 0
 
- 		AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
 
- 		AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
 
- 		AND NOT EXISTS (SELECT id_ FROM practice_group WHERE m.group_type_='PRACTICE' AND m.music_group_id_=id_ AND type_='TRIAL')
 
- 		AND m.organ_id_ IS NOT NULL AND m.pre_course_flag_ = 0
 
- 		<if test="groupType!=null">
 
- 			AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 		</if>
 
- 		<if test="dayStr!=null and dayStr!=''">
 
- 			AND m.class_date_ = #{dayStr}
 
- 		</if>
 
- 		<if test="teachMode!=null">
 
- 			AND m.teach_mode_ = #{teachMode, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 		</if>
 
- 		GROUP BY
 
- 			m.organ_id_
 
- 		ORDER BY
 
- 			m.organ_id_;
 
- 	</select>
 
- 	<select id="getVipGroupCategoryCourseData" resultType="com.ym.mec.biz.dal.dto.OrganVipGroupCategoryCourseNumDto">
 
- 		SELECT
 
- 		m.organ_id_ organId,
 
- 		vgc.name_ categoryName,
 
- 		COUNT( m.id_ ) courseNum
 
- 		FROM
 
- 		course_schedule m
 
- 		LEFT JOIN vip_group vg ON m.music_group_id_=vg.id_
 
- 		LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_=vgc.id_
 
- 		WHERE
 
- 		m.del_flag_ = 0
 
- 		AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
 
- 		AND (m.new_course_id_ IS NULL OR m.new_course_id_=m.id_)
 
- 		AND m.organ_id_ IS NOT NULL
 
- 		<if test="groupType!=null">
 
- 			AND m.group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 		</if>
 
- 		<if test="dayStr!=null and dayStr!=''">
 
- 			AND m.class_date_ = #{dayStr}
 
- 		</if>
 
- 		<if test="teachMode!=null">
 
- 			AND m.teach_mode_ = #{teachMode, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 		</if>
 
- 		GROUP BY
 
- 		m.organ_id_,vgc.name_
 
- 		ORDER BY
 
- 		m.organ_id_;
 
- 	</select>
 
- 	<select id="getOtherStudentData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			su.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT s.user_id_ ) total_num_,
 
- 			COUNT( DISTINCT s.user_id_ ) activate_num_,
 
- 			COUNT( DISTINCT s.user_id_ ) percent_
 
- 		FROM
 
- 		    sys_user su
 
- 			LEFT JOIN course_schedule_student_payment s ON su.id_=s.user_id_
 
- 			LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
 
- 		WHERE
 
- 			m.del_flag_ = 0
 
- 			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
 
- 			AND su.organ_id_ IS NOT NULL
 
- 			AND m.group_type_ IN ('VIP', 'PRACTICE')
 
- 			AND m.status_ = 'NOT_START'
 
- 			<if test="dayStr!=null and dayStr!=''">
 
- 				AND (DATE_FORMAT(s.create_time_, '%Y-%m-%d') <= #{dayStr} OR YEAR(m.create_time_)=3000)
 
- 			</if>
 
- 		GROUP BY
 
- 			su.organ_id_
 
- 		ORDER BY
 
- 			su.organ_id_;
 
- 	</select>
 
- 	<select id="getVipPracticeAddStudentData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			su.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT s.user_id_ ) total_num_,
 
- 			COUNT( DISTINCT s.user_id_ ) activate_num_,
 
- 			COUNT( DISTINCT s.user_id_ ) percent_
 
- 		FROM
 
- 			sys_user su
 
- 			LEFT JOIN course_schedule_student_payment s ON su.id_=s.user_id_
 
- 			LEFT JOIN course_schedule_student_payment cssp1 ON s.user_id_=cssp1.user_id_ AND cssp1.create_time_<#{dayStr}
 
- 			LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
 
- 		WHERE
 
- 			m.del_flag_ = 0
 
- 			AND (m.is_lock_ = 0 OR m.is_lock_ IS NULL)
 
- 			AND cssp1.id_ IS NULL
 
- 			AND su.organ_id_ IS NOT NULL
 
- 			AND m.group_type_ IN ('VIP', 'PRACTICE')
 
- 			<if test="dayStr!=null and dayStr!=''">
 
- 				AND DATE_FORMAT(s.create_time_, '%Y-%m-%d') = #{dayStr}
 
- 			</if>
 
- 		GROUP BY su.organ_id_
 
- 		ORDER BY su.organ_id_;
 
- 	</select>
 
- 	<select id="getStudentConversionData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			cs.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT m.user_id_ ) total_num_,
 
- 			COUNT( DISTINCT m.user_id_ ) activate_num_,
 
- 			COUNT( DISTINCT m.user_id_ ) percent_
 
- 		FROM
 
- 			course_schedule_student_payment m
 
- 			LEFT JOIN course_schedule cs ON m.course_schedule_id_=cs.id_
 
- 			LEFT JOIN practice_group pg ON m.music_group_id_=pg.id_ AND m.group_type_='PRACTICE'
 
- 		WHERE
 
- 			(cs.del_flag_ IS NULL OR cs.del_flag_=0)
 
- 			AND cs.organ_id_ IS NOT NULL
 
- 			AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
 
- 			AND m.group_type_ IN ('VIP', 'PRACTICE')
 
- 			AND (pg.id_ IS NULL OR pg.type_='CHARGE')
 
- 			AND m.user_id_ IN
 
- 			<foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
 
- 				#{studentId}
 
- 			</foreach>
 
- 			AND DATE_FORMAT(m.create_time_, '%Y-%m-%d')<=#{dayStr}
 
- 		GROUP BY
 
- 			cs.organ_id_
 
- 		ORDER BY
 
- 			cs.organ_id_;
 
- 	</select>
 
- 	<select id="getMusicGroupPreRegistrationStudentData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			mg.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT spr.user_id_ ) total_num_,
 
- 			COUNT( DISTINCT spr.user_id_ ) activate_num_,
 
- 			COUNT( DISTINCT spr.user_id_ ) percent_
 
- 		FROM
 
- 			student_pre_registration spr
 
- 			LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
 
- 		WHERE
 
- 			mg.del_flag_ = 0
 
- 			AND mg.organ_id_ IS NOT NULL
 
- 		  	AND mg.status_ = 'PROGRESS'
 
- 			AND DATE_FORMAT( spr.create_time_, '%Y-%m-%d' ) <= #{dayStr}
 
- 		GROUP BY
 
- 			mg.organ_id_
 
- 		ORDER BY
 
- 			mg.organ_id_;
 
- 	</select>
 
- 	<select id="getMusicGroupStudentFromPreData" resultMap="IndexBaseMonthData">
 
- 		SELECT
 
- 			mg.organ_id_,
 
- 			#{dayStr} month_,
 
- 			COUNT( DISTINCT sr.user_id_ ) total_num_,
 
- 			COUNT( DISTINCT sr.user_id_ ) activate_num_,
 
- 			COUNT( DISTINCT sr.user_id_ ) percent_
 
- 		FROM
 
- 			student_registration sr
 
- 			LEFT JOIN student_pre_registration spr ON sr.user_id_ = spr.user_id_ AND sr.music_group_id_ = spr.music_group_id_
 
- 			LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
 
- 		WHERE
 
- 			mg.del_flag_ = 0
 
- 			AND mg.organ_id_ IS NOT NULL
 
- 			AND mg.status_ = 'PROGRESS'
 
- 			<if test="paymentStatus==null">
 
- 				AND sr.music_group_status_ IN ('APPLY', 'NORMAL')
 
- 			</if>
 
- 		  	<if test="paymentStatus!=null">
 
- 				AND sr.music_group_status_ IN ('NORMAL')
 
- 				AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 			</if>
 
- 			AND DATE_FORMAT( sr.create_time_, '%Y-%m-%d' ) <= #{dayStr}
 
- 		GROUP BY
 
- 			mg.organ_id_
 
- 		ORDER BY
 
- 			mg.organ_id_;
 
- 	</select>
 
- 	<select id="getMusicGroupStudentIdFromPre" resultType="int">
 
- 		SELECT
 
- 			sr.user_id_
 
- 		FROM
 
- 			student_registration sr
 
- 			LEFT JOIN student_pre_registration spr ON sr.user_id_ = spr.user_id_ AND sr.music_group_id_ = spr.music_group_id_
 
- 			LEFT JOIN music_group mg ON spr.music_group_id_ = mg.id_
 
- 		WHERE
 
- 			mg.del_flag_ = 0
 
- 			AND mg.organ_id_ IS NOT NULL
 
- 			AND mg.status_ = 'PROGRESS'
 
- 			<if test="paymentStatus==null">
 
- 				AND sr.music_group_status_ IN ('APPLY', 'NORMAL')
 
- 			</if>
 
- 			<if test="paymentStatus!=null">
 
- 				AND sr.music_group_status_ IN ('NORMAL')
 
- 				AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 			</if>
 
- 			AND DATE_FORMAT( sr.create_time_, '%Y-%m-%d' ) <= #{dayStr}
 
- 	</select>
 
- 	<select id="countLessThenThreeClassGroupNum" resultType="int">
 
- 		SELECT COUNT(t.id_) FROM (
 
- 		SELECT cg.id_ FROM
 
- 		class_group cg
 
- 		LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
 
- 		LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
 
- 		LEFT JOIN course_schedule cs ON cs.class_group_id_=cg.id_
 
- 		WHERE
 
- 		cg.type_ IN ('HIGH', 'HIGH_ONLINE')
 
- 		AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0 AND cs.pre_course_flag_ = 0
 
- 		AND cs.del_flag_=0
 
- 		AND cs.status_='NOT_START'
 
- 		AND ( cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_ )
 
- 		<if test="educationUserId != null">
 
- 			AND mg.educational_teacher_id_ = #{educationUserId}
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND mg.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY cg.id_
 
- 		HAVING
 
- 		COUNT(DISTINCT CASE WHEN cgsm.status_ = 'NORMAL' THEN cgsm.user_id_ ELSE NULL END) < 3
 
- 		) t
 
- 	</select>
 
- 	<select id="countLessThenThreeClassOrganGroupNum" resultType="map">
 
- 		SELECT t.organ_id_ AS 'key',
 
- 		       COUNT(t.id_) AS 'value'
 
- 		FROM (
 
- 		SELECT mg.organ_id_,cg.id_ FROM
 
- 		class_group cg
 
- 		LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
 
- 		LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
 
- 		LEFT JOIN course_schedule cs ON cs.class_group_id_=cg.id_
 
- 		WHERE
 
- 		cg.type_ IN ('HIGH', 'HIGH_ONLINE') AND cs.pre_course_flag_ = 0
 
- 		AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0
 
- 		AND cs.del_flag_=0
 
- 		AND cs.status_='NOT_START'
 
- 		AND ( cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_ )
 
- 		<if test="educationUserId != null">
 
- 			AND mg.educational_teacher_id_ = #{educationUserId}
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND mg.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY cg.id_
 
- 		HAVING
 
- 		COUNT(DISTINCT CASE WHEN cgsm.status_ = 'NORMAL' THEN cgsm.user_id_ ELSE NULL END) < 3
 
- 		) t GROUP BY t.organ_id_
 
- 	</select>
 
-     <select id="getLessThenThreeMusicGroup" resultType="java.lang.String">
 
- 		SELECT cg.music_group_id_ FROM
 
- 		class_group cg
 
- 		LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
 
- 		LEFT JOIN music_group mg ON cg.music_group_id_=mg.id_
 
- 		WHERE
 
- 		cg.type_ IN ('HIGH_ONLINE')
 
- 		AND mg.status_ = 'PROGRESS' AND cg.del_flag_ = 0
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND mg.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY cg.id_
 
- 		HAVING
 
- 		COUNT(CASE WHEN cgsm.status_ = 'NORMAL' THEN 1 ELSE NULL END) < 3
 
- 	</select>
 
- 	<select id="countNoPaymentStudentNum" resultType="int">
 
- 		SELECT
 
- 			COUNT(DISTINCT mgpc.music_group_id_,mgpcd.user_id_)
 
- 		FROM
 
- 		music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 		LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
 
- 		WHERE
 
- 		mg.status_ = 'PROGRESS'
 
- 		<if test="noPaymentType==null or noPaymentType==0">
 
- 			AND DATE_FORMAT(NOW(),'%Y-%m-%d') > mgpc.deadline_payment_date_
 
- 		</if>
 
- 		<if test="noPaymentType!=null and noPaymentType==1">
 
- 			AND DATE_FORMAT(NOW(),'%Y-%m-%d') BETWEEN mgpc.start_payment_date_ AND mgpc.deadline_payment_date_
 
- 		</if>
 
- 		AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpcd.expect_amount_ > 0 AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
 
- 		<if test="educationUserId != null">
 
- 			AND mg.educational_teacher_id_ = #{educationUserId}
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND mg.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 	</select>
 
- 	<select id="countOrganNoPaymentStudentNum" resultType="map">
 
- 		SELECT
 
- 		    mg.organ_id_ AS 'key',
 
- 			COUNT(DISTINCT mgpc.music_group_id_,mgpcd.user_id_) AS 'value'
 
- 		FROM
 
- 		music_group_payment_calender_detail mgpcd
 
- 		LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 		LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
 
- 		WHERE
 
- 		mg.status_ = 'PROGRESS'
 
- 		AND DATE_FORMAT(NOW(),'%Y-%m-%d') > mgpc.deadline_payment_date_
 
- 		AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpcd.expect_amount_ > 0 AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
 
- 		<if test="educationUserId != null">
 
- 			AND mg.educational_teacher_id_ = #{educationUserId}
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND mg.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY mg.organ_id_
 
- 	</select>
 
- 	<select id="getNoPaymentMusicGroup" resultType="java.lang.String">
 
- 		SELECT
 
- 			DISTINCT mg.id_
 
- 		FROM
 
- 			music_group_payment_calender_detail mgpcd
 
- 			LEFT JOIN music_group_payment_calender mgpc ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
 
- 			LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
 
- 		WHERE
 
- 			mg.status_ = 'PROGRESS'
 
- 			AND DATE_FORMAT(NOW(),'%Y-%m-%d') >= DATE_FORMAT(mgpc.payment_valid_start_date_,'%Y-%m-%d')
 
- 			AND mgpcd.payment_status_ = 'NON_PAYMENT'
 
- 			<if test="educationUserId != null">
 
- 				AND mg.educational_teacher_id_ = #{educationUserId}
 
- 			</if>
 
- 			<if test="organIds!=null and organIds.size()>0">
 
- 				AND mg.organ_id_ IN
 
- 				<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 					#{organId}
 
- 				</foreach>
 
- 			</if>
 
- 	</select>
 
- 	<select id="queryApplyForQuitGroupNum" resultType="java.lang.Long">
 
- 		SELECT mgq.id_ FROM music_group_quit mgq
 
- 			LEFT JOIN music_group mg ON mgq.music_group_id_=mg.id_
 
- 		WHERE mg.status_='PROGRESS'
 
- 		  AND mgq.status_='PROCESSING'
 
- 		<if test="educationUserId != null">
 
- 			AND mg.educational_teacher_id_ = #{educationUserId}
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size() > 0">
 
- 			AND mg.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 	</select>
 
- 	<select id="queryOrganApplyForQuitGroupNum" resultType="map">
 
- 		SELECT
 
- 			mg.organ_id_ AS 'key',
 
- 		    COUNT(mgq.id_) AS 'value'
 
- 		FROM music_group_quit mgq
 
- 		LEFT JOIN music_group mg ON mgq.music_group_id_=mg.id_
 
- 		WHERE mg.status_='PROGRESS'
 
- 		AND mgq.status_='PROCESSING'
 
- 		<if test="educationUserId != null">
 
- 			AND mg.educational_teacher_id_ = #{educationUserId}
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size() > 0">
 
- 			AND mg.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY mg.organ_id_
 
- 	</select>
 
- 	<select id="queryStudentAttendanceInfo" resultType="int">
 
- 		SELECT
 
- 			COUNT(DISTINCT cssp.id_)
 
- 		FROM
 
- 			course_schedule_student_payment cssp
 
- 			LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
 
- 			LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND sa.user_id_ = cssp.user_id_
 
- 			LEFT JOIN student_visit sv ON cssp.id_ = sv.object_id_
 
- 		WHERE
 
- 				cs.status_ = 'OVER' AND sv.id_ IS NULL AND cs.del_flag_ = 0 AND cs.class_date_ >= #{startTime} AND cs.class_date_ <= DATE_FORMAT(NOW(),'%Y-%m-%d')
 
- 				AND cssp.group_type_ IN ('MUSIC','PRACTICE','VIP') AND cs.pre_course_flag_ = 0
 
- 			<if test="type!=null and type=='LEAVE'">
 
- 				AND sa.status_ = 'LEAVE'
 
- 			</if>
 
- 			<if test="type!=null and type=='TRUANT'">
 
- 				AND (sa.status_ = 'TRUANT' OR sa.id_ IS NULL) AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
 
- 			</if>
 
- 			<if test="organIds!=null and organIds.size()>0">
 
- 				AND cs.organ_id_ IN
 
- 				<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 					#{organId}
 
- 				</foreach>
 
- 			</if>
 
- 	</select>
 
-     <select id="getCourseTimeError" resultType="int">
 
- 		SELECT COUNT(cs.id_) FROM course_schedule cs
 
- 		WHERE cs.status_ = 'NOT_START' AND cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.start_class_time_ < '06:00:00'
 
- 		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cs.pre_course_flag_ = 0
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="organIds != null and organIds.size()>0">
 
- 			AND cs.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 	</select>
 
- 	<select id="getOrganCourseTimeError" resultType="map">
 
- 		SELECT
 
- 		       cs.organ_id_ AS 'key',
 
- 		       COUNT(cs.id_) AS 'value'
 
- 		FROM course_schedule cs
 
- 		WHERE cs.status_ = 'NOT_START' AND cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.start_class_time_ < '06:00:00'
 
- 		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cs.pre_course_flag_ = 0
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="organIds != null and organIds.size()>0">
 
- 			AND cs.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY cs.organ_id_
 
- 	</select>
 
-     <select id="getAttendanceError" resultType="int">
 
- 		SELECT COUNT(DISTINCT c.id_) FROM (SELECT cs.id_ FROM course_schedule cs
 
- 		LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
 
- 		LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
 
- 		LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
 
- 		WHERE ta.teacher_id_ = cs.actual_teacher_id_ AND cs.pre_course_flag_ = 0
 
- 		AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_ >= '2021-02-01'
 
- 		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)))
 
- 		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))
 
- 		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cssp.id_ IS NOT NULL
 
- 		AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="organIds != null and organIds.size()>0">
 
- 			AND cs.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY cs.id_) c
 
- 	</select>
 
- 	<select id="getOrganAttendanceError" resultType="map">
 
- 		SELECT
 
- 			c.organ_id_ AS 'key',
 
- 		    COUNT(DISTINCT c.id_) AS 'value'
 
- 		FROM (SELECT cs.organ_id_,cs.id_ FROM course_schedule cs
 
- 		LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
 
- 		LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
 
- 		LEFT JOIN student_attendance sa ON sa.course_schedule_id_ = cssp.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
 
- 		WHERE ta.teacher_id_ = cs.actual_teacher_id_
 
- 		AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_ >= '2021-02-01' AND cs.pre_course_flag_ = 0
 
- 		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)))
 
- 		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))
 
- 		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cssp.id_ IS NOT NULL
 
- 		AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="organIds != null and organIds.size()>0">
 
- 			AND cs.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY cs.id_) c GROUP BY c.organ_id_
 
- 	</select>
 
- 	<select id="getNoAttendance" resultType="int">
 
- 		SELECT COUNT(DISTINCT cs.id_) FROM course_schedule cs
 
- 		LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
 
- 		WHERE ta.teacher_id_ = cs.actual_teacher_id_
 
- 		AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_>='2021-02-01' AND cs.pre_course_flag_ = 0
 
- 		AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.dispose_content_ IS NULL
 
- 		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
 
- 		AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size() > 0">
 
- 			AND cs.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 	</select>
 
- 	<select id="getOrganNoAttendance" resultType="map">
 
- 		SELECT
 
- 		    cs.organ_id_ AS 'key',
 
- 		    COUNT(DISTINCT cs.id_) AS 'value'
 
- 		FROM course_schedule cs
 
- 		LEFT JOIN teacher_attendance ta ON ta.course_schedule_id_ = cs.id_
 
- 		WHERE ta.teacher_id_ = cs.actual_teacher_id_
 
- 		AND cs.status_ = 'OVER' AND cs.del_flag_ = 0 AND cs.class_date_>='2021-02-01' AND cs.pre_course_flag_ = 0
 
- 		AND ta.sign_in_time_ IS NULL AND ta.sign_out_time_ IS NULL AND ta.dispose_content_ IS NULL
 
- 		AND (cs.new_course_id_ IS NULL OR cs.new_course_id_ = cs.id_)
 
- 		AND EXISTS (SELECT id_ FROM course_schedule_teacher_salary WHERE cs.id_=course_schedule_id_ AND settlement_time_ IS NULL)
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size() > 0">
 
- 			AND cs.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY cs.organ_id_
 
- 	</select>
 
- 	<select id="queryTeacherLeave" resultType="int">
 
- 		SELECT COUNT(DISTINCT tlr.id_) FROM teacher_leave_record tlr
 
- 		LEFT JOIN teacher t ON t.id_ = tlr.user_id_
 
- 		WHERE tlr.status_ = 'ING' AND DATE_FORMAT( tlr.create_time_, '%Y-%m-%d' ) >= #{startTime}
 
- 		<if test="organIdsStr != null and organIdsStr != ''">
 
- 			AND FIND_IN_SET(t.organ_id_,#{organIdsStr})
 
- 		</if>
 
- 	</select>
 
- 	<select id="queryLowTeacherSalary" resultType="int">
 
- 		SELECT COUNT(DISTINCT tcs.user_id_) FROM teacher_course_statistics tcs
 
- 		LEFT JOIN teacher t ON t.id_ = tcs.user_id_
 
- 		LEFT JOIN sys_user su ON su.id_ = tcs.user_id_
 
- 		WHERE su.lock_flag_ = 0 AND su.del_flag_ = 0 AND t.job_nature_ = 'FULL_TIME' AND t.demission_date_ IS NULL
 
- 		  AND t.is_settlement_salary_ = 1
 
- 		AND DATE_FORMAT(tcs.month_,'%Y-%m') = #{monthStr} AND tcs.low_salary = 1
 
- 		<if test="organIdsStr != null and organIdsStr != ''">
 
- 			AND FIND_IN_SET(tcs.organ_id_,#{organIdsStr})
 
- 		</if>
 
- 	</select>
 
- 	<select id="queryOrganLowTeacherSalary" resultType="map">
 
- 		SELECT
 
- 			tcs.organ_id_ AS 'key',
 
- 			COUNT(DISTINCT tcs.user_id_) AS 'value'
 
- 		FROM teacher_course_statistics tcs
 
- 		LEFT JOIN teacher t ON t.id_ = tcs.user_id_
 
- 		LEFT JOIN sys_user su ON su.id_ = tcs.user_id_
 
- 		WHERE su.lock_flag_ = 0 AND su.del_flag_ = 0 AND t.job_nature_ = 'FULL_TIME' AND t.demission_date_ IS NULL
 
- 		AND t.is_settlement_salary_ = 1
 
- 		AND DATE_FORMAT(tcs.month_,'%Y-%m') = #{monthStr} AND tcs.low_salary = 1
 
- 		<if test="organIdsStr != null and organIdsStr != ''">
 
- 			AND FIND_IN_SET(tcs.organ_id_,#{organIdsStr})
 
- 		</if>
 
- 		GROUP BY tcs.organ_id_
 
- 	</select>
 
- 	<select id="queryInspectionItem" resultType="int">
 
- 		SELECT COUNT(DISTINCT ii.id_) FROM inspection_item ii
 
- 		LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
 
- 		WHERE ii.times_ > planned_times_ AND ii.item_ = 'INSPECT' AND ii.memo_ =''
 
- 		AND DATE_FORMAT(i.month_,'%Y-%m-%d') >= #{startTime}
 
- 		<if test="organIdsStr != null and organIdsStr != ''">
 
- 			AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
 
- 		</if>
 
- 		<if test="userId != null">
 
- 			AND ii.user_id_ = #{userId}
 
- 		</if>
 
- 	</select>
 
- 	<select id="queryOrganInspectionItem" resultType="map">
 
- 		SELECT
 
- 		       ii.organ_id_ AS 'key',
 
- 		       COUNT(DISTINCT ii.id_) AS 'value'
 
- 		FROM inspection_item ii
 
- 		LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
 
- 		WHERE ii.times_ > planned_times_ AND ii.item_ = 'INSPECT' AND ii.memo_ =''
 
- 		AND DATE_FORMAT(i.month_,'%Y-%m-%d') >= #{startTime}
 
- 		<if test="organIdsStr != null and organIdsStr != ''">
 
- 			AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
 
- 		</if>
 
- 		<if test="userId != null">
 
- 			AND ii.user_id_ = #{userId}
 
- 		</if>
 
- 		GROUP BY ii.organ_id_
 
- 	</select>
 
- 	<select id="queryInspectionItemPlan" resultType="int">
 
- 		SELECT COUNT(DISTINCT iip.id_) FROM inspection_item_plan iip
 
- 		WHERE iip.status_ = 0 AND iip.memo_ = '' AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') < DATE_FORMAT(NOW(),'%Y-%m-%d')
 
- 		AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') >= #{startTime} AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') <= DATE_FORMAT(NOW(),'%Y-%m-%d')
 
- 		<if test="organIdsStr != null and organIdsStr != ''">
 
- 			AND FIND_IN_SET(iip.organ_id_,#{organIdsStr})
 
- 		</if>
 
- 	</select>
 
- 	<select id="queryOrganInspectionItemPlan" resultType="map">
 
- 		SELECT
 
- 			iip.organ_id_ AS 'key',
 
- 		    COUNT(DISTINCT iip.id_) AS 'value'
 
- 		FROM inspection_item_plan iip
 
- 		WHERE iip.status_ = 0 AND iip.memo_ = '' AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') < DATE_FORMAT(NOW(),'%Y-%m-%d')
 
- 		AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') >= #{startTime} AND DATE_FORMAT(iip.plan_start_,'%Y-%m-%d') <= DATE_FORMAT(NOW(),'%Y-%m-%d')
 
- 		<if test="organIdsStr != null and organIdsStr != ''">
 
- 			AND FIND_IN_SET(iip.organ_id_,#{organIdsStr})
 
- 		</if>
 
- 		GROUP BY iip.organ_id_
 
- 	</select>
 
- 	<select id="queryStudentVisit" resultType="int">
 
- 		SELECT COUNT(DISTINCT ii.id_) FROM inspection_item ii
 
- 		LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
 
- 		WHERE ii.item_ = 'VISIT' AND ii.memo_ =''
 
- 		AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
 
- 		WHERE sv.teacher_id_ = ii.user_id_ AND DATE_FORMAT(i.month_,'%Y-%m') = DATE_FORMAT(sv.visit_time_,'%Y-%m'))
 
- 		AND i.month_ >= #{startTime} AND i.month_ <= DATE_FORMAT(NOW(),'%Y-%m-%d')
 
- 		<if test="organIdsStr != null and organIdsStr != ''">
 
- 			AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
 
- 		</if>
 
- 		<if test="userId != null">
 
- 			AND ii.user_id_ = #{userId}
 
- 		</if>
 
- 	</select>
 
- 	<select id="queryOrganStudentVisit" resultType="map">
 
- 		SELECT
 
- 			ii.organ_id_ AS 'key',
 
- 		    COUNT(DISTINCT ii.id_) AS 'value'
 
- 		FROM inspection_item ii
 
- 		LEFT JOIN inspection i ON ii.inspection_id_ = i.id_
 
- 		WHERE ii.item_ = 'VISIT' AND ii.memo_ =''
 
- 		AND ii.times_ > (SELECT COUNT(DISTINCT sv.id_) FROM student_visit sv
 
- 		WHERE sv.teacher_id_ = ii.user_id_ AND DATE_FORMAT(i.month_,'%Y-%m') = DATE_FORMAT(sv.visit_time_,'%Y-%m'))
 
- 		AND i.month_ >= #{startTime} AND i.month_ <= DATE_FORMAT(NOW(),'%Y-%m-%d')
 
- 		<if test="organIdsStr != null and organIdsStr != ''">
 
- 			AND FIND_IN_SET(ii.organ_id_,#{organIdsStr})
 
- 		</if>
 
- 		<if test="userId != null">
 
- 			AND ii.user_id_ = #{userId}
 
- 		</if>
 
- 		GROUP BY ii.organ_id_
 
- 	</select>
 
-     <select id="queryErrInspection" resultType="int">
 
- 		SELECT
 
- 			COUNT(id_)
 
- 		FROM
 
- 			inspection_item_plan
 
- 		WHERE
 
- 			conclusion_status_ = 1 AND memo_ = '' AND DATE_FORMAT(plan_start_,'%Y-%m-%d') >= #{startTime}
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 	</select>
 
- 	<select id="queryOrganErrInspection" resultType="map">
 
- 		SELECT
 
- 			organ_id_ AS 'key',
 
- 		    COUNT(id_) AS 'value'
 
- 		FROM
 
- 		inspection_item_plan
 
- 		WHERE
 
- 		conclusion_status_ = 1 AND memo_ = '' AND DATE_FORMAT(plan_start_,'%Y-%m-%d') >= #{startTime}
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY organ_id_
 
- 	</select>
 
- 	<select id="getNoClassMusicGroupStudentInfo" resultType="com.ym.mec.biz.dal.entity.IndexErrInfoDto">
 
- 		SELECT
 
- 			'NO_CLASS_MUSIC_GROUP_STUDENT_INFO' errorType,
 
- 			COUNT( DISTINCT sr.music_group_id_ ) num,
 
- 			COUNT( sr.user_id_ ) num2
 
- 		FROM
 
- 			student_registration sr
 
- 			LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
 
- 			LEFT JOIN `subject` sub ON sr.actual_subject_id_=sub.id_
 
- 			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'
 
- 		WHERE
 
- 			sr.music_group_status_ = 'NORMAL'
 
- 			AND mg.status_ = 'PROGRESS'
 
- 			AND cgsm.id_ IS NULL
 
- 			AND sub.parent_subject_id_!=24
 
- 			<if test="educationUserId != null">
 
- 				AND mg.educational_teacher_id_ = #{educationUserId}
 
- 			</if>
 
- 			<if test="organIds!=null and organIds.size()>0">
 
- 				AND mg.organ_id_ IN
 
- 				<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 					#{organId}
 
- 				</foreach>
 
- 			</if>
 
- 	</select>
 
- 	<select id="getOrganNoClassMusicGroupStudentNum" resultType="map">
 
- 		SELECT
 
- 		mg.organ_id_ AS 'key',
 
- 		COUNT( sr.user_id_ ) AS 'value'
 
- 		FROM
 
- 		student_registration sr
 
- 		LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
 
- 		LEFT JOIN `subject` sub ON sr.actual_subject_id_=sub.id_
 
- 		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'
 
- 		WHERE
 
- 		sr.music_group_status_ = 'NORMAL'
 
- 		AND mg.status_ = 'PROGRESS'
 
- 		AND cgsm.id_ IS NULL
 
- 		AND sub.parent_subject_id_!=24
 
- 		<if test="educationUserId != null">
 
- 			AND mg.educational_teacher_id_ = #{educationUserId}
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND mg.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY mg.organ_id_
 
- 	</select>
 
- 	<select id="getFinancePayData"  resultMap="IndexBaseMonthData">
 
- 		SELECT SUM(fe.amount_) total_num_,SUM(fe.amount_) activate_num_,SUM(fe.amount_) percent_,fe.organ_id_,#{dayStr} month_ FROM financial_expenditure fe
 
- 		WHERE DATE_FORMAT(fe.create_time_,'%Y-%m-%d') = #{dayStr}
 
- 		AND del_flag_ = 0 GROUP BY fe.organ_id_
 
- 	</select>
 
- 	<select id="getFinanceBalanceData" resultMap="IndexBaseMonthData">
 
- 		SELECT spo.organ_id_,SUM(spo.balance_payment_amount_) total_num_,
 
- 			   SUM(spo.balance_payment_amount_) activate_num_,
 
- 			   SUM(spo.balance_payment_amount_) percent_,#{dayStr} month_
 
- 		FROM student_payment_order spo
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr}
 
- 		GROUP BY spo.organ_id_
 
- 	</select>
 
- 	<select id="getFinanceActualData" resultMap="IndexBaseMonthData">
 
- 		SELECT spo.organ_id_,SUM(spo.actual_amount_) total_num_,
 
- 			   SUM(spo.actual_amount_) activate_num_,
 
- 			   SUM(spo.actual_amount_) percent_,#{dayStr} month_
 
- 		FROM student_payment_order spo
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') = #{dayStr}
 
- 		GROUP BY spo.organ_id_
 
- 	</select>
 
- 	<select id="getFinancePayDataWithTimely"  resultMap="IndexBaseMonthData">
 
- 		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_
 
- 		FROM financial_expenditure fe
 
- 		WHERE DATE_FORMAT(fe.create_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 
- 		  AND del_flag_ = 0
 
- 			<if test="organIds!=null and organIds.size()>0">
 
- 				AND fe.organ_id_ IN
 
- 				<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 					#{organId}
 
- 				</foreach>
 
- 			</if>
 
- 		GROUP BY DATE_FORMAT(fe.create_time_,'%Y-%m-%d')
 
- 	</select>
 
- 	<select id="getFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
 
- 		SELECT spo.organ_id_,SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
 
- 			   SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
 
- 			   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_
 
- 		FROM student_payment_order spo
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND spo.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 
- 	</select>
 
- 	<select id="getFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
 
- 		SELECT spo.organ_id_,SUM(spo.actual_amount_) total_num_,
 
- 			   SUM(spo.actual_amount_) activate_num_,
 
- 			   SUM(spo.actual_amount_) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
 
- 		FROM student_payment_order spo
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND spo.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 
- 	</select>
 
- 	<select id="getTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
 
- 		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
 
- 		                         CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
 
- 			   SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
 
- 		CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
 
- 			   SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
 
- 		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_
 
- 		FROM student_payment_order spo
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND spo.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 
- 	</select>
 
- 	<select id="getTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
 
- 		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
 
- 		                         CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
 
- 			   SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
 
- 		CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
 
- 			   SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
 
- 		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_
 
- 		FROM student_payment_order spo
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 
- 		<if test="orderType != null">
 
- 			AND FIND_IN_SET(spo.type_,#{orderType})
 
- 		</if>
 
- 		<if test="notOrderType != null">
 
- 			AND spo.type_ NOT IN
 
- 			<foreach collection="notOrderType" open="(" close=")" item="item" separator=",">
 
- 				#{item}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND spo.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 
- 	</select>
 
- 	<select id="getVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
 
- 		SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_ FROM (
 
- 		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_
 
- 		FROM student_payment_order spo
 
- 		LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 
- 		AND spo.type_ = 'DEGREE' AND spod.type_ IN ('THEORY_COURSE','VIP')
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND spo.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 
- 		UNION
 
- 		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
 
- 		CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
 
- 		,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
 
- 		FROM student_payment_order spo
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 
- 		AND spo.type_ = 'SMALL_CLASS_TO_BUY'
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND spo.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 
- 		)c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d')
 
- 	</select>
 
- 	<select id="getOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
 
- 		SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_ FROM (
 
- 		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
 
- 							   CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
 
- 		   ,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
 
- 		FROM student_payment_order spo
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 
- 		AND spo.type_ NOT IN ('APPLY','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND spo.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 
- 		UNION
 
- 		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_
 
- 		FROM student_payment_order spo
 
- 			   LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
 
- 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 
- 		AND spo.type_ = 'DEGREE' AND spod.type_ = 'DEGREE_REGISTRATION'
 
- 		<if test="organIds!=null and organIds.size()>0">
 
- 			AND spo.organ_id_ IN
 
- 			<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 				#{organId}
 
- 			</foreach>
 
- 		</if>
 
- 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 
- 		)c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d')
 
- 	</select>
 
- 	<sql id="queryTeacherServeInfoCondition">
 
- 		<where>
 
- 			<if test="organIds!=null and organIds.size()>0">
 
- 				AND tea.organ_id_ IN
 
- 				<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
 
- 					#{organId}
 
- 				</foreach>
 
- 			</if>
 
- 			<if test="monday!=null and monday!='' and sunday!=null and sunday!=''">
 
- 				AND sees.monday_ BETWEEN #{monday} AND #{sunday}
 
- 			</if>
 
- 			<if test="teacherId!=null">
 
- 				AND sees.teacher_id_ = #{teacherId}
 
- 			</if>
 
- 			<if test="reminded!=null and reminded==0">
 
- 				AND NOT EXISTS (SELECT id_ FROM teacher_remind WHERE teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
 
- 			</if>
 
- 			<if test="reminded!=null and reminded==1">
 
- 				AND EXISTS (SELECT id_ FROM teacher_remind WHERE teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
 
- 			</if>
 
- 			<if test="operatorId!=null">
 
- 				AND EXISTS (SELECT id_ FROM teacher_remind WHERE operator_id_=#{operatorId} AND teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
 
- 			</if>
 
- 			<if test="jobNature!=null">
 
- 				AND tea.job_nature_=#{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 
- 			</if>
 
- 		</where>
 
- 	</sql>
 
- 	<select id="countOrganTeacherServeInfo" resultType="map">
 
- 		SELECT
 
- 		    e.organ_id_ AS 'key',
 
- 		    COUNT(1) AS 'value'
 
- 		FROM (
 
- 		SELECT
 
- 			tea.organ_id_,
 
- 			sees.id_
 
- 		FROM
 
- 		student_extracurricular_exercises_situation_ sees
 
- 		LEFT JOIN teacher tea ON tea.id_=sees.teacher_id_
 
- 		<if test="unDone!=null and unDone==1">
 
- 			LEFT JOIN teacher_remind tm ON sees.monday_=tm.monday_ AND sees.teacher_id_=tm.teacher_id_
 
- 		</if>
 
- 		<include refid="queryTeacherServeInfoCondition" />
 
- 		GROUP BY sees.monday_,sees.sunday_,sees.teacher_id_
 
- 		<if test="unDone!=null">
 
- 			HAVING
 
- 			<if test="unDone==1">
 
- 				SUM( sees.expect_exercises_num_-sees.not_over_course_num_ ) > SUM( sees.actual_exercises_num_ )
 
- 			</if>
 
- 			<if test="unDone==0">
 
- 				SUM( sees.expect_exercises_num_-sees.not_over_course_num_ ) <= SUM( sees.actual_exercises_num_ )
 
- 			</if>
 
- 		</if>
 
- 		ORDER BY sees.monday_,sees.sunday_,sees.teacher_id_
 
- 		) e GROUP BY e.organ_id_
 
- 	</select>
 
- 	<select id="countStudentErrorLeave" resultType="java.lang.Integer">
 
- 		SELECT COUNT(DISTINCT c.user_id_) FROM (
 
- 		SELECT sa.user_id_ FROM student_attendance sa
 
- 		LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
 
- 		WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{format} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
 
- 		<if test="organIdList != null and organIdList.size > 0">
 
- 			AND cs.organ_id_ IN
 
- 			<foreach collection="organIdList" open="(" close=")" item="item" separator=",">
 
- 				#{item}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		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_)) c
 
- 	</select>
 
- 	<select id="countStudentErrorLeave1" resultType="java.lang.Integer">
 
- 		SELECT COUNT(DISTINCT c.user_id_) FROM (
 
- 		SELECT sa.user_id_ FROM student_attendance sa
 
- 		LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
 
- 		LEFT JOIN sys_user su ON su.id_ = sa.user_id_
 
- 		WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
 
- 		<if test="organId != null">
 
- 			AND FIND_IN_SET(cs.organ_id_,#{organId})
 
- 		</if>
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="search != null and search != ''">
 
- 			AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
 
- 		</if>
 
- 		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_)) c
 
- 	</select>
 
- 	<resultMap id="StudentErrorLeaveDto" type="com.ym.mec.biz.dal.dto.StudentErrorLeaveDto">
 
- 		<result property="currentNum" column="current_num_"/>
 
- 		<result property="totalNum" column="total_num_"/>
 
- 		<result property="userId" column="user_id_"/>
 
- 		<result property="studentName" column="username_"/>
 
- 		<result property="phone" column="phone_"/>
 
- 		<result property="organId" column="organ_id_"/>
 
- 		<result property="organName" column="organ_name_"/>
 
- 	</resultMap>
 
- 	<select id="queryStudentErrorLeave" resultMap="StudentErrorLeaveDto">
 
- 		SELECT organ_id_,organ_name_,user_id_,username_,phone_,current_num_,class_date_
 
- 		FROM (SELECT cs.organ_id_,o.name_ organ_name_,sa.user_id_,su.username_,su.phone_,
 
- 		COUNT(sa.id_) current_num_,cs.class_date_
 
- 		FROM student_attendance sa
 
- 		LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
 
- 		LEFT JOIN organization o ON o.id_ = cs.organ_id_
 
- 		LEFT JOIN sys_user su ON su.id_ = sa.user_id_
 
- 		WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{currentMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
 
- 		<if test="organId != null">
 
- 			AND FIND_IN_SET(cs.organ_id_,#{organId})
 
- 		</if>
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="search != null and search != ''">
 
- 			AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
 
- 		</if>
 
- 		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
 
- 		GROUP BY c.user_id_
 
- 		<include refid="global.limit"/>
 
- 	</select>
 
- 	<select id="countStudentLeaveCourseList" resultType="java.lang.Integer">
 
- 		SELECT COUNT(sa.id_)
 
- 		FROM student_attendance sa
 
- 		LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
 
- 		LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
 
- 		<include refid="queryStudentLeaveCourseListSql"/>
 
- 	</select>
 
- 	<sql id="queryStudentLeaveCourseListSql">
 
- 		<where>
 
- 			sa.user_id_ = #{userId} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
 
- 			<if test="search != null and search != ''">
 
- 				AND (cs.id_ = #{search} OR cs.actual_teacher_id_ = #{search} OR su.real_name_ LIKE CONCAT('%',#{search},'%'))
 
- 			</if>
 
- 			<if test="leaveVisitFlag != null">
 
- 				AND sa.leave_visit_flag_ = #{leaveVisitFlag}
 
- 			</if>
 
- 			<if test="courseType != null">
 
- 				AND cs.type_ = #{courseType}
 
- 			</if>
 
- 		</where>
 
- 	</sql>
 
- 	<resultMap id="StudentLeaveCourseDto" type="com.ym.mec.biz.dal.dto.StudentLeaveCourseDto">
 
- 		<result property="leaveVisitFlag" column="leave_visit_flag_"/>
 
- 		<result property="classDate" column="class_date_"/>
 
- 		<result property="startClassTime" column="start_class_time_"/>
 
- 		<result property="endClassTime" column="end_class_time_"/>
 
- 		<result property="teacherName" column="teacher_name_"/>
 
- 		<result property="actualTeacherId" column="actual_teacher_id_"/>
 
- 		<result property="courseScheduleId" column="course_schedule_id_"/>
 
- 		<result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 
- 		<result property="courseScheduleType" column="type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 
- 		<result property="courseName" column="name_"/>
 
- 		<result property="groupId" column="music_group_id_"/>
 
- 	</resultMap>
 
- 	<select id="queryStudentLeaveCourseList" resultMap="StudentLeaveCourseDto">
 
- 		SELECT sa.leave_visit_flag_,cs.class_date_,cs.start_class_time_,
 
- 		       cs.end_class_time_,su.real_name_ teacher_name_,cs.actual_teacher_id_,
 
- 		       sa.course_schedule_id_,cs.group_type_,cs.type_,cs.name_,cs.music_group_id_
 
- 		FROM student_attendance sa
 
- 		 LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
 
- 		 LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
 
- 		<include refid="queryStudentLeaveCourseListSql"/>
 
- 		ORDER BY cs.class_date_ DESC,cs.start_class_time_ DESC
 
- 		<include refid="global.limit"/>
 
- 	</select>
 
- 	<select id="getStudentErrorLeaveNumMap" resultType="java.util.Map">
 
- 		SELECT user_id_ 'key',SUM(total_num_) 'value'
 
- 		FROM (SELECT sa.user_id_,COUNT(sa.id_) total_num_
 
- 		FROM student_attendance sa
 
- 		LEFT JOIN course_schedule cs ON cs.id_ = sa.course_schedule_id_
 
- 		LEFT JOIN sys_user su ON su.id_ = sa.user_id_
 
- 		WHERE DATE_FORMAT(cs.class_date_,'%Y-%m') >= #{totalMonth} AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0
 
- 		<if test="organId != null">
 
- 			AND FIND_IN_SET(cs.organ_id_,#{organId})
 
- 		</if>
 
- 		<if test="classGroupIds != null and classGroupIds.size() > 0">
 
- 			AND cs.class_group_id_ IN
 
- 			<foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
 
- 				#{classGroupId}
 
- 			</foreach>
 
- 		</if>
 
- 		<if test="search != null and search != ''">
 
- 			AND (sa.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
 
- 		</if>
 
- 		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
 
- 		GROUP BY c.user_id_
 
- 	</select>
 
- </mapper>
 
 
  |