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

    <!--填报信息头表的映射 -->
    <resultMap type="SysTeacherKpiFillingStuMgt" id="SysTeacherKpiFillingStuMgtResult">
        <result property="id" column="id"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="departmentName" column="departmentName"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
        <result property="classScoring" column="class_scoring"/>
        <result property="cadreScoring" column="cadre_scoring"/>
        <result property="stuActivityScoring" column="stu_activity_scoring"/>
        <result property="stuTalkScoring" column="stu_talk_scoring"/>
        <result property="visitDormitoryScoring" column="visit_dormitory_scoring"/>
        <!--干部会议佐证材料子表的集合 （多条件查询column里传入了多条件【{fdyName = fdy_name, fillingYear = filling_year, fillingMonth = filling_month}】javaType里面写了list表明你有多条件 fdyName属性 fdy_name字段）-->
        <collection property="cadreMeetingMaterialsList" column="{fdyName = fdy_name, fillingYear = filling_year, fillingMonth = filling_month}" javaType="java.util.ArrayList" select="selectCadreMeetingMaterialsById"/>
        <!--班会会议佐证材料子表的集合 -->
        <collection property="classMeetingMaterialsList" column="{fdyName = fdy_name, fillingYear = filling_year, fillingMonth = filling_month}" javaType="java.util.ArrayList" select="selectClassMeetingMaterialsById"/>
        <!--学生开展活动佐佐证材料子表的集合 -->
        <collection property="stuActivityMaterialsList" column="{fdyName = fdy_name, fillingYear = filling_year, fillingMonth = filling_month}" javaType="java.util.ArrayList" select="selectStuActivityMaterialsById"/>
        <!--与带班学生谈心谈话佐证材料子表的集合 -->
        <collection property="stuTalkMaterialsList" column="{fdyName = fdy_name, fillingYear = filling_year, fillingMonth = filling_month}" javaType="java.util.ArrayList" select="selectStuTalkMaterialsById"/>
        <!--每周深入学生宿舍佐证材料子表的集合 -->
        <collection property="visitDormitoryMaterialsList" column="{fdyName = fdy_name, fillingYear = filling_year, fillingMonth = filling_month}" javaType="java.util.ArrayList" select="selectVisitDormitoryMaterialsById"/>
    </resultMap>

    <!--干部会议佐证材料子表的映射 -->
    <resultMap type="SysTeacherCadreMeetingMaterials" id="SysTeacherCadreMeetingMaterialsResult">
        <result property="id" column="id"/>
        <result property="developmentTime" column="development_time"/>
        <result property="place" column="place"/>
        <result property="className" column="class_name"/>
        <result property="numberOfStudents" column="number_of_students"/>
        <result property="mainContent" column="main_content"/>
        <result property="photo" column="photo"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
    </resultMap>
    <!--班会会议佐证材料子表的映射 -->
    <resultMap type="SysTeacherClassMeetingMaterials" id="SysTeacherClassMeetingMaterialsResult">
        <result property="id" column="id"/>
        <result property="developmentTime" column="development_time"/>
        <result property="place" column="place"/>
        <result property="className" column="class_name"/>
        <result property="numberOfStudents" column="number_of_students"/>
        <result property="mainContent" column="main_content"/>
        <result property="photo" column="photo"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
    </resultMap>
    <!--学生开展活动佐证材料子表的映射 -->
    <resultMap type="SysTeacherStuActivityMaterials" id="SysTeacherStuActivityMaterialsResult">
        <result property="id" column="id"/>
        <result property="developmentTime" column="development_time"/>
        <result property="place" column="place"/>
        <result property="className" column="class_name"/>
        <result property="numberOfStudents" column="number_of_students"/>
        <result property="mainContent" column="main_content"/>
        <result property="photo" column="photo"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
    </resultMap>
    <!--与带班学生谈心谈话佐证材料子表的映射 -->
    <resultMap type="SysTeacherStuTalkMaterials" id="SysTeacherStuTalkMaterialsResult">
        <result property="id" column="id"/>
        <result property="developmentTime" column="development_time"/>
        <result property="place" column="place"/>
        <result property="className" column="class_name"/>
        <result property="stuName" column="stu_name"/>
        <result property="mainContent" column="main_content"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
    </resultMap>
    <!--每周深入学生宿舍佐证材料子表的映射 -->
    <resultMap type="SysTeacherVisitDormitoryMaterials" id="SysTeacherVisitDormitoryMaterialsResult">
        <result property="id" column="id"/>
        <result property="developmentTime" column="development_time"/>
        <result property="visitClassName" column="visit_class_name"/>
        <result property="visitDormitoryNum" column="visit_dormitory_num"/>
        <result property="numberOfStudents" column="number_of_students"/>
        <result property="mainContent" column="main_content"/>
        <result property="photo" column="photo"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
    </resultMap>

    <!--查询干部会议佐证材料子表的数据-->
    <select id="selectCadreMeetingMaterialsById" resultMap="SysTeacherCadreMeetingMaterialsResult">
        select *
        from sys_teacher_cadre_meeting_materials
        <where>
            <if test="fdyName != null and fdyName != ''">
                and  fdy_name  = #{fdyName}
            </if>
            <if test="fillingYear != null and fillingYear != ''">
                and filling_year = #{fillingYear}
            </if>
            <if test="fillingMonth != null and fillingMonth != ''">
                and filling_month = #{fillingMonth}
            </if>
        </where>
    </select>
    <!--查询班会会议佐证材料子表的数据-->
    <select id="selectClassMeetingMaterialsById" resultMap="SysTeacherClassMeetingMaterialsResult">
        select *
        from sys_teacher_class_meeting_materials
        <where>
            <if test="fdyName != null and fdyName != ''">
               and fdy_name  = #{fdyName}
            </if>
            <if test="fillingYear != null and fillingYear != ''">
                and filling_year = #{fillingYear}
            </if>
            <if test="fillingMonth != null and fillingMonth != ''">
                and filling_month = #{fillingMonth}
            </if>
        </where>
    </select>
    <!--学生开展活动佐证材料子表的数据-->
    <select id="selectStuActivityMaterialsById" resultMap="SysTeacherStuActivityMaterialsResult">
        select *
        from sys_teacher_stu_activity_materials
        <where>
            <if test="fdyName != null and fdyName != ''">
                and fdy_name = #{fdyName}
            </if>
            <if test="fillingYear != null and fillingYear != ''">
                and filling_year = #{fillingYear}
            </if>
            <if test="fillingMonth != null and fillingMonth != ''">
                and filling_month = #{fillingMonth}
            </if>
        </where>
    </select>
    <!--学生开展活动佐证材料子表的数据-->
    <select id="selectStuTalkMaterialsById" resultMap="SysTeacherStuTalkMaterialsResult">
        select *
        from sys_teacher_stu_talk_materials
        <where>
            <if test="fdyName != null and fdyName != ''">
                and  fdy_name  = #{fdyName}
            </if>
            <if test="fillingYear != null and fillingYear != ''">
                and filling_year = #{fillingYear}
            </if>
            <if test="fillingMonth != null and fillingMonth != ''">
                and filling_month = #{fillingMonth}
            </if>
        </where>
    </select>
    <!--每周深入学生宿舍佐证材料子表的数据-->
    <select id="selectVisitDormitoryMaterialsById" resultMap="SysTeacherVisitDormitoryMaterialsResult">
        select *
        from sys_teacher_visit_dormitory_materials
        <where>
            <if test="fdyName != null and fdyName != ''">
                and  fdy_name  = #{fdyName}
            </if>
            <if test="fillingYear != null and fillingYear != ''">
                and filling_year = #{fillingYear}
            </if>
            <if test="fillingMonth != null and fillingMonth != ''">
                and filling_month = #{fillingMonth}
            </if>
        </where>
    </select>

    <sql id="selectSysTeacherKpiFillingStuMgtVo">
        select id,
               fdy_name,
               departmentName,
               filling_year,
               filling_month,
               class_scoring,
               cadre_scoring,
               stu_activity_scoring,
               stu_talk_scoring,
               visit_dormitory_scoring
        from sys_teacher_kpi_filling_stu_mgt
    </sql>

    <select id="selectSysTeacherKpiFillingStuMgtList" parameterType="SysTeacherKpiFillingStuMgt"
            resultMap="SysTeacherKpiFillingStuMgtResult">
        <include refid="selectSysTeacherKpiFillingStuMgtVo"/>
        <where>
            <if test="fdyName != null  and fdyName != ''">and fdy_name like concat('%', #{fdyName}, '%')</if>
            <if test="departmentName != null  and departmentName != ''">and departmentName like concat('%',
                #{departmentName}, '%')
            </if>
            <if test="fillingYear != null  and fillingYear != ''">and filling_year = #{fillingYear}</if>
            <if test="fillingMonth != null  and fillingMonth != ''">and filling_month = #{fillingMonth}</if>
            <if test="classScoring != null ">and class_scoring = #{classScoring}</if>
            <if test="cadreScoring != null ">and cadre_scoring = #{cadreScoring}</if>
            <if test="stuActivityScoring != null ">and stu_activity_scoring = #{stuActivityScoring}</if>
            <if test="stuTalkScoring != null ">and stu_talk_scoring = #{stuTalkScoring}</if>
            <if test="visitDormitoryScoring != null ">and visit_dormitory_scoring = #{visitDormitoryScoring}</if>
        </where>
        order by id desc
    </select>

    <!--根据名称、年份、月份查询-->
    <select id="selectSysTeacherKpiFillingStuMgtByFdyName" parameterType="String"
            resultMap="SysTeacherKpiFillingStuMgtResult">
        <include refid="selectSysTeacherKpiFillingStuMgtVo"/>
        <where>
            <if test="fdyName != null and fdyName != ''">
                and fdy_name = #{fdyName}
            </if>
            <if test="fillingYear != null and fillingYear != ''">
                and filling_year = #{fillingYear}
            </if>
            <if test="fillingMonth != null and fillingMonth != ''">
                and filling_month = #{fillingMonth}
            </if>
        </where>
        order by id desc
    </select>

    <select id="selectSysTeacherKpiFillingStuMgtByFdyNameAndFillingYear" parameterType="String"
            resultMap="SysTeacherKpiFillingStuMgtResult">
        <include refid="selectSysTeacherKpiFillingStuMgtVo"/>
        <where>
            <if test="departmentName != null and departmentName != ''">
                and departmentName = #{departmentName}
            </if>
            <if test="fdyName != null and fdyName != ''">
                and fdy_name = #{fdyName}
            </if>
            <if test="fillingYear != null and fillingYear != ''">
                and filling_year = #{fillingYear}
            </if>
            <if test="fillingMonth != null and fillingMonth != ''">
                and filling_month = #{fillingMonth}
            </if>
        </where>
        order by id desc
    </select>

    <select id="selectSysTeacherKpiFillingStuMgtById" parameterType="Long" resultMap="SysTeacherKpiFillingStuMgtResult">
        <include refid="selectSysTeacherKpiFillingStuMgtVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysTeacherKpiFillingStuMgt" parameterType="SysTeacherKpiFillingStuMgt">
        insert into sys_teacher_kpi_filling_stu_mgt
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="fdyName != null and fdyName != ''">fdy_name,</if>
            <if test="departmentName != null and departmentName != ''">departmentName,</if>
            <if test="fillingYear != null and fillingYear != ''">filling_year,</if>
            <if test="fillingMonth != null and fillingMonth != ''">filling_month,</if>
            <if test="classScoring != null">class_scoring,</if>
            <if test="cadreScoring != null">cadre_scoring,</if>
            <if test="stuActivityScoring != null">stu_activity_scoring,</if>
            <if test="stuTalkScoring != null">stu_talk_scoring,</if>
            <if test="visitDormitoryScoring != null">visit_dormitory_scoring,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="fdyName != null and fdyName != ''">#{fdyName},</if>
            <if test="departmentName != null and departmentName != ''">#{departmentName},</if>
            <if test="fillingYear != null and fillingYear != ''">#{fillingYear},</if>
            <if test="fillingMonth != null and fillingMonth != ''">#{fillingMonth},</if>
            <if test="classScoring != null">#{classScoring},</if>
            <if test="cadreScoring != null">#{cadreScoring},</if>
            <if test="stuActivityScoring != null">#{stuActivityScoring},</if>
            <if test="stuTalkScoring != null">#{stuTalkScoring},</if>
            <if test="visitDormitoryScoring != null">#{visitDormitoryScoring},</if>
        </trim>
    </insert>

    <update id="updateSysTeacherKpiFillingStuMgt" parameterType="SysTeacherKpiFillingStuMgt">
        update sys_teacher_kpi_filling_stu_mgt
        <trim prefix="SET" suffixOverrides=",">
            <if test="fdyName != null and fdyName != ''">fdy_name = #{fdyName},</if>
            <if test="departmentName != null and departmentName != ''">departmentName = #{departmentName},</if>
            <if test="fillingYear != null and fillingYear != ''">filling_year = #{fillingYear},</if>
            <if test="fillingMonth != null and fillingMonth != ''">filling_month = #{fillingMonth},</if>
            <if test="classScoring != null">class_scoring = #{classScoring},</if>
            <if test="cadreScoring != null">cadre_scoring = #{cadreScoring},</if>
            <if test="stuActivityScoring != null">stu_activity_scoring = #{stuActivityScoring},</if>
            <if test="stuTalkScoring != null">stu_talk_scoring = #{stuTalkScoring},</if>
            <if test="visitDormitoryScoring != null">visit_dormitory_scoring = #{visitDormitoryScoring},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysTeacherKpiFillingStuMgtById" parameterType="Long">
        delete
        from sys_teacher_kpi_filling_stu_mgt
        where id = #{id}
    </delete>

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