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

    <resultMap type="RtStuQuitSchool" id="RtStuQuitSchoolResult">
        <result property="quitSchoolId"    column="quit_school_id"    />
        <result property="applicantId"    column="applicant_id"    />
        <result property="applicantName"    column="applicant_name"    />
        <result property="stuNo"    column="stu_no"    />
        <result property="stuName"    column="stu_name"    />
        <result property="stuId"    column="stu_id"    />
        <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="parentPhone"    column="parent_phone"    />
        <result property="parentName"    column="parent_name"    />
        <result property="jg"    column="jg"    />
        <result property="hksz2"    column="hksz2"    />
        <result property="attachmentUpload"    column="attachment_upload"    />
        <result property="reasonApplying"    column="reason_applying"    />
        <result property="applySignature"    column="apply_signature"    />
        <result property="ideologicalEducation"    column="ideological_education"    />
        <result property="instructionSchoolHours"    column="Instruction_school_hours"    />
        <result property="applyStatus"    column="apply_status"    />
        <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="quitType"    column="quit_type"    />
        <result property="quitStartTime"    column="quit_startTime"    />
        <result property="quitEndTime"    column="quit_endTime"    />
        <result property="quitYear"    column="quit_year"    />
        <result property="quitNumber"    column="quit_number"    />
        <result property="quitCategory"    column="quit_category"    />
    </resultMap>

    <sql id="selectRtStuQuitSchoolVo">
        select quit_school_id, applicant_id, applicant_name, stu_no, stu_name, stu_id, gender, department_Name, grade_name, class_name, mz,
               birthday, parent_phone, parent_name, jg, hksz2, attachment_upload, reason_applying, apply_signature, ideological_education,
               Instruction_school_hours, apply_status, submission_status, process_instance_id, deploy_id, create_by, create_time, update_by,
               update_time, remark,quit_type,quit_startTime,quit_endTime,quit_year,quit_number,quit_category from rt_stu_quit_school
    </sql>

    <select id="selectRtStuQuitSchoolList" parameterType="RtStuQuitSchool" resultMap="RtStuQuitSchoolResult">
        <include refid="selectRtStuQuitSchoolVo"/>
        <where>
            <if test="applicantId != null "> and applicant_id = #{applicantId}</if>
            <if test="applicantName != null  and applicantName != ''"> and applicant_name like concat('%', #{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="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="parentPhone != null  and parentPhone != ''"> and parent_phone = #{parentPhone}</if>
            <if test="parentName != null  and parentName != ''"> and parent_name like concat('%', #{parentName}, '%')</if>
            <if test="jg != null  and jg != ''"> and jg = #{jg}</if>
            <if test="hksz2 != null  and hksz2 != ''"> and hksz2 = #{hksz2}</if>
            <if test="attachmentUpload != null  and attachmentUpload != ''"> and attachment_upload = #{attachmentUpload}</if>
            <if test="reasonApplying != null  and reasonApplying != ''"> and reason_applying = #{reasonApplying}</if>
            <if test="applySignature != null  and applySignature != ''"> and apply_signature = #{applySignature}</if>
            <if test="ideologicalEducation != null  and ideologicalEducation != ''"> and ideological_education = #{ideologicalEducation}</if>
            <if test="instructionSchoolHours != null  and instructionSchoolHours != ''"> and Instruction_school_hours = #{instructionSchoolHours}</if>
            <if test="applyStatus != null "> and apply_status = #{applyStatus}</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="quitType != null  and quitType != ''"> and quit_type = #{quitType}</if>
            <if test="quitStartTime != null  and quitStartTime != ''"> and quit_startTime = #{quitStartTime}</if>
            <if test="quitEndTime != null  and quitEndTime != ''"> and quit_endTime = #{quitEndTime}</if>
            <if test="quitYear != null  and quitYear != ''"> and quit_year = #{quitYear}</if>
            <if test="quitNumber != null  and quitNumber != ''"> and quit_number = #{quitNumber}</if>
            <if test="quitCategory != null  and quitCategory != ''"> and quit_category = #{quitCategory}</if>
        </where>
    </select>

    <select id="selectRtStuQuitSchoolByQuitSchoolId" parameterType="Long" resultMap="RtStuQuitSchoolResult">
        <include refid="selectRtStuQuitSchoolVo"/>
        where quit_school_id = #{quitSchoolId}
    </select>

    <select id="selectRtStuQuitSchoolListByXW" parameterType="RtStuQuitSchool" resultMap="RtStuQuitSchoolResult">
        SELECT quit_school_id, a.applicant_id, a.applicant_name, a.stu_no, a.stu_name, a.stu_id, a.gender, a.department_Name, a.grade_name, a.class_name, a.mz,
        a.birthday, a.parent_phone, a.parent_name, a.jg, a.hksz2, a.attachment_upload, a.reason_applying, a.apply_signature, a.ideological_education,
        a.Instruction_school_hours, a.apply_status, 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.quit_type,a.quit_startTime,a.quit_endTime,a.quit_year,a.quit_number,a.quit_category FROM rt_stu_quit_school 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="applicantId != null "> and applicant_id = #{applicantId}</if>
            <if test="applicantName != null  and applicantName != ''"> and applicant_name like concat('%', #{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="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="attachmentUpload != null  and attachmentUpload != ''"> and attachment_upload = #{attachmentUpload}</if>
            <if test="reasonApplying != null  and reasonApplying != ''"> and reason_applying = #{reasonApplying}</if>
            <if test="applySignature != null  and applySignature != ''"> and apply_signature = #{applySignature}</if>
            <if test="ideologicalEducation != null  and ideologicalEducation != ''"> and ideological_education = #{ideologicalEducation}</if>
            <if test="instructionSchoolHours != null  and instructionSchoolHours != ''"> and Instruction_school_hours = #{instructionSchoolHours}</if>
            <if test="applyStatus != null "> and apply_status = #{applyStatus}</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="quitType != null  and quitType != ''"> and quit_type = #{quitType}</if>
            <if test="quitStartTime != null  and quitStartTime != ''"> and quit_startTime = #{quitStartTime}</if>
            <if test="quitEndTime != null  and quitEndTime != ''"> and quit_endTime = #{quitEndTime}</if>
            <if test="quitYear != null  and quitYear != ''"> and quit_year = #{quitYear}</if>
            <if test="quitNumber != null  and quitNumber != ''"> and quit_number = #{quitNumber}</if>
            <if test="deptId != null  and deptId != ''"> and d.dept_id = #{deptId}</if>
            <if test="quitCategory != null  and quitCategory != ''"> and d.quit_category = #{quitCategory}</if>
        </where>
    </select>

    <select id="selectRtStuQuitSchoolListByFdy" parameterType="RtStuQuitSchool" resultMap="RtStuQuitSchoolResult">
        SELECT quit_school_id, applicant_id, applicant_name, a.stu_no, a.stu_name, a.stu_id, a.gender, a.department_Name, a.grade_name, a.class_name, a.mz,
        a.birthday, a.parent_phone, a.parent_name, a.jg, a.hksz2, a.attachment_upload, a.reason_applying, a.apply_signature, a.ideological_education,
        a.Instruction_school_hours, a.apply_status, 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.quit_type,a.quit_startTime,a.quit_endTime,a.quit_year,a.quit_number,a.quit_category FROM rt_stu_quit_school 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="applicantId != null "> and applicant_id = #{applicantId}</if>
            <if test="applicantName != null  and applicantName != ''"> and applicant_name like concat('%', #{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="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="parentPhone != null  and parentPhone != ''"> and parent_phone = #{parentPhone}</if>
            <if test="parentName != null  and parentName != ''"> and parent_name like concat('%', #{parentName}, '%')</if>
            <if test="jg != null  and jg != ''"> and jg = #{jg}</if>
            <if test="hksz2 != null  and hksz2 != ''"> and hksz2 = #{hksz2}</if>
            <if test="attachmentUpload != null  and attachmentUpload != ''"> and attachment_upload = #{attachmentUpload}</if>
            <if test="reasonApplying != null  and reasonApplying != ''"> and reason_applying = #{reasonApplying}</if>
            <if test="applySignature != null  and applySignature != ''"> and apply_signature = #{applySignature}</if>
            <if test="ideologicalEducation != null  and ideologicalEducation != ''"> and ideological_education = #{ideologicalEducation}</if>
            <if test="instructionSchoolHours != null  and instructionSchoolHours != ''"> and Instruction_school_hours = #{instructionSchoolHours}</if>
            <if test="applyStatus != null "> and apply_status = #{applyStatus}</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="quitType != null  and quitType != ''"> and quit_type = #{quitType}</if>
            <if test="quitStartTime != null  and quitStartTime != ''"> and quit_startTime = #{quitStartTime}</if>
            <if test="quitEndTime != null  and quitEndTime != ''"> and quit_endTime = #{quitEndTime}</if>
            <if test="quitYear != null  and quitYear != ''"> and quit_year = #{quitYear}</if>
            <if test="quitNumber != null  and quitNumber != ''"> and quit_number = #{quitNumber}</if>
            <if test="userName != null  and userName != ''"> and d.employee_id = #{userName}</if>
            <if test="quitCategory != null  and quitCategory != ''"> and quit_category = #{quitCategory}</if>
        </where>
        order by  a.create_time desc
    </select>

    <insert id="insertRtStuQuitSchool" parameterType="RtStuQuitSchool" useGeneratedKeys="true" keyProperty="quitSchoolId">
        insert into rt_stu_quit_school
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="applicantId != null">applicant_id,</if>
            <if test="applicantName != null">applicant_name,</if>
            <if test="stuNo != null">stu_no,</if>
            <if test="stuName != null">stu_name,</if>
            <if test="stuId != null">stu_id,</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="parentPhone != null">parent_phone,</if>
            <if test="parentName != null">parent_name,</if>
            <if test="jg != null">jg,</if>
            <if test="hksz2 != null">hksz2,</if>
            <if test="attachmentUpload != null">attachment_upload,</if>
            <if test="reasonApplying != null">reason_applying,</if>
            <if test="applySignature != null">apply_signature,</if>
            <if test="ideologicalEducation != null">ideological_education,</if>
            <if test="instructionSchoolHours != null">Instruction_school_hours,</if>
            <if test="applyStatus != null">apply_status,</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="quitType != null">quit_type,</if>
            <if test="quitStartTime != null">quit_startTime,</if>
            <if test="quitEndTime != null">quit_endTime,</if>
            <if test="quitYear != null  ">quit_year,</if>
            <if test="quitNumber != null ">quit_number,</if>
            <if test="quitCategory != null ">quit_category,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="applicantId != null">#{applicantId},</if>
            <if test="applicantName != null">#{applicantName},</if>
            <if test="stuNo != null">#{stuNo},</if>
            <if test="stuName != null">#{stuName},</if>
            <if test="stuId != null">#{stuId},</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="parentPhone != null">#{parentPhone},</if>
            <if test="parentName != null">#{parentName},</if>
            <if test="jg != null">#{jg},</if>
            <if test="hksz2 != null">#{hksz2},</if>
            <if test="attachmentUpload != null">#{attachmentUpload},</if>
            <if test="reasonApplying != null">#{reasonApplying},</if>
            <if test="applySignature != null">#{applySignature},</if>
            <if test="ideologicalEducation != null">#{ideologicalEducation},</if>
            <if test="instructionSchoolHours != null">#{instructionSchoolHours},</if>
            <if test="applyStatus != null">#{applyStatus},</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="quitType != null">#{quitType},</if>
            <if test="quitStartTime != null">#{quitStartTime},</if>
            <if test="quitEndTime != null">#{quitEndTime},</if>
            <if test="quitYear != null  ">#{quitYear},</if>
            <if test="quitNumber != null ">#{quitNumber},</if>
            <if test="quitCategory != null ">#{quitCategory},</if>
         </trim>
    </insert>

    <update id="updateRtStuQuitSchool" parameterType="RtStuQuitSchool">
        update rt_stu_quit_school
        <trim prefix="SET" suffixOverrides=",">
            <if test="applicantId != null">applicant_id = #{applicantId},</if>
            <if test="applicantName != null">applicant_name = #{applicantName},</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="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="parentPhone != null">parent_phone = #{parentPhone},</if>
            <if test="parentName != null">parent_name = #{parentName},</if>
            <if test="jg != null">jg = #{jg},</if>
            <if test="hksz2 != null">hksz2 = #{hksz2},</if>
            <if test="attachmentUpload != null">attachment_upload = #{attachmentUpload},</if>
            <if test="reasonApplying != null">reason_applying = #{reasonApplying},</if>
            <if test="applySignature != null">apply_signature = #{applySignature},</if>
            <if test="ideologicalEducation != null">ideological_education = #{ideologicalEducation},</if>
            <if test="instructionSchoolHours != null">Instruction_school_hours = #{instructionSchoolHours},</if>
            <if test="applyStatus != null">apply_status = #{applyStatus},</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="quitType != null">quit_type = #{quitType},</if>
            <if test="quitStartTime != null">quit_startTime = #{quitStartTime},</if>
            <if test="quitEndTime != null">quit_endTime = #{quitEndTime},</if>
            <if test="quitYear != null  ">quit_year = #{quitYear},</if>
            <if test="quitNumber != null ">quit_number = #{quitNumber},</if>
            <if test="quitCategory != null ">quit_category = #{quitCategory},</if>
        </trim>
        where quit_school_id = #{quitSchoolId}
    </update>

    <delete id="deleteRtStuQuitSchoolByQuitSchoolId" parameterType="Long">
        delete from rt_stu_quit_school where quit_school_id = #{quitSchoolId}
    </delete>

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