diff --git a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java index c316599..5d9fa4d 100644 --- a/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java +++ b/zfipc-server/zfipc-system/src/main/java/com/inspur/system/service/impl/SysRegionServiceImpl.java @@ -2,6 +2,8 @@ package com.inspur.system.service.impl; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.inspur.system.mapper.SysRegionMapper; @@ -54,10 +56,16 @@ public class SysRegionServiceImpl implements ISysRegionService if(sysRegionList != null) { for (SysRegion sysRegion : sysRegionList) { if (sysRegion.getParentId() != 0L) { - sysRegion = sysRegionMapper.selectSysRegionById(sysRegion.getParentId()); - resultList.add(sysRegion); + SysRegion provinceRegion = sysRegionMapper.selectSysRegionById(sysRegion.getParentId()); + //去重 + if (!resultList.isEmpty() && resultList.stream().anyMatch(r -> r.getName().equals(provinceRegion.getName()))) { + continue; + } + resultList.add(provinceRegion); } else { - resultList.add(sysRegion); + if(!resultList.isEmpty() && resultList.stream().anyMatch(r -> r.getName().equals(sysRegion.getName()))) { + resultList.add(sysRegion); + } } } }