解决查询条件默认生效问题,日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">
|
||||
|
||||
@@ -33,18 +33,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectInitialCpuInfoVo"/>
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="avg1 != null "> and avg1 = #{avg1}</if>
|
||||
<if test="avg5 != null "> and avg5 = #{avg5}</if>
|
||||
<if test="avg15 != null "> and avg15 = #{avg15}</if>
|
||||
<if test="interrupt != null "> and interrupt = #{interrupt}</if>
|
||||
<if test="uti != null "> and uti = #{uti}</if>
|
||||
<if test="num != null "> and num = #{num}</if>
|
||||
<if test="normal != null "> and normal = #{normal}</if>
|
||||
<if test="idle != null "> and idle = #{idle}</if>
|
||||
<if test="iowait != null "> and iowait = #{iowait}</if>
|
||||
<if test="system != null "> and system = #{system}</if>
|
||||
<if test="noresp != null "> and noresp = #{noresp}</if>
|
||||
<if test="user != null "> and user = #{user}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
@@ -30,15 +30,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectInitialDiskInfoVo"/>
|
||||
<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="serial != null and serial != ''"> and serial = #{serial}</if>
|
||||
<if test="total != null "> and total = #{total}</if>
|
||||
<if test="writeSpeed != null "> and write_speed = #{writeSpeed}</if>
|
||||
<if test="readSpeed != null "> and read_speed = #{readSpeed}</if>
|
||||
<if test="writeTimes != null "> and write_times = #{writeTimes}</if>
|
||||
<if test="readTimes != null "> and read_times = #{readTimes}</if>
|
||||
<if test="writeBytes != null "> and write_bytes = #{writeBytes}</if>
|
||||
<if test="readBytes != null "> and read_bytes = #{readBytes}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
@@ -27,12 +27,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectInitialDockerInfoList" parameterType="InitialDockerInfo" resultMap="InitialDockerInfoResult">
|
||||
<include refid="selectInitialDockerInfoVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="cpuUtil != null and cpuUtil != ''"> and cpu_util = #{cpuUtil}</if>
|
||||
<if test="memUtil != null and memUtil != ''"> and mem_util = #{memUtil}</if>
|
||||
<if test="netInSpeed != null and netInSpeed != ''"> and net_in_speed = #{netInSpeed}</if>
|
||||
<if test="netOutSpeed != null and netOutSpeed != ''"> and net_out_speed = #{netOutSpeed}</if>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
|
||||
@@ -27,12 +27,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectInitialMemoryInfoVo"/>
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="swapSizeFree != null "> and swap_size_free = #{swapSizeFree}</if>
|
||||
<if test="untilzation != null "> and untilzation = #{untilzation}</if>
|
||||
<if test="swapSizePercent != null "> and swap_size_percent = #{swapSizePercent}</if>
|
||||
<if test="available != null "> and available = #{available}</if>
|
||||
<if test="percent != null "> and percent = #{percent}</if>
|
||||
<if test="total != null "> and total = #{total}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
@@ -26,11 +26,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectInitialMountPointInfoVo"/>
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="mount != null and mount != ''"> and mount = #{mount}</if>
|
||||
<if test="vfsType != null and vfsType != ''"> and vfs_type = #{vfsType}</if>
|
||||
<if test="vfsFree != null "> and vfs_free = #{vfsFree}</if>
|
||||
<if test="vfsTotal != null "> and vfs_total = #{vfsTotal}</if>
|
||||
<if test="vfsUtil != null "> and vfs_util = #{vfsUtil}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
@@ -34,19 +34,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectInitialSystemInfoVo"/>
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="os != null and os != ''"> and os = #{os}</if>
|
||||
<if test="arch != null and arch != ''"> and arch = #{arch}</if>
|
||||
<if test="maxProc != null "> and max_proc = #{maxProc}</if>
|
||||
<if test="runProcNum != null "> and run_proc_num = #{runProcNum}</if>
|
||||
<if test="usersNum != null "> and users_num = #{usersNum}</if>
|
||||
<if test="diskSizeTotal != null "> and disk_size_total = #{diskSizeTotal}</if>
|
||||
<if test="bootTime != null "> and boot_time = #{bootTime}</if>
|
||||
<if test="uname != null and uname != ''"> and uname like concat('%', #{uname}, '%')</if>
|
||||
<if test="localTime != null and localTime != ''"> and local_time = #{localTime}</if>
|
||||
<if test="upTime != null "> and up_time = #{upTime}</if>
|
||||
<if test="procNum != null "> and proc_num = #{procNum}</if>
|
||||
<if test="timeStamp != null "> and time_stamp = #{timeStamp}</if>
|
||||
<if test="uuid != null "> and uuid = #{uuid}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user