本文主要是介绍解决Camunda评论表中user_id为空的问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
@Override
public List<TaskDto> simpleStartProcess(PscCommonProcessRequest pscCommonProcessRequest, HttpServletRequest request)
throws Exception {
AuthenticationService authenticationService = new AuthenticationService();//获取当前流程引擎的名称
String engineName = processEngine.getName();//用户无密码登录
UserAuthentication authentication = (UserAuthentication) authenticationService.createAuthenticate(engineName,
pscCommonProcessRequest.getStarter(), null, null);
logger.info("authentication--------->" + authentication.getName());//刷新session
Authentications.revalidateSession(request, authentication);//设置当前用户为操作人
identityService.setAuthenticatedUserId(authentication.getName());
String processInstanceId = null;
List<TaskDto> resultList = new ArrayList<TaskDto>();
Map<String, Object> variables = new HashMap<String, Object>();
variables = pscCommonProcessRequest.getVariables();
// variables.put("assigneeList030", Arrays.asList("kermit", "demo"));
// variables.put("assigneeList040", Arrays.asList("kermit", "demo"));
variables.put("starter", pscCommonProcessRequest.getStarter());
variables.put("amount", "980");
ProcessInstance processInstance = null;
// 流程初始化
if (StringUtils.isNotBlank(pscCommonProcessRequest.getProcessDefKey())) {
processInstance = runtimeService.startProcessInstanceByKey(pscCommonProcessRequest.getProcessDefKey(),
variables);
} else {
processInstance = runtimeService.startProcessInstanceById(pscCommonProcessRequest.getProcessDefId(),
variables);
}
// 创建成功
if (processInstance != null && StringUtils.isNotBlank(processInstance.getId())) {
processInstanceId = processInstance.getId();
List<TaskDto> taskList = simpleGetTasks(processInstanceId);
logger.info(JSON.toJSONString(taskList));
if (taskList != null && taskList.size() == 1) {
taskService.complete(taskList.get(0).getId(), variables);
taskService.createComment(taskList.get(0).getId(), processInstanceId, "提交流程");
resultList = simpleGetTasks(processInstanceId);
} else {
throw new Exception("获取提交任务失败:" + taskList.size());
}
} else {
throw new Exception("创建流程实例失败:");
}
return resultList;
}
未添加 identityService.setAuthenticatedUserId()前
添加后
GitHub地址: https://github.com/skayliu/CamundaSpringBootDemo
码云地址:https://gitee.com/skay463/CamundaSpringBootDemo
这篇关于解决Camunda评论表中user_id为空的问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!