add - 接入 flowable form engine,并对简单 api 进行测试.

This commit is contained in:
wangli 2023-07-19 20:58:02 +08:00
parent 1adfeab1f6
commit 121330f36f
11 changed files with 174 additions and 96 deletions

View File

@ -36,22 +36,20 @@
<artifactId>hutool-all</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-bpmn-model</artifactId>
<version>${flowable.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-json-converter</artifactId>
<artifactId>flowable-spring-boot-starter-basic</artifactId>
<version>${flowable.version}</version>
<scope>compile</scope>
</dependency>
<!--<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-form-spring</artifactId>
<version>${flowable.version}</version>
</dependency>-->
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-spring-boot-starter-basic</artifactId>
<artifactId>flowable-form-spring-configurator</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
@ -59,17 +57,6 @@
<artifactId>flowable-spring-boot-starter-actuator</artifactId>
<version>${flowable.version}</version>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-bpmn-converter</artifactId>
<version>${flowable.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine</artifactId>
<version>6.7.2</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,15 @@
package cn.axzo.workflow.core.service;
/**
* TODO
*
* @author wangli
* @since 2023/7/19 16:46
*/
public interface BpmFormService {
String createFormModel();
public void deploy2();
void listDeployment();
}

View File

@ -0,0 +1,103 @@
package cn.axzo.workflow.core.service.impl;
import cn.axzo.workflow.core.service.BpmFormService;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.flowable.form.api.FormDeployment;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.api.FormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* TODO
*
* @author wangli
* @since 2023/7/19 16:47
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class BpmFormServiceImpl implements BpmFormService {
@Autowired
private FormRepositoryService formRepositoryService;
@Autowired
private FormService formService;
@Override
public String createFormModel() {
String formDefinition = "{\n" +
" \"name\": \"第一个表单\",\n" +
" \"key\": \"fristForm\",\n" +
" \"fields\": [\n" +
" {\n" +
" \"fieldType\": \"FormField\",\n" +
" \"id\": \"account\",\n" +
" \"name\": \"账号\",\n" +
" \"type\": \"text\",\n" +
" \"value\": null,\n" +
" \"required\": true,\n" +
" \"readOnly\": false,\n" +
" \"overrideId\": true,\n" +
" \"placeholder\": \"请输入账号\",\n" +
" \"params\": {\n" +
" \"minLength\": \"1\",\n" +
" \"maxLength\": \"8\",\n" +
" \"mask\": \"*\"\n" +
" },\n" +
" \"layout\": null\n" +
" },\n" +
" {\n" +
" \"fieldType\": \"FormField\",\n" +
" \"id\": \"password\",\n" +
" \"name\": \"密码\",\n" +
" \"type\": \"password\",\n" +
" \"value\": null,\n" +
" \"required\": true,\n" +
" \"readOnly\": false,\n" +
" \"overrideId\": true,\n" +
" \"placeholder\": \"请输入密码\",\n" +
" \"params\": {\n" +
" \"minLength\": \"1\",\n" +
" \"maxLength\": \"18\",\n" +
" \"passwordunmask\": true\n" +
" },\n" +
" \"layout\": null\n" +
" }\n" +
" ],\n" +
" \"outcomes\": []\n" +
" }";
FormDeployment deploy = formRepositoryService.createDeployment()
.name("第一个表单")
.category("business_category")
.addFormDefinition("firstForm", formDefinition)
.deploy();
log.info("deployId : {}", deploy.getId());
return deploy.getId();
}
public void deploy2() {
FormDeployment deploy = formRepositoryService.createDeployment()
.name("第二个表单")
.addClasspathResource("simple.form")
.deploy();
log.info("deployId : {}", deploy.getId());
}
public void listDeployment() {
List<FormDeployment> list = formRepositoryService.createDeploymentQuery()
.deploymentNameLike("第一个%")
.orderByDeploymentTime()
.desc().list();
list.forEach(i -> {
log.info("deployment: {}", JSON.toJSONString(i));
});
}
}

View File

@ -8,7 +8,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@MapperScan({"cn.axzo.workflow.core.**.mapper"})
@ComponentScan({"cn.axzo.server", "cn.axzo.workflow.core"})
@ComponentScan({"cn.axzo.workflow"})
@SpringBootApplication
@EnableTransactionManagement
public class WorkflowEnginApplication {

View File

@ -0,0 +1,43 @@
package cn.axzo.workflow.server.controller.web;
import cn.axzo.workflow.core.service.BpmFormService;
import cn.azxo.framework.common.model.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* TODO
*
* @author wangli
* @since 2023/7/19 16:45
*/
@Slf4j
@RequestMapping("/web/v1/api/form")
@RestController
public class BpmFormController {
@Autowired
private BpmFormService bpmFormService;
@PostMapping("/create")
public CommonResponse<String> createFormModel() {
bpmFormService.createFormModel();
return CommonResponse.success();
}
@GetMapping("/deploy/list")
public CommonResponse<Void> listDeployment() {
bpmFormService.listDeployment();
return CommonResponse.success();
}
@GetMapping("/deploy")
public CommonResponse<Void> deploy2() {
bpmFormService.deploy2();
return CommonResponse.success();
}
}

View File

@ -18,7 +18,7 @@ import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
@Slf4j
@RequestMapping("/web/v1/api/bpm/model")
@RequestMapping("/web/v1/api/model")
@RestController
@Validated
public class BpmModelController {

View File

@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
@Slf4j
@RequestMapping("/web/v1/api/bpm/process/definition")
@RequestMapping("/web/v1/api/process/definition")
@RestController
public class BpmProcessDefinitionController {
@Autowired

View File

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@Slf4j
@RequestMapping("/web/v1/api/bpm/processInstance")
@RequestMapping("/web/v1/api/process/instance")
@RestController
public class BpmProcessInstanceController {

View File

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
@Slf4j
@RequestMapping("/web/v1/api/bpm/task")
@RequestMapping("/web/v1/api/task")
@RestController
public class BpmTaskController {

View File

@ -1,71 +0,0 @@
server:
port: 8080
spring:
profiles:
default: local
main:
allow-bean-definition-overriding: true
cloud:
config:
override-none: true
allow-override: true
override-system-properties: false
# Servlet 配置
servlet:
# 文件上传相关配置项
multipart:
max-file-size: 16MB # 单个文件大小
max-request-size: 32MB # 设置总上传的文件大小
# Jackson 配置项
jackson:
serialization:
write-dates-as-timestamps: true # 设置 Date 的格式,使用时间戳
write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401
write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
fail-on-empty-beans: false # 允许序列化无属性的 Bean
# Cache 配置项
cache:
type: REDIS
redis:
time-to-live: 1h # 设置过期时间为 1 小时
# 工作流 Activiti 配置
activiti:
# 1. false: 默认值activiti启动时对比数据库表中保存的版本如果不匹配。将抛出异常
# 2. true: 启动时会对数据库中所有表进行更新操作,如果表存在,不做处理,反之,自动创建表
# 3. create_drop: 启动时自动创建表,关闭时自动删除表
# 4. drop_create: 启动时,删除旧表,再创建新表
database-schema-update: false # 设置为 false可通过 sql/activiti.sql 初始化
db-history-used: true # activiti7 默认 false 不生成历史信息表,需手动设置开启
check-process-definitions: false # 设置为 false禁用 /resources/processes 自动部署 BPMN XML 流程
history-level: full # full保存历史数据的最高级别可保存全部流程相关细节包括流程流转各节点参数
# MyBatis Plus 的配置项
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #这个配置会将执行的sql打印出来在开发或测试的时候可以用
global-config:
db-config:
id-type: AUTO # 自增 ID
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject
debug: true
logging:
level:
root: debug
--- #################### 数据库相关配置 ####################
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://121.36.251.132:3006/workflow?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false&verifyServerCertificate=false
type: com.zaxxer.hikari.HikariDataSource
username: workflow
password: z4P1r7cj1B3Vg94y

View File

@ -8,6 +8,7 @@ spring:
logging:
level:
com.alibaba.nacos.client.config.impl: WARN
root: debug
---
#开发环境