<?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.record.mapper.RecordBusbarTempMapper">
    
    <resultMap type="RecordBusbarTemp" id="RecordBusbarTempResult">
        <result property="objId"    column="objId"    />
        <result property="busbarCode"    column="busbar_code"    />
        <result property="cabinetCode"    column="cabinet_code"    />
        <result property="tempMax"    column="temp_max"    />
        <result property="tempMin"    column="temp_min"    />
        <result property="tempAvg"    column="temp_avg"    />
        <result property="tempDiff"    column="temp_diff"    />
        <result property="isAlarm"    column="is_alarm"    />
        <result property="filePath"    column="file_path"    />
        <result property="isFlag"    column="is_flag"    />
        <result property="remark"    column="remark"    />
        <result property="createdBy"    column="created_by"    />
        <result property="createdTime"    column="created_time"    />
        <result property="updatedBy"    column="updated_by"    />
        <result property="updatedTime"    column="updated_time"    />
        <result property="recordTime"    column="record_time"    />
    </resultMap>

    <sql id="selectRecordBusbarTempVo">
        select objId,
               busbar_code,
               cabinet_code,
               temp_max, temp_min,
               temp_avg,
               temp_diff,
               is_alarm,
               file_path,
               is_flag,
               remark,
               created_by,
               created_time,
               updated_by,
               updated_time,
               record_time
        from record_busbar_temp
    </sql>

    <select id="selectRecordBusbarTempList" parameterType="RecordBusbarTemp" resultMap="RecordBusbarTempResult">
        <include refid="selectRecordBusbarTempVo"/>
        <where>  
            <if test="objId != null "> and objId = #{objId}</if>
            <if test="busbarCode != null "> and busbar_code = #{busbarCode}</if>
            <if test="cabinetCode != null "> and cabinet_code = #{cabinetCode}</if>
            <if test="tempMax != null "> and temp_max = #{tempMax}</if>
            <if test="tempMin != null "> and temp_min = #{tempMin}</if>
            <if test="tempAvg != null "> and temp_avg = #{tempAvg}</if>
            <if test="tempDiff != null "> and temp_diff = #{tempDiff}</if>
            <if test="isAlarm != null "> and is_alarm = #{isAlarm}</if>
            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
            <if test="isFlag != null "> and is_flag = #{isFlag}</if>
            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="params.beginCreatedTime != null and params.beginCreatedTime != '' and params.endCreatedTime != null and params.endCreatedTime != ''"> and created_time between #{params.beginCreatedTime} and #{params.endCreatedTime}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and updated_by = #{updatedBy}</if>
            <if test="params.beginUpdatedTime != null and params.beginUpdatedTime != '' and params.endUpdatedTime != null and params.endUpdatedTime != ''"> and updated_time between #{params.beginUpdatedTime} and #{params.endUpdatedTime}</if>
            <if test="params.beginRecordTime != null and params.beginRecordTime != '' and params.endRecordTime != null and params.endRecordTime != ''"> and record_time between #{params.beginRecordTime} and #{params.endRecordTime}</if>
        </where>
    </select>
    
    <select id="selectRecordBusbarTempByObjId" parameterType="Long" resultMap="RecordBusbarTempResult">
        <include refid="selectRecordBusbarTempVo"/>
        where objId = #{objId}
    </select>

    <insert id="insertRecordBusbarTemp" parameterType="RecordBusbarTemp" useGeneratedKeys="true" keyProperty="objId">
        insert into record_busbar_temp
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="busbarCode != null">busbar_code,</if>
            <if test="cabinetCode != null">cabinet_code,</if>
            <if test="tempMax != null">temp_max,</if>
            <if test="tempMin != null">temp_min,</if>
            <if test="tempAvg != null">temp_avg,</if>
            <if test="tempDiff != null">temp_diff,</if>
            <if test="isAlarm != null">is_alarm,</if>
            <if test="filePath != null">file_path,</if>
            <if test="isFlag != null">is_flag,</if>
            <if test="remark != null">remark,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="updatedBy != null">updated_by,</if>
            <if test="updatedTime != null">updated_time,</if>
            <if test="recordTime != null">record_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="busbarCode != null">#{busbarCode},</if>
            <if test="cabinetCode != null">#{cabinetCode},</if>
            <if test="tempMax != null">#{tempMax},</if>
            <if test="tempMin != null">#{tempMin},</if>
            <if test="tempAvg != null">#{tempAvg},</if>
            <if test="tempDiff != null">#{tempDiff},</if>
            <if test="isAlarm != null">#{isAlarm},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="isFlag != null">#{isFlag},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updatedBy != null">#{updatedBy},</if>
            <if test="updatedTime != null">#{updatedTime},</if>
            <if test="recordTime != null">#{recordTime},</if>
         </trim>
    </insert>

    <update id="updateRecordBusbarTemp" parameterType="RecordBusbarTemp">
        update record_busbar_temp
        <trim prefix="SET" suffixOverrides=",">
            <if test="busbarCode != null">busbar_code = #{busbarCode},</if>
            <if test="cabinetCode != null">cabinet_code = #{cabinetCode},</if>
            <if test="tempMax != null">temp_max = #{tempMax},</if>
            <if test="tempMin != null">temp_min = #{tempMin},</if>
            <if test="tempAvg != null">temp_avg = #{tempAvg},</if>
            <if test="tempDiff != null">temp_diff = #{tempDiff},</if>
            <if test="isAlarm != null">is_alarm = #{isAlarm},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
            <if test="isFlag != null">is_flag = #{isFlag},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
            <if test="updatedTime != null">updated_time = #{updatedTime},</if>
            <if test="recordTime != null">record_time = #{recordTime},</if>
        </trim>
        where objId = #{objId}
    </update>

    <delete id="deleteRecordBusbarTempByObjId" parameterType="Long">
        delete from record_busbar_temp where objId = #{objId}
    </delete>

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