<?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.rocketmq.mapper.InitialSwitchMpuInfoMapper">
    
    <resultMap type="InitialSwitchMpuInfo" id="InitialSwitchMpuInfoResult">
        <result property="id"    column="id"    />
        <result property="mpuEntIndex"    column="mpu_ent_index"    />
        <result property="mpuName"    column="mpu_name"    />
        <result property="mpuEntityCpuUsage"    column="mpu_entity_cpu_usage"    />
        <result property="mpuEntityMemUsage"    column="mpu_entity_mem_usage"    />
        <result property="mpuPhysicalSoftwareRev"    column="mpu_physical_software_rev"    />
        <result property="mpuEntityTemperature"    column="mpu_entity_temperature"    />
        <result property="clientId"    column="client_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectInitialSwitchMpuInfoVo">
        select id, mpu_ent_index, mpu_name, mpu_entity_cpu_usage, mpu_entity_mem_usage, mpu_physical_software_rev, mpu_entity_temperature, client_id, create_time, update_time, create_by, update_by from initial_switch_mpu_info
    </sql>

    <select id="selectInitialSwitchMpuInfoList" parameterType="InitialSwitchMpuInfo" resultMap="InitialSwitchMpuInfoResult">
        <include refid="selectInitialSwitchMpuInfoVo"/>
        <where>  
            <if test="mpuEntIndex != null  and mpuEntIndex != ''"> and mpu_ent_index = #{mpuEntIndex}</if>
            <if test="mpuName != null  and mpuName != ''"> and mpu_name like concat('%', #{mpuName}, '%')</if>
            <if test="mpuEntityCpuUsage != null "> and mpu_entity_cpu_usage = #{mpuEntityCpuUsage}</if>
            <if test="mpuEntityMemUsage != null "> and mpu_entity_mem_usage = #{mpuEntityMemUsage}</if>
            <if test="mpuPhysicalSoftwareRev != null  and mpuPhysicalSoftwareRev != ''"> and mpu_physical_software_rev = #{mpuPhysicalSoftwareRev}</if>
            <if test="mpuEntityTemperature != null "> and mpu_entity_temperature = #{mpuEntityTemperature}</if>
            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</if>
            <if test="startTime != null  and startTime != ''"> and create_time &gt;= #{startTime}</if>
            <if test="endTime != null  and endTime != ''"> and create_time &lt;= #{endTime}</if>
        </where>
    </select>
    
    <select id="selectInitialSwitchMpuInfoById" parameterType="Long" resultMap="InitialSwitchMpuInfoResult">
        <include refid="selectInitialSwitchMpuInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertInitialSwitchMpuInfo" parameterType="InitialSwitchMpuInfo" useGeneratedKeys="true" keyProperty="id">
        insert IGNORE into initial_switch_mpu_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="mpuEntIndex != null">mpu_ent_index,</if>
            <if test="mpuName != null">mpu_name,</if>
            <if test="mpuEntityCpuUsage != null">mpu_entity_cpu_usage,</if>
            <if test="mpuEntityMemUsage != null">mpu_entity_mem_usage,</if>
            <if test="mpuPhysicalSoftwareRev != null">mpu_physical_software_rev,</if>
            <if test="mpuEntityTemperature != null">mpu_entity_temperature,</if>
            <if test="clientId != null">client_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="mpuEntIndex != null">#{mpuEntIndex},</if>
            <if test="mpuName != null">#{mpuName},</if>
            <if test="mpuEntityCpuUsage != null">#{mpuEntityCpuUsage},</if>
            <if test="mpuEntityMemUsage != null">#{mpuEntityMemUsage},</if>
            <if test="mpuPhysicalSoftwareRev != null">#{mpuPhysicalSoftwareRev},</if>
            <if test="mpuEntityTemperature != null">#{mpuEntityTemperature},</if>
            <if test="clientId != null">#{clientId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateInitialSwitchMpuInfo" parameterType="InitialSwitchMpuInfo">
        update initial_switch_mpu_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="mpuEntIndex != null">mpu_ent_index = #{mpuEntIndex},</if>
            <if test="mpuName != null">mpu_name = #{mpuName},</if>
            <if test="mpuEntityCpuUsage != null">mpu_entity_cpu_usage = #{mpuEntityCpuUsage},</if>
            <if test="mpuEntityMemUsage != null">mpu_entity_mem_usage = #{mpuEntityMemUsage},</if>
            <if test="mpuPhysicalSoftwareRev != null">mpu_physical_software_rev = #{mpuPhysicalSoftwareRev},</if>
            <if test="mpuEntityTemperature != null">mpu_entity_temperature = #{mpuEntityTemperature},</if>
            <if test="clientId != null">client_id = #{clientId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteInitialSwitchMpuInfoById" parameterType="Long">
        delete from initial_switch_mpu_info where id = #{id}
    </delete>

    <delete id="deleteInitialSwitchMpuInfoByIds" parameterType="String">
        delete from initial_switch_mpu_info where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <insert id="insertBatchInitialSwitchMpuInfo" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
        insert IGNORE into initial_switch_mpu_info
        (
        mpu_ent_index,
        mpu_name,
        mpu_entity_cpu_usage,
        mpu_entity_mem_usage,
        mpu_physical_software_rev,
        mpu_entity_temperature,
        client_id,
        create_time,
        update_time,
        create_by,
        update_by
        )
        values
        <foreach collection="list" item="item" separator=",">
            (
            #{item.mpuEntIndex},
            #{item.mpuName},
            #{item.mpuEntityCpuUsage},
            #{item.mpuEntityMemUsage},
            #{item.mpuPhysicalSoftwareRev},
            #{item.mpuEntityTemperature},
            #{item.clientId},
            #{item.createTime},
            #{item.updateTime},
            #{item.createBy},
            #{item.updateBy}
            )
        </foreach>
    </insert>
    <select id="getMpuMsg" parameterType="InitialSwitchMpuInfo" resultMap="InitialSwitchMpuInfoResult">
        <include refid="selectInitialSwitchMpuInfoVo"/>
        <where>
            <if test="mpuEntIndex != null  and mpuEntIndex != ''"> and mpu_ent_index = #{mpuEntIndex}</if>
            <if test="mpuName != null  and mpuName != ''"> and mpu_name like concat('%', #{mpuName}, '%')</if>
            <if test="mpuEntityCpuUsage != null "> and mpu_entity_cpu_usage = #{mpuEntityCpuUsage}</if>
            <if test="mpuEntityMemUsage != null "> and mpu_entity_mem_usage = #{mpuEntityMemUsage}</if>
            <if test="mpuPhysicalSoftwareRev != null  and mpuPhysicalSoftwareRev != ''"> and mpu_physical_software_rev = #{mpuPhysicalSoftwareRev}</if>
            <if test="mpuEntityTemperature != null "> and mpu_entity_temperature = #{mpuEntityTemperature}</if>
            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</if>
        </where>
        order by create_time desc limit 1
    </select>
    <select id="getAllMpuName" parameterType="InitialSwitchMpuInfo" resultType="java.util.Map">
        select mpu_name mpuName from initial_switch_mpu_info
        <where>
            <if test="mpuEntIndex != null  and mpuEntIndex != ''"> and mpu_ent_index = #{mpuEntIndex}</if>
            <if test="mpuName != null  and mpuName != ''"> and mpu_name like concat('%', #{mpuName}, '%')</if>
            <if test="mpuEntityCpuUsage != null "> and mpu_entity_cpu_usage = #{mpuEntityCpuUsage}</if>
            <if test="mpuEntityMemUsage != null "> and mpu_entity_mem_usage = #{mpuEntityMemUsage}</if>
            <if test="mpuPhysicalSoftwareRev != null  and mpuPhysicalSoftwareRev != ''"> and mpu_physical_software_rev = #{mpuPhysicalSoftwareRev}</if>
            <if test="mpuEntityTemperature != null "> and mpu_entity_temperature = #{mpuEntityTemperature}</if>
            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</if>
        </where>
        group by mpu_name
    </select>
</mapper>