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 javax.servlet.http.HttpServletResponse;
import com.solution.web.core.BehaviortreeProcessor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -38,6 +39,9 @@ public class BehaviortreeController extends BaseController
@Autowired
private IBehaviortreeService behaviortreeService;
@Autowired
private BehaviortreeProcessor behaviortreeProcessor;
/**
* 查询行为树主列表
*/
@@ -84,7 +88,7 @@ public class BehaviortreeController extends BaseController
@PostMapping
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
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.setEnglishName(template.getEnglishName());
dto.setLogicHandler(template.getLogicHandler());
dto.setTempleteType(template.getTempleteType());
dto.setTemplateType(template.getTemplateType());
return dto;
})
.collect(Collectors.groupingBy(NodetemplateDTO::getTempleteType));
.collect(Collectors.groupingBy(NodetemplateDTO::getTemplateType));
List<NodetemplateVO> vos = new ArrayList<>();
groupedByTemplateType.forEach((key, value) -> {
// 处理逻辑
NodetemplateVO vo = new NodetemplateVO();
vo.setTempleteType(key);
vo.setTemplateType(key);
vo.setDtoList(value);
vos.add(vo);
});

View File

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

View File

@@ -9,17 +9,17 @@ import java.util.List;
public class NodetemplateVO {
/** 模版类型节点模版或者条件判断例如“node”precondition“ */
@ApiModelProperty("模版类型节点模版或者条件判断例如“node”precondition“")
private String templeteType;
private String templateType;
@ApiModelProperty("节点模板数据")
private List<NodetemplateDTO> dtoList;
public String getTempleteType() {
return templeteType;
public String getTemplateType() {
return templateType;
}
public void setTempleteType(String templeteType) {
this.templeteType = templeteType;
public void setTemplateType(String templateType) {
this.templateType = templateType;
}
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 (主键) */
private Long id;
private Long treeId;
/** 父节点 (外键: TreeInstanceNode.id) */
@Excel(name = "父节点 (外键: TreeInstanceNode.id)")
private Long parentNodeId;
@@ -40,7 +42,15 @@ public class Nodeconnection extends BaseEntity
return id;
}
public void setParentNodeId(Long parentNodeId)
public Long getTreeId() {
return treeId;
}
public void setTreeId(Long treeId) {
this.treeId = treeId;
}
public void setParentNodeId(Long parentNodeId)
{
this.parentNodeId = parentNodeId;
}

View File

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

View File

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

View File

@@ -2,6 +2,7 @@ package com.solution.system.mapper;
import java.util.List;
import com.solution.system.domain.Nodeconnection;
import org.apache.ibatis.annotations.Param;
/**
* 节点连接Mapper接口
@@ -11,6 +12,8 @@ import com.solution.system.domain.Nodeconnection;
*/
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 com.solution.system.domain.Nodeparameter;
import org.apache.ibatis.annotations.Param;
/**
* 节点参数Mapper接口
@@ -11,6 +12,8 @@ import com.solution.system.domain.Nodeparameter;
*/
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 com.solution.system.domain.Treenodeinstance;
import org.apache.ibatis.annotations.Param;
/**
* 行为树实例节点Mapper接口
@@ -11,6 +12,8 @@ import com.solution.system.domain.Treenodeinstance;
*/
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 com.solution.system.domain.Nodeconnection;
import org.apache.ibatis.annotations.Param;
/**
* 节点连接Service接口
@@ -11,6 +12,9 @@ import com.solution.system.domain.Nodeconnection;
*/
public interface INodeconnectionService
{
void deleteByTreeId(@Param("treeId") Long treeId);
/**
* 查询节点连接
*

View File

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

View File

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

View File

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

View File

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

View File

@@ -19,6 +19,11 @@ public class TreenodeinstanceServiceImpl implements ITreenodeinstanceService
@Autowired
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">
<result property="id" column="id" />
<result property="treeId" column="tree_id" />
<result property="parentNodeId" column="parent_node_id" />
<result property="childNodeId" column="child_node_id" />
<result property="orderIndex" column="order_index" />
</resultMap>
<delete id="deleteByTreeId">
delete from nodeconnection where tree_id=#{treeId}
</delete>
<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>
<select id="selectNodeconnectionList" parameterType="Nodeconnection" resultMap="NodeconnectionResult">
<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="childNodeId != null "> and child_node_id = #{childNodeId}</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 into nodeconnection
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="treeId != null">tree_id,</if>
<if test="parentNodeId != null">parent_node_id,</if>
<if test="childNodeId != null">child_node_id,</if>
<if test="orderIndex != null">order_index,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="treeId != null">#{treeId},</if>
<if test="parentNodeId != null">#{parentNodeId},</if>
<if test="childNodeId != null">#{childNodeId},</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 nodeconnection
<trim prefix="SET" suffixOverrides=",">
<if test="treeId != null">tree_id = #{treeId},</if>
<if test="parentNodeId != null">parent_node_id = #{parentNodeId},</if>
<if test="childNodeId != null">child_node_id = #{childNodeId},</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">
<result property="id" column="id" />
<result property="treeId" column="tree_id" />
<result property="nodeInstanceId" column="node_instance_id" />
<result property="paramDefId" column="param_def_id" />
<result property="value" column="value" />
</resultMap>
<delete id="deleteByTreeId">
delete from nodeparameter where tree_id=#{treeId}
</delete>
<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>
<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 into nodeparameter
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="treeId != null">tree_id,</if>
<if test="nodeInstanceId != null">node_instance_id,</if>
<if test="paramDefId != null">param_def_id,</if>
<if test="value != null">value,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="treeId != null">#{treeId},</if>
<if test="nodeInstanceId != null">#{nodeInstanceId},</if>
<if test="paramDefId != null">#{paramDefId},</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 nodeparameter
<trim prefix="SET" suffixOverrides=",">
<if test="treeId != null">tree_id = #{treeId},</if>
<if test="nodeInstanceId != null">node_instance_id = #{nodeInstanceId},</if>
<if test="paramDefId != null">param_def_id = #{paramDefId},</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="description" column="description" />
<result property="englishName" column="english_name" />
<result property="templeteType" column="templete_type" />
<result property="templateType" column="templete_type" />
</resultMap>
<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="description != null and description != ''"> and description = #{description}</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>
</select>
@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null">logic_handler,</if>
<if test="description != null">description,</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 prefix="values (" suffix=")" suffixOverrides=",">
<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="description != null">#{description},</if>
<if test="englishName != null">#{englishName},</if>
<if test="templeteType != null and templeteType != ''">#{templeteType},</if>
<if test="templateType != null and templateType != ''">#{templateType},</if>
</trim>
</insert>
@@ -63,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null">logic_handler = #{logicHandler},</if>
<if test="description != null">description = #{description},</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>
where id = #{id}
</update>

View File

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

View File

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

View File

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

View File

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

View File

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