修复测试任务时节点不存在就报错问题

master
面包骑士 2024-09-05 17:49:03 +08:00
parent 0b688226bb
commit da16ad74ac
1 changed files with 10 additions and 4 deletions

View File

@ -100,14 +100,20 @@ public class NodeUtils {
nodeTypeList.forEach(nodeType -> {
// 根据节点类型查询对应类型节点
List<Node> nodes = nodeMapAll.get(nodeType.getNodeTypeCode());
Integer maxNum = nodeType.getNodeMaxNum();
Integer minNum = nodeType.getNodeMinNum();
int num = nodes.size();
if (minNum != -1 && num < minNum){
if (!nodes.isEmpty()){
int num = nodes.size();
if (minNum != -1 && num < minNum){
throw new TaskException("节点 " + nodeType.getNodeTypeName() + " 数量不足,至少需要 " + minNum + " 个");
}else if (maxNum != -1 && num > maxNum){
throw new TaskException("节点 " + nodeType.getNodeTypeName() + " 数量超出范围,最多允许 " + maxNum + " 个");
}
}else if (minNum != -1){
throw new TaskException("节点 " + nodeType.getNodeTypeName() + " 数量不足,至少需要 " + minNum + " 个");
}else if (maxNum != -1 && num > maxNum){
throw new TaskException("节点 " + nodeType.getNodeTypeName() + " 数量超出范围,最多允许 " + maxNum + " 个");
}
});
}