优化95值计算单位、实际流量保留两位小数
This commit is contained in:
+2
-2
@@ -232,12 +232,12 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
Map<String, Function<InitialBandwidthTraffic, ?>> extractors = new LinkedHashMap<>();
|
||||
extractors.put("netInSpeedData", info ->
|
||||
info != null && info.getInSpeed() != null ?
|
||||
new BigDecimal(info.getInSpeed()).divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
new BigDecimal(info.getInSpeed()).divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
|
||||
extractors.put("netOutSpeedData", info ->
|
||||
info != null && info.getOutSpeed() != null ?
|
||||
new BigDecimal(info.getOutSpeed()).divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
new BigDecimal(info.getOutSpeed()).divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, InitialBandwidthTraffic::getCreateTime, extractors);
|
||||
resultMap.put("unit", unit);
|
||||
|
||||
+2
-2
@@ -156,12 +156,12 @@ public class InitialSwitchInfoServiceImpl implements IInitialSwitchInfoService
|
||||
Map<String, Function<InitialSwitchInfo, ?>> extractors = new LinkedHashMap<>();
|
||||
extractors.put("netInSpeedData", info ->
|
||||
info != null && info.getInSpeed() != null ?
|
||||
info.getInSpeed().divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
info.getInSpeed().divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
|
||||
extractors.put("netOutSpeedData", info ->
|
||||
info != null && info.getOutSpeed() != null ?
|
||||
info.getOutSpeed().divide(divisor, 0, RoundingMode.HALF_UP) :
|
||||
info.getOutSpeed().divide(divisor, 2, RoundingMode.HALF_UP) :
|
||||
0);
|
||||
Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, InitialSwitchInfo::getCreateTime, extractors);
|
||||
resultMap.put("unit", unit);
|
||||
|
||||
+6
-2
@@ -157,8 +157,12 @@ public class ProcessSwitchCollectDataService {
|
||||
long millis = timestamp * 1000;
|
||||
Date createTime = new Date(millis / 1000 * 1000); // 去除毫秒
|
||||
String timeStr = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",createTime);
|
||||
// 创建比timestamp少5分钟的时间
|
||||
long fiveMinutesEarlier = millis - (5 * 60 * 1000); // 减去5分钟的毫秒数
|
||||
Date fiveMinutesEarlierDate = new Date(fiveMinutesEarlier / 1000 * 1000); // 同样去除毫秒
|
||||
// 查询临时表信息,计算实际流量值
|
||||
InitialSwitchInfoTemp temp = new InitialSwitchInfoTemp();
|
||||
temp.setCreateTime(fiveMinutesEarlierDate);
|
||||
temp.setClientId(clientId);
|
||||
List<InitialSwitchInfoTemp> tempList = initialSwitchInfoTempService.selectInitialSwitchInfoTempList(temp);
|
||||
if(!tempList.isEmpty()){
|
||||
@@ -197,6 +201,8 @@ public class ProcessSwitchCollectDataService {
|
||||
}
|
||||
}
|
||||
});
|
||||
// 清空临时表对应switch信息
|
||||
initialSwitchInfoTempService.truncateSwitchInfoTemp(clientId);
|
||||
}else{
|
||||
switchInfos.forEach(switchInfo -> {
|
||||
switchInfo.setClientId(clientId);
|
||||
@@ -204,8 +210,6 @@ public class ProcessSwitchCollectDataService {
|
||||
switchInfo.setSwitchIp(switchDataVo.getSwitchIp());
|
||||
});
|
||||
}
|
||||
// 清空临时表对应switch信息
|
||||
initialSwitchInfoTempService.truncateSwitchInfoTemp(clientId);
|
||||
// 临时表 用来计算inSpeed outSeppd
|
||||
initialSwitchInfoTempService.batchInsertInitialSwitchInfoTemp(switchInfos);
|
||||
// 初始交换机数据入库
|
||||
|
||||
@@ -134,6 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="name != null and name != ''"> and name = #{name}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
limit 1
|
||||
</select>
|
||||
<select id="getNetTrafficList" parameterType="InitialBandwidthTraffic" resultMap="InitialBandwidthTrafficResult">
|
||||
|
||||
@@ -182,6 +182,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="getCpuInfoByClientId" parameterType="String" resultMap="InitialCpuInfoResult">
|
||||
<include refid="selectInitialCpuInfoVo"/>
|
||||
where client_id = #{clientId}
|
||||
order by create_time desc
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -169,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="getDistDetailsMsgByClientId" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
|
||||
<include refid="selectInitialDiskInfoVo"/>
|
||||
where client_id = #{clientId} and `name`= #{name}
|
||||
order by create_time desc
|
||||
limit 1
|
||||
</select>
|
||||
<select id="getAllDistName" parameterType="String" resultType="java.util.Map">
|
||||
|
||||
@@ -144,6 +144,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="mount != null and mount != ''"> and mount = #{mount}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
limit 1
|
||||
</select>
|
||||
<select id="getAllMountName" parameterType="String" resultType="java.util.Map">
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<if test="ifOutDiscards != null "> and if_out_discards = #{ifOutDiscards}</if>
|
||||
<if test="ifInErrors != null "> and if_in_errors = #{ifInErrors}</if>
|
||||
<if test="ifOutErrors != null "> and if_out_errors = #{ifOutErrors}</if>
|
||||
<if test="createTime != null "> and create_time = #{createTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user