<?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.reliability.mapper.TKekaoMgListMapper">
    
    <resultMap type="TKekaoMgList" id="TKekaoMgListResult">
        <result property="id"    column="id"    />
        <result property="plantCode"    column="plant_code"    />
        <result property="influenceFactor"    column="influence_factor"    />
        <result property="measures"    column="measures"    />
        <result property="completeStatus"    column="complete_status"    />
        <result property="implementDate"    column="implement_date"    />
        <result property="implementPerson"    column="implement_person"    />
        <result property="approveStatus"    column="approve_status"    />
        <result property="delFlag"    column="del_flag"    />

    </resultMap>

    <sql id="selectTKekaoMgListVo">
        select d.id, d.plant_code, d.influence_factor, d.measures, d.complete_status, d.implement_date, d.implement_person, d.approve_status, d.del_flag  from t_kekao_mg_list d

    </sql>

    <select id="selectTKekaoMgListList" parameterType="TKekaoMgList" resultMap="TKekaoMgListResult">
        <include refid="selectTKekaoMgListVo"/>
        <where>  
            <if test="plantCode != null  and plantCode != ''"> and plant_code = #{plantCode}</if>
            <if test="influenceFactor != null  and influenceFactor != ''"> and influence_factor = #{influenceFactor}</if>
            <if test="measures != null  and measures != ''"> and measures = #{measures}</if>
            <if test="completeStatus != null "> and complete_status = #{completeStatus}</if>
            <if test="implementDate != null "> and implement_date = #{implementDate}</if>
            <if test="implementPerson != null  and implementPerson != ''"> and implement_person = #{implementPerson}</if>
            <if test="approveStatus != null "> and approve_status = #{approveStatus}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    
    <select id="selectTKekaoMgListById" parameterType="Long" resultMap="TKekaoMgListResult">
        <include refid="selectTKekaoMgListVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTKekaoMgList" parameterType="TKekaoMgList">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_kekao_mg_list.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_kekao_mg_list
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="plantCode != null">plant_code,</if>
            <if test="influenceFactor != null">influence_factor,</if>
            <if test="measures != null">measures,</if>
            <if test="completeStatus != null">complete_status,</if>
            <if test="implementDate != null">implement_date,</if>
            <if test="implementPerson != null">implement_person,</if>
            <if test="approveStatus != null">approve_status,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plantCode != null">#{plantCode},</if>
            <if test="influenceFactor != null">#{influenceFactor},</if>
            <if test="measures != null">#{measures},</if>
            <if test="completeStatus != null">#{completeStatus},</if>
            <if test="implementDate != null">#{implementDate},</if>
            <if test="implementPerson != null">#{implementPerson},</if>
            <if test="approveStatus != null">#{approveStatus},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateTKekaoMgList" parameterType="TKekaoMgList">
        update t_kekao_mg_list
        <trim prefix="SET" suffixOverrides=",">
            <if test="plantCode != null">plant_code = #{plantCode},</if>
            <if test="influenceFactor != null">influence_factor = #{influenceFactor},</if>
            <if test="measures != null">measures = #{measures},</if>
            <if test="completeStatus != null">complete_status = #{completeStatus},</if>
            <if test="implementDate != null">implement_date = #{implementDate},</if>
            <if test="implementPerson != null">implement_person = #{implementPerson},</if>
            <if test="approveStatus != null">approve_status = #{approveStatus},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

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

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