flowable自动更新表,不用手动创建

本文介绍了如何配置数据库连接,包括设置`nullCatalogMeansCurrent=true`参数,以及Flowable在不同环境下的数据库更新策略。同时,讲解了如何开启Flowable的SQL日志,以便于调试。在流程实例的启动与跟踪方面,展示了如何设置和获取流程发起人,并提供了两种不同的获取方式,通过HistoricProcessInstance和HistoricIdentityLink查询。这些信息对于理解和调试Flowable工作流引擎的运行至关重要。
1、数据库连接增加:nullCatalogMeansCurrent=true
url: jdbc:mysql://localhost:3306/ksh_llcb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true

2、yml配置

#flase:       默认值。activiti在启动时,会对比数据库表中保存的版本,如果没有表或者版本不匹配,将抛出异常。(生产环境常用)
#true:        activiti会对数据库中所有表进行更新操作。如果表不存在,则自动创建。(开发时常用)
flowable:
  database-schema-update: false

3、打印flowable的SQL日志需要打开

# 日志配置
logging:
  level:
    org.flowable.engine.impl.persistence.entity.*: debug
    org.flowable.task.service.impl.persistence.entity.*: debug# 日志配置

4、获取流程发起人

1.  设置流程发起人
//设置流程发起人
Authentication.setAuthenticatedUserId(userId);
ProcessInstance processInstance =  runtimeService.startProcessInstanceByKey(procdefKey,businessKey, paras);
//这个方法最终使用一个ThreadLocal类型的变量进行存储,也就是与当前的线程绑定,所以流程实例启动完毕之后,需要设置为null,防止多线程的时候出问题。
Authentication.setAuthenticatedUserId(null);



2. 获取流程发起人(需要在启动流程前设置流程发起人)


HistoricProcessInstance hi = historyService.createHistoricProcessInstanceQuery()
        .processInstanceId(procInsId)
        .singleResult();
String startUserId = hi.getStartUserId();

5、获取流程发起人方法2

-- 历史的流程运行过程中用户关系
-- select * from act_hi_identitylink 
FlowTaskDto flowTaskCreater = new FlowTaskDto();
            List<HistoricIdentityLink> linksForTaskCreater = historyService.getHistoricIdentityLinksForProcessInstance(procInsId);
            for (HistoricIdentityLink identityLink : linksForTaskCreater) {
                // 关联发起人
                if("starter".equals(identityLink.getType())&& StrUtil.isNotBlank(identityLink.getUserId())){
                    SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId()));
                    flowTaskCreater.setStartUserName(sysUser.getNickName());
                    flowTaskCreater.setCandidate(sysUser.getNickName());
                    flowTaskCreater.setCandidate(sysUser.getNickName());
                    flowTaskCreater.setCreateTime(identityLink.getCreateTime());
                }
            }
            hisFlowList.add(flowTaskCreater);

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值