优化常用单位、用户自定义列保存优化、业务流量库优化
This commit is contained in:
+52
@@ -113,4 +113,56 @@ public class UnitChangeUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 次数单位换算
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
public static String formatWithUnit(long count) {
|
||||
String[] units = {"", "万", "百万", "亿"};
|
||||
double[] divisors = {1, 10_000.0, 1_000_000.0, 100_000_000.0};
|
||||
|
||||
int unitIndex = 0;
|
||||
double value = count;
|
||||
|
||||
for (int i = divisors.length - 1; i >= 0; i--) {
|
||||
if (count >= divisors[i]) {
|
||||
unitIndex = i;
|
||||
value = count / divisors[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 根据数值大小决定小数位数
|
||||
String formatPattern = (value >= 100 || unitIndex == 0) ? "%.0f %s次" : "%.1f %s次";
|
||||
return String.format(formatPattern, value, units[unitIndex]).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 简洁版本:所有值都显示为KB及以上单位
|
||||
*/
|
||||
public static String formatWithKbMin(long bytes) {
|
||||
if (bytes == 0) {
|
||||
return "0.00 KB";
|
||||
}
|
||||
|
||||
final String[] units = {"KB", "MB", "GB", "TB"};
|
||||
double value = bytes / 1024.0;
|
||||
int unitIndex = 0;
|
||||
|
||||
while (value >= 1024 && unitIndex < units.length - 1) {
|
||||
value /= 1024;
|
||||
unitIndex++;
|
||||
}
|
||||
|
||||
// 四舍五入到两位小数
|
||||
double roundedValue = Math.round(value * 100.0) / 100.0;
|
||||
|
||||
// 处理四舍五入后可能出现的情况
|
||||
if (roundedValue == 0.0 && value > 0) {
|
||||
roundedValue = 0.01; // 最小值显示为0.01而不是0.00
|
||||
}
|
||||
|
||||
return String.format("%.2f %s", roundedValue, units[unitIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-4
@@ -179,12 +179,17 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
||||
RmResourceRegistration registerMsg = registerLst.get(0);
|
||||
// 赋值
|
||||
if(registerMsg != null){
|
||||
// 根据业务名称查询业务代码
|
||||
EpsBusiness epsBusiness = epsBusinessMapper.selectEpsBusinessByName(registerMsg.getBusinessName());
|
||||
String businessName = registerMsg.getBusinessName();
|
||||
if(businessName != null){
|
||||
initialTrafficData.setBusinessName(businessName);
|
||||
// 根据业务名称查询业务代码
|
||||
EpsBusiness epsBusiness = epsBusinessMapper.selectEpsBusinessByName(businessName);
|
||||
if(epsBusiness != null){
|
||||
initialTrafficData.setBusinessId(epsBusiness.getId());
|
||||
}
|
||||
}
|
||||
initialTrafficData.setServiceSn(registerMsg.getHardwareSn());
|
||||
initialTrafficData.setRevenueMethod("1");
|
||||
initialTrafficData.setBusinessId(epsBusiness.getId());
|
||||
initialTrafficData.setBusinessName(registerMsg.getBusinessName());
|
||||
}
|
||||
}
|
||||
// id自增
|
||||
|
||||
+2
-5
@@ -73,11 +73,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<when test="id != null">
|
||||
and id = #{id}
|
||||
</when>
|
||||
<when test="userId != null">
|
||||
and user_id = #{userId}
|
||||
</when>
|
||||
<when test="pageRoute != null">
|
||||
and page_route = #{pageRoute}
|
||||
<when test="userId != null and pageRoute != null">
|
||||
and user_id = #{userId} and page_route = #{pageRoute}
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1=0 <!-- 如果两个条件都不满足,则不更新任何记录 -->
|
||||
|
||||
@@ -61,5 +61,13 @@ public class InitialDiskInfo extends BaseEntity
|
||||
private String startTime;
|
||||
/** 结束时间 */
|
||||
private String endTime;
|
||||
/** 换算后的读取次数 */
|
||||
private String readTimesStr;
|
||||
/** 换算后的写入次数 */
|
||||
private String writeTimesStr;
|
||||
/** 换算后的读取字节 */
|
||||
private String readBytesStr;
|
||||
/** 换算后的写入次数 */
|
||||
private String writeBytesStr;
|
||||
|
||||
}
|
||||
|
||||
+10
-3
@@ -2,6 +2,7 @@ package com.ruoyi.rocketmq.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.utils.EchartsDataUtils;
|
||||
import com.ruoyi.common.core.utils.UnitChangeUtil;
|
||||
import com.ruoyi.rocketmq.domain.InitialDiskInfo;
|
||||
import com.ruoyi.rocketmq.mapper.InitialDiskInfoMapper;
|
||||
import com.ruoyi.rocketmq.service.IInitialDiskInfoService;
|
||||
@@ -126,9 +127,15 @@ public class InitialDiskInfoServiceImpl implements IInitialDiskInfoService
|
||||
@Override
|
||||
public InitialDiskInfo getDistDetailsMsg(InitialDiskInfo initialDiskInfo) {
|
||||
InitialDiskInfo info = initialDiskInfoMapper.getDistDetailsMsgByClientId(initialDiskInfo);
|
||||
long gbUnit = 1024L * 1024 * 1024;
|
||||
info.setTotal(info.getTotal() / gbUnit);
|
||||
return initialDiskInfoMapper.getDistDetailsMsgByClientId(initialDiskInfo);
|
||||
if(info != null){
|
||||
long gbUnit = 1024L * 1024 * 1024;
|
||||
info.setTotal(info.getTotal() / gbUnit);
|
||||
info.setReadTimesStr(UnitChangeUtil.formatWithUnit(info.getReadTimes()));
|
||||
info.setWriteTimesStr(UnitChangeUtil.formatWithUnit(info.getWriteTimes()));
|
||||
info.setReadBytesStr(UnitChangeUtil.formatWithKbMin(info.getReadBytes()));
|
||||
info.setWriteBytesStr(UnitChangeUtil.formatWithKbMin(info.getWriteBytes()));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
/**
|
||||
* /dev/sda读写速率(KB/s)
|
||||
|
||||
Reference in New Issue
Block a user