feat: 语音交互绑定指标
This commit is contained in:
parent
e3e5626e20
commit
ef676cc692
@ -50,4 +50,10 @@ public class AeIndicatorController extends BaseController {
|
|||||||
public AjaxResult updateIndicator(@Valid @RequestBody AeIndicatorUpdateDTO updateDTO) {
|
public AjaxResult updateIndicator(@Valid @RequestBody AeIndicatorUpdateDTO updateDTO) {
|
||||||
return toAjax(indicatorService.updateIndicator(updateDTO));
|
return toAjax(indicatorService.updateIndicator(updateDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取指定parentId下指定level层级的指标")
|
||||||
|
@GetMapping("/getChildrenByParentIdWithLevelLimit")
|
||||||
|
public AjaxResult getChildrenByParentIdWithLevelLimit(@RequestParam Long parentId, @RequestParam Integer maxLevel, @RequestParam Integer type) {
|
||||||
|
return success(indicatorService.getChildrenByParentIdWithLevelLimit(parentId, maxLevel, type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.cmvr.evaluation.model.domain;
|
package com.cmvr.evaluation.model.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.cmvr.common.core.domain.BaseEntity;
|
import com.cmvr.common.core.domain.BaseEntity;
|
||||||
@ -10,6 +11,7 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ -51,4 +53,8 @@ public class AeIndicatorEntity extends BaseEntity {
|
|||||||
|
|
||||||
@ApiModelProperty("类型 0-语音 1-触控")
|
@ApiModelProperty("类型 0-语音 1-触控")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
|
@ApiModelProperty("子指标列表")
|
||||||
|
@TableField(exist = false) // 关键:标注该字段不是数据库列,避免MP映射报错
|
||||||
|
private List<AeIndicatorEntity> children;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,4 +17,6 @@ public interface AeIndicatorService extends IService<AeIndicatorEntity> {
|
|||||||
boolean removeIndicator(Long id);
|
boolean removeIndicator(Long id);
|
||||||
|
|
||||||
boolean updateIndicator(AeIndicatorUpdateDTO dto);
|
boolean updateIndicator(AeIndicatorUpdateDTO dto);
|
||||||
|
|
||||||
|
List<AeIndicatorEntity> getChildrenByParentIdWithLevelLimit(Long parentId, Integer maxLevel, Integer type);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.cmvr.evaluation.service.impl;
|
package com.cmvr.evaluation.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
import com.cmvr.evaluation.mapper.AeIndicatorMapper;
|
import com.cmvr.evaluation.mapper.AeIndicatorMapper;
|
||||||
@ -15,7 +16,10 @@ import org.springframework.util.Assert;
|
|||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@ -102,6 +106,23 @@ public class AeIndicatorServiceImpl extends ServiceImpl<AeIndicatorMapper, AeInd
|
|||||||
return saveResult;
|
return saveResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AeIndicatorEntity> getChildrenByParentIdWithLevelLimit(Long parentId, Integer maxLevel, Integer type) {
|
||||||
|
// 1. 参数校验与默认值处理:避免空指针,适配业务默认规则
|
||||||
|
if (parentId == null) {
|
||||||
|
parentId = 0L; // 默认查父ID为0的根节点(一级指标)
|
||||||
|
}
|
||||||
|
if (maxLevel == null || maxLevel < 1) {
|
||||||
|
maxLevel = 3; // 默认最大层级为3,贴合三级指标业务
|
||||||
|
}
|
||||||
|
if (type == null) {
|
||||||
|
return new ArrayList<>(); // 类型为null时,无数据可查,返回空列表
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer currentLevel = 1;
|
||||||
|
return buildTree(parentId, currentLevel, maxLevel, type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 私有工具方法:递归查询指定ID的所有后代指标ID(子→孙→重孙,无限级)
|
* 私有工具方法:递归查询指定ID的所有后代指标ID(子→孙→重孙,无限级)
|
||||||
* @param parentId 父/祖指标ID
|
* @param parentId 父/祖指标ID
|
||||||
@ -194,4 +215,41 @@ public class AeIndicatorServiceImpl extends ServiceImpl<AeIndicatorMapper, AeInd
|
|||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私有递归辅助方法:核心构建树形结构,实现层级限制
|
||||||
|
* @param parentId 当前父节点ID
|
||||||
|
* @param currentLevel 当前要构建的节点层级
|
||||||
|
* @param maxLevel 允许的最大层级(达到则停止递归)
|
||||||
|
* @param type 指标类型 0-语音 1-触控
|
||||||
|
* @return 带children的树形节点列表
|
||||||
|
*/
|
||||||
|
private List<AeIndicatorEntity> buildTree(Long parentId, Integer currentLevel, Integer maxLevel, Integer type) {
|
||||||
|
// 3. 构建Lambda查询条件:类型过滤+父ID匹配+逻辑删除过滤+按sort降序
|
||||||
|
LambdaQueryWrapper<AeIndicatorEntity> queryWrapper = new LambdaQueryWrapper<AeIndicatorEntity>()
|
||||||
|
.eq(AeIndicatorEntity::getParentId, parentId) // 匹配当前父ID
|
||||||
|
.eq(AeIndicatorEntity::getType, type); // 过滤指标类型
|
||||||
|
|
||||||
|
// 4. 查询当前父ID下的直接子节点
|
||||||
|
List<AeIndicatorEntity> childNodes = this.list(queryWrapper);
|
||||||
|
if (CollectionUtils.isEmpty(childNodes)) {
|
||||||
|
return new ArrayList<>(); // 无直接子节点,返回空列表,递归终止
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 遍历子节点,递归构建子节点的children(层级未达最大值时才递归)
|
||||||
|
for (AeIndicatorEntity node : childNodes) {
|
||||||
|
// 核心:判断当前节点层级是否小于最大层级,未达则继续递归查询子节点的子节点
|
||||||
|
if (currentLevel < maxLevel) {
|
||||||
|
// 递归:当前节点作为父ID,层级+1,继续构建子树
|
||||||
|
List<AeIndicatorEntity> grandChildren = buildTree(node.getId(), currentLevel + 1, maxLevel, type);
|
||||||
|
node.setChildren(grandChildren); // 给当前节点设置子节点列表
|
||||||
|
} else {
|
||||||
|
node.setChildren(new ArrayList<>()); // 达到最大层级,子节点置空,停止递归
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 返回当前层级的带children的节点列表
|
||||||
|
return childNodes;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,10 @@ public class ViProject extends BaseEntity {
|
|||||||
@ApiModelProperty("计划测试结束时间")
|
@ApiModelProperty("计划测试结束时间")
|
||||||
private Date planEnd;
|
private Date planEnd;
|
||||||
|
|
||||||
|
@Excel(name = "评价指标")
|
||||||
|
@ApiModelProperty("评价指标")
|
||||||
|
private Long indicatorId;
|
||||||
|
|
||||||
@Excel(name = "项目描述")
|
@Excel(name = "项目描述")
|
||||||
@ApiModelProperty("项目描述")
|
@ApiModelProperty("项目描述")
|
||||||
private String description;
|
private String description;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user