根据平台id获取该行为树的下属

This commit is contained in:
MHW
2026-04-15 16:26:49 +08:00
parent 4404d0e411
commit 2d60a8b90f
7 changed files with 98 additions and 35 deletions

View File

@@ -4,6 +4,7 @@ import java.util.List;
import com.solution.system.domain.Behaviortree;
import com.solution.system.domain.PlatformChiefCommander;
import com.solution.system.domain.PlatformVO;
/**
* 行为树主Service接口
@@ -65,11 +66,11 @@ public interface IBehaviortreeService
public int deleteBehaviortreeById(Long id);
/**
* 根据行为树id获取该行为树的下属
* @param treeId
* 根据平台id获取该行为树的下属
* @param platformId
* @return
*/
List<String> getUnderling(Integer treeId);
List<PlatformVO> getUnderling(Integer platformId);
/**
* 根据场景id获取总指挥的行为树的原数据

View File

@@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.solution.common.constant.ExceptionConstants;
import com.solution.system.domain.PlatformChiefCommander;
import com.solution.system.domain.PlatformTree;
import com.solution.system.domain.PlatformVO;
import com.solution.system.mapper.PlatformCommunicationMapper;
import com.solution.system.mapper.PlatformMapper;
import org.springframework.beans.factory.annotation.Autowired;
@@ -112,29 +113,28 @@ public class BehaviortreeServiceImpl implements IBehaviortreeService
}
/**
* 根据行为树id获取该行为树的下属
* @param treeId
* 根据平台id获取该行为树的下属
* @param platformId
* @return
*/
@Override
public List<String> getUnderling(Integer treeId) {
if(null == treeId){
public List<PlatformVO> getUnderling(Integer platformId) {
if(null == platformId){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
Behaviortree behaviortree = behaviortreeMapper.selectBehaviortreeById(Long.valueOf(treeId));
if(ObjectUtil.isEmpty(behaviortree) || null == behaviortree.getId()){
throw new RuntimeException(ExceptionConstants.PARAMETER_EXCEPTION);
}
//根据行为树id获取行为树所属平台
PlatformTree platform = platformMapper.getPlatformByTreeId(behaviortree.getPlatformId());
//根据平台id获取平台实体
PlatformTree platform = platformMapper.getPlatformById(platformId);
//根据平台name获取平台下属英文名
List<String> underlingEnglishName = platformCommunicationMapper.getUnderlingBytreeId(platform.getName());
//根据下属平台英文名获取中文名返回
List<String> underlingChineseName = platformMapper.selectPlatformChineseName(underlingEnglishName);
if(CollUtil.isEmpty(underlingChineseName)){
if(CollUtil.isEmpty(underlingEnglishName)){
throw new RuntimeException("该平台暂无下属");
}
return underlingChineseName;
//根据平台英文名查询该平台实体
List<PlatformVO> resultList = platformMapper.getPlatformByEnglishName(underlingEnglishName);
if(CollUtil.isEmpty(resultList)){
throw new RuntimeException("无法根据平台英文名获取平台实体");
}
return resultList;
}
/**