From 55f4e7e4471260b3ac193bb0d3264ee7daeb518c Mon Sep 17 00:00:00 2001 From: zhangjunwen Date: Tue, 30 Jul 2024 14:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E5=8A=9F=E8=83=BD=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/SysRegionServiceImpl.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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); + } } } }