flowable自动更新表,不用手动创建
1、数据库连接增加:nullCatalogMeansCurrent=trueurl: jdbc:mysql://localhost:3306/ksh_llcb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT
·
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);
更多推荐
已为社区贡献2条内容
所有评论(0)