20250808优化-单体电池优化

This commit is contained in:
2025-08-16 10:28:06 +08:00
parent ff058dceaf
commit b2527507e4
9 changed files with 99 additions and 64 deletions

View File

@ -252,6 +252,10 @@ public class BaseController
// 计算结束索引(处理超出列表长度的情况)
endIndex = Math.min(startIndex + pageSize, sourceList.size());
}
// 防止越界
if (startIndex >= sourceList.size()) {
return Collections.emptyList();
}
// 截取分页数据
return sourceList.subList(startIndex, endIndex);
}

View File

@ -751,4 +751,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
}
return result;
}
// 补全三位数字(返回字符串)
public static String fillThreeDigits(String value) {
if (value == null || value.trim().isEmpty()) {
return "000";
}
try {
int num = Integer.parseInt(value.trim());
return String.format("%03d", num);
} catch (NumberFormatException e) {
return value;
}
}
}