<?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.shkj.wms.mapper.BusinPlcStatusMapper">
    
    <resultMap type="BusinPlcStatus" id="BusinPlcStatusResult">
        <result property="id"    column="id"    />
        <result property="stkRun"    column="stk_run"    />
        <result property="stkWait"    column="stk_wait"    />
        <result property="stkPause"    column="stk_pause"    />
        <result property="stkFault"    column="stk_fault"    />
        <result property="stkStop"    column="stk_stop"    />
        <result property="createTime"    column="create_time"    />
        <result property="dpsRun"    column="dps_run"    />
        <result property="dpsWait"    column="dps_wait"    />
        <result property="dpsPause"    column="dps_pause"    />
        <result property="dpsFault"    column="dps_fault"    />
        <result property="dpsStop"    column="dps_stop"    />
        <result property="dtsRun"    column="dts_run"    />
        <result property="dtsWait"    column="dts_wait"    />
        <result property="dtsPause"    column="dts_pause"    />
        <result property="dtsFault"    column="dts_fault"    />
        <result property="dtsStop"    column="dts_stop"    />
    </resultMap>

    <sql id="selectBusinPlcStatusVo">
        select id, stk_run, stk_wait, stk_pause, stk_fault, stk_stop, create_time, dps_run, dps_wait, dps_pause, dps_fault, dps_stop, dts_run, dts_wait, dts_pause, dts_fault, dts_stop from busin_plc_status
    </sql>

    <select id="selectBusinPlcStatusList" parameterType="BusinPlcStatus" resultMap="BusinPlcStatusResult">
        <include refid="selectBusinPlcStatusVo"/>
        <where>  
            <if test="stkRun != null  and stkRun != ''"> and stk_run = #{stkRun}</if>
            <if test="stkWait != null  and stkWait != ''"> and stk_wait = #{stkWait}</if>
            <if test="stkPause != null  and stkPause != ''"> and stk_pause = #{stkPause}</if>
            <if test="stkFault != null  and stkFault != ''"> and stk_fault = #{stkFault}</if>
            <if test="stkStop != null  and stkStop != ''"> and stk_stop = #{stkStop}</if>
            <if test="dpsRun != null  and dpsRun != ''"> and dps_run = #{dpsRun}</if>
            <if test="dpsWait != null  and dpsWait != ''"> and dps_wait = #{dpsWait}</if>
            <if test="dpsPause != null  and dpsPause != ''"> and dps_pause = #{dpsPause}</if>
            <if test="dpsFault != null  and dpsFault != ''"> and dps_fault = #{dpsFault}</if>
            <if test="dpsStop != null  and dpsStop != ''"> and dps_stop = #{dpsStop}</if>
            <if test="dtsRun != null  and dtsRun != ''"> and dts_run = #{dtsRun}</if>
            <if test="dtsWait != null  and dtsWait != ''"> and dts_wait = #{dtsWait}</if>
            <if test="dtsPause != null  and dtsPause != ''"> and dts_pause = #{dtsPause}</if>
            <if test="dtsFault != null  and dtsFault != ''"> and dts_fault = #{dtsFault}</if>
            <if test="dtsStop != null  and dtsStop != ''"> and dts_stop = #{dtsStop}</if>
        </where>
    </select>
    
    <select id="selectBusinPlcStatusById" parameterType="Long" resultMap="BusinPlcStatusResult">
        <include refid="selectBusinPlcStatusVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBusinPlcStatus" parameterType="BusinPlcStatus" useGeneratedKeys="true" keyProperty="id">
        insert into busin_plc_status
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stkRun != null">stk_run,</if>
            <if test="stkWait != null">stk_wait,</if>
            <if test="stkPause != null">stk_pause,</if>
            <if test="stkFault != null">stk_fault,</if>
            <if test="stkStop != null">stk_stop,</if>
            <if test="createTime != null">create_time,</if>
            <if test="dpsRun != null">dps_run,</if>
            <if test="dpsWait != null">dps_wait,</if>
            <if test="dpsPause != null">dps_pause,</if>
            <if test="dpsFault != null">dps_fault,</if>
            <if test="dpsStop != null">dps_stop,</if>
            <if test="dtsRun != null">dts_run,</if>
            <if test="dtsWait != null">dts_wait,</if>
            <if test="dtsPause != null">dts_pause,</if>
            <if test="dtsFault != null">dts_fault,</if>
            <if test="dtsStop != null">dts_stop,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stkRun != null">#{stkRun},</if>
            <if test="stkWait != null">#{stkWait},</if>
            <if test="stkPause != null">#{stkPause},</if>
            <if test="stkFault != null">#{stkFault},</if>
            <if test="stkStop != null">#{stkStop},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="dpsRun != null">#{dpsRun},</if>
            <if test="dpsWait != null">#{dpsWait},</if>
            <if test="dpsPause != null">#{dpsPause},</if>
            <if test="dpsFault != null">#{dpsFault},</if>
            <if test="dpsStop != null">#{dpsStop},</if>
            <if test="dtsRun != null">#{dtsRun},</if>
            <if test="dtsWait != null">#{dtsWait},</if>
            <if test="dtsPause != null">#{dtsPause},</if>
            <if test="dtsFault != null">#{dtsFault},</if>
            <if test="dtsStop != null">#{dtsStop},</if>
         </trim>
    </insert>

    <update id="updateBusinPlcStatus" parameterType="BusinPlcStatus">
        update busin_plc_status
        <trim prefix="SET" suffixOverrides=",">
            <if test="stkRun != null">stk_run = #{stkRun},</if>
            <if test="stkWait != null">stk_wait = #{stkWait},</if>
            <if test="stkPause != null">stk_pause = #{stkPause},</if>
            <if test="stkFault != null">stk_fault = #{stkFault},</if>
            <if test="stkStop != null">stk_stop = #{stkStop},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="dpsRun != null">dps_run = #{dpsRun},</if>
            <if test="dpsWait != null">dps_wait = #{dpsWait},</if>
            <if test="dpsPause != null">dps_pause = #{dpsPause},</if>
            <if test="dpsFault != null">dps_fault = #{dpsFault},</if>
            <if test="dpsStop != null">dps_stop = #{dpsStop},</if>
            <if test="dtsRun != null">dts_run = #{dtsRun},</if>
            <if test="dtsWait != null">dts_wait = #{dtsWait},</if>
            <if test="dtsPause != null">dts_pause = #{dtsPause},</if>
            <if test="dtsFault != null">dts_fault = #{dtsFault},</if>
            <if test="dtsStop != null">dts_stop = #{dtsStop},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusinPlcStatusById" parameterType="Long">
        delete from busin_plc_status where id = #{id}
    </delete>

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