当前位置:网站首页>使用camunda做工作流设计,驳回操作

使用camunda做工作流设计,驳回操作

2022-07-07 18:13:00 枫林残@

判断是否驳回,可参照如下表格:

 

 camunda页面表象:

 

具体代码实现:

 ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
        List<HistoricActivityInstance> resultList = historyService
                .createHistoricActivityInstanceQuery()
                .processInstanceId(processInstanceId)
                .activityType("userTask")
                .finished()
                .orderByHistoricActivityInstanceEndTime()
                .asc()
                .list();
        //得到任务节点id
        List<HistoricActivityInstance> historicActivityInstanceList = resultList.stream().filter(historicActivityInstance -> historicActivityInstance.getActivityId().equals(rejectTaskDTO.getTaskKey())).collect(Collectors.toList());
        HistoricActivityInstance historicActivityInstance = historicActivityInstanceList.get(0);
        String toActId = historicActivityInstance.getActivityId();
        taskService.createComment(task.getId(), processInstanceId, rejectTaskDTO.getMessage());
        runtimeService.createProcessInstanceModification(processInstanceId)
                .cancelActivityInstance(getInstanceIdForActivity(tree, task.getTaskDefinitionKey()))
                .cancelAllForActivity(currentTaskId)
                .setAnnotation("进行了驳回到指定任务节点操作")
                .startBeforeActivity(toActId)//启动目标活动节点
                .execute();

taskKey :为需要驳回到的活动节点key

currentTaskId:为当前任务id

驳回后要修改ACT_HI_TASKINST status状态,要不与加减签状态重复。

修改逻辑如下:

        actHiTaskInstDao.updateHiTaskInstByIdArray(Arrays.asList(currentTaskId), Constant.DATE_TIME_CODE_FORMATTER.format(LocalDateTime.now()));

@Mapper
public interface ActHiTaskInstDao {

    @Update(" <script> " +
            " update ACT_HI_TASKINST set " +
            " END_TIME_ = #{endTime},  DELETE_REASON_ = 'rejected' " +
            " where ID_ in " +
            " <foreach collection = 'taskIdLit' item = 't' separator = ',' open = '(' close = ')' > " +
            " #{t}" +
            " </foreach> " +
            " </script> ")
    int updateHiTaskInstByIdArray(@Param("taskIdLit") List<String> taskIdLit, @Param("endTime") String endTime);
}

原网站

版权声明
本文为[枫林残@]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_44705744/article/details/124986536