update 优化一些性能问题

This commit is contained in:
疯狂的狮子Li
2026-04-01 10:13:42 +08:00
parent d11990bfd8
commit 568547ada5
5 changed files with 16 additions and 12 deletions

View File

@@ -548,4 +548,11 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return Strings.CS.containsAny(cs, searchCharSequences);
}
/**
* 将一个字符串替换为较大字符串内的另一个字符串,一次
*/
public static String replaceOnce(final String text, final String searchString, final String replacement) {
return Strings.CS.replaceOnce(text, searchString, replacement);
}
}

View File

@@ -62,7 +62,7 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
errMsg = StrUtil.format("第{}行-第{}列-表头{}: 解析异常<br/>",
rowIndex + 1, columnIndex + 1, headMap.get(columnIndex));
if (log.isDebugEnabled()) {
log.error(errMsg);
log.warn(errMsg);
}
}
if (exception instanceof ConstraintViolationException constraintViolationException) {
@@ -70,12 +70,12 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
String constraintViolationsMsg = StreamUtils.join(constraintViolations, ConstraintViolation::getMessage, ", ");
errMsg = StrUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
if (log.isDebugEnabled()) {
log.error(errMsg);
log.warn(errMsg);
}
}
if (errMsg == null) {
errMsg = StrUtil.format("第{}行数据异常: {}", context.readRowHolder().getRowIndex() + 1, exception.getMessage());
log.error(errMsg, exception);
log.warn(errMsg, exception);
}
excelResult.getErrorList().add(errMsg);
throw new ExcelAnalysisException(errMsg);

View File

@@ -16,6 +16,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 数据库助手
@@ -26,7 +27,7 @@ import java.util.Map;
public class DataBaseHelper {
private static final DynamicRoutingDataSource DS = SpringUtils.getBean(DynamicRoutingDataSource.class);
private static final Map<String, DataBaseType> DB_TYPE_CACHE = new java.util.concurrent.ConcurrentHashMap<>();
private static final Map<String, DataBaseType> DB_TYPE_CACHE = new ConcurrentHashMap<>();
/**
* 获取当前数据源对应的数据库类型

View File

@@ -10,11 +10,11 @@ import org.apache.fesod.sheet.metadata.GlobalConfiguration;
import org.apache.fesod.sheet.metadata.data.ReadCellData;
import org.apache.fesod.sheet.metadata.data.WriteCellData;
import org.apache.fesod.sheet.metadata.property.ExcelContentProperty;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.TreeBuildUtils;
import org.dromara.system.domain.bo.SysDeptBo;
import org.dromara.system.service.ISysDeptService;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
* @author AprilWind
*/
@RequiredArgsConstructor
@Component
public class DeptExcelConverter implements Converter<Long> {
private static final String CACHE_KEY = "dept:excel";
@@ -38,9 +37,8 @@ public class DeptExcelConverter implements Converter<Long> {
.expireAfterWrite(30, TimeUnit.SECONDS)
.build();
private final ISysDeptService deptService;
private DeptMaps getDeptMaps() {
ISysDeptService deptService = SpringUtils.getBean(ISysDeptService.class);
return DEPT_CACHE.get(CACHE_KEY, k -> {
Map<String, Tree<Long>> deptPathToTreeMap = buildDeptPathMap(deptService);
Map<Long, String> idToName = new HashMap<>();

View File

@@ -1,9 +1,9 @@
package org.dromara.system.listener;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.excel.core.ExcelOptionsProvider;
import org.dromara.system.service.ISysDeptService;
import org.springframework.stereotype.Component;
import java.util.Set;
@@ -13,11 +13,8 @@ import java.util.Set;
* @author AprilWind
*/
@RequiredArgsConstructor
@Component
public class DeptExcelOptions implements ExcelOptionsProvider {
private final ISysDeptService deptService;
/**
* 获取下拉选项数据
*
@@ -25,6 +22,7 @@ public class DeptExcelOptions implements ExcelOptionsProvider {
*/
@Override
public Set<String> getOptions() {
ISysDeptService deptService = SpringUtils.getBean(ISysDeptService.class);
return DeptExcelConverter.buildDeptPathMap(deptService).keySet();
}