<?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.teacher.mapper.SysPerformanceMapper">
    
    <resultMap type="SysPerformance" id="SysPerformanceResult">
        <result property="id"    column="id"    />
        <result property="fdTime"    column="fd_time"    />
        <result property="creditPass"    column="credit_pass"    />
        <result property="yjstatus"    column="yjstatus"    />
        <result property="yjidea"    column="yjidea"    />
        <result property="xgstatus"    column="xgstatus"    />
        <result property="xgidea"    column="xgidea"    />
        <result property="college"    column="college"    />
        <result property="fdName"    column="fd_name"    />
        <result property="activeType"    column="active_type"    />
        <result property="years"    column="years"    />
        <result property="sucesss"    column="sucesss"    />
        <result property="substatus"    column="substatus"    />
        <result property="shstatus"    column="shstatus"    />
        <result property="xwstatus"    column="xwstatus"    />
        <result property="xwidea"    column="xwidea"    />
        <result property="ksstatus"    column="ksstatus"    />
        <result property="ksidea"    column="ksidea"    />
        <!--个人填报-工作室绩效-->
        <collection property="activeList" column="{fdName = fd_name,years = years}" javaType="java.util.ArrayList" select="selectActiveById"/>
        <!--个人填报-承担任务绩效-->
        <collection property="rwList" column="{fdName = fd_name,years = years}" javaType="java.util.ArrayList" select="selectRwById"/>
        <!--个人填报-担任职务-->
        <collection property="servingList" column="{fdName = fd_name,years = years}" javaType="java.util.ArrayList" select="selectServingById"/>
        <!--个人填报-最大奖励-->
        <collection property="taskList" column="{fdName = fd_name,years = years}" javaType="java.util.ArrayList" select="selectTaskById"/>
        <!--个人填报-第二课堂活动及格人数-->
        <collection property="passList" column="{fdName = fd_name,years = years}" javaType="java.util.ArrayList" select="selectPassById"/>
    </resultMap>

<!--    第二课堂及格人数-->
    <resultMap type="SysPerformancePass" id="SysPerformancePassResult">
        <result property="id"    column="id"    />
        <result property="passs"    column="passs"    />
        <result property="years"    column="years"    />
        <result property="fdName"    column="fd_name"    />
    </resultMap>
    <!--个人填报-第二课堂及格人数-->
    <select id="selectPassById" resultMap="SysPerformancePassResult">
        select *
        from sys_performance_pass
        <where>
            <if test="fdName != null and fdName != ''">
                and  fd_name  = #{fdName}
            </if>
            <if test="years != null and years != ''">
                and  years  = #{years}
            </if>
        </where>
    </select>








<!--    最大奖励-->
    <resultMap type="SysPerformanceTask" id="SysPerformanceTaskResult">
        <result property="id"    column="id"    />
        <result property="taskDescribe"    column="task_describe"    />
        <result property="taskStart"    column="task_start"    />
        <result property="taskEnd"    column="task_end"    />
        <result property="prizes"    column="prizes"    />
        <result property="years"    column="years"    />
        <result property="fdName"    column="fd_name"    />
    </resultMap>
    <!--个人填报-最大奖励的数据-->
    <select id="selectTaskById" resultMap="SysPerformanceTaskResult">
        select *
        from sys_performance_task
        <where>
            <if test="fdName != null and fdName != ''">
                and  fd_name  = #{fdName}
            </if>
            <if test="years != null and years != ''">
                and  years  = #{years}
            </if>
        </where>
    </select>



<!--    担任职务-->
    <resultMap type="SysPerformanceServing" id="SysPerformanceServingResult">
        <result property="id"    column="id"    />
        <result property="servingPost"    column="serving_post"    />
        <result property="servingTime"    column="serving_time"    />
        <result property="servingFile"    column="serving_file"    />
        <result property="appointment"    column="appointment"    />
        <result property="years"    column="years"    />
        <result property="fdName"    column="fd_name"    />
    </resultMap>

    <!--个人填报-担任职务的数据-->
    <select id="selectServingById" resultMap="SysPerformanceServingResult">
        select *
        from sys_performance_serving
        <where>
            <if test="fdName != null and fdName != ''">
                and  fd_name  = #{fdName}
            </if>
            <if test="years != null and years != ''">
                and  years  = #{years}
            </if>
        </where>
    </select>


<!--    联表-承担任务-->
    <resultMap type="SysPerformanceRw" id="SysPerformanceRwResult">
        <result property="id"    column="id"    />
        <result property="rwType"    column="rw_type"    />
        <result property="rwTime"    column="rw_time"    />
        <result property="rwPlace"    column="rw_place"    />
        <result property="rwParticipate"    column="rw_participate"    />
        <result property="rwPeople"    column="rw_people"    />
        <result property="rwTheme"    column="rw_theme"    />
        <result property="rwSituation"    column="rw_situation"    />
        <result property="rwStu"    column="rw_stu"    />
        <result property="rwProportion"    column="rw_proportion"    />
        <result property="rwFile"    column="rw_file"    />
        <result property="rwNews"    column="rw_news"    />
        <result property="rwPicture"    column="rw_picture"    />
        <result property="years"    column="years"    />
        <result property="fdName"    column="fd_name"    />
    </resultMap>

    <!--个人填报-承担任务的数据-->
    <select id="selectRwById" resultMap="SysPerformanceRwResult">
        select *
        from sys_performance_rw
        <where>
            <if test="fdName != null and fdName != ''">
                and  fd_name  = #{fdName}
            </if>
            <if test="years != null and years != ''">
                and  years  = #{years}
            </if>
        </where>
    </select>

<!--    工作室绩效-->
    <resultMap type="SysPerformanceActive" id="SysPerformanceActiveResult">
        <result property="id"    column="id"    />
        <result property="activeType"    column="active_type"    />
        <result property="gzsTime"    column="gzs_time"    />
        <result property="gzsPlace"    column="gzs_place"    />
        <result property="gzsParticipate"    column="gzs_participate"    />
        <result property="gzsFdy"    column="gzs_fdy"    />
        <result property="gzsStu"    column="gzs_stu"    />
        <result property="gzsTheme"    column="gzs_theme"    />
        <result property="gzsIntroduce"    column="gzs_introduce"    />
        <result property="gzsPicture"    column="gzs_picture"    />
        <result property="gzsNews"    column="gzs_news"    />
        <result property="gzsProportion"    column="gzs_proportion"    />
        <result property="years"    column="years"    />
        <result property="fdName"    column="fd_name"    />
    </resultMap>

    <!--个人填报-工作室子表的数据-->
    <select id="selectActiveById" resultMap="SysPerformanceActiveResult">
        select *
        from sys_performance_active
        <where>
            <if test="fdName != null and fdName != ''">
                and  fd_name  = #{fdName}
            </if>
            <if test="years != null and years != ''">
                and  years  = #{years}
            </if>
        </where>
    </select>

    <sql id="selectSysPerformanceVo">
        select id, fd_time, credit_pass, yjstatus, yjidea, xgstatus, xgidea, college, fd_name, active_type, years, sucesss, substatus, shstatus, xwstatus, xwidea, ksstatus, ksidea from sys_performance
    </sql>

    <select id="selectSysPerformanceList" parameterType="SysPerformance" resultMap="SysPerformanceResult">
        <include refid="selectSysPerformanceVo"/>
        <where>  
            <if test="fdTime != null "> and fd_time = #{fdTime}</if>
            <if test="creditPass != null  and creditPass != ''"> and credit_pass = #{creditPass}</if>
            <if test="yjstatus != null "> and yjstatus = #{yjstatus}</if>
            <if test="yjidea != null  and yjidea != ''"> and yjidea = #{yjidea}</if>
            <if test="xgstatus != null "> and xgstatus = #{xgstatus}</if>
            <if test="xgidea != null  and xgidea != ''"> and xgidea = #{xgidea}</if>
            <if test="college != null  and college != ''"> and college = #{college}</if>
            <if test="fdName != null  and fdName != ''"> and fd_name like concat('%', #{fdName}, '%')</if>
<!--            <if test="activeType != null  and activeType != ''"> and active_type = #{activeType}</if>-->
            <if test="activeType != null  and activeType != ''"> and active_type like concat('%', #{activeType}, '%')</if>
            <if test="years != null  and years != ''"> and years = #{years}</if>
            <if test="sucesss != null  and sucesss != ''"> and sucesss = #{sucesss}</if>
            <if test="substatus != null "> and substatus = #{substatus}</if>
            <if test="shstatus != null "> and shstatus = #{shstatus}</if>
            <if test="xwstatus != null "> and xwstatus = #{xwstatus}</if>
            <if test="xwidea != null  and xwidea != ''"> and xwidea = #{xwidea}</if>
            <if test="ksstatus != null "> and ksstatus = #{ksstatus}</if>
            <if test="ksidea != null  and ksidea != ''"> and ksidea = #{ksidea}</if>
        </where>
    </select>
    
    <select id="selectSysPerformanceById" parameterType="Long" resultMap="SysPerformanceResult">
        <include refid="selectSysPerformanceVo"/>
        where id = #{id}
    </select>

    <select id="selectSysPerformanceByYears" resultMap="SysPerformanceResult">
        <include refid="selectSysPerformanceVo"/>
        <where>
            <if test="years != null and years != ''">
                and years = #{years}
            </if>
            <if test="fdName != null and fdName != ''">
                and fd_name = #{fdName}
            </if>
        </where>
    </select>
        
    <insert id="insertSysPerformance" parameterType="SysPerformance" useGeneratedKeys="true" keyProperty="id">
        insert into sys_performance
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fdTime != null">fd_time,</if>
            <if test="creditPass != null">credit_pass,</if>
            <if test="yjstatus != null">yjstatus,</if>
            <if test="yjidea != null">yjidea,</if>
            <if test="xgstatus != null">xgstatus,</if>
            <if test="xgidea != null">xgidea,</if>
            <if test="college != null">college,</if>
            <if test="fdName != null">fd_name,</if>
            <if test="activeType != null">active_type,</if>
            <if test="years != null">years,</if>
            <if test="sucesss != null">sucesss,</if>
            <if test="substatus != null">substatus,</if>
            <if test="shstatus != null">shstatus,</if>
            <if test="xwstatus != null">xwstatus,</if>
            <if test="xwidea != null">xwidea,</if>
            <if test="ksstatus != null">ksstatus,</if>
            <if test="ksidea != null">ksidea,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fdTime != null">#{fdTime},</if>
            <if test="creditPass != null">#{creditPass},</if>
            <if test="yjstatus != null">#{yjstatus},</if>
            <if test="yjidea != null">#{yjidea},</if>
            <if test="xgstatus != null">#{xgstatus},</if>
            <if test="xgidea != null">#{xgidea},</if>
            <if test="college != null">#{college},</if>
            <if test="fdName != null">#{fdName},</if>
            <if test="activeType != null">#{activeType},</if>
            <if test="years != null">#{years},</if>
            <if test="sucesss != null">#{sucesss},</if>
            <if test="substatus != null">#{substatus},</if>
            <if test="shstatus != null">#{shstatus},</if>
            <if test="xwstatus != null">#{xwstatus},</if>
            <if test="xwidea != null">#{xwidea},</if>
            <if test="ksstatus != null">#{ksstatus},</if>
            <if test="ksidea != null">#{ksidea},</if>
         </trim>
    </insert>

    <update id="updateSysPerformance" parameterType="SysPerformance">
        update sys_performance
        <trim prefix="SET" suffixOverrides=",">
            <if test="fdTime != null">fd_time = #{fdTime},</if>
            <if test="creditPass != null">credit_pass = #{creditPass},</if>
            <if test="yjstatus != null">yjstatus = #{yjstatus},</if>
            <if test="yjidea != null">yjidea = #{yjidea},</if>
            <if test="xgstatus != null">xgstatus = #{xgstatus},</if>
            <if test="xgidea != null">xgidea = #{xgidea},</if>
            <if test="college != null">college = #{college},</if>
            <if test="fdName != null">fd_name = #{fdName},</if>
            <if test="activeType != null">active_type = #{activeType},</if>
            <if test="years != null">years = #{years},</if>
            <if test="sucesss != null">sucesss = #{sucesss},</if>
            <if test="substatus != null">substatus = #{substatus},</if>
            <if test="shstatus != null">shstatus = #{shstatus},</if>
            <if test="xwstatus != null">xwstatus = #{xwstatus},</if>
            <if test="xwidea != null">xwidea = #{xwidea},</if>
            <if test="ksstatus != null">ksstatus = #{ksstatus},</if>
            <if test="ksidea != null">ksidea = #{ksidea},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysPerformanceById" parameterType="Long">
        delete from sys_performance where id = #{id}
    </delete>

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