解决查询条件默认生效问题,日95计算值覆盖问题。
This commit is contained in:
@@ -83,4 +83,6 @@ public interface EpsNodeBandwidthMapper
|
||||
public int countByAvgMsg(EpsNodeBandwidth epsNodeBandwidth);
|
||||
|
||||
int updateEpsNodeBandwidthByServerSn(EpsNodeBandwidth epsNodeBandwidth);
|
||||
|
||||
int updateEpsNodeBandwidthBySwitchSn(EpsNodeBandwidth epsNodeBandwidth);
|
||||
}
|
||||
|
||||
@@ -61,4 +61,6 @@ public interface RmEpsTopologyManagementMapper
|
||||
public int deleteRmEpsTopologyManagementByIds(Long[] ids);
|
||||
|
||||
int updateRmEpsTopologyManagementByServerSn(RmEpsTopologyManagement rmEpsTopologyManagement);
|
||||
|
||||
int updateRmEpsTopologyManagementBySwitchSn(RmEpsTopologyManagement rmEpsTopologyManagement);
|
||||
}
|
||||
|
||||
@@ -324,30 +324,44 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
* 计算并保存95带宽值
|
||||
*/
|
||||
private void calculateAndSave95Bandwidth(List<EpsInitialTrafficData> dataList, String dateTime, String dayOrMonth) {
|
||||
// 1. 提取并转换带宽值
|
||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||
.map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed()))
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 计算95百分位
|
||||
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
|
||||
|
||||
// 3. 保存结果
|
||||
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
|
||||
epsInitialTrafficData.setResourceType("1");
|
||||
if("2".equals(epsInitialTrafficData.getRevenueMethod())){
|
||||
percentile95 = epsInitialTrafficData.getPackageBandwidth();
|
||||
epsInitialTrafficData.setBandwidthType("3");
|
||||
}else {
|
||||
if("1".equals(dayOrMonth)){
|
||||
epsInitialTrafficData.setBandwidthType("1");
|
||||
boolean eff = false;
|
||||
if(!dataList.isEmpty()){
|
||||
if(dataList.size()<288){
|
||||
eff = true;
|
||||
}
|
||||
if("2".equals(dayOrMonth)){
|
||||
epsInitialTrafficData.setBandwidthType("2");
|
||||
// 1. 提取并转换带宽值
|
||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||
.map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed()))
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 计算95百分位
|
||||
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
|
||||
|
||||
// 3. 保存结果
|
||||
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
|
||||
epsInitialTrafficData.setResourceType("1");
|
||||
if("2".equals(epsInitialTrafficData.getRevenueMethod())){
|
||||
percentile95 = epsInitialTrafficData.getPackageBandwidth();
|
||||
epsInitialTrafficData.setBandwidthType("3");
|
||||
}else {
|
||||
if("1".equals(dayOrMonth)){
|
||||
if(eff){
|
||||
epsInitialTrafficData.setBandwidthType("5");
|
||||
}else {
|
||||
epsInitialTrafficData.setBandwidthType("1");
|
||||
}
|
||||
}
|
||||
if("2".equals(dayOrMonth)){
|
||||
if(eff){
|
||||
epsInitialTrafficData.setBandwidthType("6");
|
||||
}else {
|
||||
epsInitialTrafficData.setBandwidthType("2");
|
||||
}
|
||||
}
|
||||
}
|
||||
saveBandwidthResult(epsInitialTrafficData, percentile95, dateTime);
|
||||
}
|
||||
saveBandwidthResult(epsInitialTrafficData, percentile95, dateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,4 +490,18 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
epsNodeBandwidthMapper.insertEpsNodeBandwidth(bandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为有效
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private Boolean isEff(List<EpsInitialTrafficData> list){
|
||||
if(!list.isEmpty()){
|
||||
if(list.size()<288){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,6 +312,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
// 遍历处理每个交换机
|
||||
switchSnList.forEach(interfaceName -> {
|
||||
queryParam.setSwitchSn(interfaceName.getSwitchSn());
|
||||
queryParam.setSwitchIp(interfaceName.getSwitchIp());
|
||||
processSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime);
|
||||
});
|
||||
}
|
||||
@@ -474,34 +475,49 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
||||
* 计算并保存交换机95带宽值
|
||||
*/
|
||||
private void calculateAndSaveSwitch95Bandwidth(List<InitialSwitchInfoDetails> dataList, String dateTime, String dayOrMonth) {
|
||||
// 1. 提取并转换带宽值
|
||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||
.map(data -> {
|
||||
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
|
||||
String speed = ("1".equals(data.getInterfaceDeviceType())) ?
|
||||
data.getInSpeed() + "" : data.getOutSpeed() + "";
|
||||
// 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s)
|
||||
if (speed.matches("^\\d+(\\.\\d+)?$")) {
|
||||
speed += " B/S";
|
||||
}
|
||||
return CalculateUtil.parseSpeedToMbps(speed);
|
||||
})
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
boolean eff = false;
|
||||
if(!dataList.isEmpty()){
|
||||
if(dataList.size()<288){
|
||||
eff = true;
|
||||
}
|
||||
// 1. 提取并转换带宽值
|
||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||
.map(data -> {
|
||||
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
|
||||
String speed = "1".equals(data.getInterfaceDeviceType())
|
||||
? (data.getInSpeed() != null ? data.getInSpeed().toString() : BigDecimal.ZERO.toString())
|
||||
: (data.getOutSpeed() != null ? data.getOutSpeed().toString() : BigDecimal.ZERO.toString());
|
||||
// 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s)
|
||||
if (speed.matches("^\\d+(\\.\\d+)?$")) {
|
||||
speed += " B/S";
|
||||
}
|
||||
return CalculateUtil.parseSpeedToMbps(speed);
|
||||
})
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 计算95百分位
|
||||
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
|
||||
// 2. 计算95百分位
|
||||
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
|
||||
|
||||
// 3. 保存结果
|
||||
InitialSwitchInfoDetails switchInfo = dataList.get(0);
|
||||
switchInfo.setResourceType("2");
|
||||
if("1".equals(dayOrMonth)){
|
||||
switchInfo.setBandwidthType("1");
|
||||
// 3. 保存结果
|
||||
InitialSwitchInfoDetails switchInfo = dataList.get(0);
|
||||
switchInfo.setResourceType("2");
|
||||
if("1".equals(dayOrMonth)){
|
||||
if(eff){
|
||||
switchInfo.setBandwidthType("5");
|
||||
}else{
|
||||
switchInfo.setBandwidthType("1");
|
||||
}
|
||||
}
|
||||
if("2".equals(dayOrMonth)){
|
||||
if(eff){
|
||||
switchInfo.setBandwidthType("6");
|
||||
}else{
|
||||
switchInfo.setBandwidthType("2");
|
||||
}
|
||||
}
|
||||
saveSwitchBandwidthResult(switchInfo, percentile95, dateTime);
|
||||
}
|
||||
if("2".equals(dayOrMonth)){
|
||||
switchInfo.setBandwidthType("2");
|
||||
}
|
||||
saveSwitchBandwidthResult(switchInfo, percentile95, dateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,25 +96,46 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
Long id = rmResourceRegistration.getId();
|
||||
// 根据id查询sn信息
|
||||
RmResourceRegistration resourceRegistration = rmResourceRegistrationMapper.selectRmResourceRegistrationById(id);
|
||||
// sn
|
||||
String hardwareSn = resourceRegistration.getHardwareSn();
|
||||
String newResourceName = rmResourceRegistration.getResourceName();
|
||||
|
||||
// 如果资源名称有修改,同步修改其他表的资源名称
|
||||
if (!resourceRegistration.getResourceName().equals(rmResourceRegistration.getResourceName())){
|
||||
// 拓扑管理配置
|
||||
if (!resourceRegistration.getResourceName().equals(newResourceName)) {
|
||||
// 公共的更新对象创建
|
||||
RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement();
|
||||
rmEpsTopologyManagement.setServerSn(hardwareSn);
|
||||
rmEpsTopologyManagement.setServerName(rmResourceRegistration.getResourceName());
|
||||
rmEpsTopologyManagementMapper.updateRmEpsTopologyManagementByServerSn(rmEpsTopologyManagement);
|
||||
// 服务器收益配置表
|
||||
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
|
||||
epsServerRevenueConfig.setHardwareSn(hardwareSn);
|
||||
epsServerRevenueConfig.setNodeName(rmResourceRegistration.getResourceName());
|
||||
epsServerRevenueConfigMapper.updateEpsServerRevenueConfigByServerSn(epsServerRevenueConfig);
|
||||
// 95收益信息表
|
||||
EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
|
||||
epsNodeBandwidth.setHardwareSn(hardwareSn);
|
||||
epsNodeBandwidth.setNodeName(rmResourceRegistration.getResourceName());
|
||||
epsNodeBandwidthMapper.updateEpsNodeBandwidthByServerSn(epsNodeBandwidth);
|
||||
|
||||
switch (resourceRegistration.getResourceType()) {
|
||||
case "1": // 服务器类型
|
||||
// 更新拓扑管理配置
|
||||
rmEpsTopologyManagement.setServerSn(hardwareSn);
|
||||
rmEpsTopologyManagement.setServerName(newResourceName);
|
||||
rmEpsTopologyManagementMapper.updateRmEpsTopologyManagementByServerSn(rmEpsTopologyManagement);
|
||||
|
||||
// 更新服务器收益配置表
|
||||
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
|
||||
epsServerRevenueConfig.setHardwareSn(hardwareSn);
|
||||
epsServerRevenueConfig.setNodeName(newResourceName);
|
||||
epsServerRevenueConfigMapper.updateEpsServerRevenueConfigByServerSn(epsServerRevenueConfig);
|
||||
|
||||
// 更新95收益信息表
|
||||
epsNodeBandwidth.setHardwareSn(hardwareSn);
|
||||
epsNodeBandwidth.setNodeName(newResourceName);
|
||||
epsNodeBandwidthMapper.updateEpsNodeBandwidthByServerSn(epsNodeBandwidth);
|
||||
break;
|
||||
|
||||
case "2": // 交换机类型
|
||||
// 更新拓扑管理配置
|
||||
rmEpsTopologyManagement.setSwitchSn(hardwareSn);
|
||||
rmEpsTopologyManagement.setSwitchName(newResourceName);
|
||||
rmEpsTopologyManagementMapper.updateRmEpsTopologyManagementBySwitchSn(rmEpsTopologyManagement);
|
||||
|
||||
// 更新95收益信息表
|
||||
epsNodeBandwidth.setSwitchSn(hardwareSn);
|
||||
epsNodeBandwidth.setUplinkSwitch(newResourceName);
|
||||
epsNodeBandwidthMapper.updateEpsNodeBandwidthBySwitchSn(epsNodeBandwidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 禁止修改sn序列号
|
||||
rmResourceRegistration.setHardwareSn(null);
|
||||
|
||||
@@ -210,7 +210,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<!-- 检查交换机接口名称是否存在 -->
|
||||
<select id="getAllSwitchSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
||||
SELECT
|
||||
switch_sn AS switchSn
|
||||
switch_sn AS switchSn, switch_ip switchIp
|
||||
FROM
|
||||
all_interface_name
|
||||
<where>
|
||||
|
||||
@@ -68,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark1 != null and remark1 != ''"> and remark1 = #{remark1}</if>
|
||||
<if test="startTime != null and startTime != ''"> and create_time >= #{startTime}</if>
|
||||
<if test="endTime != null and endTime != ''"> and create_time <= #{endTime}</if>
|
||||
<if test="createTime != null"> and create_time = #{createTime}</if>
|
||||
<if test="nodeNames != null and nodeNames.size() > 0">
|
||||
AND node_name IN
|
||||
<foreach collection="nodeNames" item="name" open="(" separator="," close=")">
|
||||
@@ -81,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
<if test="createDatetime != null "> and create_datetime = #{createDatetime}</if>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectEpsNodeBandwidthById" parameterType="Long" resultMap="EpsNodeBandwidthResult">
|
||||
@@ -191,6 +192,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</trim>
|
||||
where hardware_sn = #{hardwareSn}
|
||||
</update>
|
||||
<update id="updateEpsNodeBandwidthBySwitchSn" parameterType="EpsNodeBandwidth">
|
||||
update eps_node_bandwidth
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="uplinkSwitch != null">uplink_switch = #{uplinkSwitch},</if>
|
||||
</trim>
|
||||
where switch_sn = #{switchSn}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEpsNodeBandwidthById" parameterType="Long">
|
||||
delete from eps_node_bandwidth where id = #{id}
|
||||
|
||||
@@ -112,6 +112,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</trim>
|
||||
where server_sn = #{serverSn}
|
||||
</update>
|
||||
<update id="updateRmEpsTopologyManagementBySwitchSn" parameterType="RmEpsTopologyManagement">
|
||||
update rm_eps_topology_management
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="switchName != null">`switch_name` = #{switchName},</if>
|
||||
</trim>
|
||||
where switch_sn = #{switchSn}
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteRmEpsTopologyManagementById" parameterType="Long">
|
||||
|
||||
Reference in New Issue
Block a user