123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875 |
- <?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="order_type_" property="orderType"/>
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- <result column="tenant_id_" property="tenantId" />
- </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 where tenant_id_ = #{tenantId} 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_,tenant_id_)
- VALUES(#{month},#{organId},#{totalNum},#{activateNum},#{percent},#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{extendInfo},NOW(),NOW(),#{tenantId})
- </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_,tenant_id_)
- 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(),#{data.tenantId})
- </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_,tenant_id_)
- 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(),#{tenantId})
- </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} and tenant_id_ = #{tenantId}
- </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 where tenant_id_ = #{tenantId} ORDER BY id_ <include refid="global.limit"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM index_base_month_data where tenant_id_ = #{tenantId}
- </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>
- tenant_id_ = #{tenantId}
- <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="getAllIndexBaseData" resultMap="IndexBaseMonthData">
- SELECT
- *
- FROM index_base_month_data
- <where>
- tenant_id_ = #{tenantId}
- <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>
- </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>
- tenant_id_ = #{tenantId}
- <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 tenant_id_ = #{tenantId}
- AND data_type_ = #{dataType}
- AND month_>=#{day}
- </select>
- <select id="getStudentSignUpData" resultMap="IndexBaseMonthData">
- SELECT
- organ_id_,su.tenant_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 su.tenant_id_ = #{tenantId}
- 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_,su.tenant_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.tenant_id_ = #{tenantId}
- 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_,stu.tenant_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.tenant_id_ = #{tenantId}
- 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_,su.tenant_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.tenant_id_ = #{tenantId}
- 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_,su.tenant_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 su.tenant_id_ = #{tenantId}
- 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_,mg.tenant_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.tenant_id_ = #{tenantId}
- 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_,tenant_id_,
- #{dayStr} month_,
- COUNT( id_ ) total_num_,
- COUNT( id_ ) activate_num_,
- COUNT( id_ ) percent_
- FROM
- music_group
- WHERE
- del_flag_ = 0 and tenant_id_ = #{tenantId}
- 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_,sr.tenant_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.tenant_id_ = #{tenantId}
- 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_,t.tenant_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.tenant_id_ = #{tenantId}
- 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_,m.tenant_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 and m.tenant_id_ = #{tenantId}
- <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_,m.tenant_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.tenant_id_ = #{tenantId}
- 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.tenant_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.tenant_id_ = #{tenantId}
- 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.tenant_id_ = #{tenantId}
- 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_,su.tenant_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.tenant_id_ = #{tenantId}
- 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_,su.tenant_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.tenant_id_ = #{tenantId}
- 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.tenant_id_ = #{tenantId}
- 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.tenant_id_ = #{tenantId}
- 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.tenant_id_ = #{tenantId}
- 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.tenant_id_ = #{tenantId}
- 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 cg.tenant_id_ = #{tenantId}
- 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 cg.tenant_id_ = #{tenantId}
- 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 cg.tenant_id_ = #{tenantId}
- 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_
- LEFT JOIN student_registration sr ON sr.music_group_id_ = mgpc.music_group_id_ AND mgpcd.user_id_ = sr.user_id_
- WHERE
- mg.status_ = 'PROGRESS' and mg.tenant_id_ = #{tenantId}
- AND ((mgpc.member_rank_setting_id_ IS NOT NULL AND (sr.membership_end_time_ < NOW() OR sr.membership_end_time_ IS NULL)) OR mgpc.member_rank_setting_id_ IS NULL)
- <if test="noPaymentType==null or noPaymentType==0">
- AND DATE_FORMAT(NOW(),'%Y-%m-%d') > DATE_FORMAT(mgpc.deadline_payment_date_,'%Y-%m-%d')
- </if>
- <if test="noPaymentType!=null and noPaymentType==1">
- AND DATE_FORMAT(NOW(),'%Y-%m-%d') BETWEEN DATE_FORMAT(mgpc.start_payment_date_,'%Y-%m-%d') AND DATE_FORMAT(mgpc.deadline_payment_date_,'%Y-%m-%d')
- </if>
- AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
- AND (mgpcd.expect_amount_ + mgpcd.expect_member_amount_) > 0
- <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 mg.tenant_id_ = #{tenantId}
- 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 mg.tenant_id_ = #{tenantId}
- 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' and mgq.tenant_id_ = #{tenantId}
- <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' mgq.and tenant_id_ = #{tenantId}
- <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 and cssp.tenant_id_ = #{tenantId}
- <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_ < #{courseStartTimeError} OR cs.end_class_time_ > #{courseEndTimeError})
- AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_) AND cs.pre_course_flag_ = 0 and cs.tenant_id_ = #{tenantId}
- <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 and cs.tenant_id_ = #{tenantId}
- <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.tenant_id_ = #{tenantId}
- 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.tenant_id_ = #{tenantId}
- 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.tenant_id_ = #{tenantId}
- 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.tenant_id_ = #{tenantId}
- 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} and tlr.tenant_id_ = #{tenantId}
- <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 t.tenant_id_ = #{tenantId}
- 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 t.tenant_id_ = #{tenantId}
- 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 ii.tenant_id_ = #{tenantId}
- 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 ii.tenant_id_ = #{tenantId}
- 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 iip.tenant_id_ = #{tenantId}
- 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 iip.tenant_id_ = #{tenantId}
- 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.tenant_id_ = #{tenantId}
- 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 ii.tenant_id_ = #{tenantId}
- 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} and tenant_id_ = #{tenantId}
- <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} and tenant_id_ = #{tenantId}
- <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 sr.tenant_id_ = #{tenantId}
- 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 sr.tenant_id_ = #{tenantId}
- 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 fe.tenant_id_ = #{tenantId}
- 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} and spo.tenant_id_ = #{tenantId}
- 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} and spo.tenant_id_ = #{tenantId}
- 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 fe.tenant_id_ = #{tenantId}
- 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} and spo.tenant_id_ = #{tenantId}
- <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} and spo.tenant_id_ = #{tenantId}
- <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} and spo.tenant_id_ = #{tenantId}
- <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} and spo.tenant_id_ = #{tenantId}
- <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.tenant_id_ = #{tenantId}
- 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_,c.type_ order_type_ 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_,spo.type_
- FROM student_payment_order spo
- WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
- 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'),spo.type_
- 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_,spo.type_
- 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'),spo.type_
- )c GROUP BY DATE_FORMAT(c.month_,'%Y-%m-%d'),c.type_
- </select>
- <sql id="queryTeacherServeInfoCondition">
- <where>
- sees.tenant_id_ = #{tenantId}
- <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 and cs.tenant_id_ = #{tenantId}
- <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_) >= #{studentErrorLeaveNum} AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_)) c
- </select>
- <select id="countOrganStudentErrorLeave" resultType="map">
- SELECT c.organ_id_ 'key',COUNT(c.user_id_) 'value' FROM (
- SELECT sa.user_id_,cs.organ_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') >= '2021-11' AND sa.status_ = 'LEAVE' AND cs.pre_course_flag_ = 0 and cs.tenant_id_ = #{tenantId}
- <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" open="(" close=")" item="item" separator=",">
- #{item}
- </foreach>
- </if>
- GROUP BY sa.user_id_
- HAVING COUNT(sa.id_) > 1 AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_))c
- GROUP BY c.organ_id_
- </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 and cs.tenant_id_ = #{tenantId}
- <if test="organIds != null">
- AND FIND_IN_SET(cs.organ_id_,#{organIds})
- </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_) >= #{studentErrorLeaveNum} 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 and cs.tenant_id_ = #{tenantId}
- <if test="organIds != null">
- AND FIND_IN_SET(cs.organ_id_,#{organIds})
- </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_) >= #{studentErrorLeaveNum} 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 and cs.tenant_id_ = #{tenantId}
- <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 and cs.tenant_id_ = #{tenantId}
- <if test="organIds != null">
- AND FIND_IN_SET(cs.organ_id_,#{organIds})
- </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_) >= #{studentErrorLeaveNum} AND COUNT(sa.id_) > SUM(sa.leave_visit_flag_) ORDER BY cs.class_date_ DESC)c
- GROUP BY c.user_id_
- </select>
- <select id="getOrgansStudentNumData" resultMap="IndexBaseMonthData">
- SELECT
- t.organ_id_,t.tenant_id_,
- #{dayStr} month_,
- COUNT( DISTINCT t.user_id_ ) total_num_,
- COUNT( DISTINCT t.user_id_ ) activate_num_,
- COUNT( DISTINCT t.user_id_ ) percent_
- FROM((
- SELECT
- su.organ_id_,sr.tenant_id_,
- sr.user_id_
- FROM
- student_registration sr
- LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
- LEFT JOIN sys_user su ON sr.user_id_ = su.id_
- WHERE
- su.del_flag_ = 0 and sr.tenant_id_ = #{tenantId}
- AND mg.status_='PROGRESS'
- AND sr.music_group_status_ = 'NORMAL'
- <if test="dayStr!=null and dayStr!=''">
- AND DATE(sr.create_time_)<= #{dayStr}
- </if>)
- UNION ALL
- (
- SELECT
- su.organ_id_,sr.tenant_id_,
- cssp.user_id_
- FROM
- course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
- LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
- WHERE
- cssp.group_type_ IN ( 'VIP', 'PRACTICE' ) and cssp.tenant_id_ = #{tenantId}
- AND cs.status_ = 'NOT_START'
- AND su.del_flag_ = 0
- <if test="dayStr!=null and dayStr!=''">
- AND DATE(cssp.create_time_)<= #{dayStr}
- </if>)) t
- WHERE t.user_id_ NOT IN (SELECT user_id_ FROM student WHERE subject_id_list_ REGEXP '21|25|26|27|28|29')
- GROUP BY t.organ_id_
- </select>
- <select id="getMemberStudentNumData" resultMap="IndexBaseMonthData">
- SELECT
- su.organ_id_,cto.tenant_id_,
- #{dayStr} month_,
- COUNT(DISTINCT cto.student_id_) total_num_,
- COUNT(DISTINCT cto.student_id_) activate_num_,
- COUNT(DISTINCT cto.student_id_) percent_
- FROM cloud_teacher_order cto
- LEFT JOIN sys_user su ON cto.student_id_=su.id_
- WHERE su.del_flag_=0 AND cto.status_ IN (1,2) and cto.tenant_id_ = #{tenantId}
- <if test="dayStr!=null and dayStr!=''">
- AND DATE(cto.create_time_)<= #{dayStr}
- </if>
- GROUP BY su.organ_id_
- </select>
- <select id="getNewMemberStudentNumData" resultMap="IndexBaseMonthData">
- SELECT
- su.organ_id_,cto.tenant_id_,
- #{dayStr} month_,
- COUNT(DISTINCT cto.student_id_) total_num_,
- COUNT(DISTINCT cto.student_id_) activate_num_,
- COUNT(DISTINCT cto.student_id_) percent_
- FROM cloud_teacher_order cto
- LEFT JOIN sys_user su ON cto.student_id_=su.id_
- WHERE su.del_flag_=0 AND cto.status_ IN (1,2) and cto.tenant_id_ = #{tenantId}
- <if test="dayStr!=null and dayStr!=''">
- AND DATE(cto.create_time_)= #{dayStr}
- </if>
- GROUP BY su.organ_id_
- </select>
- <select id="getExperienceMemberStudentNumData" resultMap="IndexBaseMonthData">
- SELECT
- su.organ_id_,stu.tenant_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 cloud_teacher_order cto ON stu.user_id_=cto.student_id_
- LEFT JOIN sys_user su ON su.id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.experience_member_rank_setting_id_ IS NOT NULL AND (cto.id_ IS NULL OR cto.status_ NOT IN (1, 2)) and cto.tenant_id_ = #{tenantId}
- <if test="dayStr!=null and dayStr!=''">
- AND DATE(stu.experience_membership_start_time_)<= #{dayStr}
- </if>
- GROUP BY su.organ_id_
- </select>
- <select id="getCloudStudyDayUseStudentNumData" resultMap="IndexBaseMonthData">
- SELECT
- su.organ_id_,smcr.tenant_id_,
- #{dayStr} month_,
- COUNT(DISTINCT smcr.user_id_) total_num_,
- COUNT(DISTINCT smcr.user_id_) activate_num_,
- COUNT(DISTINCT smcr.user_id_) percent_
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL and smcr.tenant_id_ = #{tenantId}
- <if test="dayStr!=null and dayStr!=''">
- AND DATE(smcr.create_time_)= #{dayStr}
- </if>
- GROUP BY su.organ_id_
- </select>
- <select id="getCloudStudyLivelyStudentNumData" resultMap="IndexBaseMonthData">
- SELECT
- t.organ_id_,t.tenant_id_,
- #{dayStr} month_,
- COUNT(user_id_) total_num_,
- COUNT(user_id_) activate_num_,
- COUNT(user_id_) percent_
- FROM (SELECT
- su.organ_id_,su.tenant_id_,
- smcr.user_id_,
- COUNT(DISTINCT(CASE WHEN DATEDIFF(NOW(), smcr.create_time_)<=15 THEN DATE_FORMAT(smcr.create_time_, '%Y-%m-%d') ELSE NULL END)) days
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL and smcr.tenant_id_ = #{tenantId}
- <if test="dayStr!=null and dayStr!=''">
- AND DATE(smcr.create_time_) <= #{dayStr}
- </if>
- GROUP BY smcr.user_id_) t WHERE t.days>=5
- GROUP BY t.organ_id_
- </select>
- <select id="getCloudStudyNewStudentNumData" resultMap="IndexBaseMonthData">
- SELECT
- organ_id_,tenant_id_,
- #{dayStr} month_,
- COUNT( DISTINCT user_id_ ) total_num_,
- COUNT( DISTINCT user_id_ ) activate_num_,
- COUNT( DISTINCT user_id_ ) percent_
- FROM
- (
- SELECT
- su.organ_id_,smcr.tenant_id_,
- smcr.user_id_
- FROM
- sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_ = su.id_
- WHERE su.del_flag_ = 0 and smcr.tenant_id_ = #{tenantId}
- GROUP BY user_id_
- HAVING MIN(DATE( smcr.create_time_ ))= #{dayStr}) t
- GROUP BY t.organ_id_
- </select>
- <resultMap id="CloudTeacherActiveTargetDto" type="com.ym.mec.biz.dal.dto.CloudTeacherActiveTargetDto">
- <result property="organId" column="organ_id_"/>
- <result property="organName" column="organ_name_"/>
- <result property="totalNum" column="total_num_"/>
- <result property="buyAmount" column="buy_amount_"/>
- <result property="buyNum" column="buy_num_"/>
- <result property="targetAmount" column="target_amount_"/>
- <result property="targetNum" column="target_num_"/>
- </resultMap>
- <select id="countCloudTeacherActive" resultMap="CloudTeacherActiveTargetDto">
- SELECT o.name_ organ_name_,o.id_ organ_id_,CASE WHEN SUM(cto.amount_) IS NULL THEN 0 ELSE SUM(cto.amount_) END buy_amount_,
- COUNT(DISTINCT cto.student_id_) buy_num_
- FROM student s
- LEFT JOIN cloud_teacher_order cto ON cto.student_id_ = s.user_id_ AND cto.status_ != 0 AND cto.active_remark_ = '202109'
- LEFT JOIN sys_user su ON su.id_ = s.user_id_
- LEFT JOIN organization o ON o.id_ = su.organ_id_
- WHERE s.tenant_id_ = #{tenantId}
- <if test="organIdList != null and organIdList.size > 0">
- AND su.organ_id_ IN
- <foreach collection="organIdList" open="(" close=")" item="item" separator=",">
- #{item}
- </foreach>
- </if>
- GROUP BY su.organ_id_
- </select>
- </mapper>
|