From 40655dd557445979b7e3b5dd8f807a9cb4ae676c Mon Sep 17 00:00:00 2001 From: MHW Date: Thu, 16 Apr 2026 09:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=8C=E4=B8=BA=E6=A0=91?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=BA=E6=99=AFid=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/core/BehaviortreeProcessor.java | 20 ++++++++++++++++--- .../mapper/system/BehaviortreeMapper.xml | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/auto-solution-admin/src/main/java/com/solution/web/core/BehaviortreeProcessor.java b/auto-solution-admin/src/main/java/com/solution/web/core/BehaviortreeProcessor.java index 3630cb2..5a186ac 100644 --- a/auto-solution-admin/src/main/java/com/solution/web/core/BehaviortreeProcessor.java +++ b/auto-solution-admin/src/main/java/com/solution/web/core/BehaviortreeProcessor.java @@ -247,9 +247,23 @@ public class BehaviortreeProcessor { //获取行为树重复名称个数 Integer num = behaviortreeService.getCountName(newName); if(num > 0){ - Integer count = num + 1; - behaviortree.setName(newName + count); - behaviortree.setEnglishName(newEnglishName + count); + // 从2开始尝试,因为基础名称已经存在 + int count = 2; + String finalName; + String finalEnglishName; + do { + finalName = newName + "_" + count; + finalEnglishName = newEnglishName + "_" + count; + // 检查当前生成的名称是否存在 + num = behaviortreeService.getCountName(finalName); + count++; + } while(num > 0); + + behaviortree.setName(finalName); + behaviortree.setEnglishName(finalEnglishName); + } else { + behaviortree.setName(newName); + behaviortree.setEnglishName(newEnglishName); } return this.create(behaviortree); } 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 fbea4a4..d71a9f4 100644 --- a/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml +++ b/auto-solution-behaviour/src/main/resources/mapper/system/BehaviortreeMapper.xml @@ -72,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" english_name, xml_content, platform_id, + scenario_id, #{name}, @@ -81,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{englishName}, #{xmlContent}, #{platformId}, + #{scenarioId},