<?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.system.mapper.WmsImportResultHistoryMapper">

    <resultMap type="WmsImportResultHistory" id="WmsImportResultHistoryResult">
        <result property="id"    column="id"    />
        <result property="model"    column="model"    />
        <result property="specification"    column="specification"    />
        <result property="wireDisc"    column="wire_disc"    />
        <result property="totalNumber"    column="total_number"    />
        <result property="totalNetWeight"    column="total_net_weight"    />
        <result property="totalGrossWeight"    column="total_gross_weight"    />
        <result property="type"    column="type"    />
        <result property="warningValue"    column="warning_value"    />
        <result property="updateTime"    column="update_time"    javaType="java.util.Date" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="selectWmsImportResultHistoryVo">
        select id, model, specification, wire_disc, total_number, total_net_weight, total_gross_weight, type, warning_value, update_time from wms_import_result_history
    </sql>

    <select id="selectWmsImportResultHistoryList" parameterType="WmsImportResultHistory" resultMap="WmsImportResultHistoryResult">
        <include refid="selectWmsImportResultHistoryVo"/>
        <where>
            <if test="model != null  and model != ''"> and model = #{model}</if>
            <if test="specification != null  and specification != ''"> and specification = #{specification}</if>
            <if test="wireDisc != null  and wireDisc != ''"> and wire_disc = #{wireDisc}</if>
            <if test="totalNumber != null "> and total_number = #{totalNumber}</if>
            <if test="totalNetWeight != null "> and total_net_weight = #{totalNetWeight}</if>
            <if test="totalGrossWeight != null "> and total_gross_weight = #{totalGrossWeight}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="warningValue != null "> and warning_value = #{warningValue}</if>
            <if test="updateTime != null">
                and update_time >= #{updateTime, javaType=java.util.Date, jdbcType=TIMESTAMP}
                and update_time &lt; DATE_ADD(#{updateTime, javaType=java.util.Date, jdbcType=TIMESTAMP}, INTERVAL 1 MINUTE)
            </if>
        </where>
    </select>

    <select id="selectWmsImportResultHistoryById" parameterType="Long" resultMap="WmsImportResultHistoryResult">
        <include refid="selectWmsImportResultHistoryVo"/>
        where id = #{id}
    </select>

    <insert id="insertWmsImportResultHistory" parameterType="WmsImportResultHistory" useGeneratedKeys="true" keyProperty="id">
        insert into wms_import_result_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="model != null">model,</if>
            <if test="specification != null">specification,</if>
            <if test="wireDisc != null">wire_disc,</if>
            <if test="totalNumber != null">total_number,</if>
            <if test="totalNetWeight != null">total_net_weight,</if>
            <if test="totalGrossWeight != null">total_gross_weight,</if>
            <if test="type != null">type,</if>
            <if test="warningValue != null">warning_value,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="model != null">#{model},</if>
            <if test="specification != null">#{specification},</if>
            <if test="wireDisc != null">#{wireDisc},</if>
            <if test="totalNumber != null">#{totalNumber},</if>
            <if test="totalNetWeight != null">#{totalNetWeight},</if>
            <if test="totalGrossWeight != null">#{totalGrossWeight},</if>
            <if test="type != null">#{type},</if>
            <if test="warningValue != null">#{warningValue},</if>
            <if test="updateTime != null">#{updateTime, javaType=java.util.Date, jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>

    <update id="updateWmsImportResultHistory" parameterType="WmsImportResultHistory">
        update wms_import_result_history
        <trim prefix="SET" suffixOverrides=",">
            <if test="model != null">model = #{model},</if>
            <if test="specification != null">specification = #{specification},</if>
            <if test="wireDisc != null">wire_disc = #{wireDisc},</if>
            <if test="totalNumber != null">total_number = #{totalNumber},</if>
            <if test="totalNetWeight != null">total_net_weight = #{totalNetWeight},</if>
            <if test="totalGrossWeight != null">total_gross_weight = #{totalGrossWeight},</if>
            <if test="type != null">type = #{type},</if>
            <if test="warningValue != null">warning_value = #{warningValue},</if>
            <if test="updateTime != null">update_time = #{updateTime, javaType=java.util.Date, jdbcType=TIMESTAMP},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWmsImportResultHistoryById" parameterType="Long">
        delete from wms_import_result_history where id = #{id}
    </delete>

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