fix: 空数据时接口报错
This commit is contained in:
+12
-6
@@ -208,7 +208,9 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl<SarMenuStandar
|
||||
esRelations.add(standMenuRelation);
|
||||
}
|
||||
// 计算每个节点的数值
|
||||
TsResources.get(0).calculateAndSetCounts(gbRelations, fbRelations, esRelations, 0);
|
||||
if (!TsResources.isEmpty()) {
|
||||
TsResources.get(0).calculateAndSetCounts(gbRelations, fbRelations, esRelations, 0);
|
||||
}
|
||||
// 拼接返回
|
||||
return TsResources;
|
||||
}
|
||||
@@ -486,11 +488,15 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl<SarMenuStandar
|
||||
.filter(resource1 -> resource1.getParentId().equals(resource.getId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!tsResources.isEmpty()) {
|
||||
tsResources = tsResources.stream().sorted(Comparator.comparing(resource1 -> resource1.getDisplaySeq())).collect(Collectors.toList());
|
||||
tsResources.forEach(resource1 -> {
|
||||
resource1.setTreeType("sarMs");
|
||||
resource1.setChildren(recursionGetListChildrenStand((resource1), (children)));
|
||||
});
|
||||
try {
|
||||
tsResources = tsResources.stream().sorted(Comparator.comparing(resource1 -> resource1.getDisplaySeq())).collect(Collectors.toList());
|
||||
tsResources.forEach(resource1 -> {
|
||||
resource1.setTreeType("sarMs");
|
||||
resource1.setChildren(recursionGetListChildrenStand((resource1), (children)));
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.error("异常");
|
||||
}
|
||||
}
|
||||
return tsResources;
|
||||
}
|
||||
|
||||
+10
-8
@@ -147,14 +147,16 @@ public class SarMenuStandard extends BaseEntity {
|
||||
this.fbStandCount = countMatches(fbStandMenu, this.id, fbStandIdList);
|
||||
this.esStandCount = countMatches(esStandMenu, this.id, esStandIdList);
|
||||
|
||||
for (SarMenuStandard child : children) {
|
||||
child.calculateAndSetCounts(gbStandMenu, fbStandMenu, esStandMenu, curLevel + 1);
|
||||
this.gbStandCount += child.gbStandCount;
|
||||
this.gbStandIdList.addAll(child.gbStandIdList);
|
||||
this.fbStandCount += child.fbStandCount;
|
||||
this.fbStandIdList.addAll(child.fbStandIdList);
|
||||
this.esStandCount += child.esStandCount;
|
||||
this.esStandIdList.addAll(child.esStandIdList);
|
||||
if (children != null && !children.isEmpty()) {
|
||||
for (SarMenuStandard child : children) {
|
||||
child.calculateAndSetCounts(gbStandMenu, fbStandMenu, esStandMenu, curLevel + 1);
|
||||
this.gbStandCount += child.gbStandCount;
|
||||
this.gbStandIdList.addAll(child.gbStandIdList);
|
||||
this.fbStandCount += child.fbStandCount;
|
||||
this.fbStandIdList.addAll(child.fbStandIdList);
|
||||
this.esStandCount += child.esStandCount;
|
||||
this.esStandIdList.addAll(child.esStandIdList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user