Files
saas-houduan/tongran-rocketmq/src/main/resources/mapper/rocketmq/InitialSwitchOtherCollectDataMapper.xml
T
2025-12-24 19:55:47 +08:00

120 lines
6.6 KiB
XML

<?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.tongran.rocketmq.mapper.InitialSwitchOtherCollectDataMapper">
<resultMap type="InitialSwitchOtherCollectData" id="InitialSwitchOtherCollectDataResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="collectType" column="collect_type" />
<result property="collectValue" column="collect_value" />
<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="selectInitialSwitchOtherCollectDataVo">
select id, client_id, collect_type, collect_value, create_time, update_time, create_by, update_by from initial_switch_other_collect_data
</sql>
<select id="selectInitialSwitchOtherCollectDataList" parameterType="InitialSwitchOtherCollectData" resultMap="InitialSwitchOtherCollectDataResult">
<include refid="selectInitialSwitchOtherCollectDataVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="collectType != null and collectType != ''"> and collect_type = #{collectType}</if>
<if test="collectValue != null and collectValue != ''"> and collect_value = #{collectValue}</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="selectInitialSwitchOtherCollectDataById" parameterType="Long" resultMap="InitialSwitchOtherCollectDataResult">
<include refid="selectInitialSwitchOtherCollectDataVo"/>
where id = #{id}
</select>
<insert id="insertInitialSwitchOtherCollectData" parameterType="InitialSwitchOtherCollectData" useGeneratedKeys="true" keyProperty="id">
insert IGNORE into initial_switch_other_collect_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="collectType != null and collectType != ''">collect_type,</if>
<if test="collectValue != null">collect_value,</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="clientId != null and clientId != ''">#{clientId},</if>
<if test="collectType != null and collectType != ''">#{collectType},</if>
<if test="collectValue != null">#{collectValue},</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="updateInitialSwitchOtherCollectData" parameterType="InitialSwitchOtherCollectData">
update initial_switch_other_collect_data
<trim prefix="SET" suffixOverrides=",">
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
<if test="collectType != null and collectType != ''">collect_type = #{collectType},</if>
<if test="collectValue != null">collect_value = #{collectValue},</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="deleteInitialSwitchOtherCollectDataById" parameterType="Long">
delete from initial_switch_other_collect_data where id = #{id}
</delete>
<delete id="deleteInitialSwitchOtherCollectDataByIds" parameterType="String">
delete from initial_switch_other_collect_data where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getSwitchMonitorMsg" parameterType="InitialSwitchOtherCollectData" resultType="java.util.Map">
SELECT
MAX(CASE WHEN t.collect_type = 'sysDescr' THEN t.collect_value END) as sysDescr,
MAX(CASE WHEN t.collect_type = 'sysObjectID' THEN t.collect_value END) as sysObjectID,
MAX(CASE WHEN t.collect_type = 'sysUpTime' THEN t.collect_value END) as sysUpTime,
MAX(CASE WHEN t.collect_type = 'sysContact' THEN t.collect_value END) as sysContact,
MAX(CASE WHEN t.collect_type = 'sysName' THEN t.collect_value END) as sysName,
MAX(CASE WHEN t.collect_type = 'sysLocation' THEN t.collect_value END) as sysLocation,
MAX(CASE WHEN t.collect_type = 'hwStackSystemMac' THEN t.collect_value END) as hwStackSystemMac,
MAX(CASE WHEN t.collect_type = 'entIndex' THEN t.collect_value END) as entIndex,
MAX(CASE WHEN t.collect_type = 'entPhysicalName' THEN t.collect_value END) as entPhysicalName,
MAX(CASE WHEN t.collect_type = 'entPhysicalSoftwareRev' THEN t.collect_value END) as entPhysicalSoftwareRev
FROM `initial_switch_other_collect_data` t
INNER JOIN (
SELECT collect_type, MAX(create_time) as max_time
FROM `initial_switch_other_collect_data`
WHERE client_id = #{clientId}
GROUP BY collect_type
) latest ON t.collect_type = latest.collect_type AND t.create_time = latest.max_time
WHERE t.client_id = #{clientId}
</select>
<delete id="deleteInitialSwitchOtherCollectData" parameterType="Long">
delete from initial_switch_other_collect_data
<where>
<choose>
<when test="clientId != null and collectType != null and createTime != null">
AND client_id = #{clientId}
AND collect_type = #{collectType}
AND create_time &lt; #{createTime}
</when>
<otherwise>
and 1=0
</otherwise>
</choose>
</where>
</delete>
</mapper>