当前位置:网站首页>Use camunda to do workflow design and reject operations

Use camunda to do workflow design and reject operations

2022-07-07 21:20:00 Maple forest [email protected]

Judge whether to reject , Refer to the following table :

 

 camunda Page representation :

 

Specific code implementation :

 ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
        List<HistoricActivityInstance> resultList = historyService
                .createHistoricActivityInstanceQuery()
                .processInstanceId(processInstanceId)
                .activityType("userTask")
                .finished()
                .orderByHistoricActivityInstanceEndTime()
                .asc()
                .list();
        // Get the task node 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(" The operation of docking back to the specified task node ")
                .startBeforeActivity(toActId)// Start the target active node 
                .execute();

taskKey : For the activity node that needs to be transferred back key

currentTaskId: For the current task id

Modify after rejection ACT_HI_TASKINST status state , It should not be repeated with the addition and subtraction status .

The modification logic is as follows :

        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);
}

原网站

版权声明
本文为[Maple forest [email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071812417561.html