<?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.qmth.distributed.print.business.mapper.ExamTaskPrintMapper">
    <select id="listTaskPrintHouse"
            resultType="com.qmth.distributed.print.business.bean.dto.TaskPrintHouseDto">
        SELECT distinct
            o.id houseId,
            o.name houseName
        FROM
            sys_org o
        WHERE
            o.school_id = #{schoolId} AND o.type = #{type}
    </select>
    <select id="listTaskPrintHouseAll"
            resultType="com.qmth.distributed.print.business.bean.dto.TaskPrintHouseDto">
        SELECT
            o.id houseId,
            o.name houseName
        FROM
            sys_org o
        WHERE
            o.school_id = #{schoolId} AND o.type = #{type}
        ORDER BY o.name
    </select>
    <select id="listByPrintPlanIdAndCourseCodeAndPaperNumber"
            resultType="com.qmth.distributed.print.business.bean.dto.ExamTaskPrintDetailDto">
        SELECT
            a.id,
            a.school_id schoolId,
            a.org_id orgId,
            a.print_plan_id printPlanId,
            a.course_code courseCode,
            a.course_name courseName,
            a.paper_number paperNumber,
            a.exam_start_time examStartTime,
            a.exam_end_time examEndTime,
            a.exam_place examPlace,
            a.exam_room examRoom,
            a.class_id classId,
            a.class_name className,
            a.student_count studentCount,
            a.campus_id campusId,
            a.print_house_id printHouseId,
            c.name printHouseName,
            a.exam_detail_id examDetailId,
            a.extend_fields extendFields,
            b.status
        FROM
            exam_task_print a
                LEFT JOIN
            exam_detail b ON a.exam_detail_id = b.id
                LEFT JOIN
            sys_org c ON a.print_house_id = c.id
        WHERE
            a.print_plan_id = #{printPlanId}
                AND a.course_code = #{courseCode}
                AND a.paper_number = #{paperNumber}
    </select>
</mapper>