<?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.SrsZxjApplyMapper">

    <resultMap type="SrsZxjApply" id="SrsZxjApplyResult">
        <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="zzmm"    column="zzmm"    />
        <result property="xh"    column="xh"    />
        <result property="rxsj"    column="rxsj"    />
        <result property="csny"    column="csny"    />
        <result property="dh"    column="dh"    />
        <result property="nj"    column="nj"    />
        <result property="xy"    column="xy"    />
        <result property="zy"    column="zy"    />
        <result property="bj"    column="bj"    />
        <result property="kndj"    column="kndj"    />
        <result property="knlx"    column="knlx"    />
        <result property="knlx2"    column="knlx2"    />
        <result property="rkzs"    column="rkzs"    />
        <result property="yzsr"    column="yzsr"    />
        <result property="rjyr"    column="rjyr"    />
        <result property="srly"    column="srly"    />
        <result property="jtcy"    column="jtcy"    />
        <result property="sqly"    column="sqly"    />
        <result property="fdyqm"    column="fdyqm"    />
        <result property="fdyqmrq"    column="fdyqmrq"    />
        <result property="ejxyldqm"    column="ejxyldqm"    />
        <result property="ejxyldqmrq"    column="ejxyldqmrq"    />
        <result property="xsqm"    column="xsqm"    />
        <result property="xsqmrq"    column="xsqmrq"    />
        <result property="csdj"    column="csdj"    />
        <result property="zzdj"    column="zzdj"    />
        <result property="zzls"    column="zzls"    />
        <result property="zp"    column="zp"    />
        <result property="affixId"    column="affix_id"    />
        <result property="status1"    column="status1"    />
        <result property="status2"    column="status2"    />
        <result property="status3"    column="status3"    />
        <result property="dz"    column="dz"    />
        <result property="yb"    column="yb"    />
        <result property="xxyjrq"    column="xxyjrq"    />
        <result property="applyYear"    column="apply_year"    />
        <result property="isExist"    column="is_exist"    />
        <result property="penaltyStatus0" column="penalty_status0"/>
        <result property="penaltyStatus1" column="penalty_status1"/>
        <result property="penaltyStatus3" column="penalty_status3"/>
        <result property="sfzhm" column="sfzhm"/>
        <result property="gyhd" column="gyhd"/>
        <result property="bankAddr" column="bankAddr"/>
        <result property="bankCard" column="bankCard"/>
        <result property="rjnsr" column="rjnsr"/>
        <result property="bjyj" column="bjyj"/>
        <result property="bjyjdj" column="bjyjdj"/>
        <result property="ejxyyj" column="ejxyyj"/>
        <result property="ejxyyjdj" column="ejxyyjdj"/>
        <result property="xxyj" column="xxyj"/>
        <result property="xxqm" column="xxqm"/>
        <result property="stuYearId" column="stu_year_id"/>
        <result property="fdygh"    column="fdygh"    />
        <result property="fdymc"    column="fdymc"    />
        <result property="ejxyldmc"    column="ejxyldmc"    />
        <result property="ejxyldgh"    column="ejxyldgh"    />
        <result property="xxmc"    column="xxmc"    />
        <result property="xxgh"    column="xxgh"    />
        <result property="locked"    column="locked"    />
        <result property="lockedTime"    column="lockedTime"    />
        <result property="countXw"    column="countXw"    />
        <result property="level" column="level"/>
    </resultMap>

    <sql id="selectSrsZxjApplyVo">
        select id, step, xm, xb, mz, zzmm, xh, rxsj, csny, dh, nj, xy, zy, bj, kndj, knlx, knlx2, rkzs, yzsr, rjyr, srly, jtcy, sqly, fdyqm, fdyqmrq, ejxyldqm, ejxyldqmrq, xsqm, xsqmrq, csdj, zzdj, zzls, zp,affix_id,status1,status2,status3,dz,yb,xxyjrq,apply_year,locked,level,
       EXISTS(SELECT application_id FROM rt_stu_disciplinary_application rsda WHERE rsda.stu_no = srs_zxj_apply.xh and (penalty_status = 0 or  penalty_status = 2)) as penalty_status0,
       EXISTS(SELECT application_id FROM rt_stu_disciplinary_application rsda WHERE rsda.stu_no = srs_zxj_apply.xh and (penalty_status = 1 )) as penalty_status1,
       EXISTS(SELECT application_id FROM rt_stu_disciplinary_application rsda WHERE rsda.stu_no = srs_zxj_apply.xh and (penalty_status = 3 )) as penalty_status3,
        sfzhm,
        gyhd,
        bankCard,
        bankAddr,
       rjnsr,
       bjyj,
       bjyjdj,
        ejxyyj,
        ejxyyjdj,
        xxyj,
        xxqm,
               stu_year_id,fdygh,fdymc,ejxyldmc,ejxyldgh,xxmc,xxgh


        from srs_zxj_apply

    </sql>

    <select id="selectSrsZxjApplyList" parameterType="SrsZxjApply" resultMap="SrsZxjApplyResult">
        <include refid="selectSrsZxjApplyVo"/>
        <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="zzmm != null  and zzmm != ''"> and zzmm = #{zzmm}</if>
            <if test="xh != null  and xh != ''"> and xh = #{xh}</if>
            <if test="rxsj != null  and rxsj != ''"> and rxsj = #{rxsj}</if>
            <if test="csny != null  and csny != ''"> and csny = #{csny}</if>
            <if test="dh != null  and dh != ''"> and dh = #{dh}</if>
            <if test="nj != null  and nj != ''"> and nj = #{nj}</if>
            <if test="xy != null  and xy != ''"> and xy = #{xy}</if>
            <if test="zy != null  and zy != ''"> and zy = #{zy}</if>
            <if test="bj != null  and bj != ''"> and bj = #{bj}</if>
            <if test="kndj != null  and kndj != ''"> and kndj = #{kndj}</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="yzsr != null  and yzsr != ''"> and yzsr = #{yzsr}</if>
            <if test="rjyr != null  and rjyr != ''"> and rjyr = #{rjyr}</if>
            <if test="srly != null  and srly != ''"> and srly = #{srly}</if>
            <if test="jtcy != null  and jtcy != ''"> and jtcy = #{jtcy}</if>
            <if test="sqly != null  and sqly != ''"> and sqly = #{sqly}</if>
            <if test="fdyqm != null  and fdyqm != ''"> and fdyqm = #{fdyqm}</if>
            <if test="fdyqmrq != null  and fdyqmrq != ''"> and fdyqmrq = #{fdyqmrq}</if>
            <if test="ejxyldqm != null  and ejxyldqm != ''"> and ejxyldqm = #{ejxyldqm}</if>
            <if test="ejxyldqmrq != null  and ejxyldqmrq != ''"> and ejxyldqmrq = #{ejxyldqmrq}</if>
            <if test="xsqm != null  and xsqm != ''"> and xsqm = #{xsqm}</if>
            <if test="xsqmrq != null  and xsqmrq != ''"> and xsqmrq = #{xsqmrq}</if>
            <if test="csdj != null  and csdj != ''"> and csdj = #{csdj}</if>
            <if test="zzdj != null  and zzdj != ''"> and zzdj = #{zzdj}</if>
            <if test="zzls != null  and zzls != ''"> and zzls = #{zzls}</if>
            <if test="zp != null  and zp != ''"> and zp = #{zp}</if>
            <if test="affixId != null  and affixId != ''"> and affix_id = #{affixId}</if>
            <if test="status1 != null  and status1 != ''"> and status1 = #{status1}</if>
            <if test="status2 != null  and status2 != ''"> and status2 = #{status2}</if>
            <if test="status3 != null  and status3 != ''"> and status3 = #{status3}</if>
            <if test="dz != null  and dz != ''"> and dz = #{dz}</if>
            <if test="yb != null  and yb != ''"> and yb = #{yb}</if>
            <if test="xxyjrq != null  and xxyjrq != ''"> and xxyjrq = #{xxyjrq}</if>
            <if test="applyYear != null  and applyYear != ''"> and apply_year = #{applyYear}</if>
            <if test="stuYearId != null  and stuYearId != ''"> and stu_year_id = #{stuYearId}</if>
        </where>
    </select>

    <select id="selectSrsZxjApplyById" parameterType="Long" resultMap="SrsZxjApplyResult">
        <include refid="selectSrsZxjApplyVo"/>
        where id = #{id}
    </select>
<!--    获取下一个未审批的-->
    <select id="nextApply" parameterType="CphSearch" resultMap="SrsZxjApplyResult">
        select a.*

        from srs_zxj_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">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}

                and exists (SELECT
                u.user_id
                FROM sys_user u left join sys_user_post up on u.user_id = up.user_id
                LEFT JOIN sys_post post on  up.post_id = post.post_id
                where post.post_code = 'ejxysj' and u.user_name = #{userName})
            </if>
            <if test="stuNo != null "> and a.xh = #{stuNo}</if>
            <if test="xm != null "> and a.xm like concat('%',#{xm},'%')</if>
            <if test="xh != null "> and a.xh like concat('%',#{xh},'%')</if>
        </where>
        order by a.id asc limit 1;
    </select>
    <select id="listView" parameterType="CphSearch" resultType="SrsZxjApply">
        select a.*,
        EXISTS(SELECT application_id FROM rt_stu_disciplinary_application rsda WHERE rsda.stu_no = a.xh and (penalty_status = 0 or  penalty_status = 2)) as penalty_status0,
        EXISTS(SELECT application_id FROM rt_stu_disciplinary_application rsda WHERE rsda.stu_no = a.xh and (penalty_status = 1 )) as penalty_status1,
        EXISTS(SELECT application_id FROM rt_stu_disciplinary_application rsda WHERE rsda.stu_no = a.xh and (penalty_status = 3 )) as penalty_status3
        from srs_zxj_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">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}

                and exists (SELECT
                u.user_id
                FROM sys_user u left join sys_user_post up on u.user_id = up.user_id
                LEFT JOIN sys_post post on  up.post_id = post.post_id
                where post.post_code = 'ejxysj' and u.user_name = #{userName})
             </if>
            <if test="stuNo != null "> and a.xh = #{stuNo}</if>
            <if test="xm != null "> and a.xm like concat('%',#{xm},'%')</if>
            <if test="xh != null "> and a.xh like concat('%',#{xh},'%')</if>
        </where>
        order by a.id asc
    </select>

    <select id="countXw" parameterType="CphSearch" resultType="SrsZxjApply">
        select a.ejxyyjdj, count(*) as countXw
        from srs_zxj_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">d.college_id = #{collegeId}</if>
            <if test="step != null "> and a.step = #{step} </if>
            <if test="tNo != null "> and e.employee_id = #{tNo}</if>
            <if test="deptId != null "> and f.new_dept_id = #{deptId}</if>
        </where>
        group by ejxyyjdj
    </select>


    <select id="listRecordView" parameterType="CphSearch" resultType="SrsZxjApply">
        select a.id as id,
               a.step as step,
               a.apply_year as apply_year,
               a.xm as xm,
               a.xb as xb,
               a.mz as mz,
               a.zzmm as zzmm,
               a.xh as xh,
               a.rxsj as rxsj,
               a.csny as csny,
               a.dh as dh,
               a.nj as nj,
               a.xy as xy,
               a.zy as zy,
               a.bj as bj,
               a.kndj as kndj,
               a.knlx as knlx,
               a.knlx2 as knlx2,
               a.rkzs as rkzs,
               a.yzsr as yzsr,
               a.rjyr as rjyr,
               a.srly as srly,
               a.jtcy as jtcy,
               a.sqly as sqly,
               a.fdyqm as fdyqm,
               a.fdyqmrq as fdyqmrq,
               a.ejxyldqm as ejxyldqm,
               a.ejxyldqmrq as ejxyldqmrq,
               a.xsqm as xsqm,
                a.xsqmrq as xsqmrq,
               a.csdj as csdj,
               a.zzdj as zzdj,
               a.zzls as zzls,
               a.zp as zp,
               a.create_id as create_id,
               a.affix_id as affix_id,
               a.status1 as status1,
               a.status2 as status2,
               a.status3 as status3,
               a.dz as dz,
               a.yb as yb,
               a.bjyj as bjyj,
               a.bjyjdj as bjyjdj,
               a.ejxyyj as ejxyyj,
               a.ejxyyjdj as ejxyyjdj,
               a.xxyj as xxyj,
               a.xxyjrq as xxyjrq,
               a.gyhd as gyhd,
               a.rjnsr as rjnsr,
               a.bankCard as bankCard,
               a.bankAddr as bankAddr,
               a.xxqm as xxqm,
--                f.step as step,
--                f.status  as status,
               EXISTS(SELECT application_id FROM rt_stu_disciplinary_application rsda WHERE rsda.stu_no = a.xh and (penalty_status = 0 or  penalty_status = 2)) as penalty_status0,
               EXISTS(SELECT application_id FROM rt_stu_disciplinary_application rsda WHERE rsda.stu_no = a.xh and (penalty_status = 1 )) as penalty_status1,
               EXISTS(SELECT application_id FROM rt_stu_disciplinary_application rsda WHERE rsda.stu_no = a.xh and (penalty_status = 3 )) as penalty_status3,
               a.sfzhm as sfzhm,d.major_type_name
        from srs_zxj_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 (
            SELECT * FROM srs_zxj_approval_record as record where id in(
                select MAX(id)  FROM srs_zxj_approval_record   GROUP BY apply_id
            )
        ) as f on f.apply_id = a.id
        left join sys_dept_map as g on d.college_id = g.old_dept_id
        <where>
<!--            <if test="step != null "> and exists (select apply_id from srs_zxj_approval_record r where r.step = ${step} and r.apply_id = a.id )</if>-->
            <if test="tNo != null "> and e.employee_id = #{tNo}</if>
            <if test="deptId != null "> and g.new_dept_id = #{deptId}</if>
            <if test="stuNo != null "> and a.xh = #{stuNo}</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="status != null "> and (a.status1 =  #{status} or a.status2 = #{status} or a.status3 = #{status})</if>
            <if test="applyYear != null"> and a.apply_year like CONCAT('%',#{applyYear},'%')</if>
        </where>
        order by a.id asc
    </select>

    <insert id="insertSrsZxjApply" parameterType="SrsZxjApply" useGeneratedKeys="true" keyProperty="id">
        insert into srs_zxj_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="zzmm != null">zzmm,</if>
            <if test="xh != null">xh,</if>
            <if test="rxsj != null">rxsj,</if>
            <if test="csny != null">csny,</if>
            <if test="dh != null">dh,</if>
            <if test="nj != null">nj,</if>
            <if test="xy != null">xy,</if>
            <if test="zy != null">zy,</if>
            <if test="bj != null">bj,</if>
            <if test="kndj != null">kndj,</if>
            <if test="knlx != null">knlx,</if>
            <if test="knlx2 != null">knlx2,</if>
            <if test="rkzs != null">rkzs,</if>
            <if test="yzsr != null">yzsr,</if>
            <if test="rjyr != null">rjyr,</if>
            <if test="srly != null">srly,</if>
            <if test="jtcy != null">jtcy,</if>
            <if test="sqly != null">sqly,</if>
            <if test="fdyqm != null">fdyqm,</if>
            <if test="fdyqmrq != null">fdyqmrq,</if>
            <if test="ejxyldqm != null">ejxyldqm,</if>
            <if test="ejxyldqmrq != null">ejxyldqmrq,</if>
            <if test="xsqm != null">xsqm,</if>
            <if test="xsqmrq != null">xsqmrq,</if>
            <if test="csdj != null">csdj,</if>
            <if test="zzdj != null">zzdj,</if>
            <if test="zzls != null">zzls,</if>
            <if test="zp != null">zp,</if>
            <if test="affixId != null">affix_id,</if>
            <if test="status1 != null">status1,</if>
            <if test="status2 != null">status2,</if>
            <if test="status3 != null">status3,</if>
            <if test="dz != null">dz,</if>
            <if test="yb != null">yb,</if>
            <if test="xxyjrq != null">xxyjrq,</if>
            <if test="applyYear != null">apply_year,</if>
            <if test="sfzhm != null">sfzhm,</if>
            <if test="gyhd != null">gyhd,</if>
            <if test="bankCard != null">bankCard,</if>
            <if test="bankAddr != null">bankAddr,</if>
            <if test="rjnsr != null">rjnsr,</if>
            <if test="bjyj != null">bjyj,</if>
            <if test="bjyjdj != null">bjyjdj,</if>
            <if test="ejxyyj != null">ejxyyj,</if>
            <if test="ejxyyjdj != null">ejxyyjdj,</if>
            <if test="xxyj != null">xxyj,</if>
            <if test="xxqm != null">xxqm,</if>
            <if test="stuYearId != null">stu_year_id,</if>
            <if test="fdymc != null">fdymc,</if>
            <if test="fdygh != null">fdygh,</if>
            <if test="ejxyldmc != null">ejxyldmc,</if>
            <if test="ejxyldgh != null">ejxyldgh,</if>
            <if test="xxmc != null">xxmc,</if>
            <if test="xxgh != null">xxgh,</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="zzmm != null">#{zzmm},</if>
            <if test="xh != null">#{xh},</if>
            <if test="rxsj != null">#{rxsj},</if>
            <if test="csny != null">#{csny},</if>
            <if test="dh != null">#{dh},</if>
            <if test="nj != null">#{nj},</if>
            <if test="xy != null">#{xy},</if>
            <if test="zy != null">#{zy},</if>
            <if test="bj != null">#{bj},</if>
            <if test="kndj != null">#{kndj},</if>
            <if test="knlx != null">#{knlx},</if>
            <if test="knlx2 != null">#{knlx2},</if>
            <if test="rkzs != null">#{rkzs},</if>
            <if test="yzsr != null">#{yzsr},</if>
            <if test="rjyr != null">#{rjyr},</if>
            <if test="srly != null">#{srly},</if>
            <if test="jtcy != null">#{jtcy},</if>
            <if test="sqly != null">#{sqly},</if>
            <if test="fdyqm != null">#{fdyqm},</if>
            <if test="fdyqmrq != null">#{fdyqmrq},</if>
            <if test="ejxyldqm != null">#{ejxyldqm},</if>
            <if test="ejxyldqmrq != null">#{ejxyldqmrq},</if>
            <if test="xsqm != null">#{xsqm},</if>
            <if test="xsqmrq != null">#{xsqmrq},</if>
            <if test="csdj != null">#{csdj},</if>
            <if test="zzdj != null">#{zzdj},</if>
            <if test="zzls != null">#{zzls},</if>
            <if test="zp != null">#{zp},</if>
            <if test="affixId != null">#{affixId},</if>
            <if test="status1 != null">#{status1},</if>
            <if test="status2 != null">#{status2},</if>
            <if test="status3 != null">#{status3},</if>
            <if test="dz != null">#{dz},</if>
            <if test="yb != null">#{yb},</if>
            <if test="xxyjrq != null">#{xxyjrq},</if>
            <if test="applyYear != null">#{applyYear},</if>
            <if test="sfzhm != null">#{sfzhm},</if>
            <if test="gyhd != null">#{gyhd},</if>
            <if test="bankCard != null">#{bankCard},</if>
            <if test="bankAddr != null">#{bankAddr},</if>
            <if test="rjnsr != null">#{rjnsr},</if>
            <if test="bjyj != null">#{bjyj},</if>
            <if test="bjyjdj != null">#{bjyjdj},</if>
            <if test="ejxyyj != null">#{ejxyyj},</if>
            <if test="ejxyyjdj != null">#{ejxyyjdj},</if>
            <if test="xxyj != null">#{xxyj},</if>
            <if test="xxqm != null">#{xxqm},</if>
            <if test="stuYearId != null">#{stuYearId},</if>

            <if test="fdymc != null">#{fdymc},</if>
            <if test="fdygh != null">#{fdygh},</if>
            <if test="ejxyldmc != null">#{ejxyldmc},</if>
            <if test="ejxyldgh != null">#{ejxyldgh},</if>
            <if test="xxmc != null">#{xxmc},</if>
            <if test="xxgh != null">#{xxgh},</if>
         </trim>
    </insert>

    <update id="updateSrsZxjApply" parameterType="SrsZxjApply">
        update srs_zxj_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="zzmm != null">zzmm = #{zzmm},</if>
            <if test="xh != null">xh = #{xh},</if>
            <if test="rxsj != null">rxsj = #{rxsj},</if>
            <if test="csny != null">csny = #{csny},</if>
            <if test="dh != null">dh = #{dh},</if>
            <if test="nj != null">nj = #{nj},</if>
            <if test="xy != null">xy = #{xy},</if>
            <if test="zy != null">zy = #{zy},</if>
            <if test="bj != null">bj = #{bj},</if>
            <if test="kndj != null">kndj = #{kndj},</if>
            <if test="knlx != null">knlx = #{knlx},</if>
            <if test="knlx2 != null">knlx2 = #{knlx2},</if>
            <if test="rkzs != null">rkzs = #{rkzs},</if>
            <if test="yzsr != null">yzsr = #{yzsr},</if>
            <if test="rjyr != null">rjyr = #{rjyr},</if>
            <if test="srly != null">srly = #{srly},</if>
            <if test="jtcy != null">jtcy = #{jtcy},</if>
            <if test="sqly != null">sqly = #{sqly},</if>
            <if test="fdyqm != null">fdyqm = #{fdyqm},</if>
            <if test="fdyqmrq != null">fdyqmrq = #{fdyqmrq},</if>
            <if test="ejxyldqm != null">ejxyldqm = #{ejxyldqm},</if>
            <if test="ejxyldqmrq != null">ejxyldqmrq = #{ejxyldqmrq},</if>
            <if test="xsqm != null">xsqm = #{xsqm},</if>
            <if test="xsqmrq != null">xsqmrq = #{xsqmrq},</if>
            <if test="csdj != null">csdj = #{csdj},</if>
            <if test="zzdj != null">zzdj = #{zzdj},</if>
            <if test="zzls != null">zzls = #{zzls},</if>
            <if test="zp != null">zp = #{zp},</if>
            <if test="affixId != null">affix_id = #{affixId},</if>
            <if test="status1 != null">status1 = #{status1},</if>
            <if test="status2 != null">status2 = #{status2},</if>
            <if test="status3 != null">status3 = #{status3},</if>
            <if test="dz != null">dz = #{dz},</if>
            <if test="yb != null">yb = #{yb},</if>
            <if test="xxyjrq != null">xxyjrq = #{xxyjrq},</if>
            <if test="applyYear != null">apply_year = #{applyYear},</if>
            <if test="sfzhm != null">sfzhm = #{sfzhm},</if>
            <if test="gyhd != null">gyhd = #{gyhd},</if>
            <if test="bankCard != null">bankCard = #{bankCard},</if>
            <if test="bankAddr != null">bankAddr = #{bankAddr},</if>
            <if test="rjnsr != null">rjnsr = #{rjnsr},</if>
            <if test="bjyj != null">bjyj = #{bjyj},</if>
            <if test="bjyjdj != null">bjyjdj = #{bjyjdj},</if>
            <if test="ejxyyj != null">ejxyyj = #{ejxyyj},</if>
            <if test="ejxyyjdj != null">ejxyyjdj = #{ejxyyjdj},</if>
            <if test="xxyj != null">xxyj = #{xxyj},</if>
            <if test="xxqm != null">xxqm = #{xxqm},</if>
            <if test="stuYearId != null">stu_year_id = #{stuYearId},</if>
            <if test="fdymc != null">fdymc = #{fdymc},</if>
            <if test="fdygh != null">fdygh = #{fdygh},</if>
            <if test="ejxyldmc != null">ejxyldmc = #{ejxyldmc},</if>
            <if test="ejxyldgh != null">ejxyldgh = #{ejxyldgh},</if>
            <if test="xxmc != null">xxmc = #{xxmc},</if>
            <if test="xxgh != null">xxgh = #{xxgh},</if>
            <if test="level != null and level != ''">level = #{level},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSrsZxjApplyById" parameterType="Long">
        delete from srs_zxj_apply where id = #{id}
    </delete>

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

    <update id="batchUpdate" parameterType="SrsZxjApply">
        update srs_zxj_apply a left  join srs_zxj_apply b on a.id = b.id
        <trim prefix="SET" suffixOverrides=",">
            <if test="step != null">a.step = #{step},</if>
            <if test="fdyqm != null">a.fdyqm = #{fdyqm},</if>
            <if test="fdyqmrq != null">a.fdyqmrq = #{fdyqmrq},</if>
            <if test="ejxyyj != null">a.ejxyyj = b.bjyj,</if>
            <if test="ejxyyjdj != null">a.ejxyyjdj = b.bjyjdj,</if>
            <if test="ejxyldqm != null">a.ejxyldqm = #{ejxyldqm},</if>
            <if test="ejxyldqmrq != null">a.ejxyldqmrq = #{ejxyldqmrq},</if>
            <if test="csdj != null">a.csdj = #{csdj},</if>
            <if test="xxyj != null">a.xxyj = b.bjyj,</if>
            <if test="xxqm != null">a.xxqm = #{xxqm},</if>
            <if test="zzdj != null">a.zzdj = b.bjyjdj,</if>
            <if test="xxyjrq != null">a.xxyjrq = #{xxyjrq},</if>
            <if test="status1 != null">a.status1 = #{status1},</if>
            <if test="status2 != null">a.status2 = #{status2},</if>
            <if test="status3 != null">a.status3 = #{status3},</if>
            <if test="bjyj != null">a.bjyj = #{bjyj},</if>
            <if test="bjyjdj != null">a.bjyjdj = #{bjyjdj},</if>
            <if test="fdygh != null">a.fdygh = #{fdygh},</if>
            <if test="ejxyldmc != null">a.ejxyldmc = #{ejxyldmc},</if>
            <if test="ejxyldgh != null">a.ejxyldgh = #{ejxyldgh},</if>
            <if test="xxmc != null">a.xxmc = #{xxmc},</if>
            <if test="xxgh != null">a.xxgh = #{xxgh},</if>
        </trim>
        where a.id in
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <!--撤回-->
    <update id="revoke" parameterType="SrsZxjApply">
        update srs_zxj_apply

        set step = #{targetStep}
        <if test="targetStep == 1">
            ,bjyjdj = null
            ,fdyqm = null
            ,status1 = '未审核'
        </if>
        <if test="targetStep == 2">
            ,ejxyyjdj = null
            ,ejxyldqm = null
            ,status2 = '未审核'

        </if>
        <if test="targetStep == 3">
            ,zzdj = null
            ,xxqm = null
            ,status3 = '未审核'
        </if>
        where id = #{id} and step = #{step} and step != -1
    </update>
    <!--锁定-->
    <update id="lock">
        update srs_zxj_apply
        set locked = 1,
            locked_time = now()
        where id = #{id}
    </update>
    <!--解锁-->
    <update id="unlock">
        update srs_zxj_apply
        set locked = 0,
            locked_time = null
        where id = #{id}
    </update>
    <!--修改助学金学生签名-->
    <update id="updateStuSignature" parameterType="CphSearch">
        update srs_zxj_apply set xsqm = #{qm}
        where  xsqm is not null
          and xh = #{gh}
    </update>
    <!--  修改助学金辅导员辅导员签名  -->
    <update id="updateFdySignature" parameterType="CphSearch">
        update srs_zxj_apply set fdyqm = #{qm}
        where  fdyqm is not null
          and fdygh = #{gh}
    </update>
    <!-- 修改助学金二级学院签名   ejxyldqm -->
    <update id="updateEjxySignature" parameterType="CphSearch">
        update srs_zxj_apply set ejxyldqm = #{qm}
        where  ejxyldqm is not null
          and ejxyldgh = #{gh}
    </update>

    <!-- 修改助学金学校层签名 -->
    <update id="updateScSignature" parameterType="CphSearch">
        update srs_zxj_apply set xxqm = #{qm}
        where xxqm is not null
          and xxgh = #{gh}
    </update>

</mapper>
