<?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.ruoyi.voluntary.mapper.PdMarjorMatchDataMapper">
    
    <resultMap type="PdMarjorMatchData" id="PdMarjorMatchDataResult">
        <result property="planId"    column="planId"    />
        <result property="groupId"    column="groupId"    />
        <result property="year"    column="year"    />
        <result property="submitId"    column="submitId"    />
        <result property="planXuezhi"    column="planXuezhi"    />
        <result property="submitXuezhi"    column="submitXuezhi"    />
        <result property="planLevel"    column="planLevel"    />
        <result property="planMarjorName"    column="planMarjorName"    />
        <result property="planMarjorDirection"    column="planMarjorDirection"    />
        <result property="planSpecialProject"    column="planSpecialProject"    />
        <result property="submitMarjorName"    column="submitMarjorName"    />
        <result property="submitMarjorDirection"    column="submitMarjorDirection"    />
        <result property="submitSpecialProject"    column="submitSpecialProject"    />
    </resultMap>


    <select id="selectNewGaokao" resultType="Integer">
        SELECT COUNT(*) FROM `b_busi_wish_university_submit_recruit_plan` u WHERE u.`location` = #{location} AND u.`year` = #{year} AND u.`type` IN ('物理', '历史')
    </select>

    <select id="selectPlanCollegeIdList" resultMap="PdMarjorMatchDataResult">
        SELECT ps.`plan_id` planId, ps.`marjorCollegeId` groupId FROM `b_busi_wish_university_marjors_plan_submit` ps
        WHERE ps.`plan_id` IN <foreach item="o" collection="list" open="(" separator="," close=")">#{o}</foreach>
    </select>

    <insert id="updateGroupSubmitBatch">
        INSERT INTO `b_busi_wish_university_match_submit`(`location`,`group_id`,`year`,`manual_id`,`submit_id`,`submit_ids`,`memo`) VALUES
        <foreach collection="list" item="item" index="index" separator=",">(#{item.location}, #{item.id}, #{item.year}, #{item.manualId}, #{item.matchedId}, '', '导入')</foreach>
        ON DUPLICATE KEY UPDATE `manual_id` = VALUES(`manual_id`), `submit_id` = VALUES(`submit_id`)
    </insert>
</mapper>