mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
fix 修复 多次驳回无法锁定审批人问题
This commit is contained in:
parent
cef1797828
commit
511fb6c8d5
@ -2,6 +2,7 @@ package org.dromara.common.mybatis.helper;
|
|||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||||
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
@ -15,6 +16,8 @@ import java.sql.DatabaseMetaData;
|
|||||||
import java.sql.SQLException;
|
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.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库助手
|
* 数据库助手
|
||||||
@ -25,6 +28,7 @@ import java.util.List;
|
|||||||
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 ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前数据源对应的数据库类型
|
* 获取当前数据源对应的数据库类型
|
||||||
@ -38,13 +42,17 @@ public class DataBaseHelper {
|
|||||||
*/
|
*/
|
||||||
public static DataBaseType getDataBaseType() {
|
public static DataBaseType getDataBaseType() {
|
||||||
DataSource dataSource = DS.determineDataSource();
|
DataSource dataSource = DS.determineDataSource();
|
||||||
try (Connection conn = dataSource.getConnection()) {
|
String dsKey = DynamicDataSourceContextHolder.peek();
|
||||||
DatabaseMetaData metaData = conn.getMetaData();
|
final String key = dsKey != null ? dsKey : "primary";
|
||||||
String databaseProductName = metaData.getDatabaseProductName();
|
return DB_TYPE_CACHE.computeIfAbsent(key, k -> {
|
||||||
return DataBaseType.find(databaseProductName);
|
try (Connection conn = dataSource.getConnection()) {
|
||||||
} catch (SQLException e) {
|
DatabaseMetaData metaData = conn.getMetaData();
|
||||||
throw new RuntimeException("获取数据库类型失败", e);
|
String databaseProductName = metaData.getDatabaseProductName();
|
||||||
}
|
return DataBaseType.find(databaseProductName);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException("获取数据库类型失败", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,13 +64,15 @@ public class DataBaseHelper {
|
|||||||
*/
|
*/
|
||||||
public static DataBaseType getDataBaseType(String dsName) {
|
public static DataBaseType getDataBaseType(String dsName) {
|
||||||
DataSource dataSource = DS.getDataSource(dsName);
|
DataSource dataSource = DS.getDataSource(dsName);
|
||||||
try (Connection conn = dataSource.getConnection()) {
|
return DB_TYPE_CACHE.computeIfAbsent(dsName, k -> {
|
||||||
DatabaseMetaData metaData = conn.getMetaData();
|
try (Connection conn = dataSource.getConnection()) {
|
||||||
String databaseProductName = metaData.getDatabaseProductName();
|
DatabaseMetaData metaData = conn.getMetaData();
|
||||||
return DataBaseType.find(databaseProductName);
|
String databaseProductName = metaData.getDatabaseProductName();
|
||||||
} catch (SQLException e) {
|
return DataBaseType.find(databaseProductName);
|
||||||
throw new RuntimeException("获取数据库类型失败", e);
|
} catch (SQLException e) {
|
||||||
}
|
throw new RuntimeException("获取数据库类型失败", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +105,9 @@ public class DataBaseHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前加载的数据库名
|
* 获取当前注册的数据源名称列表。
|
||||||
|
*
|
||||||
|
* @return 数据源名称列表
|
||||||
*/
|
*/
|
||||||
public static List<String> getDataSourceNameList() {
|
public static List<String> getDataSourceNameList() {
|
||||||
return new ArrayList<>(DS.getDataSources().keySet());
|
return new ArrayList<>(DS.getDataSources().keySet());
|
||||||
|
|||||||
@ -159,9 +159,11 @@ public class WorkflowGlobalListener implements GlobalListener {
|
|||||||
String[] userIdArray = userIds.split(StringUtils.SEPARATOR);
|
String[] userIdArray = userIds.split(StringUtils.SEPARATOR);
|
||||||
if (userIdArray.length > 0) {
|
if (userIdArray.length > 0) {
|
||||||
flowTask.setPermissionList(List.of(userIdArray));
|
flowTask.setPermissionList(List.of(userIdArray));
|
||||||
// 移除已处理的状态变量
|
if (TaskStatusEnum.PASS.getStatus().equals(taskStatus)) {
|
||||||
variable.remove(nodeKey);
|
// 办理指定人变量只消费一次;驳回指定人变量需要保留给后续重复驳回。
|
||||||
FlowEngine.insService().removeVariables(flowTask.getInstanceId(), nodeKey);
|
variable.remove(nodeKey);
|
||||||
|
FlowEngine.insService().removeVariables(flowTask.getInstanceId(), nodeKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user