<?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.ximai.mes.pro.mapper.task.ProFdQrcodePrintRecordMapper">

    <resultMap type="ProFdQrcodePrintRecord" id="ProFdQrcodePrintRecordResult">
        <result property="recordId"    column="record_id"    />
        <result property="taskWorkunitId"    column="task_workunit_id"    />
        <result property="workorderId"    column="workorder_id"    />
        <result property="barcode"    column="barcode"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectProFdQrcodePrintRecordVo">
        select record_id, task_workunit_id, workorder_id, barcode, create_by, create_time from pro_fd_qrcode_print_record
    </sql>

    <select id="selectProFdQrcodePrintRecordList" parameterType="ProFdQrcodePrintRecord" resultMap="ProFdQrcodePrintRecordResult">
        <include refid="selectProFdQrcodePrintRecordVo"/>
        <where>
            <if test="taskWorkunitId != null "> and task_workunit_id = #{taskWorkunitId}</if>
            <if test="workorderId != null "> and workorder_id = #{workorderId}</if>
            <if test="barcode != null  and barcode != ''"> and barcode = #{barcode}</if>
        </where>
    </select>

    <select id="selectProFdQrcodePrintRecordByRecordId" parameterType="Long" resultMap="ProFdQrcodePrintRecordResult">
        <include refid="selectProFdQrcodePrintRecordVo"/>
        where record_id = #{recordId}
    </select>

    <insert id="insertProFdQrcodePrintRecord" parameterType="ProFdQrcodePrintRecord" useGeneratedKeys="true" keyProperty="recordId">
        insert into pro_fd_qrcode_print_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskWorkunitId != null">task_workunit_id,</if>
            <if test="workorderId != null">workorder_id,</if>
            <if test="barcode != null">barcode,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskWorkunitId != null">#{taskWorkunitId},</if>
            <if test="workorderId != null">#{workorderId},</if>
            <if test="barcode != null">#{barcode},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <update id="updateProFdQrcodePrintRecord" parameterType="ProFdQrcodePrintRecord">
        update pro_fd_qrcode_print_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskWorkunitId != null">task_workunit_id = #{taskWorkunitId},</if>
            <if test="workorderId != null">workorder_id = #{workorderId},</if>
            <if test="barcode != null">barcode = #{barcode},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where record_id = #{recordId}
    </update>

    <delete id="deleteProFdQrcodePrintRecordByRecordId" parameterType="Long">
        delete from pro_fd_qrcode_print_record where record_id = #{recordId}
    </delete>

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