|
|
@ -81,7 +81,6 @@ public class ProcessOperationServiceImpl implements ProcessOperationService { |
|
|
|
ProcessInstanceBuilder builder =runtimeService.createProcessInstanceBuilder(); |
|
|
|
builder.processDefinitionKey(processDefinitionKey); |
|
|
|
builder.businessKey(bussinessKey); |
|
|
|
//builder.name(getNameByProcessDefinitionKey(processDefinitionKey,bussinessKey));
|
|
|
|
if(variables!=null){ |
|
|
|
builder.variables(variables); |
|
|
|
} |
|
|
@ -105,7 +104,6 @@ public class ProcessOperationServiceImpl implements ProcessOperationService { |
|
|
|
ProcessInstanceBuilder builder =runtimeService.createProcessInstanceBuilder(); |
|
|
|
builder.processDefinitionId(processDefinitionId); |
|
|
|
builder.businessKey(bussinessKey); |
|
|
|
//builder.name(getNameByProcessDefinitionId(processDefinitionId,bussinessKey));
|
|
|
|
if(variables!=null){ |
|
|
|
builder.variables(variables); |
|
|
|
} |
|
|
@ -266,6 +264,9 @@ public class ProcessOperationServiceImpl implements ProcessOperationService { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
//是否是退回操作
|
|
|
|
boolean isReturn =isReturn(task,newTask); |
|
|
|
|
|
|
|
//如果未分配到单一的一个处理人,需要根据流程定义查找可用的处理人
|
|
|
|
String taskDefinitionKey =newTask.getTaskDefinitionKey(); |
|
|
|
String procDefinitionId =newTask.getProcessDefinitionId(); |
|
|
@ -299,7 +300,7 @@ public class ProcessOperationServiceImpl implements ProcessOperationService { |
|
|
|
} |
|
|
|
} |
|
|
|
String historyAssignee =historyTask.getAssignee(); |
|
|
|
if(StringUtils.hasText(historyAssignee)) { |
|
|
|
if(StringUtils.hasText(historyAssignee) && isReturn) { |
|
|
|
AgentEntity agent =getAgent(historyAssignee); |
|
|
|
if(agent!=null){ |
|
|
|
taskService.setAssignee(newTask.getId(), agent.getAgentLoginName()); |
|
|
@ -353,6 +354,84 @@ public class ProcessOperationServiceImpl implements ProcessOperationService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 判断节点间连线是否是回退操作 |
|
|
|
* @param fromTask from 任务 |
|
|
|
* @param toTask to 任务 |
|
|
|
* @return 是否是回退操作 |
|
|
|
*/ |
|
|
|
private boolean isReturn(Task fromTask,Task toTask){ |
|
|
|
if(fromTask==null || toTask==null){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
// from 节点 KEY
|
|
|
|
String fromTaskDefinitionKey =fromTask.getTaskDefinitionKey(); |
|
|
|
if(!StringUtils.hasText(fromTaskDefinitionKey)){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// to 节点 Key
|
|
|
|
String toTaskDefinitionKey =toTask.getTaskDefinitionKey(); |
|
|
|
if(!StringUtils.hasText(toTaskDefinitionKey)){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
//获取流程定义模型对象
|
|
|
|
BpmnModel model = repositoryService.getBpmnModel(fromTask.getProcessDefinitionId()); |
|
|
|
if(model==null){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
//获取所有元素
|
|
|
|
Collection<FlowElement> elements =model.getMainProcess().getFlowElements(); |
|
|
|
if(elements==null || elements.size()==0){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
//查找 from 任务的节点
|
|
|
|
UserTask fromUserTaskDefinition =null; |
|
|
|
if(elements!=null && elements.size()>0){ |
|
|
|
for(FlowElement element : elements){ |
|
|
|
if(fromTaskDefinitionKey.equals(element.getId()) && (element instanceof UserTask)){ |
|
|
|
fromUserTaskDefinition =(UserTask)element; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(fromUserTaskDefinition==null){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
//查找 to 任务的节点
|
|
|
|
UserTask toUserTaskDefinition =null; |
|
|
|
if(elements!=null && elements.size()>0){ |
|
|
|
for(FlowElement element : elements){ |
|
|
|
if(toTaskDefinitionKey.equals(element.getId()) && (element instanceof UserTask)){ |
|
|
|
toUserTaskDefinition =(UserTask)element; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(toUserTaskDefinition==null){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
// 查找从 from 到 to 的线
|
|
|
|
SequenceFlow from2toFlow =null; |
|
|
|
List<SequenceFlow> flows =fromUserTaskDefinition.getOutgoingFlows(); |
|
|
|
for(SequenceFlow flow : flows){ |
|
|
|
if(toTaskDefinitionKey.equals(flow.getTargetFlowElement().getId())){ |
|
|
|
from2toFlow =flow; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if(from2toFlow==null){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
// 获取线上配置的 goback 值
|
|
|
|
Integer value =parseGobackVariableValue(from2toFlow.getConditionExpression()); |
|
|
|
if(value==null){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
return value<0; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public List<Goback> getGobacks(String taskId) throws Exception { |
|
|
|