Browse Source

Merge remote-tracking branch 'refs/remotes/origin/工作流配置' into milestone-20251016-现金管理

milestone-20251016-现金管理
huangqizhen 2 weeks ago
parent
commit
2b7151bcd6
  1. 5
      pom.xml
  2. 6
      src/main/java/com/example/demo/DemoApplication.java
  3. 34
      src/main/java/com/example/demo/config/FlowableDataSourceConfig.java
  4. 56
      src/main/java/com/example/demo/config/work/FlowableEngineConfig.java
  5. 11
      src/main/resources/application-dev.yml
  6. 13
      src/main/resources/application-test.yml

5
pom.xml

@ -75,6 +75,11 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter</artifactId>
<version>7.0.0</version> <!-- 请查看最新版本:https://mvnrepository.com/artifact/org.flowable -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>

6
src/main/java/com/example/demo/DemoApplication.java

@ -1,12 +1,16 @@
package com.example.demo;
import org.flowable.spring.boot.ProcessEngineAutoConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling // 启用调度功能
@SpringBootApplication(exclude = {
ProcessEngineAutoConfiguration.class,
})
@MapperScan(basePackages = "com.example.demo.mapper.coin", sqlSessionTemplateRef = "mysql1SqlSessionTemplate")
@MapperScan(basePackages = "com.example.demo.mapper.bean", sqlSessionTemplateRef = "mysql2SqlSessionTemplate")
@MapperScan(basePackages = "com.example.demo.mapper.pay", sqlSessionTemplateRef = "mysql3SqlSessionTemplate")

34
src/main/java/com/example/demo/config/FlowableDataSourceConfig.java

@ -0,0 +1,34 @@
// FlowableDataSourceConfig.java
package com.example.demo.config;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
@Configuration
public class FlowableDataSourceConfig {
@Bean(name = "flowableDataSource")
@ConfigurationProperties(prefix = "spring.datasource.flowable")
public DataSource flowableDataSource() {
HikariDataSource ds = DataSourceBuilder
.create()
.type(HikariDataSource.class)
.build();
ds.setConnectionInitSql("SET SESSION sql_mode='TRADITIONAL';");
return ds;
}
@Bean(name = "flowableTransactionManager")
public PlatformTransactionManager flowableTransactionManager(
@Qualifier("flowableDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}

56
src/main/java/com/example/demo/config/work/FlowableEngineConfig.java

@ -0,0 +1,56 @@
// FlowableEngineConfig.java
package com.example.demo.config.work;
import org.flowable.common.engine.impl.history.HistoryLevel;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
@Configuration
public class FlowableEngineConfig {
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration(
@Qualifier("flowableDataSource") DataSource flowableDataSource,
@Qualifier("flowableTransactionManager") PlatformTransactionManager transactionManager) {
SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
config.setDataSource(flowableDataSource); // 👈 指定 Flowable 数据源
config.setTransactionManager(transactionManager);
config.setDatabaseSchemaUpdate("true"); // 自动建表
config.setHistoryLevel(HistoryLevel.FULL).setAsyncExecutorActivate(false); // 记录完整历史
// 暂时关闭异步执行器
return config;
}
// 👇 以下 Service Bean 可选但推荐注入方便 Controller 使用
@Bean
public RepositoryService repositoryService(SpringProcessEngineConfiguration config) {
return config.buildProcessEngine().getRepositoryService();
}
@Bean
public RuntimeService runtimeService(SpringProcessEngineConfiguration config) {
return config.buildProcessEngine().getRuntimeService();
}
@Bean
public TaskService taskService(SpringProcessEngineConfiguration config) {
return config.buildProcessEngine().getTaskService();
}
@Bean
public HistoryService historyService(SpringProcessEngineConfiguration config) {
return config.buildProcessEngine().getHistoryService();
}
}

11
src/main/resources/application-dev.yml

@ -48,6 +48,14 @@ spring:
username: gjb_test
password: qweuio!@#$2
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
flowable:
jdbc-url: jdbc:mysql://localhost:3306/flowable?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true
username: hwgoldc
password: zB48T55wCsHC8KPz
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
pool-name: flowableHikariCP
maximum-pool-size: 10
application:
name: demo
@ -98,5 +106,4 @@ bean:
url: http://39.101.133.168:8828/hljwgo/api/wallet/recharge
consume:
url: http://39.101.133.168:8828/hljwgo/api/wallet/pay
server:
port: 10704
server:

13
src/main/resources/application-test.yml

@ -48,7 +48,18 @@ spring:
username: gjb_test
password: qweuio!@#$2
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
flowable:
jdbc-url: jdbc:mysql://54.255.212.181:3306/flowable?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&allowMultiQueries=true&rewriteBatchedStatements=true
username: flowable
password: bN8NLHLAreSWTEZB
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
pool-name: FlowableHikariPool
maximum-pool-size: 20
minimum-idle: 5
connection-timeout: 30000
idle-timeout: 600000
max-lifetime: 1200000
application:
name: demo
cache:

Loading…
Cancel
Save