diff --git a/auto-solution-admin/src/main/java/com/solution/web/controller/scene/SceneController.java b/auto-solution-admin/src/main/java/com/solution/web/controller/scene/SceneController.java index 5b92009..311cbed 100644 --- a/auto-solution-admin/src/main/java/com/solution/web/controller/scene/SceneController.java +++ b/auto-solution-admin/src/main/java/com/solution/web/controller/scene/SceneController.java @@ -55,4 +55,13 @@ public class SceneController extends BaseController { { return success(sceneService.findOneById(id)); } + + /** + * 根据场景id获取场景下所有行为树 + */ + @GetMapping("/getAllTree/{id}") + @ApiOperation("根据场景id获取场景下所有行为树") + public AjaxResult getAllTree(@PathVariable Integer id){ + return success(sceneService.getAllTree(id)); + } } diff --git a/auto-solution-behaviour/src/main/java/com/solution/system/domain/Behaviortree.java b/auto-solution-behaviour/src/main/java/com/solution/system/domain/Behaviortree.java index 857d083..7ca0fec 100644 --- a/auto-solution-behaviour/src/main/java/com/solution/system/domain/Behaviortree.java +++ b/auto-solution-behaviour/src/main/java/com/solution/system/domain/Behaviortree.java @@ -49,6 +49,17 @@ public class Behaviortree extends BaseEntity @Excel(name = "平台ID") private Integer platformId; + @Excel(name = "场景ID") + private Integer scenarioId; + + public Integer getScenarioId() { + return scenarioId; + } + + public void setScenarioId(Integer scenarioId) { + this.scenarioId = scenarioId; + } + public Integer getPlatformId() { return platformId; } diff --git a/auto-solution-behaviour/src/main/java/com/solution/system/mapper/PlatformMapper.java b/auto-solution-behaviour/src/main/java/com/solution/system/mapper/PlatformMapper.java index 4ebd58a..520e8ea 100644 --- a/auto-solution-behaviour/src/main/java/com/solution/system/mapper/PlatformMapper.java +++ b/auto-solution-behaviour/src/main/java/com/solution/system/mapper/PlatformMapper.java @@ -2,6 +2,7 @@ package com.solution.system.mapper; import com.solution.system.domain.PlatformTree; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -13,12 +14,12 @@ public interface PlatformMapper { * @param id * @return */ - PlatformTree getPlatformByTreeId(Long id); + PlatformTree getPlatformByTreeId(Integer id); /** * 根据下属平台英文名获取中文名返回 * @param underlingEnglishName * @return */ - List selectPlatformChineseName(List underlingEnglishName); + List selectPlatformChineseName(@Param("underlingEnglishName") List underlingEnglishName); } diff --git a/auto-solution-behaviour/src/main/java/com/solution/system/service/impl/BehaviortreeServiceImpl.java b/auto-solution-behaviour/src/main/java/com/solution/system/service/impl/BehaviortreeServiceImpl.java index a389b2a..86d126b 100644 --- a/auto-solution-behaviour/src/main/java/com/solution/system/service/impl/BehaviortreeServiceImpl.java +++ b/auto-solution-behaviour/src/main/java/com/solution/system/service/impl/BehaviortreeServiceImpl.java @@ -121,11 +121,11 @@ public class BehaviortreeServiceImpl implements IBehaviortreeService throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION); } Behaviortree behaviortree = behaviortreeMapper.selectBehaviortreeById(Long.valueOf(treeId)); - if(ObjectUtil.isEmpty(behaviortree) && null == behaviortree.getId()){ + if(ObjectUtil.isEmpty(behaviortree) || null == behaviortree.getId()){ throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION); } //根据行为树id获取行为树所属平台 - PlatformTree platform = platformMapper.getPlatformByTreeId(behaviortree.getId()); + PlatformTree platform = platformMapper.getPlatformByTreeId(behaviortree.getPlatformId()); //根据平台name获取平台下属英文名 List underlingEnglishName = platformCommunicationMapper.getUnderlingBytreeId(platform.getName()); //根据下属平台英文名获取中文名返回 diff --git a/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml b/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml index ecd2411..f43522a 100644 --- a/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml +++ b/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml @@ -5,13 +5,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - - - - + + + + + + + + + diff --git a/auto-solution-behaviour/src/main/resources/mapper/system/PlatformMapper.xml b/auto-solution-behaviour/src/main/resources/mapper/system/PlatformMapper.xml index c09638f..e6fc609 100644 --- a/auto-solution-behaviour/src/main/resources/mapper/system/PlatformMapper.xml +++ b/auto-solution-behaviour/src/main/resources/mapper/system/PlatformMapper.xml @@ -6,7 +6,7 @@ SELECT id, name, description, scenario_path, communication_graph FROM afsim_scenario + update afsim_scenario diff --git a/modeler/src/views/decision/designer/api.ts b/modeler/src/views/decision/designer/api.ts index e05404e..16fdd21 100644 --- a/modeler/src/views/decision/designer/api.ts +++ b/modeler/src/views/decision/designer/api.ts @@ -28,6 +28,10 @@ export const findOneTreeByPlatformId = (platformId: number): Promise => { + return req.get(`/system/behaviortree/underling/${treeId}`); +}; + export const findOneTreeById = (id: number): Promise => { return req.get(`/system/behaviortree/${id}`); }; diff --git a/modeler/src/views/decision/designer/designer.vue b/modeler/src/views/decision/designer/designer.vue index 428d109..8766aa0 100644 --- a/modeler/src/views/decision/designer/designer.vue +++ b/modeler/src/views/decision/designer/designer.vue @@ -43,10 +43,11 @@ @@ -74,8 +75,8 @@ import { createGraphTaskElementFromTemplate } from './utils'; import { createGraphTaskElement, createLineOptions, type GraphContainer, type GraphTaskElement, hasElements, hasRootElementNode, resolveGraph, useGraphCanvas } from '../graph'; import { registerNodeElement } from './register'; import { findAllBasicPlatforms, findAllNodeCommands } from '../api'; -import type { Platform } from '../types'; -import { createTree, findOneTreeById, findOneTreeByPlatformId, updateTree } from './api'; +import type { NodeCommand, Platform } from '../types'; +import { createTree, findOneTreeById, findOneTreeByPlatformId, updateTree, findSubPlatforms } from './api'; import TressCard from './trees-card.vue'; import NodesCard from './nodes-card.vue'; @@ -112,6 +113,7 @@ export default defineComponent({ const changed = ref(false); const treesCardRef = ref | null>(null); const platforms = ref([]); + const subPlatforms = ref([]); const nodeCommands = ref([]) const currentScenarioId = ref(null); const currentPlatformId = ref(null); @@ -153,6 +155,27 @@ export default defineComponent({ loadNodeCommands(); } + // 加载下属平台 + const loadSubPlatforms = (treeId: number) => { + console.log(treeId); + + if (!treeId || treeId <= 0) { + subPlatforms.value = []; + return; + } + + findSubPlatforms(treeId).then(r => { + if (r.data && Array.isArray(r.data)) { + subPlatforms.value = r.data as Platform[]; + } else { + subPlatforms.value = []; + } + }).catch(err => { + console.error('加载下属平台失败:', err); + subPlatforms.value = []; + }); + }; + // 处理拖动开始 const handleDragStart = (nm: NodeDragTemplate) => { draggedNodeData.value = nm; @@ -267,6 +290,10 @@ export default defineComponent({ graph: nodeGraph, }; currentTreeEditing.value = true; + + // 加载下属平台 + loadSubPlatforms(r.data.id); + nextTick(() => { initGraph(); }); @@ -343,6 +370,7 @@ export default defineComponent({ }; selectedModelNode.value = null; selectedNodeTaskElement.value = null; + subPlatforms.value = []; // 重置下属平台 nextTick(() => { initGraph(); @@ -487,6 +515,7 @@ export default defineComponent({ nodeCommands, currentScenarioId, platforms, + subPlatforms, treesCardRef, handleCreateTree, currentTreeEditing, diff --git a/modeler/src/views/decision/designer/properties.vue b/modeler/src/views/decision/designer/properties.vue index ed0e85a..bde1f84 100644 --- a/modeler/src/views/decision/designer/properties.vue +++ b/modeler/src/views/decision/designer/properties.vue @@ -101,7 +101,7 @@ size="small" type="editable-card" @edit="onEditParameterTab"> - + - {{pl.description}} + {{pl.description}} | null | undefined>, required: false }, graph: { type: [Object, null] as PropType, required: true }, platforms: { type: Array as PropType, required: true }, + subPlatforms: { type: Array as PropType, required: false, default: () => [] }, nodeCommands: { type: Array as PropType, required: true }, }, emits: ['update-element', 'update-tree'], setup(props, { emit }) { const platforms = ref(props.platforms ?? []); + const subPlatforms = ref(props.subPlatforms ?? []); const nodeCommands = ref(props.nodeCommands ?? []); const activeTopTabsKey = ref('1'); @@ -299,6 +301,41 @@ export default defineComponent({ multiableParameters.value = multiable === true && groupedParameters.value.length > 0; }; + // 获取平台Tab显示名称 + const getPlatformTabName = (index: number): string => { + if (!currentTree.value?.platformId) { + return `平台 ${index + 1}`; + } + + // 查找当前行为树绑定的平台 + const currentPlatform = platforms.value.find(p => p.id === currentTree.value?.platformId); + if (!currentPlatform) { + return `平台 ${index + 1}`; + } + + // 如果有多个分组,显示平台名称和索引 + if (groupedParameters.value.length > 1) { + return `${currentPlatform.name || '未知平台'}-${index + 1}`; + } + + return currentPlatform.name || '平台'; + }; + + // 获取可用的平台列表(包括当前平台和其下属平台) + const getAvailablePlatforms = (): Platform[] => { + if (!currentTree.value?.platformId) { + return platforms.value; + } + + // 如果有下属平台,返回下属平台列表 + if (subPlatforms.value && subPlatforms.value.length > 0) { + return subPlatforms.value; + } + + // 否则返回所有平台 + return platforms.value; + }; + const resolveNode = (n?: Node | null | undefined) => { groupedParametersActiveTab.value = 0; @@ -389,6 +426,7 @@ export default defineComponent({ watch(() => props.nodeCommands, (n: NodeCommand[] | null | undefined) => nodeCommands.value = n ?? [], { deep: true, immediate: true }); watch(() => props.platforms, (n: Platform[] | null | undefined) => platforms.value = n ?? [], { deep: true, immediate: true }); + watch(() => props.subPlatforms, (n: Platform[] | null | undefined) => subPlatforms.value = n ?? [], { deep: true, immediate: true }); onMounted(() => load()); @@ -400,6 +438,8 @@ export default defineComponent({ multiableParameters, onEditParameterTab, groupedParameters, + getPlatformTabName, + getAvailablePlatforms, actionSpaceColumns, activeTopTabsKey, activeBottomTabsKey,