<?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.wcs.mapper.BasePunchRecordMapper">
    <resultMap type="BasePunchRecord" id="BusinPunchRecordResult">
        <result property="id"    column="id"    />
        <result property="punchNo"    column="punch_no"    />
        <result property="agvNo"    column="agv_no"    />
        <result property="isState"    column="is_state"    />
        <result property="taskCode"    column="task_code"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="branchId"    column="branch_id"    />
    </resultMap>

    <sql id="selectBusinPunchRecordVo">
        select id, punch_no, agv_no, is_state, task_code, create_time, update_time, create_by, update_by, branch_id from busin_punch_record
    </sql>

    <select id="selectBusinPunchRecordList" parameterType="com.shkj.wcs.domain.BasePunchRecord" resultMap="BusinPunchRecordResult">
        <include refid="selectBusinPunchRecordVo"/>
        <where>
            <if test="punchNo != null "> and punch_no = #{punchNo}</if>
            <if test="agvNo != null  and agvNo != ''"> and agv_no = #{agvNo}</if>
            <if test="isState != null  and isState != ''"> and is_state = #{isState}</if>
            <if test="taskCode != null "> and task_code = #{taskCode}</if>
            <if test="branchId != null "> and branch_id = #{branchId}</if>
        </where>
    </select>


    <select id="selectBusinPunchRecordById" parameterType="Long" resultMap="BusinPunchRecordResult">
        <include refid="selectBusinPunchRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertBusinPunchRecord" parameterType="com.shkj.wcs.domain.BasePunchRecord" useGeneratedKeys="true" keyProperty="id">
        insert into busin_punch_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="punchNo != null">punch_no,</if>
            <if test="agvNo != null">agv_no,</if>
            <if test="isState != null">is_state,</if>
            <if test="taskCode != null">task_code,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="branchId != null">branch_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="punchNo != null">#{punchNo},</if>
            <if test="agvNo != null">#{agvNo},</if>
            <if test="isState != null">#{isState},</if>
            <if test="taskCode != null">#{taskCode},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="branchId != null">#{branchId},</if>
        </trim>
    </insert>

    <update id="updateBusinPunchRecord" parameterType="com.shkj.wcs.domain.BasePunchRecord">
        update busin_punch_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="punchNo != null">punch_no = #{punchNo},</if>
            <if test="agvNo != null">agv_no = #{agvNo},</if>
            <if test="isState != null">is_state = #{isState},</if>
            <if test="taskCode != null">task_code = #{taskCode},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="branchId != null">branch_id = #{branchId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusinPunchRecordById" parameterType="Long">
        delete from busin_punch_record where id = #{id}
    </delete>

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

    <select id="selectBusinPunchRecord" parameterType="com.shkj.wcs.bo.BasePunchRecordQueryBo" resultMap="BusinPunchRecordResult">
        <include refid="selectBusinPunchRecordVo"/>
        <where>
            <if test="punchNo != null "> and punch_no = #{punchNo}</if>
            <if test="agvNo != null  and agvNo != ''"> and agv_no = #{agvNo}</if>
            <if test="isState != null  and isState != ''"> and is_state = #{isState}</if>
            <if test="taskCode != null "> and task_code = #{taskCode}</if>
            <if test="branchId != null "> and branch_id = #{branchId}</if>
        </where>
    </select>


</mapper>
