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

    <resultMap type="BasePlcDps" id="BasePlcDpsResult">
        <result property="id"    column="id"    />
        <result property="plcPoint"    column="plc_point"    />
        <result property="plcName"    column="plc_name"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBasePlcDpsVo">
        select id, plc_point, plc_name, remark,plc_ip,tunnel from base_plc_dps
    </sql>

    <select id="selectBasePlcDpsList" parameterType="BasePlcDps" resultType="com.shkj.wms.vo.BasePlcDpsVo">
        <include refid="selectBasePlcDpsVo"/>
        <where>
            <if test="plcPoint != null  and plcPoint != ''"> and plc_point = #{plcPoint}</if>
            <if test="plcName != null  and plcName != ''"> and plc_name like concat('%', #{plcName}, '%')</if>
        </where>
    </select>

    <select id="selectBasePlcDpsById" parameterType="Long" resultMap="BasePlcDpsResult">
        <include refid="selectBasePlcDpsVo"/>
        where id = #{id}
    </select>

    <insert id="insertBasePlcDps" parameterType="BasePlcDps" useGeneratedKeys="true" keyProperty="id">
        insert into base_plc_dps
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="plcPoint != null">plc_point,</if>
            <if test="plcName != null">plc_name,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="plcPoint != null">#{plcPoint},</if>
            <if test="plcName != null">#{plcName},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBasePlcDps" parameterType="BasePlcDps">
        update base_plc_dps
        <trim prefix="SET" suffixOverrides=",">
            <if test="plcPoint != null">plc_point = #{plcPoint},</if>
            <if test="plcName != null">plc_name = #{plcName},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBasePlcDpsById" parameterType="Long">
        delete from base_plc_dps where id = #{id}
    </delete>

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