SubjectSemesterMapper.xml 4.78 KB
<?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.meishu.mapper.SubjectSemesterMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.meishu.model.SubjectSemesterDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="subject_id" property="subjectId" />
        <result column="semester" property="semester" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, subject_id, semester
    </sql>

    <select id="getSemesterScore" resultType="com.meishu.vo.semester.GetSemesterScoreVO">
        SELECT
            t3.id,
            t5.id as userId,
            t5.user_name,
            t6.study_code,
            t2.`subject`,
            t4.score
        FROM
             subject_dict t2
            LEFT JOIN subject_semester t3 ON t2.id = t3.subject_id
            LEFT JOIN pt_student_score t4 ON t3.id = t4.semester_id
            LEFT JOIN user_role t5 ON t4.student_id = t5.id
            LEFT JOIN user_studycode t6 ON t5.id = t6.user_role_id
        where
            t2.grade = #{grade}
            and t3.delete_date is null
            and t2.delete_date is null
            and t2.classes = #{classes}
            and t2.session = #{session}
            and t3.delete_date is null
            and t2.delete_date is null
            <if  test="semester != null and semester !=''">
                and t3.semester = #{semester}
            </if>
            <if test="userName != null and userName !=''">
                and t5.user_name like  concat('%',#{userName} ,'%')
            </if>
            <if test="subject != null and subject !=''">
                and t2.subject = #{subject}
            </if>
    </select>

    <select id="exportScore" resultType="com.meishu.vo.semester.GetSemesterScoreVO">
        SELECT
        t3.id,
        t5.user_name,
        t6.study_code,
        t2.`subject`,
        t4.score
        FROM
            subject_dict t2
        LEFT JOIN subject_semester t3 ON t2.id = t3.subject_id
        LEFT JOIN pt_student_score t4 ON t3.id = t4.semester_id
        LEFT JOIN user_role t5 ON t4.student_id = t5.id
        LEFT JOIN user_studycode t6 ON t5.id = t6.user_role_id
        where
            t2.grade = #{grade}
            and t2.classes = #{classes}
            and t2.session = #{session}
        <if test="semester != null and semester != '' ">
            and t3.semester = #{semester}
        </if>
        <if test="userName != null and userName !=''">
            and t5.user_name = #{userName}
        </if>
        <if test="subject != null and subject !=''">
            and t2.subject = #{subject}
        </if>
    </select>

    <select id="getStudentDetail" resultType="com.meishu.vo.semester.GetStudentDetailVO">
        SELECT
            t3.user_name as teacherName,
            t2.item_desc,
            t2.score,
            t2.item_type,
            t.create_date
        FROM
            pt_student_score_record t
            LEFT JOIN pt_score_item_dict t2 ON t.score_item_id = t2.id
            LEFT JOIN administer t3 ON t.create_by = t3.id
        WHERE
            t.semester_id = #{id}
            AND t.student_id = #{userId}
    </select>

    <select id="getStudentRecord" parameterType="com.meishu.dto.semester.GetStudentRecordDTO" resultType="com.meishu.vo.semester.GetStudentRecordVO">
        SELECT
            t5.class_name,
            t3.user_name,
            t2.item_desc,
            t2.score,
            t6.user_name AS teacherName,
            t8.`subject`,
            t.create_date
        FROM
            pt_student_score_record t
        LEFT JOIN pt_score_item_dict t2 ON t.score_item_id = t2.id
        LEFT JOIN user_role t3 ON t.student_id = t3.id
        LEFT JOIN classes_user_mapping t4 ON t3.id = t4.user_id
        LEFT JOIN classes_dict t5 ON t4.classes_id = t5.id
        LEFT JOIN administer t6 ON t.create_by = t6.id
        left join subject_semester t7 on t.semester_id = t7.id
        left join subject_dict t8 on t7.subject_id = t8.id
        WHERE
            t2.item_type = 0
            and t4.delete_date is null
            <if test="startDate != null and startDate != ''">
                and  DATE_FORMAT(t.create_date, '%Y-%m-%d') >= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
            </if>
            <if test="endDate != null and endDate !=''">
                and  DATE_FORMAT(t.create_date, '%Y-%m-%d')  &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
            </if>
    </select>

</mapper>