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

    <resultMap type="RtStuDropOutSchool" id="RtStuDropOutSchoolResult">
        <result property="dropOutSchoolId"    column="drop_out_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="politicalStatus"    column="political_status"    />
        <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="dropOutType"    column="drop_out_type"    />
        <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="quitStarttime"    column="quit_startTime"    />
        <result property="quitEndtime"    column="quit_endTime"    />
        <result property="quitYear"    column="quit_year"    />
        <result property="quitNumber"    column="quit_number"    />
        <result property="dropOutCategory"    column="drop_out_category"    />
    </resultMap>

    <sql id="selectRtStuDropOutSchoolVo">
        select drop_out_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,political_status,hksz2, attachment_upload, reason_applying, apply_signature,
               ideological_education, Instruction_school_hours, apply_status, submission_status, drop_out_type, process_instance_id,
               deploy_id, create_by, create_time, update_by, update_time, remark, quit_startTime, quit_endTime, quit_year, quit_number,drop_out_category
        from rt_stu_drop_out_school
    </sql>

    <select id="selectRtStuDropOutSchoolList" parameterType="RtStuDropOutSchool" resultMap="RtStuDropOutSchoolResult">
        <include refid="selectRtStuDropOutSchoolVo"/>
        <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="politicalStatus != null  and politicalStatus != ''"> and political_status = #{politicalStatus}</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="dropOutType != null  and dropOutType != ''"> and drop_out_type = #{dropOutType}</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="quitStarttime != null "> and quit_startTime = #{quitStarttime}</if>
            <if test="quitEndtime != null "> 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="dropOutCategory != null  and dropOutCategory != ''"> and drop_out_category = #{dropOutCategory}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectRtStuDropOutSchoolByDropOutSchoolId" parameterType="Long" resultMap="RtStuDropOutSchoolResult">
        <include refid="selectRtStuDropOutSchoolVo"/>
        where drop_out_school_id = #{dropOutSchoolId}
    </select>

    <select id="selectRtStuDropOutSchoolListByXW" parameterType="RtStuDropOutSchoolVo" resultMap="RtStuDropOutSchoolResult">
        select a.drop_out_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.political_status,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.drop_out_type, a.process_instance_id,
               a.deploy_id, a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.quit_startTime, a.quit_endTime,
               a.quit_year, a.quit_number,a.drop_out_category from rt_stu_drop_out_school a
            LEFT JOIN sys_user b ON a.applicant_id = b.user_id
            LEFT JOIN cph_teacher c ON b.user_name = c.employee_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="quitYear != null  and quitYear != ''"> and quit_year = #{quitYear}</if>
            <if test="quitNumber != null  and quitNumber != ''"> and quit_number = #{quitNumber}</if>
            <if test="quitNumber != null  and quitNumber != ''"> and quit_number = #{quitNumber}</if>
            <if test="deptId != null  and deptId != ''">and c.dept_id = #{deptId}</if>
            <if test="dropOutCategory != null  and dropOutCategory != ''"> and drop_out_category = #{dropOutCategory}</if>
        </where>
        order by create_time desc
    </select>

    <insert id="insertRtStuDropOutSchool" parameterType="RtStuDropOutSchoolVo" useGeneratedKeys="true" keyProperty="dropOutSchoolId">
        insert into rt_stu_drop_out_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="politicalStatus != null">political_status,</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="dropOutType != null">drop_out_type,</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="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="dropOutCategory != null">drop_out_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="politicalStatus != null">#{politicalStatus},</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="dropOutType != null">#{dropOutType},</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="quitStarttime != null">#{quitStarttime},</if>
            <if test="quitEndtime != null">#{quitEndtime},</if>
            <if test="quitYear != null">#{quitYear},</if>
            <if test="quitNumber != null">#{quitNumber},</if>
            <if test="dropOutCategory != null">#{dropOutCategory},</if>
         </trim>
    </insert>

    <update id="updateRtStuDropOutSchool" parameterType="RtStuDropOutSchoolVo">
        update rt_stu_drop_out_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="politicalStatus != null">political_status = #{politicalStatus},</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="dropOutType != null">drop_out_type = #{dropOutType},</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="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="dropOutCategory != null">drop_out_category = #{dropOutCategory},</if>
        </trim>
        where drop_out_school_id = #{dropOutSchoolId}
    </update>

    <delete id="deleteRtStuDropOutSchoolByDropOutSchoolId" parameterType="Long">
        delete from rt_stu_drop_out_school where drop_out_school_id = #{dropOutSchoolId}
    </delete>

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