Browse Source

10.11 运行修改配置

lihuilin1015备份
huangqizhen 2 months ago
parent
commit
6090356a42
  1. 11
      src/main/java/com/example/demo/config/Mysql1DataSourceConfig.java
  2. 61
      src/main/java/com/example/demo/config/work/FlowableEngineConfig.java
  3. 4
      src/main/java/com/example/demo/controller/cash/CashRefundController.java
  4. 7
      src/main/resources/application.yml
  5. 132
      src/main/resources/processes/work.bpmn20.xml

11
src/main/java/com/example/demo/config/Mysql1DataSourceConfig.java

@ -15,6 +15,7 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
import java.util.Arrays;
@Slf4j
@Configuration
@ -48,11 +49,19 @@ public DataSource mysql1DataSource() {
@Qualifier("globalConfiguration1") org.apache.ibatis.session.Configuration globalConfiguration1) throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:{mapper,cashMapper}/*.xml"));
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
org.springframework.core.io.Resource[] mapperResources = resolver.getResources("classpath*:mapper/*.xml");
org.springframework.core.io.Resource[] cashMapperResources = resolver.getResources("classpath*:cashMapper/*.xml");
org.springframework.core.io.Resource[] allResources = Arrays.copyOf(mapperResources, mapperResources.length + cashMapperResources.length);
System.arraycopy(cashMapperResources, 0, allResources, mapperResources.length, cashMapperResources.length);
sessionFactory.setMapperLocations(allResources);
sessionFactory.setConfiguration(globalConfiguration1);
return sessionFactory.getObject();
}
@Bean(name = "mysql1SqlSessionTemplate")
// @Primary
public SqlSessionTemplate mysql1SqlSessionTemplate(@Qualifier("mysql1SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {

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

@ -1,12 +1,8 @@
// 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.engine.*;
import org.flowable.spring.ProcessEngineFactoryBean;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
@ -18,39 +14,56 @@ import javax.sql.DataSource;
@Configuration
public class FlowableEngineConfig {
/**
* 1. 创建 ProcessEngineFactoryBean
* Spring 会负责调用 buildProcessEngine() 并缓存实例
*/
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration(
@Qualifier("flowableDataSource") DataSource flowableDataSource,
public ProcessEngineFactoryBean processEngineFactory(
@Qualifier("flowableDataSource") DataSource dataSource,
@Qualifier("flowableTransactionManager") PlatformTransactionManager transactionManager) {
SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
config.setDataSource(flowableDataSource); // 👈 指定 Flowable 数据源
config.setTransactionManager(transactionManager);
config.setDatabaseSchemaUpdate("true"); // 自动建表
config.setHistoryLevel(HistoryLevel.FULL).setAsyncExecutorActivate(false); // 记录完整历史
// 暂时关闭异步执行器
SpringProcessEngineConfiguration cfg = new SpringProcessEngineConfiguration();
cfg.setDataSource(dataSource);
cfg.setTransactionManager(transactionManager);
cfg.setDatabaseSchemaUpdate("false"); // 自动建/升级表
cfg.setHistoryLevel(HistoryLevel.FULL); // 记录完整历史
cfg.setAsyncExecutorActivate(false); // 暂不开启异步执行器
ProcessEngineFactoryBean factory = new ProcessEngineFactoryBean();
factory.setProcessEngineConfiguration(cfg);
return factory;
}
/* 2. 各类 Service 注入 —— 都取自同一个 ProcessEngine *********************/
return config;
@Bean
public RepositoryService repositoryService(ProcessEngine processEngine) {
return processEngine.getRepositoryService();
}
@Bean
public RuntimeService runtimeService(ProcessEngine processEngine) {
return processEngine.getRuntimeService();
}
// 👇 以下 Service Bean 可选但推荐注入方便 Controller 使用
@Bean
public RepositoryService repositoryService(SpringProcessEngineConfiguration config) {
return config.buildProcessEngine().getRepositoryService();
public TaskService taskService(ProcessEngine processEngine) {
return processEngine.getTaskService();
}
@Bean
public RuntimeService runtimeService(SpringProcessEngineConfiguration config) {
return config.buildProcessEngine().getRuntimeService();
public HistoryService historyService(ProcessEngine processEngine) {
return processEngine.getHistoryService();
}
@Bean
public TaskService taskService(SpringProcessEngineConfiguration config) {
return config.buildProcessEngine().getTaskService();
public ManagementService managementService(ProcessEngine processEngine) {
return processEngine.getManagementService();
}
@Bean
public HistoryService historyService(SpringProcessEngineConfiguration config) {
return config.buildProcessEngine().getHistoryService();
public IdentityService identityService(ProcessEngine processEngine) {
return processEngine.getIdentityService();
}
}

4
src/main/java/com/example/demo/controller/cash/CashRefundController.java

@ -89,4 +89,8 @@ public class CashRefundController {
public Result update(@RequestBody CashCollection cashCollection){
return Result.success(cashRefundServiceImpl.update(cashCollection));
}
// @PostMapping("/local")
// public Result local(@RequestBody CashCollection cashCollection){
// return Result.success(cashRefundServiceImpl.local(cashCollection));
// }
}

7
src/main/resources/application.yml

@ -15,8 +15,13 @@ spring:
name: demo
mybatis:
type-handlers-package: com.example.demo.Util
mapper-locations: classpath*:**/*Mapper.xml
type-aliases-package: com.example.demo.domain.entity
mapper-locations:
- classpath:mapper/*.xml
- classpath:cashMapper/*.xml
- classpath:jindouMapper/*.xml
- classpath:liveMapper/*.xml
- classpath:paymapper/*.xml
configuration:
mysql1:
map-underscore-to-camel-case: true

132
src/main/resources/processes/work.bpmn20.xml

@ -1,132 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef">
<process id="work" name="work" isExecutable="true">
<startEvent id="sid-f8ab3e40-3236-4e2c-8c2e-42c8b0673350" name="start"/>
<userTask id="sid-bf6d438a-c124-4d0b-9616-7a8917fe31be" name="当地财务审核">
<extensionElements>
<flowable:executionListener class="Class 1"/>
</extensionElements>
</userTask>
<sequenceFlow id="sid-21dc60a2-3215-441d-a332-9fcc18f3554a" sourceRef="sid-f8ab3e40-3236-4e2c-8c2e-42c8b0673350" targetRef="sid-bf6d438a-c124-4d0b-9616-7a8917fe31be"/>
<userTask id="sid-468a34ae-6742-442d-968a-4a64da1c4d42" name="地区负责人审核"/>
<exclusiveGateway id="sid-2fee5126-0cab-454d-83b8-7e1590ca672b"/>
<sequenceFlow id="sid-d99251a8-f290-4c61-88f3-67c4fdb3936f" sourceRef="sid-bf6d438a-c124-4d0b-9616-7a8917fe31be" targetRef="sid-2fee5126-0cab-454d-83b8-7e1590ca672b"/>
<endEvent id="sid-dd93e6d7-7685-442e-923b-1914223d8fab">
<terminateEventDefinition/>
</endEvent>
<sequenceFlow id="sid-383a4ef0-2fc2-415a-b8cf-bab0bcca8273" sourceRef="sid-2fee5126-0cab-454d-83b8-7e1590ca672b" targetRef="sid-dd93e6d7-7685-442e-923b-1914223d8fab" name="财务驳回">
<conditionExpression xsi:type="tFormalExpression">${status=='12'}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-89dc161a-9f8b-4c81-be12-c9d517118d4f" sourceRef="sid-2fee5126-0cab-454d-83b8-7e1590ca672b" targetRef="sid-468a34ae-6742-442d-968a-4a64da1c4d42" name="当地财务审核通过">
<conditionExpression xsi:type="tFormalExpression">${status=='20'}</conditionExpression>
</sequenceFlow>
<exclusiveGateway id="sid-2e8f3dde-f7dd-42e6-9578-188489000af4"/>
<sequenceFlow id="sid-4e6091b1-dac2-4af9-a10b-4102962f699d" sourceRef="sid-468a34ae-6742-442d-968a-4a64da1c4d42" targetRef="sid-2e8f3dde-f7dd-42e6-9578-188489000af4"/>
<endEvent id="sid-c7acb14b-e462-4e1a-bdf6-6b05c96b11f9">
<terminateEventDefinition/>
</endEvent>
<sequenceFlow id="sid-c99e2377-dfb1-4a07-a6fd-487fd03f45c3" sourceRef="sid-2e8f3dde-f7dd-42e6-9578-188489000af4" targetRef="sid-c7acb14b-e462-4e1a-bdf6-6b05c96b11f9" name="负责人驳回">
<conditionExpression xsi:type="tFormalExpression">${status=='22'}</conditionExpression>
</sequenceFlow>
<userTask id="sid-22acc750-e0a9-49d1-80e2-2d8b19ec0a9f" name="总部财务审批"/>
<sequenceFlow id="sid-9c0b8ad2-8f5f-418f-913c-9b2be1ea139e" sourceRef="sid-2e8f3dde-f7dd-42e6-9578-188489000af4" targetRef="sid-22acc750-e0a9-49d1-80e2-2d8b19ec0a9f" name="地区负责人审核通过">
<conditionExpression xsi:type="tFormalExpression">${status=='30'}</conditionExpression>
</sequenceFlow>
<exclusiveGateway id="sid-82edb572-12d0-457e-a5b0-c416803c42ef"/>
<sequenceFlow id="sid-557630ce-b991-400e-a800-1d09fa2999d9" sourceRef="sid-22acc750-e0a9-49d1-80e2-2d8b19ec0a9f" targetRef="sid-82edb572-12d0-457e-a5b0-c416803c42ef"/>
<endEvent id="sid-44496c97-4cae-4011-8af2-6923f8016a3f">
<terminateEventDefinition/>
</endEvent>
<sequenceFlow id="sid-034cda19-b5a4-4505-9880-7bc947c6a1c1" sourceRef="sid-82edb572-12d0-457e-a5b0-c416803c42ef" targetRef="sid-44496c97-4cae-4011-8af2-6923f8016a3f" name="总部财务审批">
<conditionExpression xsi:type="tFormalExpression"/>
</sequenceFlow>
<endEvent id="sid-6df885e4-d40a-4a6c-bff0-bc8604eb186a">
<terminateEventDefinition/>
<extensionElements>
<flowable:executionListener class="Class 1" event="end">
<flowable:field name="Name 1"/>
</flowable:executionListener>
</extensionElements>
</endEvent>
<sequenceFlow id="sid-dc24872f-5c8e-43fa-8348-6ea038d3dda9" sourceRef="sid-82edb572-12d0-457e-a5b0-c416803c42ef" targetRef="sid-6df885e4-d40a-4a6c-bff0-bc8604eb186a" name="总部财务审批通过">
<conditionExpression xsi:type="tFormalExpression">${status=='40'}</conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_work">
<bpmndi:BPMNPlane bpmnElement="work" id="BPMNPlane_work">
<bpmndi:BPMNShape id="shape-822c5fe2-36b7-4467-826c-0f1dd8fc80fe" bpmnElement="sid-f8ab3e40-3236-4e2c-8c2e-42c8b0673350">
<omgdc:Bounds x="-70.0" y="40.0" width="30.0" height="30.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape-084334ea-0095-4ca2-9c70-620a2e5ffeb7" bpmnElement="sid-bf6d438a-c124-4d0b-9616-7a8917fe31be">
<omgdc:Bounds x="5.0" y="10.0" width="100.0" height="80.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge-19e173f1-0fd2-43ca-995f-d1d03097318c" bpmnElement="sid-21dc60a2-3215-441d-a332-9fcc18f3554a">
<omgdi:waypoint x="-40.0" y="47.5"/>
<omgdi:waypoint x="5.0" y="50.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="shape-84d30d41-e66a-496e-8ce7-2d3d6a384345" bpmnElement="sid-468a34ae-6742-442d-968a-4a64da1c4d42">
<omgdc:Bounds x="205.0" y="10.0" width="100.0" height="80.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape-9b68e4fd-ea80-4b09-b9f3-fd734bb4321f" bpmnElement="sid-2fee5126-0cab-454d-83b8-7e1590ca672b">
<omgdc:Bounds x="130.0" y="30.0" width="40.0" height="40.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge-921c6dc0-4707-417f-af15-c3339f530411" bpmnElement="sid-d99251a8-f290-4c61-88f3-67c4fdb3936f">
<omgdi:waypoint x="105.0" y="50.0"/>
<omgdi:waypoint x="130.0" y="50.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="shape-bac9b355-7d7d-4779-9c3f-814f6023fecb" bpmnElement="sid-dd93e6d7-7685-442e-923b-1914223d8fab">
<omgdc:Bounds x="135.0" y="100.0" width="30.0" height="30.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge-5bafc0c0-2bfc-4aca-bf40-4057253a8ec7" bpmnElement="sid-383a4ef0-2fc2-415a-b8cf-bab0bcca8273">
<omgdi:waypoint x="150.0" y="70.0"/>
<omgdi:waypoint x="150.0" y="100.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge-45ad2c75-2cb6-4d16-9fbe-461d31f91ea8" bpmnElement="sid-89dc161a-9f8b-4c81-be12-c9d517118d4f">
<omgdi:waypoint x="170.0" y="50.0"/>
<omgdi:waypoint x="205.0" y="50.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="shape-517c52d0-04dd-472f-b807-df6a9d843e99" bpmnElement="sid-2e8f3dde-f7dd-42e6-9578-188489000af4">
<omgdc:Bounds x="355.0" y="30.0" width="40.0" height="40.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge-8a30bd1d-80d1-4ae8-a3ed-81c72c55213f" bpmnElement="sid-4e6091b1-dac2-4af9-a10b-4102962f699d">
<omgdi:waypoint x="305.0" y="50.0"/>
<omgdi:waypoint x="355.0" y="50.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="shape-a44faab4-bac1-43e7-bf22-c173b971e3b7" bpmnElement="sid-c7acb14b-e462-4e1a-bdf6-6b05c96b11f9">
<omgdc:Bounds x="360.0" y="100.0" width="30.0" height="30.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge-26a40ce5-e66e-45d9-9dad-8f5fa6633c07" bpmnElement="sid-c99e2377-dfb1-4a07-a6fd-487fd03f45c3">
<omgdi:waypoint x="375.0" y="70.0"/>
<omgdi:waypoint x="375.0" y="100.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="shape-6f86a7c0-32a7-4511-baa7-52f11ce57a21" bpmnElement="sid-22acc750-e0a9-49d1-80e2-2d8b19ec0a9f">
<omgdc:Bounds x="440.0" y="10.0" width="100.0" height="80.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge-1aa7f3d5-b79c-44de-aba3-eb086e8a5274" bpmnElement="sid-9c0b8ad2-8f5f-418f-913c-9b2be1ea139e">
<omgdi:waypoint x="395.0" y="50.0"/>
<omgdi:waypoint x="440.0" y="50.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="shape-bc18feae-7519-4693-b30c-ec647a3c985c" bpmnElement="sid-82edb572-12d0-457e-a5b0-c416803c42ef">
<omgdc:Bounds x="580.0" y="30.0" width="40.0" height="40.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge-afe759c8-9b35-4771-a711-01be0bd46230" bpmnElement="sid-557630ce-b991-400e-a800-1d09fa2999d9">
<omgdi:waypoint x="540.0" y="50.0"/>
<omgdi:waypoint x="580.0" y="50.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="shape-400c0807-7443-488e-8d1e-a72e93853f65" bpmnElement="sid-44496c97-4cae-4011-8af2-6923f8016a3f">
<omgdc:Bounds x="585.0" y="100.0" width="30.0" height="30.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge-89fb4c38-c73e-4ab5-ba48-ddeae0b199e1" bpmnElement="sid-034cda19-b5a4-4505-9880-7bc947c6a1c1">
<omgdi:waypoint x="600.0" y="70.0"/>
<omgdi:waypoint x="600.0" y="100.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="shape-26a2f5e7-cd7d-4319-9442-a2006a703954" bpmnElement="sid-6df885e4-d40a-4a6c-bff0-bc8604eb186a">
<omgdc:Bounds x="665.0" y="35.0" width="30.0" height="30.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge-1bed364a-4069-450b-b9f0-4691f385e817" bpmnElement="sid-dc24872f-5c8e-43fa-8348-6ea038d3dda9">
<omgdi:waypoint x="620.0" y="50.0"/>
<omgdi:waypoint x="665.0" y="50.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
Loading…
Cancel
Save