Compare commits

..

4 Commits

Author SHA1 Message Date
libertyspy
538a43f597 Merge remote-tracking branch 'origin/master' 2026-02-09 14:53:43 +08:00
libertyspy
fcab8585c5 UPDATE: fk 2026-02-09 14:53:05 +08:00
libertyspy
0ffc42ab69 UPDATE: fk 2026-02-09 14:52:56 +08:00
libertyspy
46bead08a0 UPDATE: fk 2026-02-09 14:52:46 +08:00
29 changed files with 707 additions and 111 deletions

View File

@@ -3,6 +3,7 @@ package com.solution.web.controller.behaviour;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.solution.web.core.BehaviortreeProcessor;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@@ -38,6 +39,9 @@ public class BehaviortreeController extends BaseController
@Autowired @Autowired
private IBehaviortreeService behaviortreeService; private IBehaviortreeService behaviortreeService;
@Autowired
private BehaviortreeProcessor behaviortreeProcessor;
/** /**
* 查询行为树主列表 * 查询行为树主列表
*/ */
@@ -84,7 +88,7 @@ public class BehaviortreeController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Behaviortree behaviortree) public AjaxResult add(@RequestBody Behaviortree behaviortree)
{ {
return toAjax(behaviortreeService.insertBehaviortree(behaviortree)); return toAjax(behaviortreeProcessor.create(behaviortree));
} }
/** /**
@@ -96,7 +100,7 @@ public class BehaviortreeController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody Behaviortree behaviortree) public AjaxResult edit(@RequestBody Behaviortree behaviortree)
{ {
return toAjax(behaviortreeService.updateBehaviortree(behaviortree)); return toAjax(behaviortreeProcessor.update(behaviortree));
} }
/** /**

View File

@@ -103,15 +103,15 @@ public class NodetemplateController extends BaseController {
dto.setDescription(template.getDescription()); dto.setDescription(template.getDescription());
dto.setEnglishName(template.getEnglishName()); dto.setEnglishName(template.getEnglishName());
dto.setLogicHandler(template.getLogicHandler()); dto.setLogicHandler(template.getLogicHandler());
dto.setTempleteType(template.getTempleteType()); dto.setTemplateType(template.getTemplateType());
return dto; return dto;
}) })
.collect(Collectors.groupingBy(NodetemplateDTO::getTempleteType)); .collect(Collectors.groupingBy(NodetemplateDTO::getTemplateType));
List<NodetemplateVO> vos = new ArrayList<>(); List<NodetemplateVO> vos = new ArrayList<>();
groupedByTemplateType.forEach((key, value) -> { groupedByTemplateType.forEach((key, value) -> {
// 处理逻辑 // 处理逻辑
NodetemplateVO vo = new NodetemplateVO(); NodetemplateVO vo = new NodetemplateVO();
vo.setTempleteType(key); vo.setTemplateType(key);
vo.setDtoList(value); vo.setDtoList(value);
vos.add(vo); vos.add(vo);
}); });

View File

@@ -23,7 +23,7 @@ public class NodetemplateDTO {
@ApiModelProperty("afsim 中转换的节点名") @ApiModelProperty("afsim 中转换的节点名")
private String englishName; private String englishName;
private String templeteType; private String templateType;
public Long getId() { public Long getId() {
return id; return id;
@@ -65,11 +65,11 @@ public class NodetemplateDTO {
this.englishName = englishName; this.englishName = englishName;
} }
public String getTempleteType() { public String getTemplateType() {
return templeteType; return templateType;
} }
public void setTempleteType(String templeteType) { public void setTemplateType(String templateType) {
this.templeteType = templeteType; this.templateType = templateType;
} }
} }

View File

@@ -9,17 +9,17 @@ import java.util.List;
public class NodetemplateVO { public class NodetemplateVO {
/** 模版类型节点模版或者条件判断例如“node”precondition“ */ /** 模版类型节点模版或者条件判断例如“node”precondition“ */
@ApiModelProperty("模版类型节点模版或者条件判断例如“node”precondition“") @ApiModelProperty("模版类型节点模版或者条件判断例如“node”precondition“")
private String templeteType; private String templateType;
@ApiModelProperty("节点模板数据") @ApiModelProperty("节点模板数据")
private List<NodetemplateDTO> dtoList; private List<NodetemplateDTO> dtoList;
public String getTempleteType() { public String getTemplateType() {
return templeteType; return templateType;
} }
public void setTempleteType(String templeteType) { public void setTemplateType(String templateType) {
this.templeteType = templeteType; this.templateType = templateType;
} }
public List<NodetemplateDTO> getDtoList() { public List<NodetemplateDTO> getDtoList() {

View File

@@ -0,0 +1,160 @@
package com.solution.web.core;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.solution.system.domain.*;
import com.solution.system.service.IBehaviortreeService;
import com.solution.system.service.INodeconnectionService;
import com.solution.system.service.INodeparameterService;
import com.solution.system.service.ITreenodeinstanceService;
import com.solution.web.core.graph.Graph;
import com.solution.web.core.graph.GraphEdge;
import com.solution.web.core.graph.GraphNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class BehaviortreeProcessor {
@Autowired
private IBehaviortreeService behaviortreeService;
@Autowired
private ITreenodeinstanceService treenodeinstanceService;
@Autowired
private INodeparameterService nodeparameterService;
@Autowired
private INodeconnectionService nodeconnectionService;
private ObjectMapper objectMapper = createObjectMapper();
public static ObjectMapper createObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
}
public int create(Behaviortree behaviortree) {
int result = behaviortreeService.insertBehaviortree(behaviortree);
processGraph(behaviortree);
return result;
}
public int update(Behaviortree behaviortree) {
int result = behaviortreeService.updateBehaviortree(behaviortree);
// 删除节点实例
treenodeinstanceService.deleteByTreeId(behaviortree.getId());
// 删除参数
nodeparameterService.deleteByTreeId(behaviortree.getId());
// 删除连线
nodeconnectionService.deleteByTreeId(behaviortree.getId());
processGraph(behaviortree);
return result;
}
private void processGraph(Behaviortree behaviortree) {
Graph graph = null;
try {
graph = objectMapper.readValue(behaviortree.getXmlContent(), Graph.class);
} catch (Exception e) {
// skip
e.printStackTrace();
}
if (null == graph) {
return;
}
// 插入节点 treenodeinstance
Map<String, Treenodeinstance> instanceKeyMap = new HashMap<>();
Map<String, Long> nodeKeyIndexMap = new HashMap<>();
if (graph.hasNodes()) {
Long index = 0L;
for (GraphNode node : graph.getNodes()) {
Treenodeinstance instance = createNodeInstance(behaviortree, node);
treenodeinstanceService.insertTreenodeinstance(instance);
instanceKeyMap.put(node.getKey(), instance);
if (node.hasParameters()) {
// 插入parameter nodeparameter
for (Templateparameterdef parameter : node.getParameters()) {
Nodeparameter nodeparameter = createNodeParameter(behaviortree, parameter, instance);
nodeparameterService.insertNodeparameter(nodeparameter);
}
}
nodeKeyIndexMap.put(node.getKey(), index);
index++;
}
}
// 插入连线 nodeconnection
if (graph.hasEdges()) {
for (GraphEdge edge : graph.getEdges()) {
Nodeconnection connection = createConnection(behaviortree, edge, instanceKeyMap, nodeKeyIndexMap);
nodeconnectionService.insertNodeconnection(connection);
}
}
}
private Nodeconnection createConnection(Behaviortree behaviortree, GraphEdge edge,
Map<String, Treenodeinstance> instanceKeyMap,
Map<String, Long> nodeKeyIndexMap) {
Nodeconnection connection = new Nodeconnection();
connection.setTreeId(behaviortree.getId());
if (null != instanceKeyMap.get(edge.getSource().getCell())) {
Treenodeinstance parent = instanceKeyMap.get(edge.getSource().getCell());
connection.setParentNodeId(parent.getId());
}
if (null != instanceKeyMap.get(edge.getTarget().getCell())) {
Treenodeinstance children = instanceKeyMap.get(edge.getTarget().getCell());
connection.setChildNodeId(children.getId());
}
if (null != nodeKeyIndexMap.get(edge.getSource().getCell())) {
connection.setOrderIndex(nodeKeyIndexMap.get(edge.getSource().getCell()));
}
return connection;
}
private Nodeparameter createNodeParameter(Behaviortree behaviortree, Templateparameterdef parameter,
Treenodeinstance instance) {
Nodeparameter nodeparameter = new Nodeparameter();
nodeparameter.setTreeId(behaviortree.getId());
nodeparameter.setNodeInstanceId(instance.getId());
nodeparameter.setParamDefId(parameter.getId());
nodeparameter.setValue(parameter.getDefaultValue());
return nodeparameter;
}
private Treenodeinstance createNodeInstance(Behaviortree behaviortree, GraphNode node) {
Treenodeinstance instance = new Treenodeinstance();
instance.setTreeId(behaviortree.getId());
instance.setTemplateId((long) node.getTemplate());
instance.setInstanceName(node.getName());
instance.setIsRoot((long) (node.isRoot() ? 1 : 0));
if ("precondition".equalsIgnoreCase(node.getTemplateType())) {
instance.setPreconditionTempleteId((long) node.getTemplate());
}
return instance;
}
}

View File

@@ -0,0 +1,52 @@
package com.solution.web.core.graph;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import java.io.Serializable;
import java.util.List;
public class Graph implements Serializable {
private List<GraphNode> nodes;
private List<GraphEdge> edges;
public boolean hasNodes() {
return nodes != null && !nodes.isEmpty();
}
public boolean hasEdges() {
return edges != null && !edges.isEmpty();
}
@Override
public String toString() {
return "Graph{" +
"nodes=" + nodes +
", edges=" + edges +
'}';
}
public List<GraphNode> getNodes() {
return nodes;
}
public void setNodes(List<GraphNode> nodes) {
this.nodes = nodes;
}
public List<GraphEdge> getEdges() {
return edges;
}
public void setEdges(List<GraphEdge> edges) {
this.edges = edges;
}
}

View File

@@ -0,0 +1,85 @@
package com.solution.web.core.graph;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import org.springframework.util.StringUtils;
import java.io.Serializable;
public class GraphEdge implements Serializable {
private String key;
private Line source;
private Line target;
public boolean hasSource() {
return source != null && StringUtils.hasText(source.cell);
}
public boolean hasTarget() {
return target != null && StringUtils.hasText(target.cell);
}
public static class Line implements Serializable {
private String cell;
@Override
public String toString() {
return "Line{" +
"cell='" + cell + '\'' +
'}';
}
public String getCell() {
return cell;
}
public void setCell(String cell) {
this.cell = cell;
}
}
@Override
public String toString() {
return "GraphEdge{" +
"key='" + key + '\'' +
", source='" + source + '\'' +
", target='" + target + '\'' +
'}';
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public Line getSource() {
return source;
}
public void setSource(Line source) {
this.source = source;
}
public Line getTarget() {
return target;
}
public void setTarget(Line target) {
this.target = target;
}
}

View File

@@ -0,0 +1,142 @@
package com.solution.web.core.graph;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import com.solution.system.domain.Templateparameterdef;
import java.io.Serializable;
import java.util.List;
public class GraphNode implements Serializable {
private int id;
private int template;
private String templateType;
private String type;
private String key;
private String name;
private String description;
private String category;
private List<Templateparameterdef> parameters;
private List<GraphVariable> variables;
public boolean hasParameters() {
return parameters != null && !parameters.isEmpty();
}
public boolean hasVariables() {
return variables != null && !variables.isEmpty();
}
public boolean isRoot() {
return "root".equalsIgnoreCase(this.category);
}
@Override
public String toString() {
return "GraphNode{" +
"id=" + id +
", key='" + key + '\'' +
", name='" + name + '\'' +
", description='" + description + '\'' +
", parameters=" + parameters +
", variables=" + variables +
'}';
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getTemplateType() {
return templateType;
}
public void setTemplateType(String templateType) {
this.templateType = templateType;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getTemplate() {
return template;
}
public void setTemplate(int template) {
this.template = template;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Templateparameterdef> getParameters() {
return parameters;
}
public void setParameters(List<Templateparameterdef> parameters) {
this.parameters = parameters;
}
public List<GraphVariable> getVariables() {
return variables;
}
public void setVariables(List<GraphVariable> variables) {
this.variables = variables;
}
}

View File

@@ -0,0 +1,65 @@
package com.solution.web.core.graph;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import java.io.Serializable;
public class GraphVariable implements Serializable {
private String key;
private String value;
private String defaults;
private String unit;
@Override
public String toString() {
return "GraphVariable{" +
"key='" + key + '\'' +
", value='" + value + '\'' +
", defaults='" + defaults + '\'' +
", unit='" + unit + '\'' +
'}';
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDefaults() {
return defaults;
}
public void setDefaults(String defaults) {
this.defaults = defaults;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
}

View File

@@ -18,6 +18,8 @@ public class Nodeconnection extends BaseEntity
/** 连接ID (主键) */ /** 连接ID (主键) */
private Long id; private Long id;
private Long treeId;
/** 父节点 (外键: TreeInstanceNode.id) */ /** 父节点 (外键: TreeInstanceNode.id) */
@Excel(name = "父节点 (外键: TreeInstanceNode.id)") @Excel(name = "父节点 (外键: TreeInstanceNode.id)")
private Long parentNodeId; private Long parentNodeId;
@@ -40,6 +42,14 @@ public class Nodeconnection extends BaseEntity
return id; return id;
} }
public Long getTreeId() {
return treeId;
}
public void setTreeId(Long treeId) {
this.treeId = treeId;
}
public void setParentNodeId(Long parentNodeId) public void setParentNodeId(Long parentNodeId)
{ {
this.parentNodeId = parentNodeId; this.parentNodeId = parentNodeId;

View File

@@ -18,6 +18,8 @@ public class Nodeparameter extends BaseEntity
/** 节点参数ID (主键) */ /** 节点参数ID (主键) */
private Long id; private Long id;
private Long treeId;
/** 关联到哪个节点实例 (外键: TreeInstanceNode.id) */ /** 关联到哪个节点实例 (外键: TreeInstanceNode.id) */
@Excel(name = "关联到哪个节点实例 (外键: TreeInstanceNode.id)") @Excel(name = "关联到哪个节点实例 (外键: TreeInstanceNode.id)")
private Long nodeInstanceId; private Long nodeInstanceId;
@@ -40,6 +42,14 @@ public class Nodeparameter extends BaseEntity
return id; return id;
} }
public Long getTreeId() {
return treeId;
}
public void setTreeId(Long treeId) {
this.treeId = treeId;
}
public void setNodeInstanceId(Long nodeInstanceId) public void setNodeInstanceId(Long nodeInstanceId)
{ {
this.nodeInstanceId = nodeInstanceId; this.nodeInstanceId = nodeInstanceId;

View File

@@ -40,7 +40,7 @@ public class Nodetemplate extends BaseEntity
/** 模版类型节点模版或者条件判断例如“node”precondition“ */ /** 模版类型节点模版或者条件判断例如“node”precondition“ */
@Excel(name = "模版类型节点模版或者条件判断例如“node”precondition“") @Excel(name = "模版类型节点模版或者条件判断例如“node”precondition“")
private String templeteType; private String templateType;
public Nodetemplate() { public Nodetemplate() {
} }
@@ -52,7 +52,7 @@ public class Nodetemplate extends BaseEntity
this.logicHandler = template.logicHandler; this.logicHandler = template.logicHandler;
this.description = template.description; this.description = template.description;
this.englishName = template.englishName; this.englishName = template.englishName;
this.templeteType = template.templeteType; this.templateType = template.templateType;
} }
public void setId(Long id) public void setId(Long id)
@@ -115,14 +115,14 @@ public class Nodetemplate extends BaseEntity
return englishName; return englishName;
} }
public void setTempleteType(String templeteType) public void setTemplateType(String templateType)
{ {
this.templeteType = templeteType; this.templateType = templateType;
} }
public String getTempleteType() public String getTemplateType()
{ {
return templeteType; return templateType;
} }
@Override @Override
@@ -134,7 +134,7 @@ public class Nodetemplate extends BaseEntity
.append("logicHandler", getLogicHandler()) .append("logicHandler", getLogicHandler())
.append("description", getDescription()) .append("description", getDescription())
.append("englishName", getEnglishName()) .append("englishName", getEnglishName())
.append("templeteType", getTempleteType()) .append("templateType", getTemplateType())
.toString(); .toString();
} }
} }

View File

@@ -2,6 +2,7 @@ package com.solution.system.mapper;
import java.util.List; import java.util.List;
import com.solution.system.domain.Nodeconnection; import com.solution.system.domain.Nodeconnection;
import org.apache.ibatis.annotations.Param;
/** /**
* 节点连接Mapper接口 * 节点连接Mapper接口
@@ -11,6 +12,8 @@ import com.solution.system.domain.Nodeconnection;
*/ */
public interface NodeconnectionMapper public interface NodeconnectionMapper
{ {
void deleteByTreeId(@Param("treeId") Long treeId);
/** /**
* 查询节点连接 * 查询节点连接
* *

View File

@@ -2,6 +2,7 @@ package com.solution.system.mapper;
import java.util.List; import java.util.List;
import com.solution.system.domain.Nodeparameter; import com.solution.system.domain.Nodeparameter;
import org.apache.ibatis.annotations.Param;
/** /**
* 节点参数Mapper接口 * 节点参数Mapper接口
@@ -11,6 +12,8 @@ import com.solution.system.domain.Nodeparameter;
*/ */
public interface NodeparameterMapper public interface NodeparameterMapper
{ {
void deleteByTreeId(@Param("treeId") Long treeId);
/** /**
* 查询节点参数 * 查询节点参数
* *

View File

@@ -2,6 +2,7 @@ package com.solution.system.mapper;
import java.util.List; import java.util.List;
import com.solution.system.domain.Treenodeinstance; import com.solution.system.domain.Treenodeinstance;
import org.apache.ibatis.annotations.Param;
/** /**
* 行为树实例节点Mapper接口 * 行为树实例节点Mapper接口
@@ -11,6 +12,8 @@ import com.solution.system.domain.Treenodeinstance;
*/ */
public interface TreenodeinstanceMapper public interface TreenodeinstanceMapper
{ {
void deleteByTreeId(@Param(value = "treeId") Long treeId);
/** /**
* 查询行为树实例节点 * 查询行为树实例节点
* *

View File

@@ -2,6 +2,7 @@ package com.solution.system.service;
import java.util.List; import java.util.List;
import com.solution.system.domain.Nodeconnection; import com.solution.system.domain.Nodeconnection;
import org.apache.ibatis.annotations.Param;
/** /**
* 节点连接Service接口 * 节点连接Service接口
@@ -11,6 +12,9 @@ import com.solution.system.domain.Nodeconnection;
*/ */
public interface INodeconnectionService public interface INodeconnectionService
{ {
void deleteByTreeId(@Param("treeId") Long treeId);
/** /**
* 查询节点连接 * 查询节点连接
* *

View File

@@ -11,6 +11,9 @@ import com.solution.system.domain.Nodeparameter;
*/ */
public interface INodeparameterService public interface INodeparameterService
{ {
void deleteByTreeId(Long treeId);
/** /**
* 查询节点参数 * 查询节点参数
* *

View File

@@ -11,6 +11,9 @@ import com.solution.system.domain.Treenodeinstance;
*/ */
public interface ITreenodeinstanceService public interface ITreenodeinstanceService
{ {
void deleteByTreeId(Long treeId);
/** /**
* 查询行为树实例节点 * 查询行为树实例节点
* *

View File

@@ -19,6 +19,11 @@ public class NodeconnectionServiceImpl implements INodeconnectionService
@Autowired @Autowired
private NodeconnectionMapper nodeconnectionMapper; private NodeconnectionMapper nodeconnectionMapper;
@Override
public void deleteByTreeId(Long treeId) {
nodeconnectionMapper.deleteByTreeId(treeId);
}
/** /**
* 查询节点连接 * 查询节点连接
* *

View File

@@ -19,6 +19,11 @@ public class NodeparameterServiceImpl implements INodeparameterService
@Autowired @Autowired
private NodeparameterMapper nodeparameterMapper; private NodeparameterMapper nodeparameterMapper;
@Override
public void deleteByTreeId(Long treeId) {
nodeparameterMapper.deleteByTreeId(treeId);
}
/** /**
* 查询节点参数 * 查询节点参数
* *

View File

@@ -19,6 +19,11 @@ public class TreenodeinstanceServiceImpl implements ITreenodeinstanceService
@Autowired @Autowired
private TreenodeinstanceMapper treenodeinstanceMapper; private TreenodeinstanceMapper treenodeinstanceMapper;
@Override
public void deleteByTreeId(Long treeId) {
treenodeinstanceMapper.deleteByTreeId(treeId);
}
/** /**
* 查询行为树实例节点 * 查询行为树实例节点
* *

View File

@@ -6,18 +6,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="Nodeconnection" id="NodeconnectionResult"> <resultMap type="Nodeconnection" id="NodeconnectionResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="treeId" column="tree_id" />
<result property="parentNodeId" column="parent_node_id" /> <result property="parentNodeId" column="parent_node_id" />
<result property="childNodeId" column="child_node_id" /> <result property="childNodeId" column="child_node_id" />
<result property="orderIndex" column="order_index" /> <result property="orderIndex" column="order_index" />
</resultMap> </resultMap>
<delete id="deleteByTreeId">
delete from nodeconnection where tree_id=#{treeId}
</delete>
<sql id="selectNodeconnectionVo"> <sql id="selectNodeconnectionVo">
select id, parent_node_id, child_node_id, order_index from nodeconnection select id, tree_id, parent_node_id, child_node_id, order_index from nodeconnection
</sql> </sql>
<select id="selectNodeconnectionList" parameterType="Nodeconnection" resultMap="NodeconnectionResult"> <select id="selectNodeconnectionList" parameterType="Nodeconnection" resultMap="NodeconnectionResult">
<include refid="selectNodeconnectionVo"/> <include refid="selectNodeconnectionVo"/>
<where> <where>
<if test="treeId != null "> and tree_id = #{treeId}</if>
<if test="parentNodeId != null "> and parent_node_id = #{parentNodeId}</if> <if test="parentNodeId != null "> and parent_node_id = #{parentNodeId}</if>
<if test="childNodeId != null "> and child_node_id = #{childNodeId}</if> <if test="childNodeId != null "> and child_node_id = #{childNodeId}</if>
<if test="orderIndex != null "> and order_index = #{orderIndex}</if> <if test="orderIndex != null "> and order_index = #{orderIndex}</if>
@@ -32,11 +38,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertNodeconnection" parameterType="Nodeconnection" useGeneratedKeys="true" keyProperty="id"> <insert id="insertNodeconnection" parameterType="Nodeconnection" useGeneratedKeys="true" keyProperty="id">
insert into nodeconnection insert into nodeconnection
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="treeId != null">tree_id,</if>
<if test="parentNodeId != null">parent_node_id,</if> <if test="parentNodeId != null">parent_node_id,</if>
<if test="childNodeId != null">child_node_id,</if> <if test="childNodeId != null">child_node_id,</if>
<if test="orderIndex != null">order_index,</if> <if test="orderIndex != null">order_index,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="treeId != null">#{treeId},</if>
<if test="parentNodeId != null">#{parentNodeId},</if> <if test="parentNodeId != null">#{parentNodeId},</if>
<if test="childNodeId != null">#{childNodeId},</if> <if test="childNodeId != null">#{childNodeId},</if>
<if test="orderIndex != null">#{orderIndex},</if> <if test="orderIndex != null">#{orderIndex},</if>
@@ -46,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateNodeconnection" parameterType="Nodeconnection"> <update id="updateNodeconnection" parameterType="Nodeconnection">
update nodeconnection update nodeconnection
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="treeId != null">tree_id = #{treeId},</if>
<if test="parentNodeId != null">parent_node_id = #{parentNodeId},</if> <if test="parentNodeId != null">parent_node_id = #{parentNodeId},</if>
<if test="childNodeId != null">child_node_id = #{childNodeId},</if> <if test="childNodeId != null">child_node_id = #{childNodeId},</if>
<if test="orderIndex != null">order_index = #{orderIndex},</if> <if test="orderIndex != null">order_index = #{orderIndex},</if>

View File

@@ -6,13 +6,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="Nodeparameter" id="NodeparameterResult"> <resultMap type="Nodeparameter" id="NodeparameterResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="treeId" column="tree_id" />
<result property="nodeInstanceId" column="node_instance_id" /> <result property="nodeInstanceId" column="node_instance_id" />
<result property="paramDefId" column="param_def_id" /> <result property="paramDefId" column="param_def_id" />
<result property="value" column="value" /> <result property="value" column="value" />
</resultMap> </resultMap>
<delete id="deleteByTreeId">
delete from nodeparameter where tree_id=#{treeId}
</delete>
<sql id="selectNodeparameterVo"> <sql id="selectNodeparameterVo">
select id, node_instance_id, param_def_id, value from nodeparameter select id, treeId, node_instance_id, param_def_id, value from nodeparameter
</sql> </sql>
<select id="selectNodeparameterList" parameterType="Nodeparameter" resultMap="NodeparameterResult"> <select id="selectNodeparameterList" parameterType="Nodeparameter" resultMap="NodeparameterResult">
@@ -32,11 +37,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertNodeparameter" parameterType="Nodeparameter" useGeneratedKeys="true" keyProperty="id"> <insert id="insertNodeparameter" parameterType="Nodeparameter" useGeneratedKeys="true" keyProperty="id">
insert into nodeparameter insert into nodeparameter
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="treeId != null">tree_id,</if>
<if test="nodeInstanceId != null">node_instance_id,</if> <if test="nodeInstanceId != null">node_instance_id,</if>
<if test="paramDefId != null">param_def_id,</if> <if test="paramDefId != null">param_def_id,</if>
<if test="value != null">value,</if> <if test="value != null">value,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="treeId != null">#{treeId},</if>
<if test="nodeInstanceId != null">#{nodeInstanceId},</if> <if test="nodeInstanceId != null">#{nodeInstanceId},</if>
<if test="paramDefId != null">#{paramDefId},</if> <if test="paramDefId != null">#{paramDefId},</if>
<if test="value != null">#{value},</if> <if test="value != null">#{value},</if>
@@ -46,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateNodeparameter" parameterType="Nodeparameter"> <update id="updateNodeparameter" parameterType="Nodeparameter">
update nodeparameter update nodeparameter
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="treeId != null">tree_id = #{treeId},</if>
<if test="nodeInstanceId != null">node_instance_id = #{nodeInstanceId},</if> <if test="nodeInstanceId != null">node_instance_id = #{nodeInstanceId},</if>
<if test="paramDefId != null">param_def_id = #{paramDefId},</if> <if test="paramDefId != null">param_def_id = #{paramDefId},</if>
<if test="value != null">value = #{value},</if> <if test="value != null">value = #{value},</if>

View File

@@ -11,7 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="logicHandler" column="logic_handler" /> <result property="logicHandler" column="logic_handler" />
<result property="description" column="description" /> <result property="description" column="description" />
<result property="englishName" column="english_name" /> <result property="englishName" column="english_name" />
<result property="templeteType" column="templete_type" /> <result property="templateType" column="templete_type" />
</resultMap> </resultMap>
<sql id="selectNodetemplateVo"> <sql id="selectNodetemplateVo">
@@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null and logicHandler != ''"> and logic_handler = #{logicHandler}</if> <if test="logicHandler != null and logicHandler != ''"> and logic_handler = #{logicHandler}</if>
<if test="description != null and description != ''"> and description = #{description}</if> <if test="description != null and description != ''"> and description = #{description}</if>
<if test="englishName != null and englishName != ''"> and english_name like concat('%', #{englishName}, '%')</if> <if test="englishName != null and englishName != ''"> and english_name like concat('%', #{englishName}, '%')</if>
<if test="templeteType != null and templeteType != ''"> and templete_type = #{templeteType}</if> <if test="templateType != null and templateType != ''"> and templete_type = #{templateType}</if>
</where> </where>
</select> </select>
@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null">logic_handler,</if> <if test="logicHandler != null">logic_handler,</if>
<if test="description != null">description,</if> <if test="description != null">description,</if>
<if test="englishName != null">english_name,</if> <if test="englishName != null">english_name,</if>
<if test="templeteType != null and templeteType != ''">templete_type,</if> <if test="templateType != null and templateType != ''">templete_type,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null and type != ''">#{type},</if> <if test="type != null and type != ''">#{type},</if>
@@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null">#{logicHandler},</if> <if test="logicHandler != null">#{logicHandler},</if>
<if test="description != null">#{description},</if> <if test="description != null">#{description},</if>
<if test="englishName != null">#{englishName},</if> <if test="englishName != null">#{englishName},</if>
<if test="templeteType != null and templeteType != ''">#{templeteType},</if> <if test="templateType != null and templateType != ''">#{templateType},</if>
</trim> </trim>
</insert> </insert>
@@ -63,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null">logic_handler = #{logicHandler},</if> <if test="logicHandler != null">logic_handler = #{logicHandler},</if>
<if test="description != null">description = #{description},</if> <if test="description != null">description = #{description},</if>
<if test="englishName != null">english_name = #{englishName},</if> <if test="englishName != null">english_name = #{englishName},</if>
<if test="templeteType != null and templeteType != ''">templete_type = #{templeteType},</if> <if test="templateType != null and templateType != ''">templete_type = #{templateType},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

View File

@@ -15,6 +15,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="desciption" column="desciption" /> <result property="desciption" column="desciption" />
</resultMap> </resultMap>
<delete id="deleteByTreeId">
delete from treenodeinstance where tree_id=#{treeId}
</delete>
<sql id="selectTreenodeinstanceVo"> <sql id="selectTreenodeinstanceVo">
select id, tree_id, template_id, instance_name, is_root, precondition_templete_id, uuid,desciption from treenodeinstance select id, tree_id, template_id, instance_name, is_root, precondition_templete_id, uuid,desciption from treenodeinstance
</sql> </sql>

View File

@@ -71,6 +71,7 @@ export interface BaseElement {
export interface GraphTaskElement extends BaseElement { export interface GraphTaskElement extends BaseElement {
template: number; template: number;
templateType: NullableString,
inputs: any; inputs: any;
outputs: any; outputs: any;
variables: ElementVariable[]; variables: ElementVariable[];

View File

@@ -15,7 +15,6 @@
</a-space> </a-space>
</template> </template>
<!-- 节点内容区域 -->
<div class="w-full"> <div class="w-full">
<a-tooltip> <a-tooltip>
<template #title> <template #title>
@@ -127,23 +126,34 @@ export default defineComponent({
<style lang="less"> <style lang="less">
.ks-designer-node { .ks-designer-node {
background: linear-gradient(150deg, #093866 1%, #1f69b3 55%); background: linear-gradient(150deg, rgba(108, 99, 255) 1%, rgba(108, 99, 255) 100%);
border: 0;
border-radius: 8px; border-radius: 8px;
width: 100%; width: 100%;
height: 100%; height: 100%;
cursor: pointer; cursor: pointer;
position: relative; position: relative;
background: #1e2533;
border: 1px solid #4a7aff;
&:hover {
border: 1px solid #4a7aff;
box-shadow: 0 0 10px rgba(74, 122, 255, 0.3);
}
.ant-card-head { .ant-card-head {
border: 0; border: 0;
height: 38px; height: 38px;
min-height: 38px; min-height: 38px;
border-radius: 0; border-radius: 0;
color: #ddd; color: #fff;
font-size: 12px; font-size: 12px;
font-weight: normal; font-weight: normal;
padding: 0 20px; padding: 0 20px;
background: linear-gradient(to bottom, #3a4c70, #2d3a56);
border-top-left-radius: 8px;
border-top-right-radius: 8px;
background: linear-gradient(to bottom, rgba(108, 99, 255, 0.15), rgba(108, 99, 255, 0.05));
//background: linear-gradient(to bottom, rgb(234 234 234 / 20%), rgb(191 191 191 / 58%));
} }
.ks-designer-node-icon { .ks-designer-node-icon {
@@ -158,115 +168,118 @@ export default defineComponent({
.ks-designer-node-title { .ks-designer-node-title {
font-size: 13px; font-size: 13px;
color: #fff;
} }
.ant-card-body { .ant-card-body {
color: #fff; color: #f5f5f5;
height: calc(100% - 38px); height: calc(100% - 38px);
border-radius: 0; border-radius: 0;
font-size: 12px; font-size: 12px;
padding: 8px 15px; padding: 8px 15px;
border-top: 1px solid #195693; border-top: 1px solid rgba(108, 99, 255, 0.5);
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
box-shadow: 0 0 10px rgba(74, 122, 255, 0.3);
} }
&.ks-designer-model-node, // model/task 节点:浅紫渐变
&.ks-designer-task-node { //&.ks-designer-model-node,
background: linear-gradient(150deg, #20421b 1%, #4a6646 55%); //&.ks-designer-task-node {
// background: linear-gradient(150deg, rgba(92,84,247,0.9) 1%, rgba(115,108,250,0.7) 55%);
.ant-card-body { //
border-top: 1px solid #466741; // .ant-card-body {
} // border-top: 1px solid rgba(92,84,247,0.5);
// }
.ks-designer-node-icon { //
background: url('@/assets/icons/m-02.png') center / 100% 100%; // .ks-designer-node-icon {
} // background: url('@/assets/icons/m-02.png') center / 100% 100%;
} // }
//}
&.ks-designer-input-node { //
background: linear-gradient(150deg, #083058 1%, #1e5d9b 55%); //// input 节点:深紫渐变
//&.ks-designer-input-node {
.ant-card-body { // background: linear-gradient(150deg, rgba(82,73,245,0.9) 1%, rgba(105,98,249,0.7) 55%);
border-top: 1px solid #105ca7; //
} // .ant-card-body {
// border-top: 1px solid rgba(82,73,245,0.5);
.ks-designer-node-icon { // }
background: url('@/assets/icons/icon-model-input.png') center / 100% 100%; //
} // .ks-designer-node-icon {
} // background: url('@/assets/icons/icon-model-input.png') center / 100% 100%;
// }
&.ks-designer-action-node { //}
background: linear-gradient(150deg, #343207 1%, #485010 55%); //
//// action 节点亮紫渐变对应之前的action-node
.ant-card-body { //&.ks-designer-action-node {
border-top: 1px solid #59550e; // background: linear-gradient(150deg, rgba(108,99,255,0.9) 1%, rgba(140,133,255,0.7) 55%);
} //
// .ant-card-body {
.ks-designer-node-icon { // border-top: 1px solid rgba(108,99,255,0.5);
background: url('@/assets/icons/bg-fk-point.png') center / 100% 100%; // }
} //
} // .ks-designer-node-icon {
// background: url('@/assets/icons/bg-fk-point.png') center / 100% 100%;
&.ks-designer-precondition-node, // }
&.ks-designer-component-node { //}
background: linear-gradient(150deg, #06226b 1%, #1a43a7 55%); //
//// precondition/component 节点:蓝紫渐变
.ant-card-body { //&.ks-designer-precondition-node,
border-top: 1px solid #26448c; //&.ks-designer-component-node {
} // background: linear-gradient(150deg, rgba(72,64,243,0.9) 1%, rgba(95,88,248,0.7) 55%);
} //
// .ant-card-body {
&.ks-designer-select-node, // border-top: 1px solid rgba(72,64,243,0.5);
&.ks-designer-control-node { // }
background: linear-gradient(150deg, #1d4f32 1%, #326a5d 55%); //}
//
.ant-card-body { //// select/control 节点:浅蓝紫渐变
border-top: 1px solid #326a5d; //&.ks-designer-select-node,
} //&.ks-designer-control-node {
// background: linear-gradient(150deg, rgba(90,82,246,0.9) 1%, rgba(118,111,251,0.7) 55%);
.ks-designer-node-icon { //
background: url('@/assets/icons/bg-model-builder-card-title.png') center / 100% 100%; // .ant-card-body {
} // border-top: 1px solid rgba(90,82,246,0.5);
} // }
//
// .ks-designer-node-icon {
// background: url('@/assets/icons/bg-model-builder-card-title.png') center / 100% 100%;
// }
//}
// 连接桩容器样式 // 连接桩容器样式
.ks-designer-node-content { .ks-designer-node-content {
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; // 每个child行之间的间距 gap: 4px;
} }
// 每个child行包含左右桩+文本)
.ks-designer-node-row { .ks-designer-node-row {
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
position: relative; position: relative;
min-height: 24px; // 固定行高,保证桩对齐 min-height: 24px;
} }
// 连接桩基础样式
.port { .port {
width: 12px; width: 12px;
height: 12px; height: 12px;
border-radius: 50%; border-radius: 50%;
cursor: crosshair; cursor: crosshair;
flex-shrink: 0; flex-shrink: 0;
box-shadow: 0 0 0 2px rgb(74 114 214 / 80%); box-shadow: 0 0 0 2px rgb(108, 99, 255, 0.8);
z-index: 10; // 确保桩在最上层 z-index: 10;
// X6 标记为可连线的磁体
magnet: true; magnet: true;
} }
// 左侧入桩样式 // 左侧入桩样式
.port-in { .port-in {
background-color: #093866; // 青色:入桩 background-color: #6C63FF;
margin-right: 8px; // 与文本的间距 margin-right: 8px;
//border: 1px solid #093866; //border: 1px solid #093866;
// X6 只能作为连线目标(入)
magnet: passive; magnet: passive;
box-shadow: none; box-shadow: none;
width: 15px; width: 15px;
@@ -279,11 +292,9 @@ export default defineComponent({
top: 12px; top: 12px;
} }
// 右侧出桩样式
.port-out { .port-out {
margin-left: 8px; // 与文本的间距 margin-left: 8px;
margin-right: 5px; margin-right: 5px;
// X6 只能作为连线源(出)
magnet: active; magnet: active;
box-shadow: none; box-shadow: none;
width: 15px; width: 15px;
@@ -298,7 +309,7 @@ export default defineComponent({
// 节点文本样式 // 节点文本样式
.ks-designer-node-name { .ks-designer-node-name {
flex: 1; // 占满中间空间 flex: 1;
line-height: 24px; line-height: 24px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;

View File

@@ -16,7 +16,7 @@ export interface NodeTemplate {
type: NullableString; type: NullableString;
logicHandler: NullableString; logicHandler: NullableString;
description: NullableString; description: NullableString;
templeteType: NullableString; templateType: NullableString;
englishName: NullableString; englishName: NullableString;
parameters: ElementParameter[], parameters: ElementParameter[],
} }

View File

@@ -22,6 +22,7 @@ export const createGraphTaskElementFromTemplate = (
key: generateKey(template.type), key: generateKey(template.type),
type: 'task', type: 'task',
template: template.id, template: template.id,
templateType: template.templateType,
name: template.name, name: template.name,
category: template.type, category: template.type,
description: template.description, description: template.description,