<?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.xhkjedu.sexam.mapper.paperstudent.EPsqbatchMapper">

   <!--获取考试科目-->
    <select id="listSubjectsByExamid" resultType="java.util.Map">
        select s.subjectid,s.subjectname,p.epid from e_subject s
        left join e_paper p on s.esid=p.esid where s.examid=#{examid} order by s.esid
    </select>

    <!--考试补录成绩批次表-->
    <select id="listPsqBatchsByExamid" resultType="java.util.Map">
        select b.batchid,b.subjectname,b.epid,b.stunum,b.teacherid,b.createtime,u.username teachername
        from e_psqbatch b left join t_user u on b.teacherid=u.userid
        where b.examid=#{examid} order by b.batchid desc
    </select>

    <!--获取补录成绩批次详情-->
    <select id="listPsqBatchDetail" resultType="java.util.Map">
        select d.detailid,d.studentid,d.eptqid,d.qn,d.stuscore,d.newscore,d.createtime,
        u.username,u.loginname from e_psqbatch_detail d left join t_user u on d.studentid=u.userid
        where d.batchid=#{ed.batchid}
        <if test="ed.eptqid!=null and ed.eptqid!='' and ed.eptqid!='0'.toString()">
            and d.eptqid=#{ed.eptqid}
        </if>
        <if test="ed.username!=null and ed.username!=''">
            and (u.username like concat('%', #{ed.username}, '%') or u.loginname like concat('%', #{ed.username}, '%'))
        </if>
        order by studentid,d.eptqid
    </select>

</mapper>
