<?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.ruoyi.project.training.mapper.TSkillevaluationMapper">
    
    <resultMap type="TSkillevaluation" id="TSkillevaluationResult">
        <result property="id"    column="id"    />
        <result property="plantCode"    column="plant_code"    />
        <result property="staffid"    column="staffid"    />
        <result property="name"    column="name"    />
        <result property="crackingBoard"    column="cracking_board"    />
        <result property="crackingField"    column="cracking_field"    />
        <result property="compressionBoard"    column="compression_board"    />
        <result property="compressionField"    column="compression_field"    />
        <result property="separationBoard"    column="separation_board"    />
        <result property="separationField"    column="separation_field"    />
        <result property="aeuBoard"    column="aeu_board"    />
        <result property="aeuField"    column="aeu_field"    />
        <result property="pguBoard"    column="pgu_board"    />
        <result property="pguField"    column="pgu_field"    />
        <result property="subBoard"    column="sub_board"    />
        <result property="subField"    column="sub_field"    />
        <result property="totalScore"    column="total_score"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="remarks"    column="remarks"    />
        <result property="deptId"    column="dept_id"    />
        <result property="year"    column="year"    />
        <result property="classes"    column="classes"    />
        <result property="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTSkillevaluationVo">
        select d.id, d.plant_code, d.name, d.cracking_board, d.cracking_field, d.compression_board, d.compression_field, d.separation_board, d.separation_field, d.aeu_board, d.aeu_field, d.pgu_board, d.pgu_field, d.sub_board, d.sub_field, d.total_score, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.remarks, d.dept_id, d.staffid, d.year, d.classes ,s.dept_name from t_skillevaluation d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTSkillevaluationList" parameterType="TSkillevaluation" resultMap="TSkillevaluationResult">
        <include refid="selectTSkillevaluationVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat(concat('%', #{name}), '%')</if>
            <if test="year != null "> and year = #{year}</if>
            <if test="classes != null  and classes != ''"> and classes = #{classes}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        <if test="sortOrder == 'desc'"> ORDER BY total_score desc</if>
        <if test="sortOrder == 'asc'"> ORDER BY total_score asc</if>
    </select>
    
    <select id="selectTSkillevaluationById" parameterType="Long" resultMap="TSkillevaluationResult">
        <include refid="selectTSkillevaluationVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTSkillevaluation" parameterType="TSkillevaluation">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_skillevaluation.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_skillevaluation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="plantCode != null and plantCode != ''">plant_code,</if>
            <if test="staffid != null and staffid != ''">staffid,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="crackingBoard != null">cracking_board,</if>
            <if test="crackingField != null">cracking_field,</if>
            <if test="compressionBoard != null">compression_board,</if>
            <if test="compressionField != null">compression_field,</if>
            <if test="separationBoard != null">separation_board,</if>
            <if test="separationField != null">separation_field,</if>
            <if test="aeuBoard != null">aeu_board,</if>
            <if test="aeuField != null">aeu_field,</if>
            <if test="pguBoard != null">pgu_board,</if>
            <if test="pguField != null">pgu_field,</if>
            <if test="subBoard != null">sub_board,</if>
            <if test="subField != null">sub_field,</if>
            <if test="totalScore != null">total_score,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="remarks != null">remarks,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="year != null">year,</if>
            <if test="classes != null">classes,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plantCode != null and plantCode != ''">#{plantCode},</if>
            <if test="staffid != null and staffid != ''">#{staffid},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="crackingBoard != null">#{crackingBoard},</if>
            <if test="crackingField != null">#{crackingField},</if>
            <if test="compressionBoard != null">#{compressionBoard},</if>
            <if test="compressionField != null">#{compressionField},</if>
            <if test="separationBoard != null">#{separationBoard},</if>
            <if test="separationField != null">#{separationField},</if>
            <if test="aeuBoard != null">#{aeuBoard},</if>
            <if test="aeuField != null">#{aeuField},</if>
            <if test="pguBoard != null">#{pguBoard},</if>
            <if test="pguField != null">#{pguField},</if>
            <if test="subBoard != null">#{subBoard},</if>
            <if test="subField != null">#{subField},</if>
            <if test="totalScore != null">#{totalScore},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="year != null">#{year},</if>
            <if test="classes != null">#{classes},</if>
         </trim>
    </insert>

    <update id="updateTSkillevaluation" parameterType="TSkillevaluation">
        update t_skillevaluation
        <trim prefix="SET" suffixOverrides=",">
            <if test="plantCode != null and plantCode != ''">plant_code = #{plantCode},</if>
            <if test="staffid != null and staffid != ''">staffid = #{staffid},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="crackingBoard != null">cracking_board = #{crackingBoard},</if>
            <if test="crackingField != null">cracking_field = #{crackingField},</if>
            <if test="compressionBoard != null">compression_board = #{compressionBoard},</if>
            <if test="compressionField != null">compression_field = #{compressionField},</if>
            <if test="separationBoard != null">separation_board = #{separationBoard},</if>
            <if test="separationField != null">separation_field = #{separationField},</if>
            <if test="aeuBoard != null">aeu_board = #{aeuBoard},</if>
            <if test="aeuField != null">aeu_field = #{aeuField},</if>
            <if test="pguBoard != null">pgu_board = #{pguBoard},</if>
            <if test="pguField != null">pgu_field = #{pguField},</if>
            <if test="subBoard != null">sub_board = #{subBoard},</if>
            <if test="subField != null">sub_field = #{subField},</if>
            <if test="totalScore != null">total_score = #{totalScore},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="year != null">year = #{year},</if>
            <if test="classes != null">classes = #{classes},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteTSkillevaluationById" parameterType="Long">
        update t_skillevaluation set del_flag = 2 where id = #{id}
    </update>

    <update id="deleteTSkillevaluationByIds" parameterType="String">
        update t_skillevaluation set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    
</mapper>