优化实时95值计算流量科学计数法、服务器底层流量所有业务网卡流量求和

This commit is contained in:
gaoyutao
2025-11-11 10:55:21 +08:00
parent 80533dc1a3
commit 5c3b6df591
2 changed files with 46 additions and 41 deletions
@@ -87,12 +87,14 @@ public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
taskStatistics.setTimeRange(timeRange);
// 处理包含资源
String resources = taskStatistics.getIncludedResources();
String result = Arrays.stream(resources.split(","))
.map(msg -> msg.split(";"))
.filter(resource -> resource.length >= 4)
.map(resource -> "[" + resource[3] + "].[" + resource[2] + "]")
.collect(Collectors.joining("\n"));
taskStatistics.setIncludedResources(result);
if("2".equals(taskStatistics.getResourceType())){
String result = Arrays.stream(resources.split(","))
.map(msg -> msg.split(";"))
.filter(resource -> resource.length >= 4)
.map(resource -> "[" + resource[3] + "].[" + resource[2] + "]")
.collect(Collectors.joining("\n"));
taskStatistics.setIncludedResources(result);
}
}
return epsTaskStatisticsList;
}
@@ -181,54 +181,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 条件查询 -->
<select id="selectByCondition" resultType="EpsInitialTrafficData">
SELECT
id,
`name` AS name,
`mac` AS mac,
`status` AS status,
`type` AS type,
`ipV4` AS ipV4,
`in_dropped` AS inDropped,
`out_dropped` AS outDropped,
CAST(sum(ifnull(`in_speed`,0)) AS DECIMAL(20,0)) AS inSpeed,
CAST(sum(ifnull(`out_speed`,0)) AS DECIMAL(20,0)) AS outSpeed,
CAST(sum(ifnull(`total_in_speed`,0)) AS DECIMAL(20,0)) AS totalInSpeed,
CAST(sum(ifnull(`total_out_speed`,0)) AS DECIMAL(20,0)) AS totalOutSpeed,
`machine_flow` AS machineFlow,
`speed` AS speed,
`duplex` AS duplex,
business_id AS businessId,
business_name AS businessName,
service_sn AS serviceSn,
node_name AS nodeName,
revenue_method AS revenueMethod,
package_bandwidth AS packageBandwidth,
create_time AS createTime,
update_time AS updateTime,
create_by AS createBy,
update_by AS updateBy,
client_id AS clientId
FROM ${tableName}
a.id,
a.`name` AS name,
a.`mac` AS mac,
a.`status` AS status,
a.`type` AS type,
a.`ipV4` AS ipV4,
a.`in_dropped` AS inDropped,
a.`out_dropped` AS outDropped,
CAST(sum(ifnull(a.`in_speed`,0)) AS DECIMAL(20,0)) AS inSpeed,
CAST(sum(ifnull(a.`out_speed`,0)) AS DECIMAL(20,0)) AS outSpeed,
CAST(sum(ifnull(a.`total_in_speed`,0)) AS DECIMAL(20,0)) AS totalInSpeed,
CAST(sum(ifnull(a.`total_out_speed`,0)) AS DECIMAL(20,0)) AS totalOutSpeed,
a.`machine_flow` AS machineFlow,
a.`speed` AS speed,
a.`duplex` AS duplex,
a.business_id AS businessId,
a.business_name AS businessName,
a.service_sn AS serviceSn,
a.node_name AS nodeName,
a.revenue_method AS revenueMethod,
a.package_bandwidth AS packageBandwidth,
a.create_time AS createTime,
a.update_time AS updateTime,
a.create_by AS createBy,
a.update_by AS updateBy,
a.client_id AS clientId
FROM ${tableName} a
INNER JOIN rm_network_interface b ON a.client_id = b.client_id and and a.mac=b.mac_address
AND (b.bind_ip = 1 OR b.bind_ip = 3)
AND b.new_flag = 1
<where>
<if test="serviceSn != '' and serviceSn != null">
and service_sn = #{serviceSn}
and a.service_sn = #{serviceSn}
</if>
<if test="businessId != '' and businessId != null">
and business_id = #{businessId}
and a.business_id = #{businessId}
</if>
<if test="clientId != '' and clientId != null">
and client_id = #{clientId}
and a.client_id = #{clientId}
</if>
<if test="startTime != null">
and create_time &gt;= #{startTime}
and a.create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and create_time &lt;= #{endTime}
and a.create_time &lt;= #{endTime}
</if>
<if test="revenueMethod != null">
and revenue_method = #{revenueMethod}
and a.revenue_method = #{revenueMethod}
</if>
</where>
group BY create_time desc
GROUP BY a.create_time DESC
</select>
<!-- 条件查询 -->
@@ -270,7 +273,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getTrafficListByClientIds" resultType="EpsInitialTrafficData">
SELECT
sum(ifnull(out_speed,0)) AS outSpeed,
CAST(sum(ifnull(out_speed,0)) AS DECIMAL(20,0)) AS outSpeed,
create_time AS createTime
FROM ${tableName}
<where>