<?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.cpms.project.safety.mapper.TSafetyEyeWasherMapper">

    <resultMap type="TSafetyEyeWasher" id="TSafetyEyeWasherResult">
        <result property="id"    column="id"    />
        <result property="washerNo"    column="washer_no"    />
        <result property="location"    column="location"    />
        <result property="status"    column="status"    />
        <result property="faultDesc"    column="fault_desc"    />
        <result property="faultSloveSign"    column="fault_slove_sign"    />
        <result property="inspector"    column="inspector"    />
        <result property="inspectdate"    column="inspectdate"    />
        <result property="inspectstatus"    column="inspectstatus"    />
        <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="deptId"    column="dept_id"    />
        <result property="remarks"    column="remarks"    />
        <result property="fileIds"    column="file_ids"    />
    </resultMap>

    <sql id="selectTSafetyEyeWasherVo">
        select id, washer_no, location, status, fault_desc, fault_slove_sign, inspector, inspectdate, inspectstatus, del_flag, creater_code, createdate, updater_code, updatedate, dept_id, remarks,file_ids from t_safety_eye_washer
    </sql>

    <select id="selectTSafetyEyeWasherList" parameterType="TSafetyEyeWasher" resultMap="TSafetyEyeWasherResult">
        <include refid="selectTSafetyEyeWasherVo"/>
        <where>
            <if test="washerNo != null  and washerNo != ''"> and washer_no = #{washerNo}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="faultDesc != null  and faultDesc != ''"> and fault_desc = #{faultDesc}</if>
            <if test="faultSloveSign != null  and faultSloveSign != ''"> and fault_slove_sign = #{faultSloveSign}</if>
            <if test="inspector != null  and inspector != ''"> and inspector = #{inspector}</if>
            <if test="inspectdate != null "> and inspectdate = #{inspectdate}</if>
            <if test="inspectstatus != null  and inspectstatus != ''"> and inspectstatus = #{inspectstatus}</if>
            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        and del_flag = 0
        </where>
    </select>

    <select id="selectTSafetyEyeWasherById" parameterType="Long" resultMap="TSafetyEyeWasherResult">
        <include refid="selectTSafetyEyeWasherVo"/>
        where id = #{id}
    </select>

    <insert id="insertTSafetyEyeWasher" parameterType="TSafetyEyeWasher" useGeneratedKeys="true" keyProperty="id">
        insert into t_safety_eye_washer
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="washerNo != null and washerNo != ''">washer_no,</if>
            <if test="location != null">location,</if>
            <if test="status != null">status,</if>
            <if test="faultDesc != null">fault_desc,</if>
            <if test="faultSloveSign != null">fault_slove_sign,</if>
            <if test="inspector != null and inspector != ''">inspector,</if>
            <if test="inspectdate != null">inspectdate,</if>
            <if test="inspectstatus != null">inspectstatus,</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="deptId != null">dept_id,</if>
            <if test="remarks != null">remarks,</if>
            <if test="fileIds != null">file_ids,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="washerNo != null and washerNo != ''">#{washerNo},</if>
            <if test="location != null">#{location},</if>
            <if test="status != null">#{status},</if>
            <if test="faultDesc != null">#{faultDesc},</if>
            <if test="faultSloveSign != null">#{faultSloveSign},</if>
            <if test="inspector != null and inspector != ''">#{inspector},</if>
            <if test="inspectdate != null">#{inspectdate},</if>
            <if test="inspectstatus != null">#{inspectstatus},</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="deptId != null">#{deptId},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="fileIds != null">#{fileIds},</if>
         </trim>
    </insert>

    <update id="updateTSafetyEyeWasher" parameterType="TSafetyEyeWasher">
        update t_safety_eye_washer
        <trim prefix="SET" suffixOverrides=",">
            <if test="washerNo != null and washerNo != ''">washer_no = #{washerNo},</if>
            <if test="location != null">location = #{location},</if>
            <if test="status != null">status = #{status},</if>
            <if test="faultDesc != null">fault_desc = #{faultDesc},</if>
            <if test="faultSloveSign != null">fault_slove_sign = #{faultSloveSign},</if>
            <if test="inspector != null and inspector != ''">inspector = #{inspector},</if>
            <if test="inspectdate != null">inspectdate = #{inspectdate},</if>
            <if test="inspectstatus != null">inspectstatus = #{inspectstatus},</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="deptId != null">dept_id = #{deptId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="fileIds != null">file_ids = #{fileIds},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTSafetyEyeWasherById" parameterType="Long">
        update t_safety_eye_washer set del_flag=1 where id = #{id}
    </delete>

    <delete id="deleteTSafetyEyeWasherByIds" parameterType="String">
        update t_safety_eye_washer set del_flag=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
