zoukankan      html  css  js  c++  java
  • flowable中动态显示节点的审批人信息

    1、上面的流程图当任务还没有到的节点,用户想看看节点的人的信息,如果我们常规的是不能实现的。

    2、思路就是我们取出节点的表达式,然后用我们流程实例的变量来给他翻译出来即可,如何做呢?

    2.1、通过流程实例id查出历史表中的所有的变量列表

    List<HistoricVariableInstance> hvis = historyService.createHistoricVariableInstanceQuery()
                    .processInstanceId(processInstanceId).list();
    

    2.2、通过流程实例id获取所有的节点信息

    List<Process> processes = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId()).getProcesses();
    if (CollectionUtils.isNotEmpty(processes)) {
                for (Process process : processes) {
                    Collection<FlowElement> flowElements = process.getFlowElements();
                    if (CollectionUtils.isNotEmpty(flowElements)) {
                        for (FlowElement flowElement : flowElements) {
                            if (flowElement instanceof UserTask) {
                    .......... } } } } }

    2.3、取出节点的表达式

    if (StringUtils.isNotBlank(userTask.getAssignee())) {
        //处理多实例的显示
        MultiInstanceLoopCharacteristics loopCharacteristics = userTask.getLoopCharacteristics();
        if(loopCharacteristics == null) {
            String expressionValue = null;
            if (userTask.getName().equals(FlowConstant.FLOW_SUBMITTER)) {
                expressionValue = processInstance.getStartUserId();
            }else {
                expressionValue = juelExpression.getValue(hvis, userTask.getAssignee());
            }
            if(StringUtils.isNotBlank(expressionValue)) {
                List<UserVo> userVos = userVoService.getUserByCodeOrGroupId(expressionValue);
                
            }
        }else {
            String inputDataItem = loopCharacteristics.getInputDataItem();
            List<String> values = (List)juelExpression.getValue(hvis, inputDataItem, List.class);
            if (CollectionUtils.isNotEmpty(values)) {
                List<UserVo> users = new ArrayList<>();
                values.forEach(code->{
                    List<UserVo> userVos = userVoService.getUserByCodeOrGroupId(code);
                    users.addAll(userVos);
                });
                
            }
        }
    }

    2.4、工具类

    public Object getValue(List<HistoricVariableInstance> hvis, String exp, Class<?> clazz) {
            ExpressionFactory factory = new ExpressionFactoryImpl();
            SimpleContext context = new SimpleContext();
            for (HistoricVariableInstance entry : hvis) {
                context.setVariable(entry.getVariableName(), factory.createValueExpression(entry.getValue(), Object.class));
            }
            ValueExpression e = factory.createValueExpression(context, exp, clazz);
            return e.getValue(context);
        }
    
        public String getValue(List<HistoricVariableInstance> hvis, String exp) {
            return (String) getValue(hvis, exp, String.class);
        }
  • 相关阅读:
    win10的power shell可以学习少部分linux命令_功能与cmd类似
    js数组的初始化
    Vue.js 学习笔记
    jquery knob旋钮插件
    jquery 城市三级联动
    xampp 配置虚拟主机
    2016 360 前端开发 面经
    2016 乐视 前端开发 面经
    主流浏览器内核及前缀
    前端代码优化方法
  • 原文地址:https://www.cnblogs.com/liuwenjun/p/10173004.html
Copyright © 2011-2022 走看看