activiti5.22获取下一流程节点

activiti5.22获取下一流程节点

2023年8月1日发(作者:)

前段时间在linux环境部署activiti5.22工作流后,根据当前运行活动节点获取下一流程节点时总是报空指针。但是当重启tomcat后的一段时间内是正常的。

当时获取下一流程节点的方法是根据activiti中 List outTransitions =

goingTransitions(); 这种方法获取的流出节点,但是在linux下一直不稳定,由于自身技术能力原因,并没有去寻找根本问题。后来换一种思路,通过自己解析配置文件获取流出节点。以下是相关代码:

1.首先拿到配置文件:

ProcessDefinition pd = ProcessDefinitionQuery()

.processDefinitionKey(processDefinitionKey).latestVersion()

.singleResult();

("===模板相应版本ID:==="+loymentId()+","+()+","+sion());

BpmnModel model =(BpmnModel) nModel(());

//获取所有节点

Collection flowElements = nProcess().getFlowElements();

2.然后根据配置文件获取当前活动节点的流出节点

节点

信息

}

}

}

nextNode=();

break;

for(FlowElement e : flowElements) {

String forEachId=();//循环节点key

if ((forEachId)) {//当前节点==循环到的节点

if(e instanceof sk) {//sequenceFlowList=((sk) e).getOutgoingFlows();//流出3.循环遍历配置文件根据自定义条件获取到当前活动节点的下一节点。

/**

* 循环得到下一流程节点

*@description

*2017年7月15日上午9:36:39

*@author

*@param flowElements:配置文件

*@param nowNode:循环后当前需判断的节点

*@param activityId:流程中当前活动节点 *@param variables:变量信息

*@param objects:自定义条件判断信息

*@return

*String

*/

private String getNextLoadInfo(Collection flowElements,String nowNode,String

activityId,Map variables,List objects){

String forEachId="";

for (FlowElement e : flowElements) {

forEachId=();//循环节点key

//如果循环节点==当前节点信息,则获取下一节点

if ((forEachId)) {

if(e instanceof

String nextNode="";//下一节点ID(所需要的节点数据)

List sequenceFlowList = new ArrayList();//下一个节点集sk&&!(forEachId)) {//节点

sequenceFlowList=((sk)

e).getOutgoingFlows();

nextNode=(0).getTargetRef();

if (variables!=null) {

variables=checkVariable(variables,nowNode,processDefinitionKey);

}

String nodeName= e();//节点名称

String nodeId=();//节点ID

processJson="{"taskId":""+nodeId+"",";

processJson+=""taskName":""+nodeName+""";

processJson+="}";

return processJson;

}else {//排他网关

if(e instanceof sk){

sequenceFlowList=((sk)

e).getOutgoingFlows();

}else{

sequenceFlowList=((iveGateway)

e).getOutgoingFlows();

} for(int i=0;i<();i++){

nextNode=(i).getTargetRef();

String

flowId=(i).getId();

BranchConf branchConf=nchConfInfo(flowId,

processInstanceId, processDefinitionKey,objects);

if (branchConf!=null&&ss()) {//如果分支条件不为空并且通过此条件

("==分支条件=="+ivitiNodeId()+"==="+nchCondition());

if (variables!=null) {

(ivitiVariable(), ss());

}

//如果流向线路为排他网关

for (FlowElement e1 : flowElements) {

if((())){

if(e1 instanceof

iveGateway){

sequenceFlowList=((iveGateway)

e1).getOutgoingFlows();

if

(()==1) {

flowId=(0).getId();

branchConf=nchConfInfo(flowId, processInstanceId,

processDefinitionKey,objects);

if

(branchConf!=null) {

if (variables!=null) {

(ivitiVariable(), ss());

}

if (ss()) {

nextNode=se return

getNextLoadInfo(flowElements,nextNode,activityId,variables,objects);

}

}else if (s

f

(ivitiVariable(), ss());

}

return

getNextLoadInfo(flowElements,nextNode,activityId,variables,objects);

}

}else if(e1 instanceof

sk){

if (variables!=null) {

variables=checkVariable(variables,(),processDefinitionKey);

}

String nodeName=

e();//节点名称

String nodeId=();//节点ID

processJson="{"taskId":""+nodeId+"",";

processJson+=""taskName":""+nodeName+""";

processJson+="}";

return processJson;

}

}} }

}

}else if(branchConf==null){//如果分支条件为空

//如果流向线路为排他网关

for (FlowElement e1 :

flowElements) {

if((())){

if(e1 instanceof

iveGateway){

sequenceFlowList=((iveGateway)

e1).getOutgoingFlows();

if

(()==1) {

flowId=(0).getId();

branchConf=nchConfInfo(flowId, processInstanceId,

processDefinitionKey,objects);

if

(branchConf!=null) {

if (variables!=null) {

(ivitiVariable(), ss());

}

if (ss()) {

return

getNextLoadInfo(flowElements,nextNode,activityId,variables,objects);

}

}

nextNode=se}else if (s f

(ivitiVariable(), ss());

}

return

getNextLoadInfo(flowElements,nextNode,activityId,variables,objects);

}

}else if(e1 instanceof

sk){

if (variables!=null) {

variables=checkVariable(variables,(),processDefinitionKey);

}

String nodeName=

e();//节点名称

String nodeId=();//节点ID

processJson="{"taskId":""+nodeId+"",";

processJson+=""taskName":""+nodeName+""";

processJson+="}";

return processJson;

}else if(e1 instanceof

nt){

if (variables!=null) {

variables=checkVariable(variables,(),processDefinitionKey);

}

String nodeName=

e();//节点名称

String nodeId=();//节点ID

}}

不为空

}

processJson="{"taskId":""+nodeId+"",";

processJson+=""taskName":""+nodeName+""";

processJson+="}";

return processJson;

}

}

}

}else if(branchConf!=null){//如果分支条件

if (variables!=null) {

(ivitiVariable(), ss());

}

}

}

}

}

}

return "";

至此,下一流程节点信息完成,运行到当前未出现问题。

发布者:admin,转转请注明出处:http://www.yc00.com/news/1690874062a452212.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信