修改入库bug 资源管理模块bug

This commit is contained in:
gaoyutao
2025-09-02 19:54:54 +08:00
parent 05e57a2fe7
commit 4dd9324dba
24 changed files with 315 additions and 724 deletions
@@ -337,9 +337,14 @@ public class RocketMsgListener implements MessageListenerConcurrently {
}
}
});
}else{
switchInfos.forEach(switchInfo -> {
switchInfo.setClientId(message.getClientId());
switchInfo.setCreateTime(createTime);
});
}
// 清空临时表
initialSwitchInfoTempService.truncateSwitchInfoTemp();
// 清空临时表对应switch信息
initialSwitchInfoTempService.truncateSwitchInfoTemp(message.getClientId());
// 临时表 用来计算inSpeed outSeppd
initialSwitchInfoTempService.batchInsertInitialSwitchInfoTemp(switchInfos);
// 初始交换机数据入库
@@ -39,6 +39,8 @@ public class InitialSwitchInfo extends BaseEntity
private BigDecimal inSpeed;
/** 发送流量(bytes/s) */
private BigDecimal outSpeed;
/** 交换机ip */
private String switchIp;
}
@@ -1,10 +1,10 @@
package com.ruoyi.rocketmq.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.math.BigDecimal;
/**
* 交换机监控信息对象 initial_switch_info_temp
@@ -12,6 +12,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
* @author gyt
* @date 2025-08-26
*/
@Data
public class InitialSwitchInfoTemp extends BaseEntity
{
private static final long serialVersionUID = 1L;
@@ -50,113 +51,6 @@ public class InitialSwitchInfoTemp extends BaseEntity
/** 发送流量(bytes/s */
@Excel(name = "发送流量", readConverterExp = "b=ytes/s")
private BigDecimal outSpeed;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setInBytes(BigDecimal inBytes)
{
this.inBytes = inBytes;
}
public BigDecimal getInBytes()
{
return inBytes;
}
public void setOutBytes(BigDecimal outBytes)
{
this.outBytes = outBytes;
}
public BigDecimal getOutBytes()
{
return outBytes;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setInSpeed(BigDecimal inSpeed)
{
this.inSpeed = inSpeed;
}
public BigDecimal getInSpeed()
{
return inSpeed;
}
public void setOutSpeed(BigDecimal outSpeed)
{
this.outSpeed = outSpeed;
}
public BigDecimal getOutSpeed()
{
return outSpeed;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("clientId", getClientId())
.append("name", getName())
.append("inBytes", getInBytes())
.append("outBytes", getOutBytes())
.append("status", getStatus())
.append("type", getType())
.append("inSpeed", getInSpeed())
.append("outSpeed", getOutSpeed())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
/** 交换机ip */
private String switchIp;
}
@@ -69,5 +69,5 @@ public interface InitialSwitchInfoTempMapper
*/
public int batchInsertInitialSwitchInfoTemp(@Param("list") List<InitialSwitchInfo> list);
void truncateSwitchInfoTemp();
void truncateSwitchInfoTemp(String clientId);
}
@@ -69,5 +69,5 @@ public interface IInitialSwitchInfoTempService
*/
public int batchInsertInitialSwitchInfoTemp(List<InitialSwitchInfo> list);
void truncateSwitchInfoTemp();
void truncateSwitchInfoTemp(String clientId);
}
@@ -116,7 +116,7 @@ public class InitialSwitchInfoTempServiceImpl implements IInitialSwitchInfoTempS
}
@Override
public void truncateSwitchInfoTemp() {
initialSwitchInfoTempMapper.truncateSwitchInfoTemp();
public void truncateSwitchInfoTemp(String clientId) {
initialSwitchInfoTempMapper.truncateSwitchInfoTemp(clientId);
}
}
@@ -5,51 +5,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.rocketmq.mapper.InitialSwitchInfoMapper">
<resultMap type="InitialSwitchInfo" id="InitialSwitchInfoResult">
<id property="id" column="id"/>
<result property="clientId" column="client_id"/>
<result property="name" column="name"/>
<result property="inBytes" column="in_bytes"/>
<result property="outBytes" column="out_bytes"/>
<result property="status" column="status"/>
<result property="type" column="type"/>
<result property="inSpeed" column="in_speed"/>
<result property="outSpeed" column="out_speed"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="name" column="name" />
<result property="inBytes" column="in_bytes" />
<result property="outBytes" column="out_bytes" />
<result property="status" column="status" />
<result property="type" column="type" />
<result property="inSpeed" column="in_speed" />
<result property="outSpeed" column="out_speed" />
<result property="switchIp" column="switch_ip" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectInitialSwitchInfoVo">
SELECT
id, client_id, `name`, in_bytes, out_bytes, status, `type`,
in_speed, out_speed, create_by, update_by, create_time, update_time
FROM initial_switch_info
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, switch_ip, create_by, update_by, create_time, update_time from initial_switch_info
</sql>
<select id="selectInitialSwitchInfoList" parameterType="InitialSwitchInfo" resultMap="InitialSwitchInfoResult">
<include refid="selectInitialSwitchInfoVo"/>
<where>
<if test="clientId != null and clientId != ''">
AND client_id = #{clientId}
</if>
<if test="name != null and name != ''">
AND name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="type != null and type != ''">
AND type = #{type}
</if>
<if test="params.beginTime != null and params.beginTime != ''">
AND create_time &gt;= #{params.beginTime}
</if>
<if test="params.endTime != null and params.endTime != ''">
AND create_time &lt;= #{params.endTime}
</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="inBytes != null "> and in_bytes = #{inBytes}</if>
<if test="outBytes != null "> and out_bytes = #{outBytes}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="inSpeed != null "> and in_speed = #{inSpeed}</if>
<if test="outSpeed != null "> and out_speed = #{outSpeed}</if>
<if test="switchIp != null and switchIp != ''"> and switch_ip = #{switchIp}</if>
</where>
ORDER BY create_time DESC
</select>
<select id="selectInitialSwitchInfoById" parameterType="Long" resultMap="InitialSwitchInfoResult">
@@ -58,52 +46,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertInitialSwitchInfo" parameterType="InitialSwitchInfo" useGeneratedKeys="true" keyProperty="id">
INSERT INTO initial_switch_info
insert into initial_switch_info
<trim prefix="(" suffix=")" suffixOverrides=",">
client_id,
<if test="name != null">name,</if>
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="inBytes != null">in_bytes,</if>
<if test="outBytes != null">out_bytes,</if>
<if test="status != null">status,</if>
<if test="type != null">type,</if>
<if test="inSpeed != null">in_speed,</if>
<if test="outSeppd != null">out_speed,</if>
<if test="outSpeed != null">out_speed,</if>
<if test="switchIp != null and switchIp != ''">switch_ip,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
create_time,
update_time
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
#{clientId},
<if test="name != null">#{name},</if>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="inBytes != null">#{inBytes},</if>
<if test="outBytes != null">#{outBytes},</if>
<if test="status != null">#{status},</if>
<if test="type != null">#{type},</if>
<if test="inSpeed != null">#{inSpeed},</if>
<if test="outSeppd != null">#{outSpeed},</if>
<if test="outSpeed != null">#{outSpeed},</if>
<if test="switchIp != null and switchIp != ''">#{switchIp},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
NOW(),
NOW()
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateInitialSwitchInfo" parameterType="InitialSwitchInfo">
UPDATE initial_switch_info
<set>
<if test="clientId != null">client_id = #{clientId},</if>
<if test="name != null">name = #{name},</if>
update initial_switch_info
<trim prefix="SET" suffixOverrides=",">
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="inBytes != null">in_bytes = #{inBytes},</if>
<if test="outBytes != null">out_bytes = #{outBytes},</if>
<if test="status != null">status = #{status},</if>
<if test="type != null">type = #{type},</if>
<if test="inSpeed != null">in_speed = #{inSpeed}</if>
<if test="outSeppd != null">out_speed = #{outSpeed}</if>
<if test="inSpeed != null">in_speed = #{inSpeed},</if>
<if test="outSpeed != null">out_speed = #{outSpeed},</if>
<if test="switchIp != null and switchIp != ''">switch_ip = #{switchIp},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
update_time = NOW()
</set>
WHERE id = #{id}
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteInitialSwitchInfoById" parameterType="Long">
@@ -120,14 +113,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsertInitialSwitchInfo" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
INSERT INTO initial_switch_info
(
client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed,
client_id, `name`, in_bytes, out_bytes, status, `type`, in_speed, out_speed, switch_ip,
create_by, update_by, create_time, update_time
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.clientId}, #{item.name}, #{item.inBytes}, #{item.outBytes},
#{item.status}, #{item.type}, #{item.inSpeed}, #{item.outSpeed}, #{item.createBy}, #{item.updateBy},
#{item.status}, #{item.type}, #{item.inSpeed}, #{item.outSpeed}, #{item.switchIp}, #{item.createBy}, #{item.updateBy},
<choose>
<when test="item.createTime != null">
#{item.createTime}
@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.rocketmq.mapper.InitialSwitchInfoTempMapper">
<resultMap type="InitialSwitchInfoTemp" id="InitialSwitchInfoTempResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="type" column="type" />
<result property="inSpeed" column="in_speed" />
<result property="outSpeed" column="out_speed" />
<result property="switchIp" column="switch_ip" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="createTime" column="create_time" />
@@ -21,12 +22,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectInitialSwitchInfoTempVo">
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, create_by, update_by, create_time, update_time from initial_switch_info_temp
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, switch_ip, create_by, update_by, create_time, update_time from initial_switch_info_temp
</sql>
<select id="selectInitialSwitchInfoTempList" parameterType="InitialSwitchInfoTemp" resultMap="InitialSwitchInfoTempResult">
<include refid="selectInitialSwitchInfoTempVo"/>
<where>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="inBytes != null "> and in_bytes = #{inBytes}</if>
@@ -35,9 +36,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="inSpeed != null "> and in_speed = #{inSpeed}</if>
<if test="outSpeed != null "> and out_speed = #{outSpeed}</if>
<if test="switchIp != null and switchIp != ''"> and switch_ip = #{switchIp}</if>
</where>
</select>
<select id="selectInitialSwitchInfoTempById" parameterType="Long" resultMap="InitialSwitchInfoTempResult">
<include refid="selectInitialSwitchInfoTempVo"/>
where id = #{id}
@@ -54,11 +56,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null">type,</if>
<if test="inSpeed != null">in_speed,</if>
<if test="outSpeed != null">out_speed,</if>
<if test="switchIp != null">switch_ip,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="name != null and name != ''">#{name},</if>
@@ -68,11 +71,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null">#{type},</if>
<if test="inSpeed != null">#{inSpeed},</if>
<if test="outSpeed != null">#{outSpeed},</if>
<if test="switchIp != null">#{switchIp},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</trim>
</insert>
<update id="updateInitialSwitchInfoTemp" parameterType="InitialSwitchInfoTemp">
@@ -86,6 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null">type = #{type},</if>
<if test="inSpeed != null">in_speed = #{inSpeed},</if>
<if test="outSpeed != null">out_speed = #{outSpeed},</if>
<if test="switchIp != null">switch_ip = #{switchIp},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
@@ -99,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteInitialSwitchInfoTempByIds" parameterType="String">
delete from initial_switch_info_temp where id in
delete from initial_switch_info_temp where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
@@ -107,14 +112,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsertInitialSwitchInfoTemp" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
INSERT INTO initial_switch_info_temp
(
client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed,
client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, switch_ip,
create_by, update_by, create_time, update_time
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.clientId}, #{item.name}, #{item.inBytes}, #{item.outBytes},
#{item.status}, #{item.type}, #{item.inSpeed}, #{item.outSpeed}, #{item.createBy}, #{item.updateBy},
#{item.status}, #{item.type}, #{item.inSpeed}, #{item.outSpeed}, #{item.switchIp}, #{item.createBy}, #{item.updateBy},
<choose>
<when test="item.createTime != null">
#{item.createTime}
@@ -134,7 +139,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</foreach>
</insert>
<update id="truncateSwitchInfoTemp">
truncate table initial_switch_info_temp
</update>
<delete id="truncateSwitchInfoTemp" parameterType="String">
DELETE FROM initial_switch_info_temp
WHERE
<choose>
<when test="clientId != null and clientId != ''">
client_id = #{clientId}
</when>
<otherwise>
1=0 <!-- 安全措施:条件不满足时不删除任何数据 -->
</otherwise>
</choose>
</delete>
</mapper>