mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-04-02 08:43:23 +08:00
update 优化一些性能问题
This commit is contained in:
@@ -548,4 +548,11 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
return Strings.CS.containsAny(cs, searchCharSequences);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
|
|||||||
errMsg = StrUtil.format("第{}行-第{}列-表头{}: 解析异常<br/>",
|
errMsg = StrUtil.format("第{}行-第{}列-表头{}: 解析异常<br/>",
|
||||||
rowIndex + 1, columnIndex + 1, headMap.get(columnIndex));
|
rowIndex + 1, columnIndex + 1, headMap.get(columnIndex));
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.error(errMsg);
|
log.warn(errMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exception instanceof ConstraintViolationException constraintViolationException) {
|
if (exception instanceof ConstraintViolationException constraintViolationException) {
|
||||||
@@ -70,12 +70,12 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
|
|||||||
String constraintViolationsMsg = StreamUtils.join(constraintViolations, ConstraintViolation::getMessage, ", ");
|
String constraintViolationsMsg = StreamUtils.join(constraintViolations, ConstraintViolation::getMessage, ", ");
|
||||||
errMsg = StrUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
|
errMsg = StrUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.error(errMsg);
|
log.warn(errMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (errMsg == null) {
|
if (errMsg == null) {
|
||||||
errMsg = StrUtil.format("第{}行数据异常: {}", context.readRowHolder().getRowIndex() + 1, exception.getMessage());
|
errMsg = StrUtil.format("第{}行数据异常: {}", context.readRowHolder().getRowIndex() + 1, exception.getMessage());
|
||||||
log.error(errMsg, exception);
|
log.warn(errMsg, exception);
|
||||||
}
|
}
|
||||||
excelResult.getErrorList().add(errMsg);
|
excelResult.getErrorList().add(errMsg);
|
||||||
throw new ExcelAnalysisException(errMsg);
|
throw new ExcelAnalysisException(errMsg);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库助手
|
* 数据库助手
|
||||||
@@ -26,7 +27,7 @@ import java.util.Map;
|
|||||||
public class DataBaseHelper {
|
public class DataBaseHelper {
|
||||||
|
|
||||||
private static final DynamicRoutingDataSource DS = SpringUtils.getBean(DynamicRoutingDataSource.class);
|
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<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前数据源对应的数据库类型
|
* 获取当前数据源对应的数据库类型
|
||||||
|
|||||||
@@ -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.ReadCellData;
|
||||||
import org.apache.fesod.sheet.metadata.data.WriteCellData;
|
import org.apache.fesod.sheet.metadata.data.WriteCellData;
|
||||||
import org.apache.fesod.sheet.metadata.property.ExcelContentProperty;
|
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.StringUtils;
|
||||||
import org.dromara.common.core.utils.TreeBuildUtils;
|
import org.dromara.common.core.utils.TreeBuildUtils;
|
||||||
import org.dromara.system.domain.bo.SysDeptBo;
|
import org.dromara.system.domain.bo.SysDeptBo;
|
||||||
import org.dromara.system.service.ISysDeptService;
|
import org.dromara.system.service.ISysDeptService;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @author AprilWind
|
* @author AprilWind
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Component
|
|
||||||
public class DeptExcelConverter implements Converter<Long> {
|
public class DeptExcelConverter implements Converter<Long> {
|
||||||
|
|
||||||
private static final String CACHE_KEY = "dept:excel";
|
private static final String CACHE_KEY = "dept:excel";
|
||||||
@@ -38,9 +37,8 @@ public class DeptExcelConverter implements Converter<Long> {
|
|||||||
.expireAfterWrite(30, TimeUnit.SECONDS)
|
.expireAfterWrite(30, TimeUnit.SECONDS)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private final ISysDeptService deptService;
|
|
||||||
|
|
||||||
private DeptMaps getDeptMaps() {
|
private DeptMaps getDeptMaps() {
|
||||||
|
ISysDeptService deptService = SpringUtils.getBean(ISysDeptService.class);
|
||||||
return DEPT_CACHE.get(CACHE_KEY, k -> {
|
return DEPT_CACHE.get(CACHE_KEY, k -> {
|
||||||
Map<String, Tree<Long>> deptPathToTreeMap = buildDeptPathMap(deptService);
|
Map<String, Tree<Long>> deptPathToTreeMap = buildDeptPathMap(deptService);
|
||||||
Map<Long, String> idToName = new HashMap<>();
|
Map<Long, String> idToName = new HashMap<>();
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package org.dromara.system.listener;
|
package org.dromara.system.listener;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
import org.dromara.common.excel.core.ExcelOptionsProvider;
|
import org.dromara.common.excel.core.ExcelOptionsProvider;
|
||||||
import org.dromara.system.service.ISysDeptService;
|
import org.dromara.system.service.ISysDeptService;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -13,11 +13,8 @@ import java.util.Set;
|
|||||||
* @author AprilWind
|
* @author AprilWind
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Component
|
|
||||||
public class DeptExcelOptions implements ExcelOptionsProvider {
|
public class DeptExcelOptions implements ExcelOptionsProvider {
|
||||||
|
|
||||||
private final ISysDeptService deptService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取下拉选项数据
|
* 获取下拉选项数据
|
||||||
*
|
*
|
||||||
@@ -25,6 +22,7 @@ public class DeptExcelOptions implements ExcelOptionsProvider {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getOptions() {
|
public Set<String> getOptions() {
|
||||||
|
ISysDeptService deptService = SpringUtils.getBean(ISysDeptService.class);
|
||||||
return DeptExcelConverter.buildDeptPathMap(deptService).keySet();
|
return DeptExcelConverter.buildDeptPathMap(deptService).keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user