<?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.jkserver.dao.ExamRoomMonitorInfoDao">

    <select id="findByExamCodeAndPlaceCodeAndRoomCode" resultType="com.qmth.jkserver.model.ExamRoomMonitorInfo">
        select * from jk_exam_room_monitor_info t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
            <if test="placeCodeSet != null and placeCodeSet != '' and placeCodeSet.size > 0">
                and t.place_code in
                <foreach collection="placeCodeSet" item="item" index="index"
                         open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="roomCodeSet != null and roomCodeSet != '' and roomCodeSet.size > 0">
                and t.room_code in
                <foreach collection="roomCodeSet" item="item" index="index"
                         open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

    <select id="findByExamCodeAndPlaceCodeAndRoomCodeByList" resultType="java.util.Map">
        select t.exam_code as examCode,t.place_code as placeCode,t.room_code as roomCode,sum(login_count) as countDl,sum(contact_error_count) as countGz from jk_exam_room_monitor_info t
        <where>
            <if test="examCode != null and examCode != ''">
                and t.exam_code = #{examCode}
            </if>
            <if test="placeCodeSet != null and placeCodeSet != '' and placeCodeSet.size > 0">
                and t.place_code in
                <foreach collection="placeCodeSet" item="item" index="index"
                         open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="roomCodeSet != null and roomCodeSet != '' and roomCodeSet.size > 0">
                and t.room_code in
                <foreach collection="roomCodeSet" item="item" index="index"
                         open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
        group by t.exam_code,t.place_code,t.room_code
    </select>
</mapper>
