| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- <?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(DATE_FORMAT(NOW(), '%Y-%m'), '-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 YEAR(create_time_)=YEAR(NOW())
- GROUP BY organ_id_
- ORDER BY organ_id_;
- </select>
- <select id="getHomeworkData" resultMap="IndexBaseMonthData">
- SELECT
- su.organ_id_,
- CONCAT(DATE_FORMAT(NOW(), '%Y-%m'), '-01') month_,
- <choose>
- <when test="type == 'submit'">
- SUM(sees.expect_exercises_num_) total_num_,
- SUM(sees.exercises_reply_num_) activate_num_,
- TRUNCATE(SUM(sees.exercises_reply_num_)/SUM(sees.expect_exercises_num_)*100, 2) percent_
- </when>
- <when test="type == 'comment'">
- SUM(sees.expect_exercises_num_) total_num_,
- SUM(sees.exercises_reply_num_) activate_num_,
- TRUNCATE(SUM(sees.exercises_reply_num_)/SUM(sees.expect_exercises_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(NOW())
- 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
- school
- WHERE
- del_flag_ = 0
- 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
- <if test="type==null">
- AND mg.status_ = 'PROGRESS'
- AND sr.music_group_status_='NORMAL'
- </if>
- <if test="type!=null and type=='QUIT'">
- AND sr.music_group_status_='QUIT'
- </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
- 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.create_time_, '%Y-%m') <= #{month} OR YEAR(m.create_time_)=3000)
- </if>
- GROUP BY
- m.organ_id_
- ORDER BY
- m.organ_id_;
- </select>
- <select id="getOtherStudentData" resultMap="IndexBaseMonthData">
- SELECT
- m.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
- course_schedule_student_payment s
- LEFT JOIN course_schedule m ON s.course_schedule_id_=m.id_
- WHERE
- m.del_flag_ = 0
- AND m.is_lock_ = 0
- AND m.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
- m.organ_id_
- ORDER BY
- m.organ_id_;
- </select>
- <select id="getStudentConversionData" resultMap="IndexBaseMonthData">
- SELECT
- mg.organ_id_,
- CONCAT( DATE_FORMAT( NOW(), '%Y-%m' ), '-01' ) month_,
- COUNT( DISTINCT sr.user_id_ ) total_num_,
- COUNT( DISTINCT IF((cssp.group_type_='PRACTICE' AND pg.type_='CHARGE') OR cssp.group_type_='VIP', cssp.user_id_, NULL) ) activate_num_,
- TRUNCATE(COUNT( DISTINCT IF((cssp.group_type_='PRACTICE' AND pg.type_='CHARGE') OR cssp.group_type_='VIP', cssp.user_id_, NULL) )/COUNT( DISTINCT sr.user_id_ )*100, 2) percent_
- FROM
- student_registration sr
- LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
- LEFT JOIN course_schedule_student_payment cssp ON sr.user_id_=cssp.user_id_
- LEFT JOIN practice_group pg ON cssp.music_group_id_=pg.id_
- WHERE
- mg.del_flag_ = 0
- AND mg.organ_id_ IS NOT NULL
- <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>
- </mapper>
|