|
|
@ -120,6 +120,7 @@ import java.util.HashSet; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Map.Entry; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -1121,7 +1122,7 @@ public class ProcessService { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* complement data needs transform parent parameter to child. |
|
|
|
* complement data needs transform parent parameter to child. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private String getSubWorkFlowParam(ProcessInstanceMap instanceMap, ProcessInstance parentProcessInstance,Map<String,String> fatherParams) { |
|
|
|
private String getSubWorkFlowParam(ProcessInstanceMap instanceMap, ProcessInstance parentProcessInstance, Map<String, String> fatherParams) { |
|
|
|
// set sub work process command
|
|
|
|
// set sub work process command
|
|
|
|
String processMapStr = JSONUtils.toJsonString(instanceMap); |
|
|
|
String processMapStr = JSONUtils.toJsonString(instanceMap); |
|
|
|
Map<String, String> cmdParam = JSONUtils.toMap(processMapStr); |
|
|
|
Map<String, String> cmdParam = JSONUtils.toMap(processMapStr); |
|
|
@ -1165,13 +1166,13 @@ public class ProcessService { |
|
|
|
Object localParams = subProcessParam.get(Constants.LOCAL_PARAMS); |
|
|
|
Object localParams = subProcessParam.get(Constants.LOCAL_PARAMS); |
|
|
|
List<Property> allParam = JSONUtils.toList(JSONUtils.toJsonString(localParams), Property.class); |
|
|
|
List<Property> allParam = JSONUtils.toList(JSONUtils.toJsonString(localParams), Property.class); |
|
|
|
Map<String, String> globalMap = this.getGlobalParamMap(parentProcessInstance.getGlobalParams()); |
|
|
|
Map<String, String> globalMap = this.getGlobalParamMap(parentProcessInstance.getGlobalParams()); |
|
|
|
Map<String,String> fatherParams = new HashMap<>(); |
|
|
|
Map<String, String> fatherParams = new HashMap<>(); |
|
|
|
if (CollectionUtils.isNotEmpty(allParam)) { |
|
|
|
if (CollectionUtils.isNotEmpty(allParam)) { |
|
|
|
for (Property info : allParam) { |
|
|
|
for (Property info : allParam) { |
|
|
|
fatherParams.put(info.getProp(), globalMap.get(info.getProp())); |
|
|
|
fatherParams.put(info.getProp(), globalMap.get(info.getProp())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
String processParam = getSubWorkFlowParam(instanceMap, parentProcessInstance,fatherParams); |
|
|
|
String processParam = getSubWorkFlowParam(instanceMap, parentProcessInstance, fatherParams); |
|
|
|
|
|
|
|
|
|
|
|
return new Command( |
|
|
|
return new Command( |
|
|
|
commandType, |
|
|
|
commandType, |
|
|
@ -2239,8 +2240,7 @@ public class ProcessService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setTaskFromTaskNode(TaskNode taskNode, TaskDefinition taskDefinition) { |
|
|
|
private void setTaskFromTaskNode(TaskNode taskNode, TaskDefinition taskDefinition) { |
|
|
|
// TODO for the front-end UI, name with id
|
|
|
|
taskDefinition.setName(taskNode.getName()); |
|
|
|
taskDefinition.setName(taskNode.getId() + "|" + taskNode.getName()); |
|
|
|
|
|
|
|
taskDefinition.setDescription(taskNode.getDesc()); |
|
|
|
taskDefinition.setDescription(taskNode.getDesc()); |
|
|
|
taskDefinition.setTaskType(TaskType.of(taskNode.getType())); |
|
|
|
taskDefinition.setTaskType(TaskType.of(taskNode.getType())); |
|
|
|
taskDefinition.setTaskParams(TaskType.of(taskNode.getType()) == TaskType.DEPENDENT ? taskNode.getDependence() : taskNode.getParams()); |
|
|
|
taskDefinition.setTaskParams(TaskType.of(taskNode.getType()) == TaskType.DEPENDENT ? taskNode.getDependence() : taskNode.getParams()); |
|
|
@ -2340,7 +2340,7 @@ public class ProcessService { |
|
|
|
List<TaskNode> taskNodeList = (processData.getTasks() == null) ? new ArrayList<>() : processData.getTasks(); |
|
|
|
List<TaskNode> taskNodeList = (processData.getTasks() == null) ? new ArrayList<>() : processData.getTasks(); |
|
|
|
Map<String, TaskDefinition> taskNameAndCode = new HashMap<>(); |
|
|
|
Map<String, TaskDefinition> taskNameAndCode = new HashMap<>(); |
|
|
|
for (TaskNode taskNode : taskNodeList) { |
|
|
|
for (TaskNode taskNode : taskNodeList) { |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionName(projectCode, taskNode.getName()); |
|
|
|
TaskDefinition taskDefinition = taskDefinitionMapper.queryByDefinitionCode(taskNode.getCode()); |
|
|
|
if (taskDefinition == null) { |
|
|
|
if (taskDefinition == null) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
long code = SnowFlakeUtils.getInstance().nextId(); |
|
|
|
long code = SnowFlakeUtils.getInstance().nextId(); |
|
|
@ -2448,7 +2448,8 @@ public class ProcessService { |
|
|
|
* @return dag graph |
|
|
|
* @return dag graph |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public DAG<String, TaskNode, TaskNodeRelation> genDagGraph(ProcessDefinition processDefinition) { |
|
|
|
public DAG<String, TaskNode, TaskNodeRelation> genDagGraph(ProcessDefinition processDefinition) { |
|
|
|
List<TaskNode> taskNodeList = genTaskNodeList(processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
Map<String, String> locationMap = locationToMap(processDefinition.getLocations()); |
|
|
|
|
|
|
|
List<TaskNode> taskNodeList = genTaskNodeList(processDefinition.getCode(), processDefinition.getVersion(), locationMap); |
|
|
|
List<ProcessTaskRelationLog> processTaskRelations = processTaskRelationLogMapper.queryByProcessCodeAndVersion(processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
List<ProcessTaskRelationLog> processTaskRelations = processTaskRelationLogMapper.queryByProcessCodeAndVersion(processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
ProcessDag processDag = DagHelper.getProcessDag(taskNodeList, new ArrayList<>(processTaskRelations)); |
|
|
|
ProcessDag processDag = DagHelper.getProcessDag(taskNodeList, new ArrayList<>(processTaskRelations)); |
|
|
|
// Generate concrete Dag to be executed
|
|
|
|
// Generate concrete Dag to be executed
|
|
|
@ -2459,7 +2460,8 @@ public class ProcessService { |
|
|
|
* generate ProcessData |
|
|
|
* generate ProcessData |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ProcessData genProcessData(ProcessDefinition processDefinition) { |
|
|
|
public ProcessData genProcessData(ProcessDefinition processDefinition) { |
|
|
|
List<TaskNode> taskNodes = genTaskNodeList(processDefinition.getCode(), processDefinition.getVersion()); |
|
|
|
Map<String, String> locationMap = locationToMap(processDefinition.getLocations()); |
|
|
|
|
|
|
|
List<TaskNode> taskNodes = genTaskNodeList(processDefinition.getCode(), processDefinition.getVersion(), locationMap); |
|
|
|
ProcessData processData = new ProcessData(); |
|
|
|
ProcessData processData = new ProcessData(); |
|
|
|
processData.setTasks(taskNodes); |
|
|
|
processData.setTasks(taskNodes); |
|
|
|
processData.setGlobalParams(JSONUtils.toList(processDefinition.getGlobalParams(), Property.class)); |
|
|
|
processData.setGlobalParams(JSONUtils.toList(processDefinition.getGlobalParams(), Property.class)); |
|
|
@ -2468,7 +2470,7 @@ public class ProcessService { |
|
|
|
return processData; |
|
|
|
return processData; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<TaskNode> genTaskNodeList(Long processCode, int processVersion) { |
|
|
|
public List<TaskNode> genTaskNodeList(Long processCode, int processVersion, Map<String, String> locationMap) { |
|
|
|
List<ProcessTaskRelationLog> processTaskRelations = processTaskRelationLogMapper.queryByProcessCodeAndVersion(processCode, processVersion); |
|
|
|
List<ProcessTaskRelationLog> processTaskRelations = processTaskRelationLogMapper.queryByProcessCodeAndVersion(processCode, processVersion); |
|
|
|
Set<TaskDefinition> taskDefinitionSet = new HashSet<>(); |
|
|
|
Set<TaskDefinition> taskDefinitionSet = new HashSet<>(); |
|
|
|
Map<Long, TaskNode> taskNodeMap = new HashMap<>(); |
|
|
|
Map<Long, TaskNode> taskNodeMap = new HashMap<>(); |
|
|
@ -2501,10 +2503,9 @@ public class ProcessService { |
|
|
|
Map<Long, TaskDefinitionLog> taskDefinitionLogMap = taskDefinitionLogs.stream().collect(Collectors.toMap(TaskDefinitionLog::getCode, log -> log)); |
|
|
|
Map<Long, TaskDefinitionLog> taskDefinitionLogMap = taskDefinitionLogs.stream().collect(Collectors.toMap(TaskDefinitionLog::getCode, log -> log)); |
|
|
|
taskNodeMap.forEach((k, v) -> { |
|
|
|
taskNodeMap.forEach((k, v) -> { |
|
|
|
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(k); |
|
|
|
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(k); |
|
|
|
// TODO split from name
|
|
|
|
v.setId(locationMap.get(taskDefinitionLog.getName())); |
|
|
|
v.setId(StringUtils.substringBefore(taskDefinitionLog.getName(), "|")); |
|
|
|
|
|
|
|
v.setCode(taskDefinitionLog.getCode()); |
|
|
|
v.setCode(taskDefinitionLog.getCode()); |
|
|
|
v.setName(StringUtils.substringAfter(taskDefinitionLog.getName(), "|")); |
|
|
|
v.setName(taskDefinitionLog.getName()); |
|
|
|
v.setDesc(taskDefinitionLog.getDescription()); |
|
|
|
v.setDesc(taskDefinitionLog.getDescription()); |
|
|
|
v.setType(taskDefinitionLog.getTaskType().getDescp().toUpperCase()); |
|
|
|
v.setType(taskDefinitionLog.getTaskType().getDescp().toUpperCase()); |
|
|
|
v.setRunFlag(taskDefinitionLog.getFlag() == Flag.YES ? Constants.FLOWNODE_RUN_FLAG_NORMAL : Constants.FLOWNODE_RUN_FLAG_FORBIDDEN); |
|
|
|
v.setRunFlag(taskDefinitionLog.getFlag() == Flag.YES ? Constants.FLOWNODE_RUN_FLAG_NORMAL : Constants.FLOWNODE_RUN_FLAG_FORBIDDEN); |
|
|
@ -2517,15 +2518,35 @@ public class ProcessService { |
|
|
|
v.setTimeout(JSONUtils.toJsonString(new TaskTimeoutParameter(taskDefinitionLog.getTimeoutFlag() == TimeoutFlag.OPEN, |
|
|
|
v.setTimeout(JSONUtils.toJsonString(new TaskTimeoutParameter(taskDefinitionLog.getTimeoutFlag() == TimeoutFlag.OPEN, |
|
|
|
taskDefinitionLog.getTimeoutNotifyStrategy(), |
|
|
|
taskDefinitionLog.getTimeoutNotifyStrategy(), |
|
|
|
taskDefinitionLog.getTimeout()))); |
|
|
|
taskDefinitionLog.getTimeout()))); |
|
|
|
// TODO name will be remove
|
|
|
|
|
|
|
|
v.getPreTaskNodeList().forEach(task -> task.setName(taskDefinitionLogMap.get(task.getCode()).getName())); |
|
|
|
v.getPreTaskNodeList().forEach(task -> task.setName(taskDefinitionLogMap.get(task.getCode()).getName())); |
|
|
|
v.setPreTasks(JSONUtils.toJsonString(v.getPreTaskNodeList().stream().map(PreviousTaskNode::getName).collect(Collectors.toList()))); |
|
|
|
v.setPreTasks(JSONUtils.toJsonString(v.getPreTaskNodeList().stream().map(PreviousTaskNode::getName).collect(Collectors.toList()))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
return new ArrayList<>(taskNodeMap.values()); |
|
|
|
return new ArrayList<>(taskNodeMap.values()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* parse locations |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param locations processDefinition locations |
|
|
|
|
|
|
|
* @return key:taskName,value:taskId |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public Map<String, String> locationToMap(String locations) { |
|
|
|
|
|
|
|
Map<String, String> frontTaskIdAndNameMap = new HashMap<>(); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(locations)) { |
|
|
|
|
|
|
|
return frontTaskIdAndNameMap; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ObjectNode jsonNodes = JSONUtils.parseObject(locations); |
|
|
|
|
|
|
|
Iterator<Entry<String, JsonNode>> fields = jsonNodes.fields(); |
|
|
|
|
|
|
|
while (fields.hasNext()) { |
|
|
|
|
|
|
|
Entry<String, JsonNode> jsonNodeEntry = fields.next(); |
|
|
|
|
|
|
|
frontTaskIdAndNameMap.put(JSONUtils.findValue(jsonNodeEntry.getValue(), "name"), jsonNodeEntry.getKey()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return frontTaskIdAndNameMap; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* add authorized resources |
|
|
|
* add authorized resources |
|
|
|
|
|
|
|
* |
|
|
|
* @param ownResources own resources |
|
|
|
* @param ownResources own resources |
|
|
|
* @param userId userId |
|
|
|
* @param userId userId |
|
|
|
*/ |
|
|
|
*/ |
|
|
|