解决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()前

 添加后

Camnunda工作流引擎

码云地址:https://gitee.com/skay463/camunda-spring-boot-demo

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值