12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643 |
- <?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_,
- m.class_date_ 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="startDate!=null and endDate!=''">
- AND m.class_date_ BETWEEN #{startDate} AND #{endDate}
- </if>
- <if test="teachMode!=null">
- AND m.teach_mode_ = #{teachMode, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="organIds!=null and organIds.size()>0">
- AND m.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- <if test="dayStr!=null and dayStr!=''">
- GROUP BY m.organ_id_
- </if>
- <if test="startDate!=null and endDate!=''">
- GROUP BY m.class_date_
- </if>
- 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="startDate!=null and endDate!=null">
- AND m.class_date_ BETWEEN #{startDate} AND #{endDate}
- </if>
- <if test="teachMode!=null">
- AND m.teach_mode_ = #{teachMode, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="organIds!=null and organIds.size()>0">
- AND m.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </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 ALL
- 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 ALL
- 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>
|