初始流量数据库读取mq入库

This commit is contained in:
gaoyutao
2025-08-21 18:29:22 +08:00
parent 80dbba70fe
commit 34049d1c78
30 changed files with 912 additions and 446 deletions
@@ -3,113 +3,125 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.rocketmq.mapper.InitialBandwidthTrafficMapper">
<resultMap type="InitialBandwidthTraffic" id="InitialBandwidthTrafficResult">
<result property="id" column="id" />
<result property="interfaceName" column="interface_name" />
<result property="macAddress" column="mac_address" />
<result property="operationStatus" column="operation_status" />
<result property="interfaceType" column="interface_type" />
<result property="ipv4Address" column="ipv4_address" />
<result property="inboundPacketLoss" column="inbound_packet_loss" />
<result property="outboundPacketLoss" column="outbound_packet_loss" />
<result property="receiveBandwidth" column="receive_bandwidth" />
<result property="sendBandwidth" column="send_bandwidth" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="mac" column="mac"/>
<result property="status" column="status"/>
<result property="type" column="type"/>
<result property="ipV4" column="ipV4"/>
<result property="inDropped" column="in_dropped"/>
<result property="outDropped" column="out_dropped"/>
<result property="inSpeed" column="in_speed"/>
<result property="outSpeed" column="out_speed"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="clientId" column="client_id"/>
</resultMap>
<sql id="selectInitialBandwidthTrafficVo">
select id, interface_name, mac_address, operation_status, interface_type, ipv4_address, inbound_packet_loss, outbound_packet_loss, receive_bandwidth, send_bandwidth, create_time, update_time, create_by, update_by from initial_bandwidth_traffic
</sql>
<sql id="selectInitialBandwidthTrafficVo"> select id, name, mac, status, type, ipV4, in_dropped, out_dropped, in_speed, out_speed, create_time, update_time, create_by, update_by, client_id from initial_bandwidth_traffic </sql>
<select id="selectInitialBandwidthTrafficList" parameterType="InitialBandwidthTraffic" resultMap="InitialBandwidthTrafficResult">
<include refid="selectInitialBandwidthTrafficVo"/>
<where>
<if test="interfaceName != null and interfaceName != ''"> and interface_name = #{interfaceName}</if>
<if test="macAddress != null and macAddress != ''"> and mac_address = #{macAddress}</if>
<if test="operationStatus != null and operationStatus != ''"> and operation_status = #{operationStatus}</if>
<if test="interfaceType != null and interfaceType != ''"> and interface_type = #{interfaceType}</if>
<if test="ipv4Address != null and ipv4Address != ''"> and ipv4_address = #{ipv4Address}</if>
<if test="inboundPacketLoss != null "> and inbound_packet_loss = #{inboundPacketLoss}</if>
<if test="outboundPacketLoss != null "> and outbound_packet_loss = #{outboundPacketLoss}</if>
<if test="receiveBandwidth != null "> and receive_bandwidth = #{receiveBandwidth}</if>
<if test="sendBandwidth != null "> and send_bandwidth = #{sendBandwidth}</if>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="mac != null and mac != ''"> and mac = #{mac}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="ipV4 != null and ipV4 != ''"> and ipV4 = #{ipV4}</if>
<if test="inDropped != null "> and in_dropped = #{inDropped}</if>
<if test="outDropped != null "> and out_dropped = #{outDropped}</if>
<if test="inSpeed != null and inSpeed != ''"> and in_speed = #{inSpeed}</if>
<if test="outSpeed != null and outSpeed != ''"> and out_speed = #{outSpeed}</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
</where>
</select>
<select id="selectInitialBandwidthTrafficById" parameterType="Long" resultMap="InitialBandwidthTrafficResult">
<include refid="selectInitialBandwidthTrafficVo"/>
where id = #{id}
</select>
<insert id="insertInitialBandwidthTraffic" parameterType="InitialBandwidthTraffic">
<insert id="insertInitialBandwidthTraffic" parameterType="InitialBandwidthTraffic" useGeneratedKeys="true" keyProperty="id">
insert into initial_bandwidth_traffic
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="interfaceName != null">interface_name,</if>
<if test="macAddress != null">mac_address,</if>
<if test="operationStatus != null">operation_status,</if>
<if test="interfaceType != null">interface_type,</if>
<if test="ipv4Address != null">ipv4_address,</if>
<if test="inboundPacketLoss != null">inbound_packet_loss,</if>
<if test="outboundPacketLoss != null">outbound_packet_loss,</if>
<if test="receiveBandwidth != null">receive_bandwidth,</if>
<if test="sendBandwidth != null">send_bandwidth,</if>
<if test="name != null">name,</if>
<if test="mac != null">mac,</if>
<if test="status != null">status,</if>
<if test="type != null">type,</if>
<if test="ipV4 != null">ipV4,</if>
<if test="inDropped != null">in_dropped,</if>
<if test="outDropped != null">out_dropped,</if>
<if test="inSpeed != null">in_speed,</if>
<if test="outSpeed != null">out_speed,</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>
<if test="clientId != null">client_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="interfaceName != null">#{interfaceName},</if>
<if test="macAddress != null">#{macAddress},</if>
<if test="operationStatus != null">#{operationStatus},</if>
<if test="interfaceType != null">#{interfaceType},</if>
<if test="ipv4Address != null">#{ipv4Address},</if>
<if test="inboundPacketLoss != null">#{inboundPacketLoss},</if>
<if test="outboundPacketLoss != null">#{outboundPacketLoss},</if>
<if test="receiveBandwidth != null">#{receiveBandwidth},</if>
<if test="sendBandwidth != null">#{sendBandwidth},</if>
<if test="name != null">#{name},</if>
<if test="mac != null">#{mac},</if>
<if test="status != null">#{status},</if>
<if test="type != null">#{type},</if>
<if test="ipV4 != null">#{ipV4},</if>
<if test="inDropped != null">#{inDropped},</if>
<if test="outDropped != null">#{outDropped},</if>
<if test="inSpeed != null">#{inSpeed},</if>
<if test="outSpeed != null">#{outSpeed},</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>
<if test="clientId != null">#{clientId},</if>
</trim>
</insert>
<update id="updateInitialBandwidthTraffic" parameterType="InitialBandwidthTraffic">
update initial_bandwidth_traffic
<trim prefix="SET" suffixOverrides=",">
<if test="interfaceName != null">interface_name = #{interfaceName},</if>
<if test="macAddress != null">mac_address = #{macAddress},</if>
<if test="operationStatus != null">operation_status = #{operationStatus},</if>
<if test="interfaceType != null">interface_type = #{interfaceType},</if>
<if test="ipv4Address != null">ipv4_address = #{ipv4Address},</if>
<if test="inboundPacketLoss != null">inbound_packet_loss = #{inboundPacketLoss},</if>
<if test="outboundPacketLoss != null">outbound_packet_loss = #{outboundPacketLoss},</if>
<if test="receiveBandwidth != null">receive_bandwidth = #{receiveBandwidth},</if>
<if test="sendBandwidth != null">send_bandwidth = #{sendBandwidth},</if>
<if test="name != null">name = #{name},</if>
<if test="mac != null">mac = #{mac},</if>
<if test="status != null">status = #{status},</if>
<if test="type != null">type = #{type},</if>
<if test="ipV4 != null">ipV4 = #{ipV4},</if>
<if test="inDropped != null">in_dropped = #{inDropped},</if>
<if test="outDropped != null">out_dropped = #{outDropped},</if>
<if test="inSpeed != null">in_speed = #{inSpeed},</if>
<if test="outSpeed != null">out_speed = #{outSpeed},</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>
<if test="clientId != null">client_id = #{clientId},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteInitialBandwidthTrafficById" parameterType="Long">
delete from initial_bandwidth_traffic where id = #{id}
</delete>
<delete id="deleteInitialBandwidthTrafficById" parameterType="Long"> delete from initial_bandwidth_traffic where id = #{id} </delete>
<delete id="deleteInitialBandwidthTrafficByIds" parameterType="String">
delete from initial_bandwidth_traffic where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
delete from initial_bandwidth_traffic where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach>
</delete>
<!-- 单条插入 -->
<insert id="insert" parameterType="InitialBandwidthTraffic">
INSERT INTO ${tableName} (
`name`, `mac`, `status`, `type`, ipV4, `in_dropped`, `out_dropped`,
`in_speed`, `out_speed`, create_by, update_by, client_id
) VALUES (
#{name}, #{mac}, #{status}, #{type}, #{ipV4}, #{inDropped}, #{outDropped},
#{inSpeed}, #{outSpeed}, #{createBy}, #{updateBy}, #{clientId}
)
</insert>
<insert id="batchInsert" parameterType="InitialBandwidthTraffic">
INSERT INTO ${tableName} (
`name`, `mac`, `status`, `type`, ipV4, `in_dropped`, `out_dropped`,
`in_speed`, `out_speed`,create_by, update_by, client_id
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.name}, #{item.mac}, #{item.status}, #{item.type}, #{item.ipV4}, #{item.inDropped}, #{item.outDropped},
#{item.inSpeed}, #{item.outSpeed}, #{item.createBy}, #{item.updateBy}, #{item.clientId}
)
</foreach>
</insert>
</mapper>