123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- <?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.ExtracurricularExercisesDao">
-
- <resultMap type="com.ym.mec.biz.dal.entity.ExtracurricularExercises" id="ExtracurricularExercises">
- <result column="id_" property="id" />
- <result column="music_group_id_" property="musicGroupId" />
- <result column="teacher_id_" property="teacherId" />
- <result column="username_" property="teacher.username" />
- <result column="classGroupId" property="classGroupId" />
- <result column="student_id_list_" property="studentIdList" />
- <result column="batch_no_" property="batchNo" />
- <result column="title_" property="title" />
- <result column="attachments_" property="attachments" />
- <result column="content_" property="content" />
- <result column="expire_date_" property="expireDate" />
- <result column="completed_num_" property="completedNum" />
- <result column="expect_num_" property="expectNum" />
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- <result column="organ_name_" property="organName" />
- <result column="tenant_id_" property="tenantId" />
- <result column="music_score_id_" property="musicScoreId" />
- <result column="assignTime" property="assignTime" />
- <result column="musicGroupName" property="musicGroupName" />
- <result column="versionTag" property="versionTag" />
- <result column="type" property="type" />
- <result column="push_flag_" property="pushFlag" />
- <result column="group_type_" property="groupType" />
- <result column="memo_" property="memo" />
- </resultMap>
- <sql id="queryPageCondition">
- <where>
- ee.tenant_id_ = #{tenantId}
- <if test="teacherId != null">
- and teacher_id_ = #{teacherId}
- </if>
- <if test="musicGroupId != null">
- and music_group_id_ = #{musicGroupId}
- </if>
- <if test="title != null">
- and title_ like '%' #{title} '%'
- </if>
- <if test="batchNo != null">
- and batch_no_ = #{batchNo}
- </if>
- <if test="organIdList != null">
- AND FIND_IN_SET(o.id_, #{organIdList})
- </if>
- <if test="assignStartTime != null">
- AND date(ee.create_time_) >= #{assignStartTime}
- </if>
- <if test="assignEndTime != null">
- AND date(ee.create_time_) <= #{assignEndTime}
- </if>
- <if test="cloudHomeworkFlag != null and cloudHomeworkFlag == true">
- AND eer.music_score_id_ IS NOT NULL AND eer.music_score_id_ != ''
- </if>
- <if test="cloudHomeworkFlag != null and cloudHomeworkFlag == false">
- AND (eer.music_score_id_ IS NULL OR eer.music_score_id_ = '')
- </if>
- <if test="type != null">
- and ee.group_type_ = #{type}
- </if>
- <if test="search != null ">
- and (su.real_name_ like '%' #{search} '%' or mg.name_ like '%' #{search} '%')
- </if>
- <if test="type != null">
- and ee.group_type_ = #{type}
- </if>
- <if test="studentExerciseId != null">
- and ee.id_ = #{studentExerciseId}
- </if>
- <if test="studentAssignFlag != null">
- <if test="studentAssignFlag == true">
- and ee.music_group_id_ is null
- </if>
- <if test="studentAssignFlag == false">
- and ee.music_group_id_ is not null
- </if>
- </if>
- </where>
- </sql>
-
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="ExtracurricularExercises" >
- SELECT * FROM extracurricular_exercises WHERE id_ = #{id}
- </select>
-
- <!-- 全查询 -->
- <select id="findAll" resultMap="ExtracurricularExercises">
- SELECT * FROM extracurricular_exercises where tenant_id_ = #{tenantId} ORDER BY id_
- </select>
-
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO extracurricular_exercises (music_group_id_,teacher_id_,student_id_list_,batch_no_,
- title_,attachments_,content_,expire_date_,completed_num_,expect_num_,
- create_time_,update_time_,tenant_id_,group_type_,memo_)
- VALUES(#{musicGroupId},#{teacherId},#{studentIdList},#{batchNo},#{title},#{attachments},
- #{content},#{expireDate},#{completedNum},#{expectNum},NOW(), NOW(),#{tenantId},#{groupType},#{memo})
- </insert>
-
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises">
- UPDATE extracurricular_exercises
- <set>
- <if test="studentIdList != null">
- student_id_list_ = #{studentIdList},
- </if>
- <if test="expireDate != null">
- expire_date_ = #{expireDate},
- </if>
- <if test="batchNo != null">
- batch_no_ = #{batchNo},
- </if>
- <if test="musicGroupId != null">
- music_group_id_ = #{musicGroupId},
- </if>
- <if test="teacherId != null">
- teacher_id_ = #{teacherId},
- </if>
- <if test="title != null">
- title_ = #{title},
- </if>
- <if test="expectNum != null">
- expect_num_ = #{expectNum},
- </if>
- <if test="content != null">
- content_ = #{content},
- </if>
- <if test="attachments != null">
- attachments_ = #{attachments},
- </if>
- <if test="completedNum != null">
- completed_num_ = #{completedNum},
- </if>
- <if test="versionTag != null and versionTag != ''">
- version_tag_ = #{versionTag},
- </if>
- <if test="memo != null and memo != ''">
- memo_ = #{memo},
- </if>
- update_time_ = NOW()
- </set> WHERE id_ = #{id} and tenant_id_ = #{tenantId}
- </update>
-
- <!-- 根据主键删除一条记录 -->
- <delete id="delete" >
- DELETE FROM extracurricular_exercises WHERE id_ = #{id}
- </delete>
-
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="ExtracurricularExercises" parameterType="map">
- SELECT ee.id_,ee.teacher_id_,ee.student_id_list_,ee.group_type_ as type,ee.batch_no_,ee.title_,ee.attachments_,ee.music_group_id_,
- ee.content_,ee.expire_date_,ee.completed_num_,ee.expect_num_,ee.create_time_,ee.update_time_,ee.tenant_id_,ee.memo_,
- ,u.real_name_ username_,o.name_ organ_name_,eer.music_score_id_,ee.create_time_ as assignTime,
- mg.name_ as musicGroupName,ee.class_group_id_ as classGroupId,ee.version_tag_ as versionTag
- FROM extracurricular_exercises ee LEFT JOIN sys_user u ON ee.teacher_id_ = u.id_
- LEFT JOIN teacher t ON t.id_ = ee.teacher_id_
- left join sys_user su on t.id_ = su.id_
- LEFT JOIN organization o ON o.id_ = t.organ_id_
- left join music_group mg on mg.id_ = ee.music_group_id_
- LEFT JOIN extracurricular_exercises_reply eer ON ee.id_ = eer.extracurricular_exercises_id_
- <include refid="queryPageCondition"/>
- GROUP BY ee.id_
- ORDER BY id_ desc <include refid="global.limit"/>
- </select>
-
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(DISTINCT ee.id_) FROM extracurricular_exercises ee left join sys_user u on ee.teacher_id_ = u.id_
- left join teacher t on t.id_ = ee.teacher_id_
- left join sys_user su on t.id_ = su.id_
- left join organization o on o.id_ = t.organ_id_
- left join music_group mg on mg.id_ = ee.music_group_id_
- LEFT JOIN extracurricular_exercises_reply eer ON ee.id_ = eer.extracurricular_exercises_id_
- <include refid="queryPageCondition"/>
- </select>
- <sql id="queryExtraExercisesCondition">
- <where>
- tenant_id_ = #{tenantId}
- <if test="teacherId!=null">
- AND teacher_id_ = #{teacherId}
- </if>
- <if test="createTime!=null">
- AND DATE_FORMAT(create_time_, '%Y-%m') = DATE_FORMAT(#{createTime}, '%Y-%m')
- </if>
- </where>
- </sql>
- <select id="countExtraExercises" resultType="int">
- SELECT COUNT(id_) FROM extracurricular_exercises
- <include refid="queryExtraExercisesCondition"/>
- </select>
- <select id="findExtraExercises" resultMap="ExtracurricularExercises">
- SELECT * FROM extracurricular_exercises
- <include refid="queryExtraExercisesCondition"/>
- ORDER BY create_time_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="findRepeatLastExercises" resultMap="ExtracurricularExercises">
- SELECT
- *
- FROM
- extracurricular_exercises
- WHERE
- teacher_id_ = #{teacherId}
- AND student_id_list_ = #{studentIdList}
- AND content_ = #{content}
- ORDER BY create_time_ DESC LIMIT 1
- </select>
- <select id="findNoExercisesStudentsInThisWeekWithTeacher"
- resultType="com.ym.mec.biz.dal.dto.BasicUserDto">
- SELECT
- su.id_ userId,
- su.username_ name,
- su.avatar_ headUrl,
- GROUP_CONCAT(sub.name_) subjectName,
- stu.member_rank_setting_id_ memberRankSettingId,
- sub.id_ subjectIdList,
- sub.id_ subjectId,
- sees.music_group_id_ musicGroupId
- FROM
- student_extracurricular_exercises_situation_ sees
- <if test="classGroupId!=null">
- LEFT JOIN class_group_student_mapper cgsm ON sees.student_id_ = cgsm.user_id_
- </if>
- LEFT JOIN student stu ON stu.user_id_ = sees.student_id_
- left join student_registration sr on sees.student_id_ = sr.user_id_ and sr.music_group_id_ = sees.music_group_id_
- LEFT JOIN sys_user su ON su.id_ = sees.student_id_
- LEFT JOIN `subject` sub ON sub.id_ = sr.actual_subject_id_
- WHERE
- sees.monday_ = #{startDate}
- AND sees.teacher_id_ = #{teacherId}
- AND sees.actual_exercises_num_ < sees.expect_exercises_num_
- AND sees.serve_type_ = 'EXERCISE'
- <if test="hasMember != null">
- <if test="hasMember == 1">
- AND stu.member_rank_setting_id_ IS NOT NULL
- </if>
- <if test="hasMember == 0">
- AND stu.member_rank_setting_id_ IS NULL
- </if>
- </if>
- <if test="studentIds!=null and studentIds!=''">
- AND FIND_IN_SET(sees.student_id_,#{studentIds})
- </if>
- <if test="musicGroupId!=null and musicGroupId!=''">
- AND sees.music_group_id_=#{musicGroupId}
- </if>
- <if test="classGroupId!=null">
- AND cgsm.class_group_id_ = #{classGroupId}
- </if>
- <if test="subjectId!=null">
- AND FIND_IN_SET(#{subjectId}, stu.subject_id_list_)
- </if>
- <if test="search!=null">
- AND (su.username_ LIKE CONCAT('%', #{search}, '%') OR su.phone_ LIKE CONCAT(#{search}, '%'))
- </if>
- GROUP BY su.id_
- ORDER BY
- su.id_;
- </select>
- <resultMap id="ExtracurricularExercisesHomeworkListDto" type="com.ym.mec.biz.dal.dto.ExtracurricularExercisesHomeworkListDto">
- <result property="type" column="type_"/>
- <result property="homeworkId" column="id_"/>
- </resultMap>
- <select id="countExtraExercilsesHomeworks" resultType="int">
- SELECT COUNT(id_) FROM (
- SELECT id_, create_time_,'EXERCISES' type_
- FROM extracurricular_exercises
- <where>
- tenant_id_ = #{tenantId}
- <if test="teacherId!=null">
- AND teacher_id_ = #{teacherId}
- </if>
- <if test="createTime!=null">
- AND DATE_FORMAT(create_time_, '%Y-%m') = DATE_FORMAT(#{createTime}, '%Y-%m')
- </if>
- <if test="startTime != null and startTime != ''">
- AND DATE_FORMAT(#{createTime}, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
- </if>
- </where>
- UNION ALL
- SELECT ch.id_,ch.create_time_,'HOMEWORK' type_ FROM course_homework ch
- LEFT JOIN course_schedule_teacher_salary csts ON ch.course_schedule_id_ = csts.course_schedule_id_ AND csts.teacher_role_ = 'BISHOP'
- <where>
- csts.tenant_id_ = #{tenantId}
- <if test="teacherId!=null">
- AND csts.user_id_ = #{teacherId}
- </if>
- <if test="classGroupId!=null">
- AND ch.class_group_id_=#{classGroupId}
- </if>
- <if test="createTime!=null">
- AND DATE_FORMAT(ch.create_time_,'%Y-%m')=DATE_FORMAT(#{createTime}, '%Y-%m')
- </if>
- </where>
- ) h
- </select>
- <select id="findExtraExercilsesHomeworks" resultMap="ExtracurricularExercisesHomeworkListDto">
- SELECT * FROM (
- SELECT id_, create_time_,'EXERCISES' type_
- FROM extracurricular_exercises
- <where>
- tenant_id_ = #{tenantId}
- <if test="teacherId!=null">
- AND teacher_id_ = #{teacherId}
- </if>
- <if test="createTime!=null">
- AND DATE_FORMAT(create_time_, '%Y-%m') = DATE_FORMAT(#{createTime}, '%Y-%m')
- </if>
- <if test="startTime != null and startTime != ''">
- AND DATE_FORMAT(#{createTime}, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
- </if>
- </where>
- UNION ALL
- SELECT ch.id_,ch.create_time_,'HOMEWORK' type_ FROM course_homework ch
- LEFT JOIN course_schedule_teacher_salary csts ON ch.course_schedule_id_ = csts.course_schedule_id_ AND csts.teacher_role_ = 'BISHOP'
- <where>
- csts.tenant_id_ = #{tenantId}
- <if test="teacherId!=null">
- AND csts.user_id_ = #{teacherId}
- </if>
- <if test="classGroupId!=null">
- AND ch.class_group_id_=#{classGroupId}
- </if>
- <if test="createTime!=null">
- AND DATE_FORMAT(ch.create_time_,'%Y-%m')=DATE_FORMAT(#{createTime}, '%Y-%m')
- </if>
- </where>) h
- </select>
- <select id="findByIdList" resultMap="com.ym.mec.biz.dal.dao.CourseHomeworkDao.teacherHomeworkListDto">
- SELECT id_ homework_id_,title_,content_,completed_num_,expect_num_,music_score_id_,memo_,
- expire_date_ expiry_date_,DATE_FORMAT(create_time_,'%Y-%m-%d') 'day_'
- FROM extracurricular_exercises WHERE id_ IN
- <foreach collection="exercisesIdList" separator="," item="item" open="(" close=")">
- #{item}
- </foreach>
- </select>
- <sql id="extraHomeworkDetailV2">
- <if test="startTime != null and endTime != null">
- create_time_ BETWEEN #{startTime} AND #{endTime}
- </if>
- <if test="homeWorkStatus != null">
- <if test="homeWorkStatus.code == 'UNASSIGNED'">
- AND id_ = -1
- </if>
- <if test="homeWorkStatus.code == 'ASSIGNED'">
- AND expire_date_ >= NOW()
- </if>
- <if test="homeWorkStatus.code == 'DEADLINE'">
- AND expire_date_ < NOW()
- </if>
- </if>
- <if test="courseScheduleId != null">
- AND id_ = #{courseScheduleId}
- </if>
- <if test="teacherId != null">
- and teacher_id_ = #{teacherId}
- </if>
- <if test="type != null">
- and group_type_ = #{type}
- </if>
- <if test="versionTag != null">
- and version_tag_ = #{versionTag}
- </if>
- <if test="musicGroupId!=null and musicGroupId!=''">
- and music_group_id_ = #{musicGroupId}
- </if>
- </sql>
- <select id="countTeacherExtraHomeworkDetailV2" resultType="int">
- select count(1) from (
- select 1 from extracurricular_exercises
- <where>
- <include refid="extraHomeworkDetailV2"/>
- </where>
- <if test="subjectIds != null and subjectIds.size() != 0">
- union all
- select 1 from music_group
- where id_ in
- <foreach collection="subjectIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>) t
- </select>
- <select id="queryTeacherExtraHomeworkDetailV2"
- resultType="com.ym.mec.biz.dal.dto.CourseHomeworkWrapper$CourseHomeworkList">
- <if test="subjectIds != null and subjectIds.size() != 0">
- (select
- id_ as musicGroupId,
- 'UNASSIGNED' as homeWorkStatus,
- 'EXTRACURRICULAR' as `type`,
- null as courseScheduleId,
- null as courseHomeworkId,
- null as classGroupId,
- null as studentNum,
- null as finishNum,
- null as assignTime,
- null as expiryDate,
- null as studentIdList,
- null as teacherId
- from music_group
- where id_ in
- <foreach collection="subjectIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- )
- union all
- </if>
- (select
- music_group_id_ as musicGroupId,
- if(expire_date_ > NOW(), 'ASSIGNED', 'DEADLINE') as homeWorkStatus,
- group_type_ as `type`,
- id_ as courseScheduleId,
- id_ as courseHomeworkId,
- class_group_id_ as classGroupId,
- expect_num_ as studentNum,
- completed_num_ as finishNum,
- create_time_ as assignTime,
- expire_date_ as expiryDate,
- student_id_list_ as studentIdList,
- teacher_id_ as teacherId
- from extracurricular_exercises
- <where>
- <include refid="extraHomeworkDetailV2"/>
- </where>
- )
- <include refid="global.limit"/>
- </select>
- <update id="updateFinishNum">
- UPDATE extracurricular_exercises SET completed_num_ = ifnull(completed_num_,0) + 1 WHERE id_ = #{courseHomeworkId}
- </update>
- <select id="findEndHomework" resultMap="ExtracurricularExercises">
- SELECT *
- FROM extracurricular_exercises ee
- WHERE ee.expire_date_ <= now() and ee.push_flag_ = 0 and ee.version_tag_ = 'v2'
- </select>
- <update id="updatePushFlag">
- UPDATE extracurricular_exercises SET push_flag_ = 1 WHERE id_ in
- <foreach collection="ids" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </update>
- </mapper>
|