| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554 |
- <?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="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="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>
- <!-- 向数据库增加一条记录 -->
- <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_,create_time_,update_time_)
- VALUES(#{month},#{organId},#{totalNum},#{activateNum},#{percent},#{dataType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},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_,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},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_,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},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>
- 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 DATE_FORMAT(month_, '%Y-%m')>=#{startMonth}
- </if>
- <if test="endMonth!=null and endMonth!=''">
- AND DATE_FORMAT(month_, '%Y-%m')<=#{endMonth}
- </if>
- </where>
- GROUP BY month_,data_type_
- </select>
- <select id="getStudentSignUpData" resultMap="IndexBaseMonthData">
- SELECT
- organ_id_,
- CONCAT(#{month}, '-01') 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 sys_user
- WHERE
- del_flag_=0
- AND organ_id_ IS NOT NULL
- AND user_type_ LIKE '%STUDENT%'
- AND DATE_FORMAT(create_time_, '%Y-%m')<=#{month}
- GROUP BY organ_id_
- ORDER BY organ_id_;
- </select>
- <select id="getHomeworkData" resultMap="IndexBaseMonthData">
- SELECT
- su.organ_id_,
- CONCAT(#{month}, '-01') 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_) total_num_,
- SUM(sees.actual_exercises_num_) activate_num_,
- TRUNCATE(SUM(sees.actual_exercises_num_)/SUM(sees.expect_exercises_num_)*100, 2) percent_
- </otherwise>
- </choose>
- FROM student_extracurricular_exercises_situation_ sees
- LEFT JOIN sys_user su ON sees.student_id_=su.id_
- WHERE su.del_flag_=0
- AND su.organ_id_ IS NOT NULL
- AND YEAR(sees.monday_)=YEAR(CONCAT(#{month}, '-01'))
- AND MONTH(sees.monday_)=MONTH(CONCAT(#{month}, '-01'))
- GROUP BY su.organ_id_
- ORDER BY su.organ_id_
- </select>
- <select id="getSchoolData" resultMap="IndexBaseMonthData">
- SELECT
- organ_id_,
- CONCAT(#{month}, '-01') month_,
- COUNT( id_ ) total_num_,
- COUNT( id_ ) activate_num_,
- COUNT( id_ ) percent_
- FROM
- cooperation_organ
- WHERE
- del_flag_ = 0
- AND is_enable_ = 1
- AND organ_id_ IS NOT NULL
- <if test="month!=null and month!=''">
- AND DATE_FORMAT(create_time_, '%Y-%m') <= #{month}
- </if>
- GROUP BY
- organ_id_
- ORDER BY
- organ_id_;
- </select>
- <select id="getMusicData" resultMap="IndexBaseMonthData">
- SELECT
- organ_id_,
- CONCAT(#{month}, '-01') 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="month!=null and month!=''">
- AND DATE_FORMAT(create_time_, '%Y-%m') <= #{month}
- </if>
- GROUP BY
- organ_id_
- ORDER BY
- organ_id_;
- </select>
- <select id="getMusicStudentData" resultMap="IndexBaseMonthData">
- SELECT
- mg.organ_id_,
- CONCAT(#{month}, '-01') 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="month!=null and month!=''">
- AND DATE_FORMAT(sr.create_time_, '%Y-%m') <= #{month}
- </if>
- GROUP BY
- mg.organ_id_
- ORDER BY
- mg.organ_id_;
- </select>
- <select id="getTeacherData" resultMap="IndexBaseMonthData">
- SELECT
- t.organ_id_,
- CONCAT(#{month}, '-01') 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
- <if test="isDemission==null">
- AND su.lock_flag_ = 0
- </if>
- <if test="isDemission!=null">
- AND (su.lock_flag_ = 1 OR t.demission_date_ IS NOT NULL)
- </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>
- GROUP BY
- t.organ_id_
- ORDER BY
- t.organ_id_;
- </select>
- <select id="getGroupCourseData" resultMap="IndexBaseMonthData">
- SELECT
- m.organ_id_,
- CONCAT(#{month}, '-01') 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_ = 'OVER'
- 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="month!=null and month!=''">
- AND DATE_FORMAT(m.class_date_, '%Y-%m') <= #{month}
- </if>
- GROUP BY
- m.organ_id_
- ORDER BY
- m.organ_id_;
- </select>
- <select id="getOtherStudentData" resultMap="IndexBaseMonthData">
- SELECT
- su.organ_id_,
- CONCAT(#{month}, '-01') 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')
- <if test="month!=null and month!=''">
- AND (DATE_FORMAT(m.create_time_, '%Y-%m') <= #{month} OR YEAR(m.create_time_)=3000)
- </if>
- GROUP BY
- su.organ_id_
- ORDER BY
- su.organ_id_;
- </select>
- <select id="getStudentConversionData" resultMap="IndexBaseMonthData">
- SELECT
- cs.organ_id_,
- CONCAT( '2020-01', '-01' ) 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_
- 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 m.user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- GROUP BY
- cs.organ_id_
- ORDER BY
- cs.organ_id_;
- </select>
- <select id="getMusicGroupPreRegistrationStudentData" resultMap="IndexBaseMonthData">
- SELECT
- mg.organ_id_,
- CONCAT( #{month}, '-01' ) 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 DATE_FORMAT( spr.create_time_, '%Y-%m' ) <= #{month}
- GROUP BY
- mg.organ_id_
- ORDER BY
- mg.organ_id_;
- </select>
- <select id="getMusicGroupStudentFromPreData" resultMap="IndexBaseMonthData">
- SELECT
- mg.organ_id_,
- CONCAT( #{month}, '-01' ) 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'
- AND sr.music_group_status_ = 'NORMAL'
- <if test="paymentStatus!=null">
- AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- AND DATE_FORMAT( sr.create_time_, '%Y-%m' ) <= #{month}
- 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_ = 'NORMAL'
- AND sr.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- AND DATE_FORMAT( sr.create_time_, '%Y-%m' ) <= #{month}
- </select>
- <select id="countLessThenThreeClassGroupNum" resultType="int">
- SELECT COUNT(t.id_) FROM (
- SELECT
- DISTINCT 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_
- WHERE
- cg.type_ = 'HIGH'
- AND mg.status_ = 'PROGRESS'
- AND cgsm.status_ = 'NORMAL'
- <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 cgsm.user_id_ )<3
- ) t
- </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_ = 'HIGH'
- AND mg.status_ = 'PROGRESS'
- AND cgsm.status_ = 'NORMAL'
- <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 cgsm.user_id_ )<3
- </select>
- <select id="countNoPaymentStudentNum" resultType="int">
- SELECT
- COUNT(DISTINCT 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'
- AND mgpc.payment_valid_end_date_ < NOW()
- AND mgpcd.payment_status_ = 'NON_PAYMENT'
- <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="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 mgpc.payment_valid_end_date_ < NOW()
- AND mgpcd.payment_status_ = 'NON_PAYMENT'
- <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="countApplyForQuitGroupNum" resultType="int">
- SELECT COUNT(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="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="countStudentAttendanceInfo" resultType="java.lang.Integer">
- SELECT
- COUNT( DISTINCT cssp.user_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
- <if test="type!=null and type=='LEAVE'">
- (sa.status_ = 'LEAVE' AND sa.remark_ IS NOT NULL AND sv.id_ IS NULL)
- </if>
- <if test="type!=null and type=='TRUANT'">
- (sa.status_ = 'TRUANT' OR sa.id_ IS NULL)
- </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>
- </mapper>
|