| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 | <?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.CourseScheduleEvaluateDao">    <resultMap id="CourseScheduleEvaluate" type="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate">        <id column="id_" jdbcType="BIGINT" property="id"/>        <result column="music_group_id_" jdbcType="VARCHAR" property="musicGroupId"/>        <result column="class_group_id_" jdbcType="INTEGER" property="classGroupId"/>        <result column="course_schedule_id_" jdbcType="BIGINT" property="courseScheduleId"/>        <result column="teacher_id_" jdbcType="INTEGER" property="teacherId"/>        <result column="item_" jdbcType="VARCHAR" property="item"/>        <result column="comment_" jdbcType="LONGVARCHAR" property="comment"/>        <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>        <result column="student_id_" jdbcType="INTEGER" property="studentId"/>        <result column="subject_id_" jdbcType="INTEGER" property="subjectId"/>        <result column="subject_name_" jdbcType="VARCHAR" property="subjectName"/>        <result column="is_pushed_" jdbcType="INTEGER" property="isPushed"/>        <result column="month_" jdbcType="VARCHAR" property="month"/>        <result column="music_theory_" jdbcType="VARCHAR" property="musicTheory"/>        <result column="song_" jdbcType="VARCHAR" property="song"/>        <result column="teaching_material_" jdbcType="VARCHAR" property="teachingMaterial"/>        <result column="times_" jdbcType="INTEGER" property="times"/>        <result column="total_minutes_" jdbcType="INTEGER" property="totalMinutes"/>        <result column="version_" jdbcType="INTEGER" property="version"/>        <result column="student_id_list_" jdbcType="VARCHAR" property="studentIdList"/>        <result column="group_name_" jdbcType="VARCHAR" property="groupName"/>        <result column="status_" jdbcType="TINYINT" property="status"/>    </resultMap>    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate" useGeneratedKeys="true"            keyColumn="id" keyProperty="id">        INSERT INTO course_schedule_evaluate (music_group_id_, class_group_id_, course_schedule_id_, music_theory_,                                              song_, times_, total_minutes_,                                              teaching_material_, teacher_id_, item_, comment_, create_time_,                                              update_time_,                                              student_id_list_, version_, status_)        values (#{musicGroupId,jdbcType=VARCHAR}, #{classGroupId,jdbcType=INTEGER}, #{courseScheduleId,jdbcType=BIGINT},                #{musicTheory,jdbcType=VARCHAR}, #{song,jdbcType=VARCHAR}, #{times,jdbcType=INTEGER}, #{totalMinutes},                #{teachingMaterial,jdbcType=VARCHAR},                #{teacherId,jdbcType=INTEGER}, #{item,jdbcType=VARCHAR}, #{comment,jdbcType=LONGVARCHAR},                #{createTime,jdbcType=TIMESTAMP},                #{updateTime,jdbcType=TIMESTAMP}, #{studentIdList}, #{version,jdbcType=INTEGER},                #{status,jdbcType=TINYINT})    </insert>    <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleEvaluate">        update course_schedule_evaluate        <set>            <if test="musicGroupId != null">                music_group_id_ = #{musicGroupId},            </if>            <if test="classGroupId != null">                class_group_id_ = #{classGroupId},            </if>            <if test="courseScheduleId != null">                course_schedule_id_ = #{courseScheduleId},            </if>            <if test="musicTheory != null">                music_theory_ = #{musicTheory},            </if>            <if test="song != null">                song_ = #{song},            </if>            <if test="teachingMaterial != null">                teaching_material_ = #{teachingMaterial},            </if>            <if test="item != null">                item_ = #{item},            </if>            <if test="comment != null">                comment_ = #{comment},            </if>            <if test="classGroupId != null">                class_group_id_ = #{classGroupId},            </if>            <if test="studentIdList != null">                student_id_list_ = #{studentIdList},            </if>            <if test="teacherId != null">                teacher_id_ = #{teacherId},            </if>            <if test="version != null != null">                version_ = #{version},            </if>            <if test="status != null">                status_ = #{status},            </if>            <if test="isPushed != null">                is_pushed_ = #{isPushed},            </if>            <if test="updateTime != null">                update_time_ = #{updateTime}            </if>        </set>        WHERE id_ = #{id}    </update>    <select id="get" resultMap="CourseScheduleEvaluate">        SELECT *        FROM course_schedule_evaluate        WHERE id_ = #{id}    </select>    <select id="findByClassGroupId" resultMap="CourseScheduleEvaluate">        SELECT cse.*, s.name_ subject_name_, pg.student_id_        FROM course_schedule_evaluate cse                 LEFT JOIN practice_group pg ON pg.id_ = cse.music_group_id_                 LEFT JOIN subject s on s.id_ = pg.subject_id_        WHERE cse.class_group_id_ = #{classGroupId}          AND status_ = 1          AND version_ = 1        ORDER BY create_time_ DESC        LIMIT 1    </select>    <select id="findByClassGroupIds" resultMap="CourseScheduleEvaluate">        SELECT * FROM course_schedule_evaluate WHERE class_group_id_ IN        <foreach collection="classGroupIds" item="classGroupId" separator="," open="(" close=")">            #{classGroupId}        </foreach>        AND status_=1        ORDER BY create_time_ ASC    </select>    <resultMap id="PracticeGroupsOrgan" type="com.ym.mec.biz.dal.dto.PracticeGroupsDto">        <result column="organ_id_" jdbcType="INTEGER" property="organId"/>        <result column="total_nums_" jdbcType="INTEGER" property="totalNums"/>        <result column="buy_nums_" jdbcType="INTEGER" property="buyNums"/>        <result column="renew_nums_" jdbcType="INTEGER" property="renewNums"/>        <result column="report_nums_" jdbcType="INTEGER" property="reportNums"/>        <result column="total_money_" jdbcType="DECIMAL" property="totalMoney"/>    </resultMap>    <!-- 体验人数 -->    <select id="getPracticeGroupsFree" resultMap="PracticeGroupsOrgan">        SELECT organ_id_, count(distinct student_id_) total_nums_        FROM practice_group        WHERE group_status_ != 'LOCK'          AND group_status_ != 'CANCEL'          AND buy_months_ IS NULL        GROUP BY organ_id_    </select>    <!-- 已购买人数 -->    <select id="getPracticeGroupsBuy" resultMap="PracticeGroupsOrgan">        SELECT organ_id_, count(distinct student_id_) buy_nums_        FROM practice_group        WHERE group_status_ != 'LOCK'          AND group_status_ != 'CANCEL'          AND buy_months_ >= 1        GROUP BY organ_id_    </select>    <!-- 报告完成数 -->    <select id="getHasReportNums" resultMap="PracticeGroupsOrgan">        SELECT pg.organ_id_, count(*) report_nums_        FROM course_schedule_evaluate cse                 LEFT JOIN practice_group pg on cse.music_group_id_ = pg.id_            AND pg.buy_months_ IS NULL            AND pg.group_status_ != 'LOCK'            AND cse.status_ = 1        GROUP BY pg.organ_id_    </select>    <!-- 已完成课程数统计 -->    <select id="getOrganPracticeGroups" resultMap="PracticeGroupsOrgan">        SELECT COUNT(class_group_id_) buy_nums_, cg.total_class_times_ total_nums_, pg.organ_id_        FROM course_schedule cs                 LEFT JOIN class_group cg on cg.id_ = cs.class_group_id_                 LEFT JOIN practice_group pg ON cs.music_group_id_ = pg.id_        WHERE cs.group_type_ = 'PRACTICE'          AND cs.status_ != 'NOT_START'          AND cs.del_flag_ = 0          AND pg.buy_months_ IS NULL          AND pg.group_status_ != 'LOCK'        GROUP BY cs.class_group_id_, pg.organ_id_    </select>    <!-- 成交金额 -->    <select id="getOrganMoney" resultMap="PracticeGroupsOrgan">        SELECT SUM(actual_amount_) total_money_, organ_id_        FROM student_payment_order        WHERE group_type_ = 'PRACTICE'          AND status_ = 'SUCCESS'        GROUP BY organ_id_    </select>    <select id="findExpiredDateBeforeReport" resultMap="CourseScheduleEvaluate">        SELECT *        FROM course_schedule_evaluate        WHERE status_ = 1          AND create_time_ <= #{expiredDate}          AND (is_pushed_ = 0 OR is_pushed_ IS NULL)    </select>    <select id="findByGroupId" resultMap="CourseScheduleEvaluate">        SELECT id_,status_,class_group_id_,version_,times_,total_minutes_, DATE_FORMAT(create_time_, '%Y年%m月') month_        FROM course_schedule_evaluate        WHERE music_group_id_ = #{groupId}        <if test="status != null">            AND status_ = #{status}        </if>        ORDER BY create_time_ ASC    </select>    <select id="findById" resultMap="CourseScheduleEvaluate">        SELECT cse.*, s.name_ subject_name_, pg.student_id_        FROM course_schedule_evaluate cse                 LEFT JOIN practice_group pg ON pg.id_ = cse.music_group_id_                 LEFT JOIN subject s on s.id_ = pg.subject_id_        WHERE cse.id_ = #{id}    </select>    <select id="findByCourseAndTeacher" resultMap="CourseScheduleEvaluate">        SELECT *        FROM course_schedule_evaluate cse        WHERE cse.teacher_id_ = #{teacherId}          AND cse.course_schedule_id_ = #{courseScheduleId}    </select>    <select id="getNeedPostReports" resultMap="CourseScheduleEvaluate">        SELECT cse.id_,cse.class_group_id_,DATE_FORMAT(cse.create_time_,'%Y年%m月') month_,pg.name_        group_name_,cse.teacher_id_ FROM course_schedule_evaluate cse        LEFT JOIN practice_group pg on cse.music_group_id_ = pg.id_ WHERE status_= 0        <if test="teacherId != null">            AND cse.teacher_id_ = #{teacherId}        </if>        ORDER BY cse.create_time_ ASC    </select>    <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">        INSERT INTO course_schedule_evaluate (music_group_id_, class_group_id_, course_schedule_id_, music_theory_,        song_,teaching_material_, teacher_id_, item_, comment_, create_time_,update_time_,student_id_list_, version_,        status_,        times_,total_minutes_)        VALUE        <foreach collection="list" item="evaluate" separator=",">            (#{evaluate.musicGroupId,jdbcType=VARCHAR}, #{evaluate.classGroupId,jdbcType=INTEGER},            #{evaluate.courseScheduleId,jdbcType=BIGINT},            #{evaluate.musicTheory,jdbcType=VARCHAR}, #{evaluate.song,jdbcType=VARCHAR},            #{evaluate.teachingMaterial,jdbcType=VARCHAR},            #{evaluate.teacherId,jdbcType=INTEGER}, #{evaluate.item,jdbcType=VARCHAR},            #{evaluate.comment,jdbcType=LONGVARCHAR}, #{evaluate.createTime,jdbcType=LONGVARCHAR},            #{evaluate.updateTime,jdbcType=LONGVARCHAR}, #{evaluate.studentIdList},            #{evaluate.version,jdbcType=INTEGER}, #{evaluate.status,jdbcType=TINYINT},            #{evaluate.times,jdbcType=INTEGER},#{evaluate.totalMinutes,jdbcType=INTEGER})        </foreach>    </insert>    <select id="getClassGroupCourseTimes" resultType="int">        SELECT COUNT(*)        FROM course_schedule        WHERE class_group_id_ = #{classGroupId}          AND (del_flag_ = 0 OR del_flag_ IS NULL)    </select>    <select id="hasReportList" resultMap="CourseScheduleEvaluate">        SELECT COUNT(*) times_, class_group_id_ FROM course_schedule_evaluate WHERE class_group_id_ IN        <foreach collection="classGroupIds" item="classGroupId" open="(" separator="," close=")">            #{classGroupId}        </foreach>        AND DATE_FORMAT(create_time_,'%Y%m%d') = DATE_FORMAT(#{nowDate},'%Y%m%d')        GROUP BY class_group_id_;    </select>    <select id="getPracticeGroupsRenew" resultMap="PracticeGroupsOrgan">        SELECT organ_id_, count(distinct student_id_) renew_nums_        FROM practice_group        WHERE group_status_ != 'LOCK'          AND group_status_ != 'CANCEL'          AND buy_months_ >= 1          AND be_renew_group_id_ >= 1        GROUP BY organ_id_    </select>    <!-- 获取当月成交金额,续费人数(新增人数) -->    <select id="getMonthOrganMoney" resultMap="PracticeGroupsOrgan">        SELECT SUM(actual_amount_) total_money_, count(distinct user_id_) buy_nums_, organ_id_        FROM student_payment_order        WHERE type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}          AND create_time_ >= #{startTime}          AND status_ = 'SUCCESS'        GROUP BY organ_id_    </select>    <select id="getOrganNewPracticeGroupsOfMonth" resultMap="PracticeGroupsOrgan">        SELECT SUM(actual_amount_) total_money_, count(distinct user_id_) buy_nums_, organ_id_        FROM student_payment_order        WHERE type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}        AND status_ = 'SUCCESS'        AND create_time_ >= #{startTime}        AND user_id_ NOT IN (        SELECT distinct student_id_ FROM practice_group        WHERE group_status_ != 'LOCK'        AND group_status_ != 'CANCEL'        AND buy_months_ >= 1        <if test="type==@com.ym.mec.biz.dal.enums.OrderTypeEnum@PRACTICE_GROUP_BUY">            <![CDATA[ AND be_renew_group_id_ IS NULL AND create_time_ < #{startTime} ]]>        </if>        <if test="type==@com.ym.mec.biz.dal.enums.OrderTypeEnum@PRACTICE_GROUP_RENEW">            <![CDATA[ AND be_renew_group_id_ >= 1 AND create_time_ < #{startTime} ]]>        </if>        )        GROUP BY organ_id_    </select>    <resultMap id="practice4Organ" type="com.ym.mec.biz.dal.dto.Practice4OrganDto">        <result column="organ_name_" property="organName"/>        <result column="organ_id_" property="organId"/>        <result column="try_num_" property="tryNum"/>        <result column="vip_num_" property="vipNum"/>        <result column="practice_num_" property="practiceNum"/>        <result column="vip4_month_num_" property="vip4MonthNum"/>        <result column="practice4_month_num_" property="practice4MonthNum"/>        <result column="renew4_month_num_" property="renew4MonthNum"/>        <result column="change4_month_num_" property="change4MonthNum"/>        <result column="total_money_" property="totalMoney"/>        <result column="student_ids_" property="studentIds"/>    </resultMap>    <!-- 体验人数(除去禁止的) -->    <select id="getTryNums" resultMap="practice4Organ">        SELECT pg.organ_id_, count(distinct pg.student_id_) try_num_        FROM practice_group pg                 LEFT JOIN student s ON s.user_id_ = pg.student_id_        WHERE pg.group_status_ IN ('NORMAL', 'FINISH')          AND s.operating_tag_ = 1          AND pg.buy_months_ IS NULL        GROUP BY pg.organ_id_    </select>    <!-- 网管课体验人数(禁止的) -->    <select id="getPracticeTryNums" resultMap="practice4Organ">        SELECT pg.organ_id_, count(distinct pg.student_id_) try_num_        FROM practice_group pg        LEFT JOIN student s ON s.user_id_ = pg.student_id_        WHERE pg.group_status_ IN ('NORMAL', 'FINISH')        <if test="studentIds != null">            AND FIND_IN_SET(pg.student_id_,#{studentIds})        </if>        AND pg.buy_months_ >=1        AND s.operating_tag_ = 0        GROUP BY pg.organ_id_    </select>    <!-- vip体验人数(禁止的) -->    <select id="getVipTryNums" resultMap="practice4Organ">        SELECT vg.organ_id_, COUNT(DISTINCT cssp.user_id_) try_num_, GROUP_CONCAT(distinct cssp.user_id_) student_ids_        FROM course_schedule_student_payment cssp                 LEFT JOIN vip_group vg ON cssp.music_group_id_ = vg.id_ AND cssp.group_type_ = 'VIP'                 LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_                 LEFT JOIN student s ON s.user_id_ = cssp.user_id_        WHERE s.operating_tag_ = 0          AND cs.teach_mode_ = 'ONLINE'        GROUP BY vg.organ_id_    </select>    <select id="getVipBuyNums" resultMap="practice4Organ">        SELECT vg.organ_id_, COUNT(DISTINCT cssp.user_id_) vip_num_, GROUP_CONCAT(DISTINCT cssp.user_id_) student_ids_        FROM course_schedule_student_payment cssp                 LEFT JOIN vip_group vg ON cssp.music_group_id_ = vg.id_ AND cssp.group_type_ = 'VIP'                 LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_        WHERE CONCAT(cs.class_date_, ' ', cs.end_class_time_) >= #{classDate}        <if test="endDate != null">            <![CDATA[AND CONCAT(cs.class_date_, ' ', cs.end_class_time_) < #{endDate}]]>        </if>          AND cs.teach_mode_ = 'ONLINE'        GROUP BY vg.organ_id_    </select>    <select id="getPracticeBuyNums" resultMap="practice4Organ">        SELECT pg.organ_id_, COUNT(DISTINCT cssp.user_id_) practice_num_        FROM course_schedule_student_payment cssp                 LEFT JOIN practice_group pg ON cssp.music_group_id_ = pg.id_ AND cssp.group_type_ = 'PRACTICE'                 LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_        WHERE CONCAT(cs.class_date_, ' ', cs.end_class_time_) >= #{classDate}        <if test="endDate != null">            <![CDATA[AND CONCAT(cs.class_date_, ' ', cs.end_class_time_) < #{endDate}]]>        </if>        <if test="studentIds != null">            AND FIND_IN_SET(cssp.user_id_,#{studentIds})        </if>          AND pg.buy_months_ >= 1        GROUP BY pg.organ_id_    </select></mapper>
 |