<?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.report.mapper.RecordDeviceamountDayMapper">

    <resultMap type="RecordDeviceamountDay" id="RecordDeviceamountDayResult">
        <result property="objid"    column="objid"    />
        <result property="deviceId"    column="device_id"    />
        <result property="deviceName"    column="device_name"    />
        <result property="realAmount"    column="real_amount"    />
        <result property="unitId"    column="unit_id"    />
        <result property="recordtime"    column="recordtime"    />
    </resultMap>

    <sql id="selectRecordDeviceamountDayVo">
        select objid, device_id, device_name, real_amount, unit_id, recordtime from record_deviceamount_day
    </sql>

    <select id="selectRecordDeviceamountDayList" parameterType="RecordDeviceamountDay" resultMap="RecordDeviceamountDayResult">
        <include refid="selectRecordDeviceamountDayVo"/>
        <where>
            <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId}</if>
            <if test="deviceName != null  and deviceName != ''"> and device_name like ('%' + #{deviceName} + '%')</if>
            <if test="recordtime != null "> and recordtime = #{recordtime}</if>
        </where>
    </select>

    <select id="selectRecordDeviceamountDayById" parameterType="Long" resultMap="RecordDeviceamountDayResult">
        <include refid="selectRecordDeviceamountDayVo"/>
        where objid = #{objid}
    </select>

    <insert id="insertRecordDeviceamountDay" parameterType="RecordDeviceamountDay">
        insert into record_deviceamount_day
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="objid != null">objid,</if>
            <if test="deviceId != null">device_id,</if>
            <if test="deviceName != null">device_name,</if>
            <if test="realAmount != null">real_amount,</if>
            <if test="unitId != null">unit_id,</if>
            <if test="recordtime != null">recordtime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="objid != null">#{objid},</if>
            <if test="deviceId != null">#{deviceId},</if>
            <if test="deviceName != null">#{deviceName},</if>
            <if test="realAmount != null">#{realAmount},</if>
            <if test="unitId != null">#{unitId},</if>
            <if test="recordtime != null">#{recordtime},</if>
         </trim>
    </insert>

    <update id="updateRecordDeviceamountDay" parameterType="RecordDeviceamountDay">
        update record_deviceamount_day
        <trim prefix="SET" suffixOverrides=",">
            <if test="deviceId != null">device_id = #{deviceId},</if>
            <if test="deviceName != null">device_name = #{deviceName},</if>
            <if test="realAmount != null">real_amount = #{realAmount},</if>
            <if test="unitId != null">unit_id = #{unitId},</if>
            <if test="recordtime != null">recordtime = #{recordtime},</if>
        </trim>
        where objid = #{objid}
    </update>

    <delete id="deleteRecordDeviceamountDayById" parameterType="Long">
        delete from record_deviceamount_day where objid = #{objid}
    </delete>

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

</mapper>
