根据平台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

@@ -0,0 +1,34 @@
package com.solution.system.domain;
import lombok.Data;
/**
* 平台视图对象 platform
*/
@Data
public class PlatformVO
{
/** 主键 */
private Integer id;
/** 名称 */
private String name;
/** 描述 */
private String description;
/** 平台出现在想定上的想定id */
private Integer scenarioId;
/** 经度 */
private String longitude;
/** 纬度 */
private String latitude;
/** 平台类型 */
private String platformType;
/** 海拔 */
private Float altitude;
}

View File

@@ -1,6 +1,7 @@
package com.solution.system.mapper;
import com.solution.system.domain.PlatformTree;
import com.solution.system.domain.PlatformVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -9,12 +10,7 @@ import java.util.List;
@Mapper
public interface PlatformMapper {
/**
* 根据行为树id获取行为树所属平台
* @param id
* @return
*/
PlatformTree getPlatformByTreeId(Integer id);
/**
* 根据下属平台英文名获取中文名返回
@@ -22,4 +18,18 @@ public interface PlatformMapper {
* @return
*/
List<String> selectPlatformChineseName(@Param("underlingEnglishName") List<String> underlingEnglishName);
/**
* 根据平台id获取平台实体
* @param platformId
* @return
*/
PlatformTree getPlatformById(Integer platformId);
/**
* 根据平台英文名查询该平台实体
* @param underlingEnglishName
* @return
*/
List<PlatformVO> getPlatformByEnglishName(@Param("underlingEnglishName") List<String> underlingEnglishName);
}

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;
}
/**

View File

@@ -5,12 +5,7 @@
<mapper namespace="com.solution.system.mapper.PlatformMapper">
<select id="getPlatformByTreeId" resultType="com.solution.system.domain.PlatformTree"
parameterType="java.lang.Integer">
SELECT id , name , description, scenario_id
FROM platform
WHERE id = #{id}
</select>
<select id="selectPlatformChineseName" resultType="java.lang.String"
parameterType="java.util.List">
SELECT description
@@ -20,4 +15,23 @@
#{item}
</foreach>
</select>
<select id="getPlatformById" resultType="com.solution.system.domain.PlatformTree"
parameterType="java.lang.Integer">
SELECT id, name, description, scenario_id AS scenarioId
FROM platform
WHERE id = #{platformId}
</select>
<select id="getPlatformByEnglishName" resultType="com.solution.system.domain.PlatformVO"
parameterType="java.util.List&lt;java.lang.String&gt;">
SELECT id,name,description,
scenario_id AS scenarioId,
longitude,latitude,
platform_type AS platformType,
altitude
FROM platform
WHERE name IN
<foreach item="item" collection="underlingEnglishName" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>