<?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.SysDisBasicMapper">
    
    <resultMap type="SysDisBasic" id="SysDisBasicResult">
        <result property="id"    column="id"    />
        <result property="fxId"    column="fx_id"    />
        <result property="fxTime"    column="fx_time"    />
        <result property="stId"    column="st_id"    />
        <result property="stName"    column="st_name"    />
        <result property="fdName"    column="fd_name"    />
        <result property="sex"    column="sex"    />
        <result property="nations"    column="nations"    />
        <result property="fdQm"    column="fd_qm"    />
        <result property="xwQm"    column="xw_qm"    />
        <result property="erQm"    column="er_qm"    />
        <result property="xjQm"    column="xj_qm"    />
        <result property="jwQm"    column="jw_qm"    />
        <result property="stClass"    column="st_class"    />
        <result property="majors"    column="majors"    />
        <result property="grade"    column="grade"    />
        <result property="college"    column="college"    />
        <result property="reasons"    column="reasons"    />
        <result property="fdIdea"    column="fd_idea"    />
        <result property="twoIdea"    column="two_idea"    />
        <result property="xwIdea"    column="xw_idea"    />
        <result property="xjIdea"    column="xj_idea"    />
        <result property="jwIdea"    column="jw_idea"    />
        <result property="zsIdea"    column="zs_idea"    />
        <result property="zsStatus"    column="zs_status"    />
        <result property="times"    column="times"    />
        <result property="fdStatus"    column="fd_status"    />
        <result property="xwStatus"    column="xw_status"    />
        <result property="twoStatus"    column="two_status"    />
        <result property="xjglStatus"    column="xjgl_status"    />
        <result property="jwStatus"    column="jw_status"    />
        <result property="rwTime"    column="rw_time"    />
        <result property="zsTime"    column="zs_time"    />
        <result property="fdTime"    column="fd_time"    />
        <result property="xwTime"    column="xw_time"    />
        <result property="twoTime"    column="two_time"    />
        <result property="xjTime"    column="xj_time"    />
        <result property="jwTime"    column="jw_time"    />
        <result property="datab"    column="datab"    />
        <result property="dataa"    column="dataa"    />
        <result property="conversion"    column="conversion"    />
        <result property="processId"    column="process_id"    />
        <result property="deployId"    column="deploy_id"    />
        <result property="studentId"    column="student_id"    />
        <result property="testData"    column="test_data"    />
        <result property="testTest"    column="test_test"    />
        <!--填报退伍材料-->
        <collection property="MaList" column="{stId = st_id}" javaType="java.util.ArrayList" select="selectMateById"/>

    </resultMap>

    <!--    联表 材料上传-->
    <resultMap type="SysDisMate" id="SysDisMateResult">
        <result property="id"    column="id"    />
        <result property="stId"    column="st_id"    />
        <result property="stName"    column="st_name"    />
        <result property="times"    column="times"    />
        <result property="college"    column="college"    />
        <result property="oldgrade"    column="oldgrade"    />
        <result property="oldmajor"    column="oldmajor"    />
        <result property="newgrade"    column="newgrade"    />
        <result property="newmajor"    column="newmajor"    />
        <result property="proof"    column="proof"    />
        <result property="idcard"    column="idcard"    />
        <result property="material"    column="material"    />
        <result property="data1"    column="data1"    />
        <result property="data2"    column="data2"    />
        <result property="finaldata1"    column="finaldata1"    />
        <result property="finaldata2"    column="finaldata2"    />
        <result property="finalmajor"    column="finalmajor"    />
        <result property="finallabel"    column="finallabel"    />
    </resultMap>

    <!--材料上传-->
    <select id="selectMateById" resultMap="SysDisMateResult">
        select *
        from sys_dis_mate
        <where>
            <if test="stId != null and stId != ''">
                and  st_id  = #{stId}
            </if>
        </where>
    </select>

    <!--查询是否插入过记录-->
    <select id="selectSysDisBasicByStId" parameterType="String" resultMap="SysDisBasicResult">
        <include refid="selectSysDisBasicVo"/>
        <where>
            <if test="stId != null and stId != ''">
                and st_id = #{stId}
            </if>

        </where>
    </select>

    <!--    根据姓名查询信息-->
    <select id="selectSysDisBasicByStName" parameterType="String" resultMap="SysDisBasicResult">
        <include refid="selectSysDisBasicVo"/>
        <where>
            <if test="stName != null and stName != ''">
                and st_name = #{stName}
            </if>

        </where>
    </select>

    <!--  根据流程编号查询申请记录  -->
    <select id="selectSysDisBasicByProcessInstanceId" parameterType="String"
            resultMap="SysDisBasicResult">
        <include refid="selectSysDisBasicVo"/>
        where process_id = #{processId}
    </select>

    <!-- 获取审批用户信息 -->
    <select id="getShenDataInfo" resultType="com.srs.common.doman.vo.TeacherVo">
        SELECT a.user_id userId, a.dept_id deptId, a.nick_name userNick, a.user_name userName
        FROM sys_user a
        LEFT JOIN sys_user_role b ON a.user_id = b.user_id
        LEFT JOIN sys_role c ON b.role_id = c.role_id
        WHERE c.role_name = #{roleName}
    </select>



    <sql id="selectSysDisBasicVo">
        select id, fx_id, fx_time, st_id, st_name, fd_name, sex, nations, fd_qm, xw_qm, er_qm, xj_qm, jw_qm, st_class, majors, grade, college, reasons, fd_idea, two_idea, xw_idea, xj_idea, jw_idea, zs_idea, zs_status, times, fd_status, xw_status, two_status, xjgl_status, jw_status, rw_time, zs_time, fd_time, xw_time, two_time, xj_time, jw_time, datab, dataa, conversion, process_id, deploy_id, student_id, test_data, test_test from sys_dis_basic
    </sql>

    <select id="selectSysDisBasicList" parameterType="SysDisBasic" resultMap="SysDisBasicResult">
        <include refid="selectSysDisBasicVo"/>
        <where>  
            <if test="fxId != null  and fxId != ''"> and fx_id = #{fxId}</if>
            <if test="fxTime != null  and fxTime != ''"> and fx_time = #{fxTime}</if>
            <if test="stId != null  and stId != ''"> and st_id = #{stId}</if>
            <if test="stName != null  and stName != ''"> and st_name like concat('%', #{stName}, '%')</if>
            <if test="fdName != null  and fdName != ''"> and fd_name like concat('%', #{fdName}, '%')</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="nations != null  and nations != ''"> and nations = #{nations}</if>
            <if test="fdQm != null  and fdQm != ''"> and fd_qm = #{fdQm}</if>
            <if test="xwQm != null  and xwQm != ''"> and xw_qm = #{xwQm}</if>
            <if test="erQm != null  and erQm != ''"> and er_qm = #{erQm}</if>
            <if test="xjQm != null  and xjQm != ''"> and xj_qm = #{xjQm}</if>
            <if test="jwQm != null  and jwQm != ''"> and jw_qm = #{jwQm}</if>
            <if test="stClass != null  and stClass != ''"> and st_class = #{stClass}</if>
            <if test="majors != null  and majors != ''"> and majors = #{majors}</if>
            <if test="grade != null  and grade != ''"> and grade = #{grade}</if>
            <if test="college != null  and college != ''"> and college = #{college}</if>
            <if test="reasons != null  and reasons != ''"> and reasons = #{reasons}</if>
            <if test="fdIdea != null  and fdIdea != ''"> and fd_idea = #{fdIdea}</if>
            <if test="twoIdea != null  and twoIdea != ''"> and two_idea = #{twoIdea}</if>
            <if test="xwIdea != null  and xwIdea != ''"> and xw_idea = #{xwIdea}</if>
            <if test="xjIdea != null  and xjIdea != ''"> and xj_idea = #{xjIdea}</if>
            <if test="jwIdea != null  and jwIdea != ''"> and jw_idea = #{jwIdea}</if>
            <if test="zsIdea != null  and zsIdea != ''"> and zs_idea = #{zsIdea}</if>
            <if test="zsStatus != null  and zsStatus != ''"> and zs_status = #{zsStatus}</if>
            <if test="times != null  and times != ''"> and times = #{times}</if>
            <if test="fdStatus != null  and fdStatus != ''"> and fd_status = #{fdStatus}</if>
            <if test="xwStatus != null  and xwStatus != ''"> and xw_status = #{xwStatus}</if>
            <if test="twoStatus != null  and twoStatus != ''"> and two_status = #{twoStatus}</if>
            <if test="xjglStatus != null  and xjglStatus != ''"> and xjgl_status = #{xjglStatus}</if>
            <if test="jwStatus != null  and jwStatus != ''"> and jw_status = #{jwStatus}</if>
            <if test="rwTime != null  and rwTime != ''"> and rw_time = #{rwTime}</if>
            <if test="zsTime != null  and zsTime != ''"> and zs_time = #{zsTime}</if>
            <if test="fdTime != null  and fdTime != ''"> and fd_time = #{fdTime}</if>
            <if test="xwTime != null  and xwTime != ''"> and xw_time = #{xwTime}</if>
            <if test="twoTime != null  and twoTime != ''"> and two_time = #{twoTime}</if>
            <if test="xjTime != null  and xjTime != ''"> and xj_time = #{xjTime}</if>
            <if test="jwTime != null  and jwTime != ''"> and jw_time = #{jwTime}</if>
            <if test="datab != null  and datab != ''"> and datab = #{datab}</if>
            <if test="dataa != null  and dataa != ''"> and dataa = #{dataa}</if>
            <if test="conversion != null  and conversion != ''"> and conversion = #{conversion}</if>
            <if test="processId != null  and processId != ''"> and process_id = #{processId}</if>
            <if test="deployId != null  and deployId != ''"> and deploy_id = #{deployId}</if>
            <if test="studentId != null "> and student_id = #{studentId}</if>
            <if test="testData != null  and testData != ''"> and test_data = #{testData}</if>
            <if test="testTest != null  and testTest != ''"> and test_test = #{testTest}</if>
        </where>
    </select>
    
    <select id="selectSysDisBasicById" parameterType="Long" resultMap="SysDisBasicResult">
        <include refid="selectSysDisBasicVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysDisBasic" parameterType="SysDisBasic" useGeneratedKeys="true" keyProperty="id">
        insert into sys_dis_basic
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fxId != null">fx_id,</if>
            <if test="fxTime != null">fx_time,</if>
            <if test="stId != null">st_id,</if>
            <if test="stName != null">st_name,</if>
            <if test="fdName != null">fd_name,</if>
            <if test="sex != null">sex,</if>
            <if test="nations != null">nations,</if>
            <if test="fdQm != null">fd_qm,</if>
            <if test="xwQm != null">xw_qm,</if>
            <if test="erQm != null">er_qm,</if>
            <if test="xjQm != null">xj_qm,</if>
            <if test="jwQm != null">jw_qm,</if>
            <if test="stClass != null">st_class,</if>
            <if test="majors != null">majors,</if>
            <if test="grade != null">grade,</if>
            <if test="college != null">college,</if>
            <if test="reasons != null">reasons,</if>
            <if test="fdIdea != null">fd_idea,</if>
            <if test="twoIdea != null">two_idea,</if>
            <if test="xwIdea != null">xw_idea,</if>
            <if test="xjIdea != null">xj_idea,</if>
            <if test="jwIdea != null">jw_idea,</if>
            <if test="zsIdea != null">zs_idea,</if>
            <if test="zsStatus != null">zs_status,</if>
            <if test="times != null">times,</if>
            <if test="fdStatus != null">fd_status,</if>
            <if test="xwStatus != null">xw_status,</if>
            <if test="twoStatus != null">two_status,</if>
            <if test="xjglStatus != null">xjgl_status,</if>
            <if test="jwStatus != null">jw_status,</if>
            <if test="rwTime != null">rw_time,</if>
            <if test="zsTime != null">zs_time,</if>
            <if test="fdTime != null">fd_time,</if>
            <if test="xwTime != null">xw_time,</if>
            <if test="twoTime != null">two_time,</if>
            <if test="xjTime != null">xj_time,</if>
            <if test="jwTime != null">jw_time,</if>
            <if test="datab != null">datab,</if>
            <if test="dataa != null">dataa,</if>
            <if test="conversion != null">conversion,</if>
            <if test="processId != null">process_id,</if>
            <if test="deployId != null">deploy_id,</if>
            <if test="studentId != null">student_id,</if>
            <if test="testData != null">test_data,</if>
            <if test="testTest != null">test_test,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fxId != null">#{fxId},</if>
            <if test="fxTime != null">#{fxTime},</if>
            <if test="stId != null">#{stId},</if>
            <if test="stName != null">#{stName},</if>
            <if test="fdName != null">#{fdName},</if>
            <if test="sex != null">#{sex},</if>
            <if test="nations != null">#{nations},</if>
            <if test="fdQm != null">#{fdQm},</if>
            <if test="xwQm != null">#{xwQm},</if>
            <if test="erQm != null">#{erQm},</if>
            <if test="xjQm != null">#{xjQm},</if>
            <if test="jwQm != null">#{jwQm},</if>
            <if test="stClass != null">#{stClass},</if>
            <if test="majors != null">#{majors},</if>
            <if test="grade != null">#{grade},</if>
            <if test="college != null">#{college},</if>
            <if test="reasons != null">#{reasons},</if>
            <if test="fdIdea != null">#{fdIdea},</if>
            <if test="twoIdea != null">#{twoIdea},</if>
            <if test="xwIdea != null">#{xwIdea},</if>
            <if test="xjIdea != null">#{xjIdea},</if>
            <if test="jwIdea != null">#{jwIdea},</if>
            <if test="zsIdea != null">#{zsIdea},</if>
            <if test="zsStatus != null">#{zsStatus},</if>
            <if test="times != null">#{times},</if>
            <if test="fdStatus != null">#{fdStatus},</if>
            <if test="xwStatus != null">#{xwStatus},</if>
            <if test="twoStatus != null">#{twoStatus},</if>
            <if test="xjglStatus != null">#{xjglStatus},</if>
            <if test="jwStatus != null">#{jwStatus},</if>
            <if test="rwTime != null">#{rwTime},</if>
            <if test="zsTime != null">#{zsTime},</if>
            <if test="fdTime != null">#{fdTime},</if>
            <if test="xwTime != null">#{xwTime},</if>
            <if test="twoTime != null">#{twoTime},</if>
            <if test="xjTime != null">#{xjTime},</if>
            <if test="jwTime != null">#{jwTime},</if>
            <if test="datab != null">#{datab},</if>
            <if test="dataa != null">#{dataa},</if>
            <if test="conversion != null">#{conversion},</if>
            <if test="processId != null">#{processId},</if>
            <if test="deployId != null">#{deployId},</if>
            <if test="studentId != null">#{studentId},</if>
            <if test="testData != null">#{testData},</if>
            <if test="testTest != null">#{testTest},</if>
         </trim>
    </insert>

    <update id="updateSysDisBasic" parameterType="SysDisBasic">
        update sys_dis_basic
        <trim prefix="SET" suffixOverrides=",">
            <if test="fxId != null">fx_id = #{fxId},</if>
            <if test="fxTime != null">fx_time = #{fxTime},</if>
            <if test="stId != null">st_id = #{stId},</if>
            <if test="stName != null">st_name = #{stName},</if>
            <if test="fdName != null">fd_name = #{fdName},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="nations != null">nations = #{nations},</if>
            <if test="fdQm != null">fd_qm = #{fdQm},</if>
            <if test="xwQm != null">xw_qm = #{xwQm},</if>
            <if test="erQm != null">er_qm = #{erQm},</if>
            <if test="xjQm != null">xj_qm = #{xjQm},</if>
            <if test="jwQm != null">jw_qm = #{jwQm},</if>
            <if test="stClass != null">st_class = #{stClass},</if>
            <if test="majors != null">majors = #{majors},</if>
            <if test="grade != null">grade = #{grade},</if>
            <if test="college != null">college = #{college},</if>
            <if test="reasons != null">reasons = #{reasons},</if>
            <if test="fdIdea != null">fd_idea = #{fdIdea},</if>
            <if test="twoIdea != null">two_idea = #{twoIdea},</if>
            <if test="xwIdea != null">xw_idea = #{xwIdea},</if>
            <if test="xjIdea != null">xj_idea = #{xjIdea},</if>
            <if test="jwIdea != null">jw_idea = #{jwIdea},</if>
            <if test="zsIdea != null">zs_idea = #{zsIdea},</if>
            <if test="zsStatus != null">zs_status = #{zsStatus},</if>
            <if test="times != null">times = #{times},</if>
            <if test="fdStatus != null">fd_status = #{fdStatus},</if>
            <if test="xwStatus != null">xw_status = #{xwStatus},</if>
            <if test="twoStatus != null">two_status = #{twoStatus},</if>
            <if test="xjglStatus != null">xjgl_status = #{xjglStatus},</if>
            <if test="jwStatus != null">jw_status = #{jwStatus},</if>
            <if test="rwTime != null">rw_time = #{rwTime},</if>
            <if test="zsTime != null">zs_time = #{zsTime},</if>
            <if test="fdTime != null">fd_time = #{fdTime},</if>
            <if test="xwTime != null">xw_time = #{xwTime},</if>
            <if test="twoTime != null">two_time = #{twoTime},</if>
            <if test="xjTime != null">xj_time = #{xjTime},</if>
            <if test="jwTime != null">jw_time = #{jwTime},</if>
            <if test="datab != null">datab = #{datab},</if>
            <if test="dataa != null">dataa = #{dataa},</if>
            <if test="conversion != null">conversion = #{conversion},</if>
            <if test="processId != null">process_id = #{processId},</if>
            <if test="deployId != null">deploy_id = #{deployId},</if>
            <if test="studentId != null">student_id = #{studentId},</if>
            <if test="testData != null">test_data = #{testData},</if>
            <if test="testTest != null">test_test = #{testTest},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysDisBasicById" parameterType="Long">
        delete from sys_dis_basic where id = #{id}
    </delete>

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