<?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.routine.mapper.RtStuDisciplinaryRelieveMapper">

    <resultMap type="RtStuDisciplinaryRelieve" id="RtStuDisciplinaryRelieveResult">
        <result property="relieveId" column="relieve_id"/>
        <result property="applicantName"    column="applicant_name"    />
        <result property="penaltyNumber" column="penalty_number"/>
        <result property="relieveNumber" column="relieve_number"/>
        <result property="stuNo" column="stu_no"/>
        <result property="stuName" column="stu_name"/>
        <result property="stuId" column="stu_id"/>
        <result property="penaltyType" column="penalty_type"/>
        <result property="penaltyStatus" column="penalty_status"/>
        <result property="violationDate" column="violation_date"/>
        <result property="dispositionDescription" column="disposition_description"/>
        <result property="applicationDismissal" column="application_dismissal"/>
        <result property="ideologicalEducation" column="ideological_education"/>
        <result property="submissionStatus" column="submission_status"/>
        <result property="processInstanceId" column="process_instance_id"/>
        <result property="deployId" column="deploy_id"/>
        <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="remark" column="remark"/>
        <result property="gender" column="gender"/>
        <result property="departmentName" column="department_Name"/>
        <result property="gradeName" column="grade_name"/>
        <result property="className" column="class_name"/>
        <result property="mz" column="mz"/>
        <result property="birthday" column="birthday"/>
        <result property="jg" column="jg"/>
        <result property="politicalStatus"    column="political_status"    />
        <result property="hksz2" column="hksz2"/>
        <result property="relieveService" column="relieve_service"/>
    </resultMap>

    <sql id="selectRtStuDisciplinaryRelieveVo">
        select relieve_id,
               penalty_number,
               relieve_number,
               stu_no,
               stu_name,
               stu_id,
               penalty_type,
               penalty_status,
               violation_date,
               disposition_description,
               application_dismissal,
               ideological_education,
               submission_status,
               process_instance_id,
               deploy_id,
               create_by,
               create_time,
               update_by,
               update_time,
               remark,
               gender,
               department_Name,
               grade_name,
               class_name,
               mz,
               birthday,
               jg,
               political_status,
               hksz2,
               relieve_service,
               applicant_name
        from rt_stu_disciplinary_relieve
    </sql>

    <select id="selectRtStuDisciplinaryRelieveList" parameterType="RtStuDisciplinaryRelieve"
            resultMap="RtStuDisciplinaryRelieveResult">
        <include refid="selectRtStuDisciplinaryRelieveVo"/>
        <where>
            <if test="penaltyNumber != null  and penaltyNumber != ''">and penalty_number = #{penaltyNumber}</if>
            <if test="relieveNumber != null  and relieveNumber != ''">and relieve_number = #{relieveNumber}</if>
            <if test="applicantName != null  and applicantName != ''">and applicant_name = #{applicantName}</if>
            <if test="stuNo != null  and stuNo != ''">and stu_no = #{stuNo}</if>
            <if test="stuName != null  and stuName != ''">and stu_name like concat('%', #{stuName}, '%')</if>
            <if test="stuId != null ">and stu_id = #{stuId}</if>
            <if test="penaltyType != null ">and penalty_type = #{penaltyType}</if>
            <if test="penaltyStatus != null ">and penalty_status = #{penaltyStatus}</if>
            <if test="violationDate != null ">and violation_date = #{violationDate}</if>
            <if test="dispositionDescription != null  and dispositionDescription != ''">and disposition_description =
                #{dispositionDescription}
            </if>
            <if test="applicationDismissal != null  and applicationDismissal != ''">and application_dismissal =
                #{applicationDismissal}
            </if>
            <if test="ideologicalEducation != null  and ideologicalEducation != ''">and ideological_education =
                #{ideologicalEducation}
            </if>
            <if test="submissionStatus != null ">and submission_status = #{submissionStatus}</if>
            <if test="processInstanceId != null  and processInstanceId != ''">and process_instance_id =
                #{processInstanceId}
            </if>
            <if test="deployId != null  and deployId != ''">and deploy_id = #{deployId}</if>
            <if test="gender != null  and gender != ''">and gender = #{gender}</if>
            <if test="departmentName != null  and departmentName != ''">and department_Name like concat('%',
                #{departmentName}, '%')
            </if>
            <if test="gradeName != null  and gradeName != ''">and grade_name like concat('%', #{gradeName}, '%')</if>
            <if test="className != null  and className != ''">and class_name like concat('%', #{className}, '%')</if>
            <if test="mz != null  and mz != ''">and mz = #{mz}</if>
            <if test="birthday != null  and birthday != ''">and birthday = #{birthday}</if>
            <if test="jg != null  and jg != ''">and jg = #{jg}</if>
            <if test="politicalStatus != null  and politicalStatus != ''">and political_status = #{politicalStatus}</if>
            <if test="hksz2 != null  and hksz2 != ''">and hksz2 = #{hksz2}</if>
            <if test="relieveService != null  and relieveService != ''">and relieve_service = #{relieveService}</if>
        </where>
        ORDER BY create_time desc
    </select>

    <select id="selectRtStuDisciplinaryRelieveByRelieveId" parameterType="Long"
            resultMap="RtStuDisciplinaryRelieveResult">
        <include refid="selectRtStuDisciplinaryRelieveVo"/>
        where relieve_id = #{relieveId}
    </select>

    <select id="selectRtStuDisciplinaryRelieveListByTeacherNo" resultMap="RtStuDisciplinaryRelieveResult" parameterType="RtStuDisciplinaryRelieve">
        select a.relieve_id,
               a.penalty_number,
               a.relieve_number,
               a.stu_no,
               a.stu_name,
               a.stu_id,
               a.penalty_type,
               a.penalty_status,
               a.violation_date,
               a.disposition_description,
               a.application_dismissal,
               a.ideological_education,
               a.submission_status,
               a.process_instance_id,
               a.deploy_id,
               a.create_by,
               a.create_time,
               a.update_by,
               a.update_time,
               a.remark,
               a.gender,
               a.department_Name,
               a.grade_name,
               a.class_name,
               a.mz,
               a.birthday,
               a.jg,
               a.political_status,
               a.hksz2,
               a.relieve_service,
               a.applicant_name
        from rt_stu_disciplinary_relieve a
                 LEFT JOIN srs_student b ON a.stu_no = b.stu_no
                 LEFT JOIN srs_class c ON b.class_id = c.class_id
                 LEFT JOIN cph_teacher d ON c.teacher_id = d.teacher_id
        <where>
            <if test="penaltyNumber != null  and penaltyNumber != ''">and a.penalty_number = #{penaltyNumber}</if>
            <if test="relieveNumber != null  and relieveNumber != ''">and a.relieve_number = #{relieveNumber}</if>
            <if test="applicantName != null  and applicantName != ''">and a.applicant_name = #{applicantName}</if>
            <if test="stuNo != null  and stuNo != ''">and a.stu_no = #{stuNo}</if>
            <if test="stuName != null  and stuName != ''">and a.stu_name like concat('%', #{stuName}, '%')</if>
            <if test="stuId != null ">and a.stu_id = #{stuId}</if>
            <if test="penaltyType != null ">and a.penalty_type = #{penaltyType}</if>
            <if test="penaltyStatus != null ">and a.penalty_status = #{penaltyStatus}</if>
            <if test="violationDate != null ">and a.violation_date = #{violationDate}</if>
            <if test="dispositionDescription != null  and dispositionDescription != ''">and a.disposition_description =
                #{dispositionDescription}
            </if>
            <if test="applicationDismissal != null  and applicationDismissal != ''">and a.application_dismissal =
                #{applicationDismissal}
            </if>
            <if test="ideologicalEducation != null  and ideologicalEducation != ''">and a.ideological_education =
                #{ideologicalEducation}
            </if>
            <if test="submissionStatus != null ">and a.submission_status = #{submissionStatus}</if>
            <if test="processInstanceId != null  and processInstanceId != ''">and a.process_instance_id =
                #{processInstanceId}
            </if>
            <if test="deployId != null  and deployId != ''">and a.deploy_id = #{deployId}</if>
            <if test="gender != null  and gender != ''">and a.gender = #{gender}</if>
            <if test="departmentName != null  and departmentName != ''">and a.department_Name like concat('%',
                #{departmentName}, '%')
            </if>
            <if test="gradeName != null  and gradeName != ''">and a.grade_name like concat('%', #{gradeName}, '%')</if>
            <if test="className != null  and className != ''">and a.class_name like concat('%', #{className}, '%')</if>
            <if test="mz != null  and mz != ''">and a.mz = #{mz}</if>
            <if test="birthday != null  and birthday != ''">and a.birthday = #{birthday}</if>
            <if test="jg != null  and jg != ''">and a.jg = #{jg}</if>
            <if test="politicalStatus != null  and politicalStatus != ''">and a.political_status = #{politicalStatus}</if>
            <if test="hksz2 != null  and hksz2 != ''">and a.hksz2 = #{hksz2}</if>
            <if test="relieveService != null  and relieveService != ''">and a.relieve_service = #{relieveService}</if>
            <if test="params.employeeId != null  and params.employeeId != ''">and d.employee_id = #{params.employeeId}</if>
            <if test="deptId != null  and deptId != ''">and d.dept_id = #{deptId}</if>
        </where>
        ORDER BY a.create_time desc
    </select>
    <select id="selectRtStuDisciplinaryRelieveListXW" resultMap="RtStuDisciplinaryRelieveResult" parameterType="RtStuDisciplinaryRelieve">
        select a.relieve_id,
        a.penalty_number,
        a.relieve_number,
        a.stu_no,
        a.stu_name,
        a.stu_id,
        a.penalty_type,
        a.penalty_status,
        a.violation_date,
        a.disposition_description,
        a.application_dismissal,
        a.ideological_education,
        a.submission_status,
        a.process_instance_id,
        a.deploy_id,
        a.create_by,
        a.create_time,
        a.update_by,
        a.update_time,
        a.remark,
        a.gender,
        a.department_Name,
        a.grade_name,
        a.class_name,
        a.mz,
        a.birthday,
        a.jg,
        a.political_status,
        a.hksz2,
        a.relieve_service,
        a.applicant_name
        from rt_stu_disciplinary_relieve a
        LEFT JOIN srs_student b ON a.stu_no = b.stu_no
        LEFT JOIN srs_class c ON b.class_id = c.class_id
        LEFT JOIN cph_teacher d ON c.teacher_id = d.teacher_id
        <where>
            <if test="penaltyNumber != null  and penaltyNumber != ''">and a.penalty_number = #{penaltyNumber}</if>
            <if test="relieveNumber != null  and relieveNumber != ''">and a.relieve_number = #{relieveNumber}</if>
            <if test="applicantName != null  and applicantName != ''">and a.applicant_name = #{applicantName}</if>
            <if test="stuNo != null  and stuNo != ''">and a.stu_no = #{stuNo}</if>
            <if test="stuName != null  and stuName != ''">and a.stu_name like concat('%', #{stuName}, '%')</if>
            <if test="stuId != null ">and a.stu_id = #{stuId}</if>
            <if test="penaltyType != null ">and a.penalty_type = #{penaltyType}</if>
            <if test="penaltyStatus != null ">and a.penalty_status = #{penaltyStatus}</if>
            <if test="violationDate != null ">and a.violation_date = #{violationDate}</if>
            <if test="dispositionDescription != null  and dispositionDescription != ''">and a.disposition_description =
                #{dispositionDescription}
            </if>
            <if test="applicationDismissal != null  and applicationDismissal != ''">and a.application_dismissal =
                #{applicationDismissal}
            </if>
            <if test="ideologicalEducation != null  and ideologicalEducation != ''">and a.ideological_education =
                #{ideologicalEducation}
            </if>
            <if test="submissionStatus != null ">and a.submission_status = #{submissionStatus}</if>
            <if test="processInstanceId != null  and processInstanceId != ''">and a.process_instance_id =
                #{processInstanceId}
            </if>
            <if test="deployId != null  and deployId != ''">and a.deploy_id = #{deployId}</if>
            <if test="gender != null  and gender != ''">and a.gender = #{gender}</if>
            <if test="departmentName != null  and departmentName != ''">and a.department_Name like concat('%',
                #{departmentName}, '%')
            </if>
            <if test="gradeName != null  and gradeName != ''">and a.grade_name like concat('%', #{gradeName}, '%')</if>
            <if test="className != null  and className != ''">and a.class_name like concat('%', #{className}, '%')</if>
            <if test="mz != null  and mz != ''">and a.mz = #{mz}</if>
            <if test="birthday != null  and birthday != ''">and a.birthday = #{birthday}</if>
            <if test="jg != null  and jg != ''">and a.jg = #{jg}</if>
            <if test="politicalStatus != null  and politicalStatus != ''">and a.political_status = #{politicalStatus}</if>
            <if test="hksz2 != null  and hksz2 != ''">and a.hksz2 = #{hksz2}</if>
            <if test="relieveService != null  and relieveService != ''">and a.relieve_service = #{relieveService}</if>
            <if test="params.employeeId != null  and params.employeeId != ''">and d.employee_id = #{params.employeeId}</if>
            <if test="deptId != null  and deptId != ''">and d.dept_id = #{deptId}</if>
        </where>
        ORDER BY create_time desc
    </select>

    <insert id="insertRtStuDisciplinaryRelieve" parameterType="RtStuDisciplinaryRelieve" useGeneratedKeys="true"
            keyProperty="relieveId">
        insert into rt_stu_disciplinary_relieve
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="penaltyNumber != null">penalty_number,</if>
            <if test="relieveNumber != null">relieve_number,</if>
            <if test="stuNo != null">stu_no,</if>
            <if test="stuName != null">stu_name,</if>
            <if test="stuId != null">stu_id,</if>
            <if test="penaltyType != null">penalty_type,</if>
            <if test="penaltyStatus != null">penalty_status,</if>
            <if test="violationDate != null">violation_date,</if>
            <if test="dispositionDescription != null">disposition_description,</if>
            <if test="applicationDismissal != null">application_dismissal,</if>
            <if test="ideologicalEducation != null">ideological_education,</if>
            <if test="submissionStatus != null">submission_status,</if>
            <if test="processInstanceId != null">process_instance_id,</if>
            <if test="deployId != null">deploy_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="gender != null">gender,</if>
            <if test="departmentName != null">department_Name,</if>
            <if test="gradeName != null">grade_name,</if>
            <if test="className != null">class_name,</if>
            <if test="mz != null">mz,</if>
            <if test="birthday != null">birthday,</if>
            <if test="jg != null">jg,</if>
            <if test="politicalStatus != null">political_status,</if>
            <if test="hksz2 != null">hksz2,</if>
            <if test="relieveService != null">relieve_service,</if>
            <if test="applicantName != null">applicant_name,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="penaltyNumber != null">#{penaltyNumber},</if>
            <if test="relieveNumber != null">#{relieveNumber},</if>
            <if test="stuNo != null">#{stuNo},</if>
            <if test="stuName != null">#{stuName},</if>
            <if test="stuId != null">#{stuId},</if>
            <if test="penaltyType != null">#{penaltyType},</if>
            <if test="penaltyStatus != null">#{penaltyStatus},</if>
            <if test="violationDate != null">#{violationDate},</if>
            <if test="dispositionDescription != null">#{dispositionDescription},</if>
            <if test="applicationDismissal != null">#{applicationDismissal},</if>
            <if test="ideologicalEducation != null">#{ideologicalEducation},</if>
            <if test="submissionStatus != null">#{submissionStatus},</if>
            <if test="processInstanceId != null">#{processInstanceId},</if>
            <if test="deployId != null">#{deployId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="gender != null">#{gender},</if>
            <if test="departmentName != null">#{departmentName},</if>
            <if test="gradeName != null">#{gradeName},</if>
            <if test="className != null">#{className},</if>
            <if test="mz != null">#{mz},</if>
            <if test="birthday != null">#{birthday},</if>
            <if test="jg != null">#{jg},</if>
            <if test="politicalStatus != null">#{politicalStatus},</if>
            <if test="hksz2 != null">#{hksz2},</if>
            <if test="relieveService != null">#{relieveService},</if>
            <if test="applicantName != null">#{applicantName},</if>
        </trim>
    </insert>

    <update id="updateRtStuDisciplinaryRelieve" parameterType="RtStuDisciplinaryRelieve">
        update rt_stu_disciplinary_relieve
        <trim prefix="SET" suffixOverrides=",">
            <if test="penaltyNumber != null">penalty_number = #{penaltyNumber},</if>
            <if test="relieveNumber != null">relieve_number = #{relieveNumber},</if>
            <if test="stuNo != null">stu_no = #{stuNo},</if>
            <if test="stuName != null">stu_name = #{stuName},</if>
            <if test="stuId != null">stu_id = #{stuId},</if>
            <if test="penaltyType != null">penalty_type = #{penaltyType},</if>
            <if test="penaltyStatus != null">penalty_status = #{penaltyStatus},</if>
            <if test="violationDate != null">violation_date = #{violationDate},</if>
            <if test="dispositionDescription != null">disposition_description = #{dispositionDescription},</if>
            <if test="applicationDismissal != null">application_dismissal = #{applicationDismissal},</if>
            <if test="ideologicalEducation != null">ideological_education = #{ideologicalEducation},</if>
            <if test="submissionStatus != null">submission_status = #{submissionStatus},</if>
            <if test="processInstanceId != null">process_instance_id = #{processInstanceId},</if>
            <if test="deployId != null">deploy_id = #{deployId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="gender != null">gender = #{gender},</if>
            <if test="departmentName != null">department_Name = #{departmentName},</if>
            <if test="gradeName != null">grade_name = #{gradeName},</if>
            <if test="className != null">class_name = #{className},</if>
            <if test="mz != null">mz = #{mz},</if>
            <if test="birthday != null">birthday = #{birthday},</if>
            <if test="jg != null">jg = #{jg},</if>
            <if test="politicalStatus != null">political_status = #{politicalStatus},</if>
            <if test="hksz2 != null">hksz2 = #{hksz2},</if>
            <if test="relieveService != null">relieve_service = #{relieveService},</if>
            <if test="applicantName != null">applicant_name = #{applicantName},</if>
        </trim>
        where relieve_id = #{relieveId}
    </update>

    <delete id="deleteRtStuDisciplinaryRelieveByRelieveId" parameterType="Long">
        delete
        from rt_stu_disciplinary_relieve
        where relieve_id = #{relieveId}
    </delete>

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