<?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.srs.comprehensive.mapper.SrsKnrdApplyMapper">

    <resultMap type="SrsKnrdApply" id="SrsKnrdApplyResult">
        <result property="id"    column="id"    />
        <result property="step"    column="step"    />
        <result property="xm"    column="xm"    />
        <result property="xb"    column="xb"    />
        <result property="mz"    column="mz"    />
        <result property="sfzhm"    column="sfzhm"    />
        <result property="xh"    column="xh"    />
        <result property="csny"    column="csny"    />
        <result property="knlx"    column="knlx"    />
        <result property="knlx2"    column="knlx2"    />
        <result property="rkzs"    column="rkzs"    />
        <result property="srly"    column="srly"    />
        <result property="hjxz"    column="hjxz"    />
        <result property="hjszd"    column="hjszd"    />
        <result property="jtcy"    column="jtcy"    />
        <result property="jtjzfqk"    column="jtjzfqk"    />
        <result property="jtqcqk"    column="jtqcqk"    />
        <result property="jtxjzdz"    column="jtxjzdz"    />
        <result property="jzdh"    column="jzdh"    />
        <result property="jtnsr"    column="jtnsr"    />
        <result property="rjnsr"    column="rjnsr"    />
        <result property="jtzysr"    column="jtzysr"    />
        <result property="jtzysr2" column="jtzysr2"/>
        <result property="ssldnl"    column="ssldnl"    />
        <result property="hbcjr"    column="hbcjr"    />
        <result property="zyssldnl"    column="zyssldnl"    />
        <result property="tfsj"    column="tfsj"    />
        <result property="sqrqm"    column="sqrqm"    />
        <result property="sqrqmrq"    column="sqrqmrq"    />
        <result property="bjpyyj"    column="bjpyyj"    />
        <result property="pyxzzzqm"    column="pyxzzzqm"    />
        <result property="pyxzzzqmrq"    column="pyxzzzqmrq"    />
        <result property="fdyqm"    column="fdyqm"    />
        <result property="fdyqmrq"    column="fdyqmrq"    />
        <result property="ejxyldqmyj"    column="ejxyldqmyj"    />
        <result property="ejxyldqm"    column="ejxyldqm"    />
        <result property="ejxyldqmrq"    column="ejxyldqmrq"    />
        <result property="xsqmyj"    column="xsqmyj"    />
        <result property="xsqm"    column="xsqm"    />
        <result property="xsqmrq"    column="xsqmrq"    />
        <result property="createId"    column="create_id"    />
        <result property="remark"    column="remark"    />
        <result property="xsqmyjstate"    column="xsqmyjstate"    />
        <result property="ejxyldqmyjstate"    column="ejxyldqmyjstate"    />
        <result property="bjpyyjstate"    column="bjpyyjstate"    />
        <result property="jtcyzxrs"    column="jtcyzxrs"    />
        <result property="syrs"    column="syrs"    />
        <result property="jtcysyrs"    column="jtcysyrs"    />
        <result property="parentstel"    column="parentstel"    />
        <result property="tfsj2"    column="tfsj2"    />
        <result property="tfsj3"    column="tfsj3"    />
        <result property="applyYear"    column="apply_year"    />
        <result property="xy"    column="xy"    />
        <result property="nj"    column="nj"    />
        <result property="bj"    column="bj"    />
        <result property="phone"    column="phone"    />
        <result property="jg"    column="jg"    />
        <result property="sqly"    column="sqly"    />
        <result property="sqrcn"    column="sqrcn"    />
        <result property="fdymc"    column="fdymc"    />
        <result property="fdygh"    column="fdygh"    />
        <result property="ejxyldgh"    column="ejxyldgh"    />
        <result property="ejxyldmc"    column="ejxyldmc"    />
        <result property="xsgh"    column="xsgh"    />
        <result property="xsmc"    column="xsmc"    />
        <result property="stuYearId"    column="stu_year_id"    />
        <result property="countXw" column="countXw"/>
    </resultMap>
    <resultMap type="SrsFemilyMenber" id="SrsFemilyMenberResult">
        <result property="kinsfolkId"    column="kinsfolk_id"    />
        <result property="kinsfolkName"    column="kinsfolk_name"    />
        <result property="kinsfolkIdentify"    column="kinsfolk_identify"    />
        <result property="nation"    column="nation"    />
        <result property="kinsfolkRelation"    column="kinsfolk_relation"    />
        <result property="postCode"    column="post_code"    />
        <result property="sex"    column="sex"    />
        <result property="bornDate"    column="born_date"    />
        <result property="politicsStatus"    column="politics_status"    />
        <result property="workUnit"    column="work_unit"    />
        <result property="duty"    column="duty"    />
        <result property="kinsfolkRelate"    column="kinsfolk_relate"    />
        <result property="civilState"    column="civil_state"    />
        <result property="healthCondition"    column="health condition"    />
        <result property="unitAddress"    column="unit address"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="studentId"    column="student_id"    />
    </resultMap>

    <resultMap type="SrsStudent" id="SrsStudentResult">
        <result property="stuId"    column="stu_id"    />
        <result property="name"    column="name"    />
        <result property="stuNo"    column="stu_no"    />
        <result property="gender"    column="gender"    />
        <result property="birthday"    column="birthday"    />
        <result property="idCard"    column="id_card"    />
        <result property="deptId"    column="dept_id"    />
        <result property="majorId"    column="major_id"    />
        <result property="classId"    column="class_id"    />
        <result property="phone"    column="phone"    />
        <result property="address"    column="address"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>
    <resultMap type="SrsParentsDetal" id="SrsParentsDetallist">
        <result property="pId"    column="p_id"    />
        <result property="fatherName"    column="father_name"    />
        <result property="fatherProfession"    column="father_profession"    />
        <result property="fatherRelation"    column="father_relation"    />
        <result property="fatehrAge"    column="fatehr_age"    />
        <result property="motherName"    column="mother_name"    />
        <result property="motherProfession"    column="mother_profession"    />
        <result property="motherRelation"    column="mother_relation"    />
        <result property="motherAge"    column="mother_age"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="studentId"    column="student_id"    />
    </resultMap>

    <resultMap id="list" type="SrsStudent" extends="SrsStudentResult">
        <collection property="srsFemilyMenberList" notNullColumn="kinsfolk_id" javaType="java.util.List" resultMap="SrsFemilyMenberResult" />
    </resultMap>
    <select id="listView"  parameterType="CphSearch" resultType="SrsKnrdApply">
        select a.*
        from srs_knrd_apply as a
        left join srs_student as b on a.xh = b.stu_no
        left join srs_class as c on b.class_id = c.class_id
        left join srs_majors as d on c.major_id = d.major_id
        left join cph_teacher as e on c.teacher_id = e.teacher_id
        left join sys_dept_map as f on d.college_id = f.old_dept_id
        left join sys_dept as dept on d.college_id = dept.dept_id
        <where>
            <if test="collegeId !=null">and d.college_id = #{collegeId}</if>
            <if test="step != null ">and a.step = #{step} and locked != 1</if>
            <if test="tNo != null ">and e.employee_id = #{tNo}</if>
            <if test="deptId != null ">and f.new_dept_id = #{deptId}
            </if>
            <if test="stuNo != null ">and a.xh = #{stuNo}</if>
            <if test="sfzhm != null ">and a.sfzhm = #{sfzhm}</if>
            <if test="xm != null ">and a.xm like concat('%',#{xm},'%')</if>
            <if test="xh != null ">and a.xh like concat('%',#{xh},'%')</if>
            <if test="majorId != null ">and d.major_id = #{majorId}</if>
            <if test="classId != null ">and c.class_id = #{classId}</if>
        </where>
        order by a.id asc
    </select>

    <select id="countXw"  parameterType="CphSearch" resultType="SrsKnrdApply">
        select ejxyldqmyj, count(a.id) as countXw
        from srs_knrd_apply as a
        left join srs_student as b on a.xh = b.stu_no
        left join srs_class as c on b.class_id = c.class_id
        left join srs_majors as d on c.major_id = d.major_id
        left join cph_teacher as e on c.teacher_id = e.teacher_id
        left join sys_dept_map as f on d.college_id = f.old_dept_id
        left join sys_dept as dept on d.college_id = dept.dept_id
        <where>
            <if test="collegeId !=null">and d.college_id = #{collegeId}</if>

            <if test="tNo != null ">and e.employee_id = #{tNo}</if>
            <if test="deptId != null ">and f.new_dept_id = #{deptId}
            </if>
            <if test="stuNo != null ">and a.xh = #{stuNo}</if>
            <if test="sfzhm != null ">and a.sfzhm = #{sfzhm}</if>
            <if test="xm != null ">and a.xm like concat('%',#{xm},'%')</if>
            <if test="xh != null ">and a.xh like concat('%',#{xh},'%')</if>
            <if test="majorId != null ">and d.major_id = #{majorId}</if>
            <if test="classId != null ">and c.class_id = #{classId}</if>
        </where>
        group by ejxyldqmyj

    </select>



    <sql id="selectSrsKnrdApplyVo">
        select * from srs_knrd_apply
    </sql>

    <select id="selectSrsKnrdApplyList" parameterType="SrsKnrdApply" resultMap="SrsKnrdApplyResult">
        select * from srs_knrd_apply
<!--        <include refid="selectSrsKnrdApplyVo"/>-->
        <where>
            <if test="step != null "> and step = #{step}</if>
            <if test="xm != null  and xm != ''"> and xm = #{xm}</if>
            <if test="xb != null  and xb != ''"> and xb = #{xb}</if>
            <if test="mz != null  and mz != ''"> and mz = #{mz}</if>
            <if test="sfzhm != null  and sfzhm != ''"> and sfzhm = #{sfzhm}</if>
            <if test="xh != null  and xh != ''"> and xh = #{xh}</if>
            <if test="csny != null  and csny != ''"> and csny = #{csny}</if>
            <if test="knlx != null  and knlx != ''"> and knlx = #{knlx}</if>
            <if test="knlx2 != null  and knlx2 != ''"> and knlx2 = #{knlx2}</if>
            <if test="rkzs != null  and rkzs != ''"> and rkzs = #{rkzs}</if>
            <if test="srly != null  and srly != ''"> and srly = #{srly}</if>
            <if test="hjxz != null  and hjxz != ''"> and hjxz = #{hjxz}</if>
            <if test="hjszd != null  and hjszd != ''"> and hjszd = #{hjszd}</if>
            <if test="jtcy != null  and jtcy != ''"> and jtcy = #{jtcy}</if>
            <if test="jtjzfqk != null  and jtjzfqk != ''"> and jtjzfqk = #{jtjzfqk}</if>
            <if test="jtqcqk != null  and jtqcqk != ''"> and jtqcqk = #{jtqcqk}</if>
            <if test="jtxjzdz != null  and jtxjzdz != ''"> and jtxjzdz = #{jtxjzdz}</if>
            <if test="jzdh != null  and jzdh != ''"> and jzdh = #{jzdh}</if>
            <if test="jtnsr != null  and jtnsr != ''"> and jtnsr = #{jtnsr}</if>
            <if test="rjnsr != null  and rjnsr != ''"> and rjnsr = #{rjnsr}</if>
            <if test="jtzysr != null  and jtzysr != ''"> and jtzysr = #{jtzysr}</if>
            <if test="jtzysr2 != null  and jtzysr2 != ''"> and jtzysr2 = #{jtzysr2}</if>
            <if test="ssldnl != null  and ssldnl != ''"> and ssldnl = #{ssldnl}</if>
            <if test="hbcjr != null  and hbcjr != ''"> and hbcjr = #{hbcjr}</if>
            <if test="zyssldnl != null  and zyssldnl != ''"> and zyssldnl = #{zyssldnl}</if>
            <if test="tfsj != null  and tfsj != ''"> and tfsj = #{tfsj}</if>
            <if test="tfsj2 != null  and tfsj2 != ''"> and tfsj2 = #{tfsj2}</if>
            <if test="tfsj3 != null  and tfsj3 != ''"> and tfsj3 = #{tfsj3}</if>
            <if test="sqrqm != null  and sqrqm != ''"> and sqrqm = #{sqrqm}</if>
            <if test="sqrqmrq != null  and sqrqmrq != ''"> and sqrqmrq = #{sqrqmrq}</if>
            <if test="bjpyyj != null  and bjpyyj != ''"> and bjpyyj = #{bjpyyj}</if>
            <if test="pyxzzzqm != null  and pyxzzzqm != ''"> and pyxzzzqm = #{pyxzzzqm}</if>
            <if test="pyxzzzqmrq != null  and pyxzzzqmrq != ''"> and pyxzzzqmrq = #{pyxzzzqmrq}</if>
            <if test="fdyqm != null  and fdyqm != ''"> and fdyqm = #{fdyqm}</if>
            <if test="fdyqmrq != null  and fdyqmrq != ''"> and fdyqmrq = #{fdyqmrq}</if>
            <if test="ejxyldqmyj != null  and ejxyldqmyj != ''"> and ejxyldqmyj = #{ejxyldqmyj}</if>
            <if test="ejxyldqm != null  and ejxyldqm != ''"> and ejxyldqm = #{ejxyldqm}</if>
            <if test="ejxyldqmrq != null  and ejxyldqmrq != ''"> and ejxyldqmrq = #{ejxyldqmrq}</if>
            <if test="xsqmyj != null  and xsqmyj != ''"> and xsqmyj = #{xsqmyj}</if>
            <if test="xsqm != null  and xsqm != ''"> and xsqm = #{xsqm}</if>
            <if test="xsqmrq != null  and xsqmrq != ''"> and xsqmrq = #{xsqmrq}</if>
            <if test="createId != null "> and create_id = #{createId}</if>
            <if test="stuYearId != null "> and stu_year_id = #{stuYearId}</if>
        </where>
    </select>

    <select id="selectSrsKnrdApplyById" parameterType="Long" resultMap="SrsKnrdApplyResult">
        <include refid="selectSrsKnrdApplyVo"/>
        where id = #{id}
    </select>
    <select id="selectSrsKnrdApplyBysfz" resultType="com.srs.comprehensive.domain.SrsKnrdApply">
        <include refid="selectSrsKnrdApplyVo"/>
        where sfzhm = #{sfzhm} and stu_year_id = #{stuYearId}
    </select>
    <select id="selectsfzhm" resultType="com.srs.comprehensive.domain.SrsKnrdApply">
        select * from srs_student where id_card=#{sfzhm}
    </select>
    <select id="getInfoxh" resultMap="SrsStudentResult">
        select s.stu_id,s.stu_no, s.name, s.gender, s.birthday, AES_DECRYPT(UNHEX(s.id_card),'zhxg') as id_card , s.dept_id, major_id, class_id, s.phone, s.address,
               s.status, s.create_by, s.create_time, s.update_by, s.update_time, s.del_flag,s.xhk from  srs_student s
--             LEFT JOIN srs_femily_menber det on stu.stu_id=det.student_id
        where stu_no=#{xh}
    </select>
    <select id="getjtxx" resultType="com.srs.comprehensive.domain.SrsFemilyMenber">
        select * from  srs_femily_menber
        where student_id=#{stuId}
    </select>
<!--    根据年份查询是否存在申请记录-->
    <select id="selectByXhAndYear" resultType="com.srs.comprehensive.domain.SrsKnrdApply" parameterType="SrsKnrdApply">
        select * from  srs_knrd_apply  where xh = #{xh} and stu_year_id = #{stuYearId} limit 1
    </select>
    <insert id="insertSrsKnrdApply" parameterType="SrsKnrdApply" useGeneratedKeys="true" keyProperty="id">
        insert into srs_knrd_apply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="step != null">step,</if>
            <if test="xm != null">xm,</if>
            <if test="xb != null">xb,</if>
            <if test="mz != null">mz,</if>
            <if test="sfzhm != null">sfzhm,</if>
            <if test="xh != null">xh,</if>
            <if test="csny != null">csny,</if>
            <if test="knlx != null">knlx,</if>
            <if test="knlx2 != null">knlx2,</if>
            <if test="rkzs != null">rkzs,</if>
            <if test="srly != null">srly,</if>
            <if test="hjxz != null">hjxz,</if>
            <if test="hjszd != null">hjszd,</if>
            <if test="jtcy != null">jtcy,</if>
            <if test="jtjzfqk != null">jtjzfqk,</if>
            <if test="jtqcqk != null">jtqcqk,</if>
            <if test="jtxjzdz != null">jtxjzdz,</if>
            <if test="jzdh != null">jzdh,</if>
            <if test="jtnsr != null">jtnsr,</if>
            <if test="rjnsr != null">rjnsr,</if>
            <if test="jtzysr != null">jtzysr,</if>
            <if test="jtzysr2 != null">jtzysr2,</if>
            <if test="ssldnl != null">ssldnl,</if>
            <if test="hbcjr != null">hbcjr,</if>
            <if test="zyssldnl != null">zyssldnl,</if>
            <if test="tfsj != null">tfsj,</if>
            <if test="sqrqm != null">sqrqm,</if>
            <if test="sqrqmrq != null">sqrqmrq,</if>
            <if test="bjpyyj != null">bjpyyj,</if>
            <if test="pyxzzzqm != null">pyxzzzqm,</if>
            <if test="pyxzzzqmrq != null">pyxzzzqmrq,</if>
            <if test="fdyqm != null">fdyqm,</if>
            <if test="fdyqmrq != null and fdyqmrq != ''">fdyqmrq,</if>
            <if test="ejxyldqmyj != null">ejxyldqmyj,</if>
            <if test="ejxyldqm != null">ejxyldqm,</if>
            <if test="ejxyldqmrq != null">ejxyldqmrq,</if>
            <if test="xsqmyj != null">xsqmyj,</if>
            <if test="xsqm != null">xsqm,</if>
            <if test="xsqmrq != null">xsqmrq,</if>
            <if test="createId != null">create_id,</if>
            <if test="xsqmyjstate != null">xsqmyjstate,</if>
            <if test="ejxyldqmyjstate != null">ejxyldqmyjstate,</if>
            <if test="bjpyyjstate != null">bjpyyjstate,</if>
            <if test="jtcyzxrs != null">jtcyzxrs,</if>
            <if test="syrs != null">syrs,</if>
            <if test="jtcysyrs != null">jtcysyrs,</if>
            <if test="affixId != null">affixId,</if>
            <if test="parentstel != null">parentstel,</if>
            <if test="tfsj2 != null">tfsj2,</if>
            <if test="tfsj3 != null">tfsj3,</if>
            <if test="applyYear != null">apply_year,</if>
            <if test="xy != null">xy,</if>
            <if test="nj != null">nj,</if>
            <if test="bj != null">bj,</if>
            <if test="phone != null">phone,</if>
            <if test="jg != null">jg,</if>
            <if test="sqly != null">sqly,</if>
            <if test="sqrcn != null">sqrcn,</if>
            <if test="fdymc != null">fdymc,</if>
            <if test="fdygh != null">fdygh,</if>
            <if test="ejxyldgh != null">ejxyldgh,</if>
            <if test="ejxyldmc != null">ejxyldmc,</if>
            <if test="xsgh != null">xsgh,</if>
            <if test="xsmc != null">xsmc,</if>
            <if test="stuYearId != null">stu_year_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="step != null">#{step},</if>
            <if test="xm != null">#{xm},</if>
            <if test="xb != null">#{xb},</if>
            <if test="mz != null">#{mz},</if>
            <if test="sfzhm != null">#{sfzhm},</if>
            <if test="xh != null">#{xh},</if>
            <if test="csny != null">#{csny},</if>
            <if test="knlx != null">#{knlx},</if>
            <if test="knlx2 != null">#{knlx2},</if>
            <if test="rkzs != null">#{rkzs},</if>
            <if test="srly != null">#{srly},</if>
            <if test="hjxz != null">#{hjxz},</if>
            <if test="hjszd != null">#{hjszd},</if>
            <if test="jtcy != null">#{jtcy},</if>
            <if test="jtjzfqk != null">#{jtjzfqk},</if>
            <if test="jtqcqk != null">#{jtqcqk},</if>
            <if test="jtxjzdz != null">#{jtxjzdz},</if>
            <if test="jzdh != null">#{jzdh},</if>
            <if test="jtnsr != null">#{jtnsr},</if>
            <if test="rjnsr != null">#{rjnsr},</if>
            <if test="jtzysr != null">#{jtzysr},</if>
            <if test="jtzysr2 != null">#{jtzysr2},</if>
            <if test="ssldnl != null">#{ssldnl},</if>
            <if test="hbcjr != null">#{hbcjr},</if>
            <if test="zyssldnl != null">#{zyssldnl},</if>
            <if test="tfsj != null">#{tfsj},</if>
            <if test="sqrqm != null">#{sqrqm},</if>
            <if test="sqrqmrq != null">#{sqrqmrq},</if>
            <if test="bjpyyj != null">#{bjpyyj},</if>
            <if test="pyxzzzqm != null">#{pyxzzzqm},</if>
            <if test="pyxzzzqmrq != null">#{pyxzzzqmrq},</if>
            <if test="fdyqm != null">#{fdyqm},</if>
            <if test="fdyqmrq != null and fdyqmrq != ''">#{fdyqmrq},</if>
            <if test="ejxyldqmyj != null">#{ejxyldqmyj},</if>
            <if test="ejxyldqm != null">#{ejxyldqm},</if>
            <if test="ejxyldqmrq != null">#{ejxyldqmrq},</if>
            <if test="xsqmyj != null">#{xsqmyj},</if>
            <if test="xsqm != null">#{xsqm},</if>
            <if test="xsqmrq != null">#{xsqmrq},</if>
            <if test="createId != null">#{createId},</if>
            <if test="xsqmyjstate != null">#{xsqmyjstate},</if>
            <if test="ejxyldqmyjstate != null">#{ejxyldqmyjstate},</if>
            <if test="bjpyyjstate != null">#{bjpyyjstate},</if>
            <if test="jtcyzxrs != null">#{jtcyzxrs},</if>
            <if test="syrs != null">#{syrs},</if>
            <if test="jtcysyrs != null">#{jtcysyrs},</if>
            <if test="affixId != null">#{affixId},</if>
            <if test="parentstel != null">#{parentstel},</if>
            <if test="tfsj2 != null">#{tfsj2},</if>
            <if test="tfsj3 != null">#{tfsj3},</if>
            <if test="applyYear != null">#{applyYear},</if>
            <if test="xy != null">#{xy},</if>
            <if test="nj != null">#{nj},</if>
            <if test="bj != null">#{bj},</if>
            <if test="phone != null">#{phone},</if>
            <if test="jg != null">#{jg},</if>
            <if test="sqly != null">#{sqly},</if>
            <if test="sqrcn != null">#{sqrcn},</if>

            <if test="fdymc != null">#{fdymc},</if>
            <if test="fdygh != null">#{fdygh},</if>
            <if test="ejxyldgh != null">#{ejxyldgh},</if>
            <if test="ejxyldmc != null">#{ejxyldmc},</if>
            <if test="xsgh != null">#{xsgh},</if>
            <if test="xsmc != null">#{xsmc},</if>
            <if test="stuYearId != null">#{stuYearId},</if>
        </trim>
    </insert>

    <update id="updateSrsKnrdApply" parameterType="SrsKnrdApply">
        update srs_knrd_apply
        <trim prefix="SET" suffixOverrides=",">
            <if test="step != null">step = #{step},</if>
            <if test="xm != null">xm = #{xm},</if>
            <if test="xb != null">xb = #{xb},</if>
            <if test="mz != null">mz = #{mz},</if>
            <if test="sfzhm != null">sfzhm = #{sfzhm},</if>
            <if test="xh != null">xh = #{xh},</if>
            <if test="csny != null">csny = #{csny},</if>
            <if test="knlx != null">knlx = #{knlx},</if>
            <if test="knlx2 != null">knlx2 = #{knlx2},</if>
            <if test="rkzs != null">rkzs = #{rkzs},</if>
            <if test="srly != null">srly = #{srly},</if>
            <if test="hjxz != null">hjxz = #{hjxz},</if>
            <if test="hjszd != null">hjszd = #{hjszd},</if>
            <if test="jtcy != null">jtcy = #{jtcy},</if>
            <if test="jtjzfqk != null">jtjzfqk = #{jtjzfqk},</if>
            <if test="jtqcqk != null">jtqcqk = #{jtqcqk},</if>
            <if test="jtxjzdz != null">jtxjzdz = #{jtxjzdz},</if>
            <if test="jzdh != null">jzdh = #{jzdh},</if>
            <if test="jtnsr != null">jtnsr = #{jtnsr},</if>
            <if test="rjnsr != null">rjnsr = #{rjnsr},</if>
            <if test="jtzysr != null">jtzysr = #{jtzysr},</if>
            <if test="jtzysr2 != null">jtzysr2 = #{jtzysr2},</if>
            <if test="ssldnl != null">ssldnl = #{ssldnl},</if>
            <if test="hbcjr != null">hbcjr = #{hbcjr},</if>
            <if test="zyssldnl != null">zyssldnl = #{zyssldnl},</if>
            <if test="tfsj != null">tfsj = #{tfsj},</if>
            <if test="sqrqm != null">sqrqm = #{sqrqm},</if>
            <if test="sqrqmrq != null">sqrqmrq = #{sqrqmrq},</if>
            <if test="bjpyyj != null">bjpyyj = #{bjpyyj},</if>
            <if test="pyxzzzqm != null">pyxzzzqm = #{pyxzzzqm},</if>
            <if test="pyxzzzqmrq != null">pyxzzzqmrq = #{pyxzzzqmrq},</if>
            <if test="fdyqm != null">fdyqm = #{fdyqm},</if>
            <if test="fdyqmrq != null and fdyqmrq != ''">fdyqmrq = #{fdyqmrq},</if>
            <if test="ejxyldqmyj != null">ejxyldqmyj = #{ejxyldqmyj},</if>
            <if test="ejxyldqm != null">ejxyldqm = #{ejxyldqm},</if>
            <if test="ejxyldqmrq != null">ejxyldqmrq = #{ejxyldqmrq},</if>
            <if test="xsqmyj != null">xsqmyj = #{xsqmyj},</if>
            <if test="xsqm != null">xsqm = #{xsqm},</if>
            <if test="xsqmrq != null">xsqmrq = #{xsqmrq},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="xsqmyjstate != null">xsqmyjstate =#{xsqmyjstate},</if>
            <if test="ejxyldqmyjstate != null">ejxyldqmyjstate =#{ejxyldqmyjstate},</if>
            <if test="bjpyyjstate != null">bjpyyjstate =#{bjpyyjstate},</if>
            <if test="jtcyzxrs != null">jtcyzxrs=#{jtcyzxrs},</if>
            <if test="syrs != null">syrs=#{syrs},</if>
            <if test="jtcysyrs != null">jtcysyrs=#{jtcysyrs},</if>
            <if test="affixId != null">affixId=#{affixId},</if>
            <if test="parentstel != null">parentstel=#{parentstel},</if>
            <if test="tfsj2 != null">tfsj2=#{tfsj2},</if>
            <if test="tfsj3 != null">tfsj3=#{tfsj3},</if>
            <if test="applyYear != null">apply_year=#{applyYear},</if>
            <if test="xy != null">xy=#{xy},</if>
            <if test="nj != null">nj=#{nj},</if>
            <if test="bj != null">bj=#{bj},</if>
            <if test="phone != null">phone=#{phone},</if>
            <if test="jg != null">jg=#{jg},</if>
            <if test="sqly != null">sqly=#{sqly},</if>
            <if test="sqrcn != null">sqrcn=#{sqrcn },</if>
            <if test="fdymc != null">fdymc=#{fdymc},</if>
            <if test="fdygh != null">fdygh=#{fdygh},</if>
            <if test="ejxyldgh != null">ejxyldgh=#{ejxyldgh},</if>
            <if test="ejxyldmc != null">ejxyldmc=#{ejxyldmc},</if>
            <if test="xsgh != null">xsgh=#{xsgh},</if>
            <if test="xsmc != null">xsmc=#{xsmc},</if>
            <if test="stuYearId != null">stu_year_id=#{stuYearId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSrsKnrdApplyById" parameterType="Long">
        delete from srs_knrd_apply where id = #{id}
    </delete>

    <delete id="deleteSrsKnrdApplyByIds" parameterType="String">
        delete from srs_knrd_apply where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <update id="updateAllSrsKnrdApply" parameterType="com.srs.comprehensive.domain.SrsHandAllKnrd" >
        update srs_knrd_apply a left  join srs_knrd_apply b on a.id = b.id
        <trim prefix="SET" suffixOverrides=",">
            <if test="step != null">a.step = #{step},</if>
            <if test="bjpyyj != null">a.bjpyyj = #{bjpyyj},</if>
            <if test="fdyqm != null">a.fdyqm = #{fdyqm},</if>
            <if test="fdyqmrq != null and fdyqmrq != ''">a.fdyqmrq = #{fdyqmrq},</if>
            <if test="ejxyldqmyj != null">a.ejxyldqmyj = b.bjpyyj,</if>
            <if test="ejxyldqm != null">a.ejxyldqm = #{ejxyldqm},</if>
            <if test="ejxyldqmrq != null">a.ejxyldqmrq = #{ejxyldqmrq},</if>
            <if test="xsqmyj != null">a.xsqmyj =  b.bjpyyj,</if>
            <if test="xsqm != null">a.xsqm = #{xsqm},</if>
            <if test="xsqmrq != null">a.xsqmrq = #{xsqmrq},</if>
            <if test="fdymc != null">a.fdymc=#{fdymc},</if>
            <if test="fdygh != null">a.fdygh=#{fdygh},</if>
            <if test="ejxyldgh != null">a.ejxyldgh=#{ejxyldgh},</if>
            <if test="ejxyldmc != null">a.ejxyldmc=#{ejxyldmc},</if>
            <if test="xsgh != null">a.xsgh=#{xsgh},</if>
            <if test="xsmc != null">a.xsmc=#{xsmc},</if>
        </trim>
            where a.id in
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <update id="revoke" parameterType="SrsKnrdApply">
        update srs_knrd_apply

        set step = #{targetStep}
        <if test="targetStep == 2">
            ,bjpyyj = null
            ,fdyqm = null
        </if>
        <if test="targetStep == 3">
            ,ejxyldqmyj = null
            ,ejxyldqm = null
        </if>
        <if test="targetStep == 4">
            ,xsqmyj = null
            ,xsqm = null
        </if>
        where id = #{id} and step = #{step}
    </update>

    <update id="fdyRevoke" parameterType="SrsKnrdApply">
        update srs_knrd_apply
        set
            step = 2,
            bjpyyj = null,
            fdyqm = null,
            ejxyldqmyj = null,
            ejxyldqm = null,
            xsqmyj = null,
            xsqm = null
        where id = #{id} and step > 2
    </update>
    <!--锁定-->
    <update id="lock">
        update srs_knrd_apply
        set locked = 1,
            locked_time = now()
        where id = #{id}
    </update>
    <!--解锁-->
    <update id="unlock">
        update srs_knrd_apply
        set locked = 0,
            locked_time = null
        where id = #{id}
    </update>
    <!--修改困难认定学生签名-->
    <update id="updateStuSignature" parameterType="CphSearch">
        update srs_knrd_apply set sqrqm = #{qm}
            where  sqrqm is not null
            and xh = #{gh}
    </update>
    <!--  修改困难辅导员辅导员签名  -->
    <update id="updateFdySignature" parameterType="CphSearch">
        update srs_knrd_apply set fdyqm = #{qm}
        where  fdyqm is not null
          and fdygh = #{gh}
    </update>
    <!-- 修改困难认定二级学院签名   ejxyldqm -->
    <update id="updateEjxySignature" parameterType="CphSearch">
        update srs_knrd_apply set ejxyldqm = #{qm}
        where  ejxyldqm is not null
          and ejxyldgh = #{gh}
    </update>

    <!-- 修改困难认定学校层签名 -->
    <update id="updateScSignature" parameterType="CphSearch">
        update srs_knrd_apply set xsqm = #{qm}
        where  xsqm is not null
          and xsgh = #{gh}
    </update>

</mapper>
