diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/dao/SarBussStandMenuDao.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/dao/SarBussStandMenuDao.java index a5d69489..14e6fa4c 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/dao/SarBussStandMenuDao.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarBussStandMenu/dao/SarBussStandMenuDao.java @@ -37,4 +37,5 @@ public interface SarBussStandMenuDao extends BaseMapper { int updateMenuidByMenuid (@Param("oldMenuid") String oldMenuid ,@Param("newMenuid") String newMenuid); + List getESStandMenu(); } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java index 18bfa191..4ecbef9f 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarMenuStandard/service/impl/SarMenuStandardNewServiceNewImpl.java @@ -2,6 +2,7 @@ package com.adc.da.slrs.sarMenuStandard.service.impl; import com.adc.da.exception.AdcDaBaseException; import com.adc.da.scheduled.dao.SarStandardInfoDao; +import com.adc.da.slrs.sarBussStandMenu.dao.SarBussStandMenuDao; import com.adc.da.slrs.sarBussStandMenu.entity.SarBussStandMenu; import com.adc.da.slrs.sarBussStandMenu.service.ISarBussStandMenuService; import com.adc.da.slrs.sarBussionessStand.dao.SarBussionessStandDao; @@ -74,7 +75,7 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl gbStandMenu = sarStandMenuDao.getGBStandMenu(); + List gbStandMenu = sarStandMenuDao.getGBStandMenu().stream().filter(item -> item.getStandId() != null).collect(Collectors.toList()); List gbRelations = BeanCopyUtils.copyBeanList(gbStandMenu, StandMenuRelation.class); // 外标 - List fbStandMenu = sarStandMenuDao.getFBStandMenu(); + List fbStandMenu = sarStandMenuDao.getFBStandMenu().stream().filter(item -> item.getStandId() != null).collect(Collectors.toList());; List fbRelations = BeanCopyUtils.copyBeanList(fbStandMenu, StandMenuRelation.class); // 企标 - LambdaQueryWrapper bussWrapper = new LambdaQueryWrapper<>(); - bussWrapper.apply("LENGTH(menu_id) > {0}", 30); - List esStandMenu = sarBussStandMenuService.list(bussWrapper); - List esRelations = BeanCopyUtils.copyBeanList(esStandMenu, StandMenuRelation.class); + List esStandMenu = sarBussStandMenuDao.getESStandMenu().stream().filter(item -> item.getBussStandId() != null).collect(Collectors.toList()); + List esRelations = new ArrayList<>(); + for (SarBussStandMenu s : esStandMenu) { + StandMenuRelation standMenuRelation = new StandMenuRelation(s.getBussStandId(), s.getMenuId()); + esRelations.add(standMenuRelation); + } // 计算每个节点的数值 TsResources.get(0).calculateAndSetCounts(gbRelations, fbRelations, esRelations, 0); // 拼接返回 @@ -191,6 +194,7 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl standardSystemList(StandSystemDTO standSystemDTO) { + boolean select = standSystemDTO.getSelectIdList() != null; String menuId = standSystemDTO.getMenuId(); // 校验menuId不能为空 if (StringUtils.isBlank(menuId)) { @@ -207,13 +211,21 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl childIds = new ArrayList<>(); targetNode.collectChildIds(childIds); standSystemDTO.setMenuIdList(childIds); - + if (!select) { + standSystemDTO.setSelectIdList(targetNode.getGbStandIdList()); + } // 查国标 - List gbList = sarStandMenuDao.getStandInfoSystemData(standSystemDTO, "INLAND"); + Set gbList = new HashSet<>(sarStandMenuDao.getStandInfoSystemData(standSystemDTO, "INLAND")); + if (!select) { + standSystemDTO.setSelectIdList(targetNode.getFbStandIdList()); + } // 查外标 - List fbList = sarStandMenuDao.getStandInfoSystemData(standSystemDTO, "FOREIGN"); + Set fbList = new HashSet<>(sarStandMenuDao.getStandInfoSystemData(standSystemDTO, "FOREIGN")); + if (!select) { + standSystemDTO.setSelectIdList(targetNode.getEsStandIdList()); + } // 查企标 - List esList = sarBussionessStandDao.getESSystemData(standSystemDTO); + Set esList = new HashSet<>(sarBussionessStandDao.getESSystemData(standSystemDTO)); // 数据转换后整合 List resultList = new ArrayList<>(); resultList.addAll(gbList); diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandMenu/SarStandMenuMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandMenu/SarStandMenuMapper.xml index a2aec6af..0fcb4fc5 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandMenu/SarStandMenuMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/SarStandMenu/SarStandMenuMapper.xml @@ -145,15 +145,35 @@ diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandMenu/SarBussStandMenuMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandMenu/SarBussStandMenuMapper.xml index 2d1f6a2b..39abea45 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandMenu/SarBussStandMenuMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussStandMenu/SarBussStandMenuMapper.xml @@ -203,6 +203,24 @@ where buss_stand_id = #{bussStandId} and valid_flag=0 + + delete from SAR_BUSS_STAND_MENU where buss_stand_id = #{bussStandId, jdbcType=VARCHAR} and MENU_ID = #{menuId, jdbcType=VARCHAR} diff --git a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml index f271b2f1..793f870e 100644 --- a/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml +++ b/adc-da-slrs/src/main/resources/mybatis/mapper/sarBussionessStand/SarBussionessStandMapper.xml @@ -1269,6 +1269,7 @@ diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/SarMenuStandard.java b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/SarMenuStandard.java index 3b8dfec4..a6393c0b 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/SarMenuStandard.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/SarMenuStandard.java @@ -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 gbStandIdList; + + @TableField(exist = false) + private List fbStandIdList; + + @TableField(exist = false) + private List esStandIdList; + // 添加用于计算和设置关联关系数量的方法 // 添加用于计算和设置关联关系数量的方法 public void calculateAndSetCounts(List gbStandMenu, List fbStandMenu, List 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 standMenuList, String menuId) { + private int countMatches(List standMenuList, String menuId, List standIdList) { int count = 0; // 计算与menuId匹配的项的数量 for (StandMenuRelation standMenu : standMenuList) { if (standMenu.getMenuId().equals(menuId)) { count++; + standIdList.add(standMenu.getStandId()); } } return count; diff --git a/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/StandMenuRelation.java b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/StandMenuRelation.java index 79ba70ec..6b1b24b2 100644 --- a/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/StandMenuRelation.java +++ b/adc-da-sys/src/main/java/com/adc/da/sys/sarMenuStandard/entity/StandMenuRelation.java @@ -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;