业界 作者:SegmentFault 2022-11-14 16:38:05 阅读:858
1. 默认行为
flowable.check-process-definitions=false
flowable.process-definition-location-prefix=classpath*:/processes/
flowable.process-definition-location-suffixes=**.bpmn20.xml,**.bpmn
flowable.check-process-definitions:这个表示是否在项目启动的时候,去检查文件目录是否有对应的流程文件,该属性为 true 表示如果有流程文件就自动部署,false 表示不检查,那么也就不会自动部署。flowable.process-definition-location-prefix:这个是流程文件的位置,默认就是 classpath*:/processes/,当然开发者也可以进行配置。flowable.process-definition-location-suffixes:这个是流程文件的后缀,默认有两个,分别是 **.bpmn20.xml和 **.bpmn,当然开发者也可以进行配置。2. 动态部署
@RestController
public class ProcessDeployController {
@Autowired
RepositoryService repositoryService;
@PostMapping("/deploy")
public RespBean deploy(MultipartFile file) throws IOException {
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment()
.category("javaboy的工作流分类")
.name("javaboy的工作流名称")
.addInputStream(file.getOriginalFilename(), file.getInputStream())
.key("javaboy的工作流key");
Deployment deployment = deploymentBuilder
.deploy();
return RespBean.ok("部署成功",deployment.getId());
}
}
3. 表分析






4. 查询操作
logging.level.org.flowable=debug
@Test
void test01() throws IOException {
List<Deployment> list = repositoryService.createDeploymentQuery().list();
for (Deployment deployment : list) {
logger.info("id:{};key:{}", deployment.getId(), deployment.getKey());
}
}


javaboy的工作流key 的流程部署文件,但是这个流程我之前部署过多次(版本升级),现在我想查询最近一次的流程部署信息,查询方式如下:@Test
void test01() throws IOException {
Deployment deployment = repositoryService.createDeploymentQuery().deploymentKey("javaboy的工作流key").latest().singleResult();
logger.info("id:{};key:{}", deployment.getId(), deployment.getKey());
}
--- [ main] i.p.e.D.selectDeploymentsByQueryCriteria : ==> Preparing: SELECT RES.* from ACT_RE_DEPLOYMENT RES WHERE RES.KEY_ = ? and RES.DEPLOY_TIME_ = (select max(DEPLOY_TIME_) from ACT_RE_DEPLOYMENT where KEY_ = RES.KEY_ and DERIVED_FROM_ is null and ( (TENANT_ID_ IS NOT NULL and TENANT_ID_ = RES.TENANT_ID_) or (TENANT_ID_ IS NULL and RES.TENANT_ID_ IS NULL) ) ) order by RES.ID_ asc
--- [ main] i.p.e.D.selectDeploymentsByQueryCriteria : ==> Parameters: javaboy的工作流key(String)
--- [ main] i.p.e.D.selectDeploymentsByQueryCriteria : <== Total: 1
javaboy的工作流key,查询时间是一个最大的时间,这就很好懂了。@Test
void test02() {
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list();
for (ProcessDefinition pd : list) {
logger.info("id:{};key:{};version:{};",pd.getId(),pd.getKey(),pd.getVersion());
}
}

@Test
void test02() {
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().processDefinitionKey("javaboy_submit_an_expense_account").list();
for (ProcessDefinition pd : list) {
logger.info("id:{};key:{};version:{};",pd.getId(),pd.getKey(),pd.getVersion());
}
}

javaboy的工作流key 的流程部署文件,但是这个流程我之前部署过多次(版本升级),现在我想查询最近一次的流程部署信息,查询方式如下:@Test
void test03() {
Deployment deployment = repositoryService.createNativeDeploymentQuery().sql("SELECT RES.* from ACT_RE_DEPLOYMENT RES WHERE RES.KEY_ = #{key} and RES.DEPLOY_TIME_ = (select max(DEPLOY_TIME_) from ACT_RE_DEPLOYMENT where KEY_ = RES.KEY_) order by RES.ID_ asc").parameter("key", "javaboy的工作流key").singleResult();
logger.info("id:{};key:{}", deployment.getId(), deployment.getKey());
}
@Test
void test04() {
List<ProcessDefinition> list = repositoryService.createNativeProcessDefinitionQuery()
.sql("SELECT RES.* from ACT_RE_PROCDEF RES WHERE RES.KEY_ = #{key} order by RES.ID_ asc")
.parameter("key", "javaboy_submit_an_expense_account").list();
for (ProcessDefinition pd : list) {
logger.info("id:{};key:{};version:{};", pd.getId(), pd.getKey(), pd.getVersion());
}
}

