<?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.weighbridge.mapper.TblWeightinfoMapper">
    
    <resultMap type="TblWeightinfo" id="TblWeightinfoResult">
        <result property="serialNo"    column="serial_no"    />
        <result property="plateNo"    column="plate_no"    />
        <result property="transportUnit"    column="transport_unit"    />
        <result property="forwardingUnit"    column="forwarding_unit"    />
        <result property="consigneeUnit"    column="consignee_unit"    />
        <result property="goodsName"    column="goods_name"    />
        <result property="goodsSpec"    column="goods_spec"    />
        <result property="grossWeight"    column="gross_weight"    />
        <result property="tareWeight"    column="tare_weight"    />
        <result property="netWeight"    column="net_weight"    />
        <result property="buckleWeight"    column="buckle_weight"    />
        <result property="actualWeight"    column="actual_weight"    />
        <result property="weightUnit"    column="weight_unit"    />
        <result property="unitPrice"    column="unit_price"    />
        <result property="sumAmt"    column="sum_amt"    />
        <result property="weightType"    column="weight_type"    />
        <result property="cardno"    column="cardno"    />
        <result property="grossStation"    column="gross_station"    />
        <result property="tareStation"    column="tare_station"    />
        <result property="grossMan"    column="gross_man"    />
        <result property="tareMan"    column="tare_man"    />
        <result property="grossTime"    column="gross_time"    />
        <result property="tareTime"    column="tare_time"    />
        <result property="firstTime"    column="first_time"    />
        <result property="secondTime"    column="second_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="printNum"    column="print_num"    />
        <result property="isUploadCloud"    column="is_upload_cloud"    />
        <result property="dataLog"    column="data_log"    />
    </resultMap>

    <sql id="selectTblWeightinfoVo">
        select serial_no, plate_no, transport_unit, forwarding_unit, consignee_unit, goods_name, goods_spec, gross_weight, tare_weight, net_weight, buckle_weight, actual_weight, weight_unit, unit_price, sum_amt, weight_type, cardno, gross_station, tare_station, gross_man, tare_man, gross_time, tare_time, first_time, second_time, update_time, print_num, is_upload_cloud, data_log from tbl_weightInfo
    </sql>

    <select id="selectTblWeightinfoList" parameterType="TblWeightinfo" resultMap="TblWeightinfoResult">
        <include refid="selectTblWeightinfoVo"/>
        <where>  
            <if test="serialNo != null  and serialNo != ''"> and serial_no = #{serialNo}</if>
            <if test="plateNo != null  and plateNo != ''"> and plate_no like concat('%', #{plateNo}, '%')</if>
            <if test="transportUnit != null  and transportUnit != ''"> and transport_unit like concat('%', #{transportUnit}, '%')</if>
            <if test="forwardingUnit != null  and forwardingUnit != ''"> and forwarding_unit like concat('%', #{forwardingUnit}, '%')</if>
            <if test="consigneeUnit != null  and consigneeUnit != ''"> and consignee_unit like concat('%', #{consigneeUnit}, '%')</if>
            <if test="goodsName != null  and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
            <if test="goodsSpec != null  and goodsSpec != ''"> and goods_spec like concat('%', #{goodsSpec}, '%')</if>
            <if test="grossWeight != null "> and gross_weight = #{grossWeight}</if>
            <if test="tareWeight != null "> and tare_weight = #{tareWeight}</if>
            <if test="netWeight != null "> and net_weight = #{netWeight}</if>
            <if test="buckleWeight != null "> and buckle_weight = #{buckleWeight}</if>
            <if test="actualWeight != null "> and actual_weight = #{actualWeight}</if>
            <if test="weightUnit != null  and weightUnit != ''"> and weight_unit = #{weightUnit}</if>
            <if test="unitPrice != null "> and unit_price = #{unitPrice}</if>
            <if test="sumAmt != null "> and sum_amt = #{sumAmt}</if>
            <if test="weightType != null  and weightType != ''"> and weight_type = #{weightType}</if>
            <if test="cardno != null  and cardno != ''"> and cardno = #{cardno}</if>
            <if test="grossStation != null  and grossStation != ''"> and gross_station = #{grossStation}</if>
            <if test="tareStation != null  and tareStation != ''"> and tare_station = #{tareStation}</if>
            <if test="grossMan != null  and grossMan != ''"> and gross_man = #{grossMan}</if>
            <if test="tareMan != null  and tareMan != ''"> and tare_man = #{tareMan}</if>
            <if test="firstTime != null "> and first_time = #{firstTime}</if>
            <if test="secondTime != null "> and second_time = #{secondTime}</if>
            <if test="updateTime != null "> and update_time = #{updateTime}</if>
            <if test="printNum != null "> and print_num = #{printNum}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                and grossTime = to_date(#{params.beginTime},'yyyy-MM-dd HH24:mi:ss')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                and grossTime = to_date(#{params.endTime},'yyyy-MM-dd HH24:mi:ss')
            </if>
            <if test="params.modBeginTime != null and params.modBeginTime != ''"><!-- 开始时间检索 -->
                and tareTime = to_date(#{params.modBeginTime},'yyyy-MM-dd HH24:mi:ss')
            </if>
            <if test="params.modEndTime != null and params.modEndTime != ''"><!-- 结束时间检索 -->
                and tareTime = to_date(#{params.modEndTime},'yyyy-MM-dd HH24:mi:ss')
            </if>
        </where>
    </select>
    
    <select id="selectTblWeightinfoBySerialNo" parameterType="String" resultMap="TblWeightinfoResult">
        <include refid="selectTblWeightinfoVo"/>
        where serial_no = #{serialNo}
    </select>

    <select id="selectTblWeightinfoByPlateNo" parameterType="String" resultMap="TblWeightinfoResult">
        <include refid="selectTblWeightinfoVo"/>
        where plate_no = #{plateNo}
    </select>
        
    <insert id="insertTblWeightinfo" parameterType="TblWeightinfo">
        insert into tbl_weightInfo
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="serialNo != null">serial_no,</if>
            <if test="plateNo != null">plate_no,</if>
            <if test="transportUnit != null">transport_unit,</if>
            <if test="forwardingUnit != null">forwarding_unit,</if>
            <if test="consigneeUnit != null">consignee_unit,</if>
            <if test="goodsName != null">goods_name,</if>
            <if test="goodsSpec != null">goods_spec,</if>
            <if test="grossWeight != null">gross_weight,</if>
            <if test="tareWeight != null">tare_weight,</if>
            <if test="netWeight != null">net_weight,</if>
            <if test="buckleWeight != null">buckle_weight,</if>
            <if test="actualWeight != null">actual_weight,</if>
            <if test="weightUnit != null">weight_unit,</if>
            <if test="unitPrice != null">unit_price,</if>
            <if test="sumAmt != null">sum_amt,</if>
            <if test="weightType != null">weight_type,</if>
            <if test="cardno != null">cardno,</if>
            <if test="grossStation != null">gross_station,</if>
            <if test="tareStation != null">tare_station,</if>
            <if test="grossMan != null">gross_man,</if>
            <if test="tareMan != null">tare_man,</if>
            <if test="grossTime != null">gross_time,</if>
            <if test="tareTime != null">tare_time,</if>
            <if test="firstTime != null">first_time,</if>
            <if test="secondTime != null">second_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="printNum != null">print_num,</if>
            <if test="isUploadCloud != null">is_upload_cloud,</if>
            <if test="dataLog != null">data_log,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="serialNo != null">#{serialNo},</if>
            <if test="plateNo != null">#{plateNo},</if>
            <if test="transportUnit != null">#{transportUnit},</if>
            <if test="forwardingUnit != null">#{forwardingUnit},</if>
            <if test="consigneeUnit != null">#{consigneeUnit},</if>
            <if test="goodsName != null">#{goodsName},</if>
            <if test="goodsSpec != null">#{goodsSpec},</if>
            <if test="grossWeight != null">#{grossWeight},</if>
            <if test="tareWeight != null">#{tareWeight},</if>
            <if test="netWeight != null">#{netWeight},</if>
            <if test="buckleWeight != null">#{buckleWeight},</if>
            <if test="actualWeight != null">#{actualWeight},</if>
            <if test="weightUnit != null">#{weightUnit},</if>
            <if test="unitPrice != null">#{unitPrice},</if>
            <if test="sumAmt != null">#{sumAmt},</if>
            <if test="weightType != null">#{weightType},</if>
            <if test="cardno != null">#{cardno},</if>
            <if test="grossStation != null">#{grossStation},</if>
            <if test="tareStation != null">#{tareStation},</if>
            <if test="grossMan != null">#{grossMan},</if>
            <if test="tareMan != null">#{tareMan},</if>
            <if test="grossTime != null">#{grossTime},</if>
            <if test="tareTime != null">#{tareTime},</if>
            <if test="firstTime != null">#{firstTime},</if>
            <if test="secondTime != null">#{secondTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="printNum != null">#{printNum},</if>
            <if test="isUploadCloud != null">#{isUploadCloud},</if>
            <if test="dataLog != null">#{dataLog},</if>
         </trim>
    </insert>

    <update id="updateTblWeightinfo" parameterType="TblWeightinfo">
        update tbl_weightInfo
        <trim prefix="SET" suffixOverrides=",">
            <if test="plateNo != null">plate_no = #{plateNo},</if>
            <if test="transportUnit != null">transport_unit = #{transportUnit},</if>
            <if test="forwardingUnit != null">forwarding_unit = #{forwardingUnit},</if>
            <if test="consigneeUnit != null">consignee_unit = #{consigneeUnit},</if>
            <if test="goodsName != null">goods_name = #{goodsName},</if>
            <if test="goodsSpec != null">goods_spec = #{goodsSpec},</if>
            <if test="grossWeight != null">gross_weight = #{grossWeight},</if>
            <if test="tareWeight != null">tare_weight = #{tareWeight},</if>
            <if test="netWeight != null">net_weight = #{netWeight},</if>
            <if test="buckleWeight != null">buckle_weight = #{buckleWeight},</if>
            <if test="actualWeight != null">actual_weight = #{actualWeight},</if>
            <if test="weightUnit != null">weight_unit = #{weightUnit},</if>
            <if test="unitPrice != null">unit_price = #{unitPrice},</if>
            <if test="sumAmt != null">sum_amt = #{sumAmt},</if>
            <if test="weightType != null">weight_type = #{weightType},</if>
            <if test="cardno != null">cardno = #{cardno},</if>
            <if test="grossStation != null">gross_station = #{grossStation},</if>
            <if test="tareStation != null">tare_station = #{tareStation},</if>
            <if test="grossMan != null">gross_man = #{grossMan},</if>
            <if test="tareMan != null">tare_man = #{tareMan},</if>
            <if test="grossTime != null">gross_time = #{grossTime},</if>
            <if test="tareTime != null">tare_time = #{tareTime},</if>
            <if test="firstTime != null">first_time = #{firstTime},</if>
            <if test="secondTime != null">second_time = #{secondTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="printNum != null">print_num = #{printNum},</if>
            <if test="isUploadCloud != null">is_upload_cloud = #{isUploadCloud},</if>
            <if test="dataLog != null">data_log = #{dataLog},</if>
        </trim>
        where serial_no = #{serialNo}
    </update>

    <delete id="deleteTblWeightinfoBySerialNo" parameterType="String">
        delete from tbl_weightInfo where serial_no = #{serialNo}
    </delete>

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