<?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.syzy.mapper.BBusiWishUniversitySubmitRecruitPlanMapper">

    <resultMap type="BBusiWishUniversitySubmitRecruitPlan" id="BBusiWishUniversitySubmitRecruitPlanResult">
        <result property="id"    column="id"    />
        <result property="collegeCode"    column="collegeCode"    />
        <result property="year"    column="year"    />
        <result property="location"    column="location"    />
        <result property="batch"    column="batch"    />
        <result property="level"    column="level"    />
        <result property="liberalScience"    column="liberalScience"    />
        <result property="type"    column="type"    />
        <result property="marjorId"    column="marjorId"    />
        <result property="universityId"    column="universityId"    />
        <result property="universityCode"    column="universityCode"    />
        <result property="universityName"    column="universityName"    />
        <result property="universityNameText"    column="universityNameText"    />
        <result property="marjorCode"    column="marjorCode"    />
        <result property="marjorName"    column="marjorName"    />
        <result property="marjorNameText"    column="marjorNameText"    />
        <result property="marjorBelongs"    column="marjorBelongs"    />
        <result property="marjorDirection"    column="marjorDirection"    />
        <result property="specialProject"    column="specialProject"    />
        <result property="createTime"    column="createTime"    />
        <result property="status"    column="status"    />
        <result property="majorCount"    column="majorCount"    />
        <result property="stats"    column="stats"  typeHandler="com.ruoyi.mxjb.handlers.SubmitYearsStatsHandler"   />
        <result property="planCount"    column="planCount"    />
        <result property="planType"    column="planType"    />
        <result property="xuefei"    column="xuefei"    />
        <result property="xuezhi"    column="xuezhi"    />
        <result property="course"    column="course"    />
        <result property="groups" column="groups" />
        <result property="groupsName" column="groupsName" />
        <result property="enrollFluctuate" column="enrollFluctuate" />
    </resultMap>

    <sql id="selectBBusiWishUniversitySubmitRecruitPlanVo">
        select id, collegeCode, year, location, batch, level, liberalScience, type, marjorId, universityId, universityCode, universityName, universityNameText, marjorCode, marjorName, marjorNameText, marjorBelongs, marjorDirection, specialProject, createTime, status, planCount, planType, xuefei, xuezhi, course ,`groups`,`groupsName` from b_busi_wish_university_submit_recruit_plan
    </sql>

    <select id="selectWishUniversitySubmitPlanForMatch" parameterType="map" resultMap="BBusiWishUniversitySubmitRecruitPlanResult">
      SELECT ms.match_type planType, pg.`plan_id` id, pg.`group_id` `majorCount`, ms.`year`, rp.`level`, rp.`type`, ms.`manual_id` liberalScience, ms.`submit_ids` `groups`, ms.`status`, ms.suggest_id `batch`,
             rp.`specialProject`, rp.`universityName`, rp.`marjorName`, rp.`xuezhi`, rp.`marjorDirection`, rp.collegeCode
        FROM `b_busi_wish_university_submit_recruit_plan` rp
        JOIN `b_busi_wish_universities` u ON rp.`universityId` = u.`id`
        JOIN `b_busi_wish_university_match_plan_group` pg ON pg.`plan_id` = rp.`id`
        JOIN `b_busi_wish_university_match_submit` ms ON pg.`location` = ms.`location` AND pg.`group_id` = ms.`group_id` AND ms.year = #{year}
         AND <choose><when test="forMany">ms.`match_type` != '预置' AND (ms.`submit_cnt` &gt; 1 OR ms.`group_status` &gt; 1 OR rp.`marjorName` LIKE '%试验班%')</when><otherwise>(ms.`match_type` = '预置' OR ms.`submit_cnt` = 1 AND ms.`group_status` = 1 AND rp.`marjorName` NOT LIKE '%试验班%')</otherwise></choose>
        <where> rp.`location` = #{location} AND rp.`year` = #{planYear}
            <if test="batch != null and batch != ''"> and rp.`batch` = #{batch}</if>
            <if test="level != null and level != ''"> and rp.`level` = #{level}</if>
            <if test="type != null and type != ''"> and rp.`type` = #{type}</if>
            <if test="collegeCode != null and collegeCode != ''"> and rp.`collegeCode` = #{collegeCode}</if>
            <if test="marjorBelongs != null and marjorBelongs != ''"> and rp.`marjorBelongs` = #{marjorBelongs}</if>
            <if test="universityCode != null and universityCode != ''"> and rp.`universityCode` = #{universityCode}</if>
            <if test="universityName != null and universityName != ''"> and rp.`universityName` like concat('%', #{universityName}, '%')</if>
            <if test="marjorName != null and marjorName != ''"> and rp.`marjorName` like concat('%', #{marjorName}, '%')</if>
        </where>
        ORDER BY IF(u.`rankingOfEdu` = 0, 999, u.`rankingOfEdu`), u.`id`, ms.`year`,  rp.`type`, rp.`marjorName`, rp.`level`, rp.id
    </select>

    <!-- AND (ps.`course` IS NULL OR ps.`course` LIKE concat(#{course0}, '%')) CASE WHEN ps.`course` IS NULL THEN TRUE WHEN ps.`course` LIKE '%和%' THEN ps.`course` LIKE concat('%',#{course1},'%') AND ps.`course` LIKE concat('%',#{course2},'%') ELSE ps.`course` LIKE concat('%',#{course1},'%') OR ps.`course` LIKE concat('%',#{course2},'%') END -->
    <select id="selectWishUniversitySubmitPlanGroups" parameterType="map" resultMap="BBusiWishUniversitySubmitRecruitPlanResult">
      SELECT DISTINCT mc.`collegeCode`, mc.`universityId`, mc.`marjorCount` majorCount, mc.`planCount`, mc.`stats`,
              <choose><when test="newSpecialGroup">mc.uCode `specialProject`</when><otherwise>mc.`specialProject`</otherwise></choose>, mc.universityName, mc.`uCode` universityCode
        FROM `b_busi_wish_university_marjors_plan_submit` ps
        JOIN `b_busi_wish_university_marjors_college` mc ON mc.`id` = ps.`marjorCollegeId`
        JOIN `b_busi_wish_universities` u ON mc.`universityId` = u.`id`
        LEFT JOIN `b_busi_wish_university_submit_marjors` m ON m.`id` = <choose><when test="sameYear">ps.`plan_submit_id`</when><otherwise>ps.`submit_id`</otherwise></choose> and m.`year` = #{year}
        <where>ps.`location` = #{location} AND ps.level = #{level} AND ps.liberalScience = #{liberalScience} and ps.`year` = #{planYear}
            <!-- <if test="lowestRank != null"> AND <choose><when test="sameYear"> mc.`curr_seat` </when><otherwise> mc.`seat` </otherwise></choose> &gt; #{lowestRank}</if>
            <if test="highestRank != null"> AND <choose><when test="sameYear"> mc.`curr_seat` </when><otherwise> mc.`seat` </otherwise></choose> &lt;= #{highestRank} </if>
            <if test="lowestScore != null"> AND <choose><when test="sameYear"> mc.`curr_score` </when><otherwise> mc.`score` </otherwise></choose> &gt;= #{lowestScore}</if>
            <if test="highestScore != null"> AND <choose><when test="sameYear"> mc.`curr_score` </when><otherwise> mc.`score` </otherwise></choose> &lt; #{highestScore} </if> -->
            <!-- <if test="course0 != null and course0 != ''"> AND (ps.`course0` IS NULL OR ps.`course0` = '' OR ps.`course0` = #{course0})</if>
            <if test="course0 != null and course1 != null and course2 != null"> AND (ps.`course1` IS NULL OR ps.`course1` = '' OR FIND_IN_SET(#{course0}, ps.`course1`) + FIND_IN_SET(#{course1}, ps.`course1`) + FIND_IN_SET(#{course2}, ps.`course1`) > 0)</if>
            <if test="course0 != null and course1 != null and course2 != null"> AND (ps.`course2` IS NULL OR ps.`course2` = '' OR LENGTH(ps.`course2`) - LENGTH(REPLACE(ps.`course2`, ',', '')) + 1 = IF(FIND_IN_SET(#{course0}, ps.`course2`), 1, 0) + IF(FIND_IN_SET(#{course1}, ps.`course2`), 1, 0) + IF(FIND_IN_SET(#{course2}, ps.`course2`), 1, 0))</if>
            <if test="collect != null"> and <choose><when test="collect"> mc.`stats` like '%"collect":1%' </when><otherwise> mc.`stats` not like '%"collect":1%' </otherwise></choose></if> -->
            <choose><when test="uName != null and uName != ''"> and (u.`name` like concat('%', #{uName}, '%') or m.`marjorName` like concat('%', #{uName}, '%')
                <if test="sinoForeign != null"> and m.`sinoForeign` = #{sinoForeign}</if>
                <!-- <choose>
                    <when test="specialProjectNation != null and specialProjectLocal != null and specialProjectNation and specialProjectLocal">
                        and ps.`specialProject` in ('地方专项', '地方专项计划', '国家专项计划', '国家专项')
                    </when>
                    <otherwise>
                        <if test="specialProjectNation != null"> <choose><when test="specialProjectNation"> and ps.`specialProject` in ('国家专项','国家专项计划')</when><otherwise> and ps.`specialProject` not in ('国家专项', '国家专项计划')</otherwise></choose></if>
                        <if test="specialProjectLocal != null"> <choose><when test="specialProjectLocal"> and ps.`specialProject` in ('地方专项','地方专项计划')</when><otherwise> and ps.`specialProject` not in ('地方专项','地方专项计划')</otherwise></choose></if>
                    </otherwise>
                </choose> -->
                <if test="majors != null"> and m.`marjorName` in <foreach item="o" collection="majors" open="(" separator="," close=")">#{o}</foreach></if>)
                </when><otherwise>
                <if test="sinoForeign != null"> and m.`sinoForeign` = #{sinoForeign}</if>
                <!-- <choose>
                    <when test="specialProjectNation != null and specialProjectLocal != null and specialProjectNation and specialProjectLocal">
                        and ps.`specialProject` in ('地方专项', '地方专项计划', '国家专项计划', '国家专项')
                    </when>
                    <otherwise>
                        <if test="specialProjectNation != null"> <choose><when test="specialProjectNation"> and ps.`specialProject` in ('国家专项','国家专项计划')</when><otherwise> and ps.`specialProject` not in ('国家专项', '国家专项计划')</otherwise></choose></if>
                        <if test="specialProjectLocal != null"> <choose><when test="specialProjectLocal"> and ps.`specialProject` in ('地方专项','地方专项计划')</when><otherwise> and ps.`specialProject` not in ('地方专项','地方专项计划')</otherwise></choose></if>
                    </otherwise>
                </choose> -->
                <if test="majors != null"> and m.`marjorName` in <foreach item="o" collection="majors" open="(" separator="," close=")">#{o}</foreach></if>
            </otherwise></choose>
            <if test="lowestRank != null"> AND if(m.`id` is null, ps.`corrSeat`, m.`corrSeat`) &gt; #{lowestRank}</if>
            <if test="highestRank != null"> AND if(m.`id` is null, ps.`corrSeat`, m.`corrSeat`) &lt;= #{highestRank} </if>
            <if test="lowestScore != null"> AND if(m.`id` is null, ps.`corrScore`, m.`corrScore`) &gt;= #{lowestScore}</if>
            <if test="highestScore != null"> AND if(m.`id` is null, ps.`corrScore`, m.`corrScore`) &lt; #{highestScore} </if>
            <if test="specialProjects != null"> and ps.`specialProject` in <foreach item="o" collection="specialProjects" open="(" separator="," close=")">#{o}</foreach></if>
            <!-- <if test="specialProjectExcl != null and specialProjectExcl"> and (ps.`specialProject` is null or ps.`specialProject` = '') </if> -->
            <if test="uIds != null"> and u.`id` in <foreach item="o" collection="uIds" open="(" separator="," close=")">#{o}</foreach></if>
            <if test="uCode != null and uCode != ''"> and u.`code` = #{uCode}</if>
            <if test="uManagerType != null and uManagerType != ''"> and u.`managerType` = #{uManagerType}</if>
            <if test="uLocations != null"> and u.location in <foreach item="o" collection="uLocations" open="(" separator="," close=")">#{o}</foreach></if>
<!--            <if test="uTypes != null"> and <foreach item="o" collection="uTypes" open="(" separator=" OR " close=")">u.`type` like concat('%', #{o}, '%')</foreach></if>-->
            <if test="uTypes != null">and u.type in <foreach item="o" collection="uTypes" open="(" separator="," close=")">#{o}</foreach></if>
            <if test="uLevels != null"> and u.`level` in <foreach item="o" collection="uLevels" open="(" separator="," close=")">#{o}</foreach></if>
            <if test="uNatureTypeCNs != null"> and <foreach item="o" collection="uNatureTypeCNs" open="(" separator=" OR " close=")">u.`natureTypeCN` like concat('%', #{o}, '%')</foreach></if>
            <if test="uFeatureses"> and <foreach item="o" collection="uFeatureses" open="(" separator=" OR " close=")">u.`features` like concat('%', #{o}, '%')</foreach></if>
        </where>ORDER BY
        <choose><when test="uName != null and uName != ''">IF(mc.`matchCount` = 0, 1, 0),</when><otherwise></otherwise></choose>
        <choose><when test="sameYear">IF(mc.`curr_score` IS NULL, ps.`corrScore`, mc.`curr_score`) DESC, IF(u.`rankingOfEdu` > 0, u.`rankingOfEdu`, 9999), u.`code`, ps.plan_id</when>
        <otherwise>IF(mc.`score` IS NULL, ps.`score`, mc.`score`) DESC, IF(u.`rankingOfEdu` > 0, u.`rankingOfEdu`, 9999), u.`code`, ps.plan_id</otherwise></choose>
    </select>

<!--    <select id="selectWishUniversityPlanSubmitPlanGroups" parameterType="map" resultMap="BBusiWishUniversitySubmitRecruitPlanResult">-->
<!--        SELECT DISTINCT mc.`collegeCode`, mc.`universityId`, mc.`marjorCount` majorCount, mc.`planCount`, mc.`stats`, m.`type`, ps.`course`, m.`specialProject`-->
<!--        FROM `b_busi_wish_university_submit_marjors` m-->
<!--        JOIN `b_busi_wish_universities` u ON m.`universityId` = u.`id`-->
<!--        JOIN `b_busi_wish_university_marjors_plan_submit` ps ON ps.`plan_submit_id` = m.`id`-->
<!--        JOIN `b_busi_wish_university_marjors_college` mc ON mc.`id` = ps.`marjorCollegeId`-->
<!--        <where>m.`location` = #{location} AND m.`year` = #{year} AND m.level = #{level} AND m.liberalScience = #{liberalScience}-->
<!--            <if test="lowestRank != null"> AND <choose><when test="sameYear"> mc.`curr_seat` </when><otherwise> mc.`seat` </otherwise></choose> &gt; #{lowestRank}</if>-->
<!--            <if test="highestRank != null"> AND <choose><when test="sameYear"> mc.`curr_seat` </when><otherwise> mc.`seat` </otherwise></choose> &lt;= #{highestRank} </if>-->
<!--            <if test="course0 != null and course0 != ''"> AND (ps.`course0` IS NULL OR ps.`course0` = '' OR ps.`course0` = #{course0})</if>-->
<!--            <if test="course0 != null and course1 != null and course2 != null"> AND (ps.`course1` IS NULL OR ps.`course1` = '' OR FIND_IN_SET(#{course0}, ps.`course1`) + FIND_IN_SET(#{course1}, ps.`course1`) + FIND_IN_SET(#{course2}, ps.`course1`) > 0)</if>-->
<!--            <if test="course0 != null and course1 != null and course2 != null"> AND (ps.`course2` IS NULL OR ps.`course2` = '' OR LENGTH(ps.`course2`) - LENGTH(REPLACE(ps.`course2`, ',', '')) + 1 = IF(FIND_IN_SET(#{course0}, ps.`course2`), 1, 0) + IF(FIND_IN_SET(#{course1}, ps.`course2`), 1, 0) + IF(FIND_IN_SET(#{course2}, ps.`course2`), 1, 0))</if>-->
<!--            <if test="sinoForeign != null"> and m.`sinoForeign` = #{sinoForeign}</if>-->
<!--            <if test="specialProjectNation != null"> <choose><when test="specialProjectNation"> and m.`specialProject` = '国家专项'</when><otherwise> and m.`specialProject` != '国家专项'</otherwise></choose></if>-->
<!--            <if test="specialProjectLocal != null"> <choose><when test="specialProjectLocal"> and m.`specialProject` not in ('', '国家专项')</when><otherwise> and m.`specialProject` in ('', '国家专项')</otherwise></choose></if>-->
<!--            &lt;!&ndash; <if test="collect != null"> and m.collect = #{collect}</if> &ndash;&gt;-->
<!--            <if test="collect != null"> and <choose><when test="collect"> mc.`stats` like '%"collect":1%' </when><otherwise> mc.`stats` not like '%"collect":1%' </otherwise></choose></if>-->
<!--            <if test="majors != null"> and m.`marjorName` in <foreach item="o" collection="majors" open="(" separator="," close=")">#{o}</foreach></if>-->
<!--            <if test="uIds != null"> and u.`id` in <foreach item="o" collection="uIds" open="(" separator="," close=")">#{o}</foreach></if>-->
<!--            <if test="uName != null and uName != ''"> and u.`name` like concat('%', #{uName}, '%')</if>-->
<!--            <if test="uCode != null and uCode != ''"> and u.`code` = #{uCode}</if>-->
<!--            <if test="uManagerType != null and uManagerType != ''"> and u.`managerType` = #{uManagerType}</if>-->
<!--            <if test="uLocations != null"> and u.location in <foreach item="o" collection="uLocations" open="(" separator="," close=")">#{o}</foreach></if>-->
<!--            <if test="uTypes != null"> and <foreach item="o" collection="uTypes" open="(" separator=" OR " close=")">u.`type` like concat('%', #{o}, '%')</foreach></if>-->
<!--            <if test="uLevels != null"> and u.`level` in <foreach item="o" collection="uLevels" open="(" separator="," close=")">#{o}</foreach></if>-->
<!--            <if test="uNatureTypeCNs != null"> and <foreach item="o" collection="uNatureTypeCNs" open="(" separator=" OR " close=")">u.`natureTypeCN` like concat('%', #{o}, '%')</foreach></if>-->
<!--            <if test="uFeatureses"> and <foreach item="o" collection="uFeatureses" open="(" separator=" OR " close=")">u.`features` like concat('%', #{o}, '%')</foreach></if>-->
<!--        </where>-->
<!--        <choose><when test="sameYear"> ORDER BY mc.`curr_score` DESC </when><otherwise> ORDER BY mc.`score` DESC </otherwise></choose>, u.`rankingOfEdu`-->
<!--    </select>-->
    <select id="selectWishUniversitySubmitPlanGroupDetails" parameterType="map" resultMap="BBusiWishUniversitySubmitRecruitPlanResult">
        SELECT rp.`id`, rp.`universityId`, rp.`universityCode`, rp.`marjorCode` marjorId, rp.`collegeCode`, rp.`marjorName`, rp.`marjorNameText`, rp.`marjorBelongs`, rp.`marjorDirection`, rp.`specialProject`, rp.`planCount`, rp.`xuezhi`, rp.`xuefei`, rp.`type`, ps.`stats`, ps.enrollFluctuate
        FROM `b_busi_wish_university_marjors_plan_submit` ps
        JOIN `b_busi_wish_university_submit_recruit_plan` rp ON ps.`plan_id` = rp.`id`
        WHERE ps.`universityId` = #{universityId} and ps.`location` = #{location} AND ps.`year` = #{year} AND ps.level = #{level} AND ps.liberalScience = #{liberalScience} AND ps.`collegeCode` = #{collegeCode}
        <choose><when test="uCode != null  and uCode != ''">AND (ps.`uCode` = #{uCode} or ps.`marjorCollegeId` = #{uCode})</when><otherwise>AND (ps.`uCode` = '' or ps.`uCode` is null)</otherwise></choose>
    </select>

    <!-- p.`location`, p.`batch`, p.`liberalScience`, p.`level`, p.`type` -->
    <select id="selectWishUniversitySubmitRecruitGroups" parameterType="map" resultMap="BBusiWishUniversitySubmitRecruitPlanResult">
        SELECT p.`id`, p.`universityId`, p.`collegeCode`, p.`marjorId`, p.`marjorName`, p.`marjorNameText`, p.`marjorBelongs`, p.`year`, p.`marjorDirection`, p.`specialProject`, p.`planCount`, p.`xuezhi`, p.`xuefei`, p.`type`, p.`course`, p.`groupsName`
        FROM `b_busi_wish_university_submit_recruit_plan` p
        <where>
            <if test="ids != null"> and p.id in <foreach item="id" collection="ids" open="(" separator="," close=")">#{id}</foreach></if>
            <if test="location != null  and location != ''"> and p.`location` = #{location}</if>
            <if test="year != null"> AND p.`year` &gt;= #{year}</if>
            <if test="currYear != null != ''"> AND p.`year` &lt;= #{currYear}</if>
            <if test="liberalScience != null "> and  p.`liberalScience` = #{liberalScience}</if>
            <if test="level != null  and level != ''"> and p.`level` = #{level}</if>
            <if test="universityIds != null"> AND p.`universityId` in <foreach item="o" collection="universityIds" open="(" separator="," close=")">#{o}</foreach></if>
            <if test="collegeCodes != null"> AND p.`collegeCode` in <foreach item="o" collection="collegeCodes" open="(" separator="," close=")">#{o}</foreach></if>
        </where>
    </select>

    <select id="selectBBusiWishUniversitySubmitRecruitPlanList" parameterType="BBusiWishUniversitySubmitRecruitPlan" resultMap="BBusiWishUniversitySubmitRecruitPlanResult">
        <include refid="selectBBusiWishUniversitySubmitRecruitPlanVo"/>
        <where>
            <if test="collegeCode != null  and collegeCode != ''"> and collegeCode = #{collegeCode}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="batch != null "> and batch = #{batch}</if>
            <if test="level != null  and level != ''"> and level like concat('%', #{level},'%')</if>
            <if test="liberalScience != null "> and liberalScience = #{liberalScience}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="marjorId != null  and marjorId != ''"> and marjorId = #{marjorId}</if>
            <if test="universityId != null  and universityId != ''"> and universityId = #{universityId}</if>
            <if test="universityCode != null  and universityCode != ''"> and universityCode = #{universityCode}</if>
            <if test="universityName != null  and universityName != ''"> and universityName like concat('%', #{universityName}, '%')</if>
            <if test="universityNameText != null  and universityNameText != ''"> and universityNameText like concat('%', #{universityNameText}, '%')</if>
            <if test="marjorName != null  and marjorName != ''"> and marjorName like concat('%', #{marjorName}, '%')</if>
            <if test="marjorNameText != null  and marjorNameText != ''"> and marjorNameText like concat('%', #{marjorNameText}, '%')</if>
            <if test="marjorBelongs != null  and marjorBelongs != ''"> and marjorBelongs = #{marjorBelongs}</if>
            <if test="marjorDirection != null  and marjorDirection != ''"> and marjorDirection like concat('%', #{marjorDirection}, '%')</if>
            <if test="specialProject != null  and specialProject != ''"> and specialProject = #{specialProject}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="planCount != null  and planCount != ''"> and planCount = #{planCount}</if>
            <if test="planType != null  and planType != ''"> and planType = #{planType}</if>
            <if test="xuefei != null  and xuefei != ''"> and xuefei = #{xuefei}</if>
            <if test="xuezhi != null  and xuezhi != ''"> and xuezhi = #{xuezhi}</if>
        </where>
        order by collegeCode, batch, marjorCode, year desc
    </select>

    <select id="selectSubmitRecruitsData" parameterType="String" resultType="String">
        SELECT DISTINCT type from b_busi_wish_university_submit_recruit_plan where status &gt; 0
        and location = #{location}
        <choose>
            <when test="year != null  and year != ''">
                and year = #{year}
            </when>
            <otherwise>
                and year=(SELECT max(`year`) from b_busi_wish_university_submit_recruit_plan  where `location`= #{location})
            </otherwise>
        </choose>

    </select>

    <select id="selectSubmitRecruitsMaxYearByLocation" parameterType="String" resultType="Integer">
        SELECT max(year) from b_busi_wish_university_submit_recruit_plan where status &gt; 0
        and location = #{location}
    </select>

    <select id="getUniversityNameText" resultType="String">
        SELECT distinct universityNameText from b_busi_wish_university_submit_recruit_plan where status &gt; 0
         and universityCode = #{universityCode} and location = #{location} and year = #{year} and type = #{type}
        <if test="level!=null and level!=''">
            and level = #{level}
        </if>
        order by universityNameText asc
    </select>


    <select id="selectBBusiWishUniversitySubmitRecruitPlanById" parameterType="Long" resultMap="BBusiWishUniversitySubmitRecruitPlanResult">
        <include refid="selectBBusiWishUniversitySubmitRecruitPlanVo"/>
        where id = #{id}
    </select>

    <select id="levels" resultType="String">
        select distinct level from b_busi_wish_university_submit_recruit_plan where status &gt; 0
        <if test="location!=null and location!=''">
            and location = #{location}
        </if>
        <if test="year!=null">
            and year = #{year}
        </if>
        order by batch asc
    </select>

    <select id="types" resultType="String">
        select distinct type from b_busi_wish_university_submit_recruit_plan where status &gt; 0
        <if test="location!=null and location!=''">
            and location = #{location}
        </if>
        <if test="year!=null">
            and year = #{year}
        </if>
        order by liberalScience desc
    </select>

    <select id="years" resultType="String">
        select distinct year from b_busi_wish_university_submit_recruit_plan where status &gt; 0
        <if test="location!=null and location!=''">
            and location = #{location}
        </if>
        <if test="type!=null and type!=''">
            and type = #{type}
        </if>
        <if test="level!=null and level!=''">
            and level = #{level}
        </if>
        order by year desc
    </select>

    <select id="specialProjects" resultMap="BBusiWishUniversitySubmitRecruitPlanResult">
        select distinct location, year, specialProject from b_busi_wish_university_submit_recruit_plan where specialProject != ''
        <if test="location!=null and location!=''">
            and location = #{location}
        </if>
        <if test="year!=null">
            and year &gt;= #{year}
        </if>
    </select>

    <insert id="insertBBusiWishUniversitySubmitRecruitPlan" parameterType="BBusiWishUniversitySubmitRecruitPlan" useGeneratedKeys="true" keyProperty="id">
        insert into b_busi_wish_university_submit_recruit_plan
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="collegeCode != null">collegeCode,</if>
            <if test="year != null and year != ''">year,</if>
            <if test="location != null">location,</if>
            <if test="batch != null">batch,</if>
            <if test="level != null">level,</if>
            <if test="liberalScience != null">liberalScience,</if>
            <if test="type != null">type,</if>
            <if test="marjorId != null">marjorId,</if>
            <if test="universityId != null">universityId,</if>
            <if test="universityCode != null">universityCode,</if>
            <if test="universityName != null">universityName,</if>
            <if test="marjorCode != null">marjorCode,</if>
            <if test="marjorName != null">marjorName,</if>
            <if test="marjorNameText != null">marjorNameText,</if>
            <if test="marjorBelongs != null">marjorBelongs,</if>
            <if test="marjorDirection != null">marjorDirection,</if>
            <if test="specialProject != null">specialProject,</if>
            <if test="createTime != null">createTime,</if>
            <if test="status != null">status,</if>
            <if test="planCount != null">planCount,</if>
            <if test="planType != null">planType,</if>
            <if test="xuefei != null">xuefei,</if>
            <if test="xuezhi != null">xuezhi,</if>
            <if test="course != null">course,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="collegeCode != null">#{collegeCode},</if>
            <if test="year != null and year != ''">#{year},</if>
            <if test="location != null">#{location},</if>
            <if test="batch != null">#{batch},</if>
            <if test="level != null">#{level},</if>
            <if test="liberalScience != null">#{liberalScience},</if>
            <if test="type != null">#{type},</if>
            <if test="marjorId != null">#{marjorId},</if>
            <if test="universityId != null">#{universityId},</if>
            <if test="universityCode != null">#{universityCode},</if>
            <if test="universityName != null">#{universityName},</if>
            <if test="marjorCode != null">#{marjorCode},</if>
            <if test="marjorName != null">#{marjorName},</if>
            <if test="marjorNameText != null">#{marjorNameText},</if>
            <if test="marjorBelongs != null">#{marjorBelongs},</if>
            <if test="marjorDirection != null">#{marjorDirection},</if>
            <if test="specialProject != null">#{specialProject},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="status != null">#{status},</if>
            <if test="planCount != null">#{planCount},</if>
            <if test="planType != null">#{planType},</if>
            <if test="xuefei != null">#{xuefei},</if>
            <if test="xuezhi != null">#{xuezhi},</if>
            <if test="course != null">#{course},</if>
         </trim>
    </insert>

    <update id="updateBBusiWishUniversitySubmitRecruitPlan" parameterType="BBusiWishUniversitySubmitRecruitPlan">
        update b_busi_wish_university_submit_recruit_plan
        <trim prefix="SET" suffixOverrides=",">
            <if test="collegeCode != null">collegeCode = #{collegeCode},</if>
            <if test="year != null and year != ''">year = #{year},</if>
            <if test="location != null">location = #{location},</if>
            <if test="batch != null">batch = #{batch},</if>
            <if test="level != null">level = #{level},</if>
            <if test="liberalScience != null">liberalScience = #{liberalScience},</if>
            <if test="type != null">type = #{type},</if>
            <if test="marjorId != null">marjorId = #{marjorId},</if>
            <if test="universityId != null">universityId = #{universityId},</if>
            <if test="universityCode != null">universityCode = #{universityCode},</if>
            <if test="universityName != null">universityName = #{universityName},</if>
            <if test="marjorCode != null">marjorCode = #{marjorCode},</if>
            <if test="marjorName != null">marjorName = #{marjorName},</if>
            <if test="marjorNameText != null">marjorNameText = #{marjorNameText},</if>
            <if test="marjorBelongs != null">marjorBelongs = #{marjorBelongs},</if>
            <if test="marjorDirection != null">marjorDirection = #{marjorDirection},</if>
            <if test="specialProject != null">specialProject = #{specialProject},</if>
            <if test="createTime != null">createTime = #{createTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="planCount != null">planCount = #{planCount},</if>
            <if test="planType != null">planType = #{planType},</if>
            <if test="xuefei != null">xuefei = #{xuefei},</if>
            <if test="xuezhi != null">xuezhi = #{xuezhi},</if>
            <if test="course != null">course = #{course},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBBusiWishUniversitySubmitRecruitPlanById" parameterType="Long">
        delete from b_busi_wish_university_submit_recruit_plan where id = #{id}
    </delete>

    <delete id="deleteBBusiWishUniversitySubmitRecruitPlanByIds" parameterType="String">
        delete from b_busi_wish_university_submit_recruit_plan where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
