Merge remote-tracking branch 'base-version/main' into dev
# Conflicts: # zt-module-bpm/zt-module-bpm-server/src/main/java/liquibase/database/core/DmDatabase.java
This commit is contained in:
@@ -8,17 +8,25 @@ import com.zt.plat.module.bpm.framework.flowable.core.event.BpmProcessInstanceEv
|
||||
import com.zt.plat.module.system.api.user.AdminUserApi;
|
||||
import org.flowable.common.engine.api.delegate.FlowableFunctionDelegate;
|
||||
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
|
||||
import org.flowable.engine.ProcessEngineConfiguration;
|
||||
import org.flowable.spring.SpringProcessEngineConfiguration;
|
||||
import org.flowable.spring.boot.EngineConfigurationConfigurer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* BPM 模块的 Flowable 配置类
|
||||
@@ -28,6 +36,8 @@ import java.util.List;
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class BpmFlowableConfiguration {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BpmFlowableConfiguration.class);
|
||||
|
||||
/**
|
||||
* 参考 {@link org.flowable.spring.boot.FlowableJobConfiguration} 类,创建对应的 AsyncListenableTaskExecutor Bean
|
||||
*
|
||||
@@ -69,6 +79,37 @@ public class BpmFlowableConfiguration {
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> dmProcessEngineConfigurationConfigurer(DataSource dataSource) {
|
||||
return configuration -> {
|
||||
try {
|
||||
configureDmCompatibility(configuration, dataSource);
|
||||
} catch (SQLException ex) {
|
||||
log.warn("Failed to inspect datasource for DM compatibility; Flowable will keep default settings", ex);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void configureDmCompatibility(SpringProcessEngineConfiguration configuration, DataSource dataSource) throws SQLException {
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = DataSourceUtils.getConnection(dataSource);
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
String productName = metaData.getDatabaseProductName();
|
||||
String jdbcUrl = metaData.getURL();
|
||||
boolean dmProduct = productName != null && productName.toLowerCase().contains("dm");
|
||||
boolean dmUrl = jdbcUrl != null && jdbcUrl.toLowerCase().startsWith("jdbc:dm");
|
||||
if (!dmProduct && !dmUrl) {
|
||||
return;
|
||||
}
|
||||
log.info("Detected DM database (product='{}'); enabling Flowable Oracle compatibility with automatic schema updates", productName);
|
||||
configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
|
||||
configuration.setDatabaseType("oracle");
|
||||
} finally {
|
||||
DataSourceUtils.releaseConnection(connection, dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
// =========== 审批人相关的 Bean ==========
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -5,6 +5,25 @@
|
||||
|
||||
package liquibase.database.core;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import liquibase.CatalogAndSchema;
|
||||
import liquibase.GlobalConfiguration;
|
||||
import liquibase.Scope;
|
||||
@@ -23,17 +42,15 @@ import liquibase.statement.UniqueConstraint;
|
||||
import liquibase.statement.core.RawCallStatement;
|
||||
import liquibase.statement.core.RawParameterizedSqlStatement;
|
||||
import liquibase.structure.DatabaseObject;
|
||||
import liquibase.structure.core.*;
|
||||
import liquibase.structure.core.Catalog;
|
||||
import liquibase.structure.core.Column;
|
||||
import liquibase.structure.core.Index;
|
||||
import liquibase.structure.core.PrimaryKey;
|
||||
import liquibase.structure.core.Schema;
|
||||
import liquibase.util.JdbcUtil;
|
||||
import liquibase.util.StringUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DmDatabase extends AbstractJdbcDatabase {
|
||||
private static final String PROXY_USER_REGEX = ".*(?:thin|oci)\\:(.+)/@.*";
|
||||
public static final Pattern PROXY_USER_PATTERN = Pattern.compile(".*(?:thin|oci)\\:(.+)/@.*");
|
||||
@@ -98,6 +115,7 @@ public class DmDatabase extends AbstractJdbcDatabase {
|
||||
public void setConnection(DatabaseConnection conn) {
|
||||
this.reservedWords.addAll(Arrays.asList("GROUP", "USER", "SESSION", "PASSWORD", "RESOURCE", "START", "SIZE", "UID", "DESC", "ORDER"));
|
||||
Connection sqlConn = null;
|
||||
boolean dmDatabase = false;
|
||||
if (!(conn instanceof OfflineConnection)) {
|
||||
try {
|
||||
if (conn instanceof JdbcConnection) {
|
||||
@@ -124,6 +142,21 @@ public class DmDatabase extends AbstractJdbcDatabase {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set remarks reporting on OracleDatabase: " + e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
DatabaseMetaData metaData = sqlConn.getMetaData();
|
||||
if (metaData != null) {
|
||||
String productName = metaData.getDatabaseProductName();
|
||||
dmDatabase = productName != null && PRODUCT_NAME.equalsIgnoreCase(productName);
|
||||
if (dmDatabase) {
|
||||
this.databaseMajorVersion = metaData.getDatabaseMajorVersion();
|
||||
this.databaseMinorVersion = metaData.getDatabaseMinorVersion();
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Scope.getCurrentScope().getLog(this.getClass()).info("Unable to inspect database metadata for DM version detection: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (!dmDatabase) {
|
||||
CallableStatement statement = null;
|
||||
|
||||
try {
|
||||
@@ -145,6 +178,7 @@ public class DmDatabase extends AbstractJdbcDatabase {
|
||||
} finally {
|
||||
JdbcUtil.closeStatement(statement);
|
||||
}
|
||||
}
|
||||
|
||||
if (GlobalConfiguration.DDL_LOCK_TIMEOUT.getCurrentValue() != null) {
|
||||
int timeoutValue = (Integer)GlobalConfiguration.DDL_LOCK_TIMEOUT.getCurrentValue();
|
||||
@@ -250,7 +284,15 @@ public class DmDatabase extends AbstractJdbcDatabase {
|
||||
}
|
||||
|
||||
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
|
||||
return "oracle".equalsIgnoreCase(conn.getDatabaseProductName());
|
||||
String databaseProductName = conn == null ? null : conn.getDatabaseProductName();
|
||||
if (databaseProductName == null) {
|
||||
return false;
|
||||
}
|
||||
if (PRODUCT_NAME.equalsIgnoreCase(databaseProductName)) {
|
||||
return true;
|
||||
}
|
||||
// Flowable 历史上将 DM 映射为 Oracle 元数据,因此这里同样接受 Oracle 以保持兼容
|
||||
return "oracle".equalsIgnoreCase(databaseProductName);
|
||||
}
|
||||
|
||||
public String getDefaultDriver(String url) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package liquibase.datatype.core;
|
||||
|
||||
import liquibase.database.Database;
|
||||
import liquibase.database.core.DmDatabase;
|
||||
import liquibase.datatype.DataTypeInfo;
|
||||
import liquibase.datatype.DatabaseDataType;
|
||||
|
||||
@DataTypeInfo(
|
||||
name = "boolean",
|
||||
aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"},
|
||||
minParameters = 0,
|
||||
maxParameters = 0,
|
||||
priority = 2
|
||||
)
|
||||
public class DmBooleanType extends BooleanType {
|
||||
|
||||
@Override
|
||||
public boolean supports(Database database) {
|
||||
if (database instanceof DmDatabase) {
|
||||
return true;
|
||||
}
|
||||
return super.supports(database);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseDataType toDatabaseDataType(Database database) {
|
||||
if (database instanceof DmDatabase) {
|
||||
return new DatabaseDataType("NUMBER", 1);
|
||||
}
|
||||
return super.toDatabaseDataType(database);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,7 @@ liquibase.database.core.MariaDBDatabase
|
||||
liquibase.database.core.MockDatabase
|
||||
liquibase.database.core.MySQLDatabase
|
||||
liquibase.database.core.OracleDatabase
|
||||
liquibase.database.core.DmDatabase
|
||||
liquibase.database.core.PostgresDatabase
|
||||
liquibase.database.core.SQLiteDatabase
|
||||
liquibase.database.core.SybaseASADatabase
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
liquibase.datatype.core.DmBooleanType
|
||||
@@ -39,14 +39,14 @@ spring:
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://172.16.46.247:4787/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||
username: jygk-test
|
||||
password: Zgty@0527
|
||||
url: jdbc:dm://172.16.46.247:1050?schema=BPM
|
||||
username: SYSDBA
|
||||
password: pgbsci6ddJ6Sqj@e
|
||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||
lazy: true # 开启懒加载,保证启动速度
|
||||
url: jdbc:mysql://172.16.46.247:4787/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
|
||||
username: jygk-test
|
||||
password: Zgty@0527
|
||||
url: jdbc:dm://172.16.46.247:1050?schema=BPM
|
||||
username: SYSDBA
|
||||
password: pgbsci6ddJ6Sqj@e
|
||||
|
||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||
data:
|
||||
@@ -56,6 +56,11 @@ spring:
|
||||
database: 0 # 数据库索引
|
||||
# password: 123456 # 密码,建议生产环境开启
|
||||
|
||||
# Flowable 在 DM 场景下需要识别为 Oracle 并自动升级表结构
|
||||
flowable:
|
||||
database-schema-update: true
|
||||
database-type: oracle
|
||||
|
||||
--- #################### MQ 消息队列相关配置 ####################
|
||||
|
||||
--- #################### 定时任务相关配置 ####################
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
create table FLW_RU_BATCH (
|
||||
ID_ VARCHAR2(64) not null,
|
||||
REV_ INTEGER,
|
||||
TYPE_ VARCHAR2(64) not null,
|
||||
SEARCH_KEY_ VARCHAR2(255),
|
||||
SEARCH_KEY2_ VARCHAR2(255),
|
||||
CREATE_TIME_ TIMESTAMP(6) not null,
|
||||
COMPLETE_TIME_ TIMESTAMP(6),
|
||||
STATUS_ VARCHAR2(255),
|
||||
BATCH_DOC_ID_ VARCHAR2(64),
|
||||
TENANT_ID_ VARCHAR2(255) default '',
|
||||
primary key (ID_)
|
||||
);
|
||||
|
||||
create table FLW_RU_BATCH_PART (
|
||||
ID_ VARCHAR2(64) not null,
|
||||
REV_ INTEGER,
|
||||
BATCH_ID_ VARCHAR2(64),
|
||||
TYPE_ VARCHAR2(64) not null,
|
||||
SCOPE_ID_ VARCHAR2(64),
|
||||
SUB_SCOPE_ID_ VARCHAR2(64),
|
||||
SCOPE_TYPE_ VARCHAR2(64),
|
||||
SEARCH_KEY_ VARCHAR2(255),
|
||||
SEARCH_KEY2_ VARCHAR2(255),
|
||||
CREATE_TIME_ TIMESTAMP(6) not null,
|
||||
COMPLETE_TIME_ TIMESTAMP(6),
|
||||
STATUS_ VARCHAR2(255),
|
||||
RESULT_DOC_ID_ VARCHAR2(64),
|
||||
TENANT_ID_ VARCHAR2(255) default '',
|
||||
primary key (ID_)
|
||||
);
|
||||
|
||||
create index FLW_IDX_BATCH_PART on FLW_RU_BATCH_PART(BATCH_ID_);
|
||||
|
||||
alter table FLW_RU_BATCH_PART
|
||||
add constraint FLW_FK_BATCH_PART_PARENT
|
||||
foreign key (BATCH_ID_)
|
||||
references FLW_RU_BATCH (ID_);
|
||||
|
||||
insert into ACT_GE_PROPERTY values ('batch.schema.version', '7.0.1.1', 1);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
drop index FLW_IDX_BATCH_PART;
|
||||
|
||||
drop table FLW_RU_BATCH_PART;
|
||||
drop table FLW_RU_BATCH;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user