Compare commits

...

2 Commits

@ -0,0 +1,53 @@
package cn.jyjz.flowable.listener;
import org.flowable.engine.delegate.DelegateExecution;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.Serializable;
/**
*
* flowable
* 1nrOfInstances3
* 2nrOfActiveInstances
* 3 nrOfCompletedInstances
*
* flag
* return flag
*/
@Component("multilnstanceCompleteTask")
public class MulitiInstanceCompleteTask implements Serializable {
private Logger log = LoggerFactory.getLogger(MulitiInstanceCompleteTask.class);
/**
*
* @param execution
* @return
* false
* true
*/
public boolean completeTask(DelegateExecution execution) {
//当前获取的会签任务数量
int nrOfActiveInstances = (int) execution.getVariable("nrOfActiveInstances");
//总的会签任务数量
int nrOfInstances = (int) execution.getVariable("nrOfInstances");
//已经完成的会签任务数量
int nrOfCompletedInstances = (int) execution.getVariable("nrOfCompletedInstances");
log.info("总的会签任务数量:" + nrOfInstances
+ "当前获取的会签任务数量:" + nrOfActiveInstances
+ " - " + "已经完成的会签任务数量:" + nrOfInstances);
if(nrOfInstances >= nrOfCompletedInstances){
return true;
}else{
return false;
}
}
}

@ -0,0 +1,16 @@
package cn.jyjz.flowable.listener;
import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;
import java.io.Serializable;
@Component("mulitiInstanceTaskListener")
public class MulitiInstanceTaskListener implements Serializable {
public void completeListener(DelegateExecution execution){
// System.out.println("任务:"+execution.getId());
// System.out.println("persons:" + execution.getVariable("persons"));
// System.out.println("person" + execution.getVariable("person"));
}
}

@ -434,6 +434,55 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
}
public UserTask getNextTasks(Task task){
//获取流程发布Id信息
String definitionId = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult().getProcessDefinitionId();
//获取bpm对象
BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionId);
//传节点定义key 获取当前节点
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey());
//输出连线
List<SequenceFlow> outgoingFlows = flowNode.getOutgoingFlows();
//遍历返回下一个节点信息
for (SequenceFlow outgoingFlow : outgoingFlows) {
//类型自己判断
FlowElement targetFlowElement = outgoingFlow.getTargetFlowElement();
//用户任务
if (targetFlowElement instanceof UserTask) {
UserTask userTask = (UserTask) targetFlowElement;
return userTask;
} else if (targetFlowElement instanceof ExclusiveGateway) {
setExclusiveGateway(targetFlowElement);
}
}
return null;
}
private void setExclusiveGateway(FlowElement targetFlow) {
//排他网关,获取连线信息
List<SequenceFlow> targetFlows = ((ExclusiveGateway) targetFlow).getOutgoingFlows();
for (SequenceFlow sequenceFlow : targetFlows) {
//目标节点信息
FlowElement targetFlowElement = sequenceFlow.getTargetFlowElement();
if (targetFlowElement instanceof UserTask) {
// do something
} else if (targetFlowElement instanceof EndEvent) {
// do something
} else if (targetFlowElement instanceof ServiceTask) {
// do something
} else if (targetFlowElement instanceof ExclusiveGateway) {
//递归寻找
setExclusiveGateway(targetFlowElement);
} else if (targetFlowElement instanceof SubProcess) {
// do something
}
}
}
/**
*
*/
@ -481,6 +530,19 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
*/
private void disposeSucceedTask(Task task, ProcessDefinition processDefinition, Map<String, Object> variables,
OcrTaskchildPicture model, String formId, UserToken userToken, FlowApprove approve, String deptid) throws Exception {
//获取下一个节点
UserTask userTask = this.getNextTasks(task);
if(null != userTask){
MultiInstanceLoopCharacteristics multiInstance = userTask.getLoopCharacteristics();
// 会签节点
if (Objects.nonNull(multiInstance)) {
if(null != userTask.getCandidateUsers() && userTask.getCandidateUsers().size() > 1){
variables.put("persons",userTask.getCandidateUsers());
}
}
}
//进入下一个节点
taskService.complete(task.getId(), variables);
updateAssignee(task.getProcessInstanceId(), task.getProcessDefinitionId(), processDefinition, deptid);

Loading…
Cancel
Save