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