fix: 体系数据列表数据条数错误
This commit is contained in:
+21
-4
@@ -15,6 +15,7 @@ import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -125,28 +126,44 @@ public class SarMenuStandard extends BaseEntity {
|
||||
@TableField(exist = false)
|
||||
private Integer esStandCount;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> gbStandIdList;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> fbStandIdList;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> esStandIdList;
|
||||
|
||||
// 添加用于计算和设置关联关系数量的方法
|
||||
// 添加用于计算和设置关联关系数量的方法
|
||||
public void calculateAndSetCounts(List<StandMenuRelation> gbStandMenu, List<StandMenuRelation> fbStandMenu, List<StandMenuRelation> esStandMenu, Integer curLevel) {
|
||||
this.gbStandIdList = new ArrayList<>();
|
||||
this.fbStandIdList = new ArrayList<>();
|
||||
this.esStandIdList = new ArrayList<>();
|
||||
this.level = curLevel;
|
||||
this.gbStandCount = countMatches(gbStandMenu, this.id);
|
||||
this.fbStandCount = countMatches(fbStandMenu, this.id);
|
||||
this.esStandCount = countMatches(esStandMenu, this.id);
|
||||
this.gbStandCount = countMatches(gbStandMenu, this.id, gbStandIdList);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private int countMatches(List<StandMenuRelation> standMenuList, String menuId) {
|
||||
private int countMatches(List<StandMenuRelation> standMenuList, String menuId, List<String> standIdList) {
|
||||
int count = 0;
|
||||
// 计算与menuId匹配的项的数量
|
||||
for (StandMenuRelation standMenu : standMenuList) {
|
||||
if (standMenu.getMenuId().equals(menuId)) {
|
||||
count++;
|
||||
standIdList.add(standMenu.getStandId());
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.adc.da.sys.sarMenuStandard.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author: Mzaxd
|
||||
* @Date: 2023/11/14 16:31
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StandMenuRelation {
|
||||
|
||||
private String standId;
|
||||
|
||||
Reference in New Issue
Block a user