<?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.ruoyi.traceability.mapper.ProUprecordMapper">
    
    <resultMap type="ProUprecord" id="ProUprecordResult">
        <result property="id"    column="id"    />
        <result property="machineId"    column="machineId"    />
        <result property="resource"    column="resource"    />
        <result property="positionId"    column="positionId"    />
        <result property="rfidStr"    column="rfidStr"    />
        <result property="sfcStr"    column="sfcStr"    />
        <result property="eaValue"    column="eaValue"    />
        <result property="isProduction"    column="is_production"    />
        <result property="isFinish"    column="is_Finish"    />
        <result property="recordTime"    column="recordTime"    />
        <result property="beginTime"    column="begin_Time"    />
        <result property="endTime"    column="end_Time"    />
    </resultMap>

    <sql id="selectProUprecordVo">
        select id, machineId, resource, positionId, rfidStr, sfcStr, eaValue, is_production, is_Finish, recordTime, begin_Time, end_Time from pro_uprecord
    </sql>

    <select id="selectProUprecordList" parameterType="ProUprecord" resultMap="ProUprecordResult">
        <include refid="selectProUprecordVo"/>
        <where>  
            <if test="resource != null  and resource != ''"> and resource = #{resource}</if>
            <if test="positionId != null "> and positionId = #{positionId}</if>
            <if test="rfidStr != null  and rfidStr != ''"> and rfidStr like concat('%', #{rfidStr}, '%')</if>
            <if test="sfcStr != null  and sfcStr != ''"> and sfcStr like concat('%', #{sfcStr}, '%')</if>
            <if test="eaValue != null "> and eaValue = #{eaValue}</if>
            <if test="isProduction != null "> and is_production = #{isProduction}</if>
            <if test="isFinish != null "> and is_Finish = #{isFinish}</if>
            <if test="beginTime != null  and beginTime != ''"> and begin_Time &gt;= #{beginTime}</if>
            <if test="endTime != null  and endTime != ''"> and end_Time &lt;= #{endTime}</if>
        </where>
    </select>
    
    <select id="selectProUprecordById" parameterType="Long" resultMap="ProUprecordResult">
        <include refid="selectProUprecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertProUprecord" parameterType="ProUprecord" useGeneratedKeys="true" keyProperty="id">
        insert into pro_uprecord
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="machineId != null">machineId,</if>
            <if test="resource != null">resource,</if>
            <if test="positionId != null">positionId,</if>
            <if test="rfidStr != null">rfidStr,</if>
            <if test="sfcStr != null">sfcStr,</if>
            <if test="eaValue != null">eaValue,</if>
            <if test="isProduction != null">is_production,</if>
            <if test="isFinish != null">is_Finish,</if>
            <if test="recordTime != null">recordTime,</if>
            <if test="beginTime != null">begin_Time,</if>
            <if test="endTime != null">end_Time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="machineId != null">#{machineId},</if>
            <if test="resource != null">#{resource},</if>
            <if test="positionId != null">#{positionId},</if>
            <if test="rfidStr != null">#{rfidStr},</if>
            <if test="sfcStr != null">#{sfcStr},</if>
            <if test="eaValue != null">#{eaValue},</if>
            <if test="isProduction != null">#{isProduction},</if>
            <if test="isFinish != null">#{isFinish},</if>
            <if test="recordTime != null">#{recordTime},</if>
            <if test="beginTime != null">#{beginTime},</if>
            <if test="endTime != null">#{endTime},</if>
         </trim>
    </insert>

    <update id="updateProUprecord" parameterType="ProUprecord">
        update pro_uprecord
        <trim prefix="SET" suffixOverrides=",">
            <if test="machineId != null">machineId = #{machineId},</if>
            <if test="resource != null">resource = #{resource},</if>
            <if test="positionId != null">positionId = #{positionId},</if>
            <if test="rfidStr != null">rfidStr = #{rfidStr},</if>
            <if test="sfcStr != null">sfcStr = #{sfcStr},</if>
            <if test="eaValue != null">eaValue = #{eaValue},</if>
            <if test="isProduction != null">is_production = #{isProduction},</if>
            <if test="isFinish != null">is_Finish = #{isFinish},</if>
            <if test="recordTime != null">recordTime = #{recordTime},</if>
            <if test="beginTime != null">begin_Time = #{beginTime},</if>
            <if test="endTime != null">end_Time = #{endTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteProUprecordById" parameterType="Long">
        delete from pro_uprecord where id = #{id}
    </delete>

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

</mapper>