flowable通过表达式来获取其值


背景:当我们在实际开发项目的情况,有很多场景是需要知道表达式里面的值,比方说我们要预先知道节点的信息(审批人等等)。

如:

那么如何做呢?

1、解析所有的节点信息,这里我就不说了,上面的博客里面已经写过了。

2、解析表达式具体代码

@Service
public class ExpressionServiceImpl implements IExpressionService {
    private static Logger logger = Logger.getLogger(ExpressionServiceImpl.class);
    @Autowired
    protected ProcessEngineConfigurationImpl processEngineConfiguration;
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    private TypeConverter typeConverter;


    @Override
    public Object getValue(String processInstanceId, String exp) {
        Expression expression = processEngineConfiguration.getExpressionManager().createExpression(exp);
        ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult();
        return expression.getValue(executionEntity);
    }

    @Override
    public <T> T getValue(String processInstanceId, String exp, Class<T> clazz) {
        Object value = this.getValue(processInstanceId, exp);
        return typeConverter.convert(value, clazz);
    }
}

这样我们就可以获得自己的表达式的值了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM