UPDATE: VERSION-20260326
This commit is contained in:
@@ -20,8 +20,11 @@ import com.solution.web.core.graph.GraphEdge;
|
|||||||
import com.solution.web.core.graph.GraphNode;
|
import com.solution.web.core.graph.GraphNode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -98,12 +101,19 @@ public class BehaviortreeProcessor {
|
|||||||
instanceKeyMap.put(node.getKey(), instance);
|
instanceKeyMap.put(node.getKey(), instance);
|
||||||
|
|
||||||
if (node.hasParameters()) {
|
if (node.hasParameters()) {
|
||||||
|
if (node.isMultiable()) {
|
||||||
|
List<Nodeparameter> nodeparameters = createMultiableNodeparameter(behaviortree, node, instance);
|
||||||
|
for (Nodeparameter nodeparameter : nodeparameters) {
|
||||||
|
nodeparameterService.insertNodeparameter(nodeparameter);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// 插入parameter nodeparameter
|
// 插入parameter nodeparameter
|
||||||
for (Templateparameterdef parameter : node.getParameters()) {
|
for (Templateparameterdef parameter : node.getParameters()) {
|
||||||
Nodeparameter nodeparameter = createNodeParameter(behaviortree, parameter, instance);
|
Nodeparameter nodeparameter = createNodeParameter(behaviortree, parameter, instance);
|
||||||
nodeparameterService.insertNodeparameter(nodeparameter);
|
nodeparameterService.insertNodeparameter(nodeparameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
nodeKeyIndexMap.put(node.getKey(), index);
|
nodeKeyIndexMap.put(node.getKey(), index);
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
@@ -148,6 +158,47 @@ public class BehaviortreeProcessor {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Nodeparameter> createMultiableNodeparameter(Behaviortree behaviortree, GraphNode node,
|
||||||
|
Treenodeinstance instance) {
|
||||||
|
|
||||||
|
List<Nodeparameter> nodeparameters = new ArrayList<>();
|
||||||
|
|
||||||
|
Map<Long, List<String>> idValues = new HashMap<>();
|
||||||
|
List<String> tmpValues = null;
|
||||||
|
Map<Long, List<Templateparameterdef>> mappedValues = new HashMap<>();
|
||||||
|
List<Templateparameterdef> tmpDefs = null;
|
||||||
|
|
||||||
|
for (Templateparameterdef parameter : node.getParameters()) {
|
||||||
|
tmpDefs = mappedValues.get(parameter.getId() );
|
||||||
|
if (null == tmpDefs) {
|
||||||
|
tmpDefs = new ArrayList<>();
|
||||||
|
}
|
||||||
|
tmpDefs.add(parameter);
|
||||||
|
mappedValues.put(parameter.getId(), tmpDefs);
|
||||||
|
|
||||||
|
tmpValues = idValues.get(parameter.getId() );
|
||||||
|
if (null == tmpValues) {
|
||||||
|
tmpValues = new ArrayList<>();
|
||||||
|
}
|
||||||
|
tmpValues.add(parameter.getDefaultValue());
|
||||||
|
idValues.put(parameter.getId(), tmpValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for (Long id : idValues.keySet()) {
|
||||||
|
tmpValues = idValues.get(id);
|
||||||
|
Nodeparameter nodeparameter = new Nodeparameter();
|
||||||
|
nodeparameter.setTreeId(behaviortree.getId());
|
||||||
|
nodeparameter.setNodeInstanceId(instance.getId());
|
||||||
|
nodeparameter.setParamDefId(id);
|
||||||
|
nodeparameter.setValue(StringUtils.collectionToCommaDelimitedString(tmpValues));
|
||||||
|
nodeparameter.setGroupIndex(index);
|
||||||
|
nodeparameters.add(nodeparameter);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return nodeparameters;
|
||||||
|
}
|
||||||
|
|
||||||
private Nodeparameter createNodeParameter(Behaviortree behaviortree, Templateparameterdef parameter,
|
private Nodeparameter createNodeParameter(Behaviortree behaviortree, Templateparameterdef parameter,
|
||||||
Treenodeinstance instance) {
|
Treenodeinstance instance) {
|
||||||
Nodeparameter nodeparameter = new Nodeparameter();
|
Nodeparameter nodeparameter = new Nodeparameter();
|
||||||
@@ -155,6 +206,7 @@ public class BehaviortreeProcessor {
|
|||||||
nodeparameter.setNodeInstanceId(instance.getId());
|
nodeparameter.setNodeInstanceId(instance.getId());
|
||||||
nodeparameter.setParamDefId(parameter.getId());
|
nodeparameter.setParamDefId(parameter.getId());
|
||||||
nodeparameter.setValue(parameter.getDefaultValue());
|
nodeparameter.setValue(parameter.getDefaultValue());
|
||||||
|
nodeparameter.setGroupIndex(parameter.getGroupIndex());
|
||||||
return nodeparameter;
|
return nodeparameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user