From d6d6d612f5ace73588764685c1181533c667cbbb Mon Sep 17 00:00:00 2001 From: wanggeng888 <450292408@qq.com> Date: Sun, 23 May 2021 20:21:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cm/plugin/map/service/IGridService.java | 9 +++++ .../map/service/impl/GridServiceImpl.java | 36 +++++++++++++++---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/service/IGridService.java b/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/service/IGridService.java index 0c6234b..3142005 100644 --- a/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/service/IGridService.java +++ b/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/service/IGridService.java @@ -125,6 +125,15 @@ public interface IGridService { * @return * @throws SearchException */ + List listGridGroupByRelationIds(List relationIds) throws SearchException; + + /** + * 获取全部网格列表 + * + * @param relationIds + * @return + * @throws SearchException + */ List listGridByRelationIds(List relationIds) throws SearchException; /** diff --git a/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/service/impl/GridServiceImpl.java b/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/service/impl/GridServiceImpl.java index 29b1e5e..e0fc0d2 100644 --- a/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/service/impl/GridServiceImpl.java +++ b/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/service/impl/GridServiceImpl.java @@ -181,11 +181,10 @@ public class GridServiceImpl extends AbstractService implements IGridService { } @Override - public List listGridByRelationIds(List relationIds) throws SearchException { + public List listGridGroupByRelationIds(List relationIds) throws SearchException { if (relationIds == null || relationIds.size() == 0) { return new ArrayList<>(); } - // List gridDTOs = gridDao.listGridGroupByRelationIds(relationIds); List gridDTOs = gridDao.listGridByRelationIds(relationIds); if (gridDTOs.isEmpty()) { return gridDTOs; @@ -216,17 +215,43 @@ public class GridServiceImpl extends AbstractService implements IGridService { continue; } } + setGridPoints(gridGroupDTOs); + return gridGroupDTOs; + } + + @Override + public List listGridByRelationIds(List relationIds) throws SearchException { + if (relationIds == null || relationIds.size() == 0) { + return new ArrayList<>(); + } + List gridDTOs = gridDao.listGridByRelationIds(relationIds); + if (gridDTOs.isEmpty()) { + return gridDTOs; + } + setGridPoints(gridDTOs); + return gridDTOs; + } + + /** + * 设置网格点 + * + * @param gridDTOs + */ + private void setGridPoints(List gridDTOs) { + if (gridDTOs.isEmpty()) { + return; + } List gridIds = new ArrayList<>(); - for (GridDTO gridDTO : gridGroupDTOs) { + for (GridDTO gridDTO : gridDTOs) { gridIds.add(gridDTO.getGridId()); } // 获取所有点 List gridPointDTOs = gridDao.listPointByGridIds(gridIds); if (gridPointDTOs.isEmpty()) { - return gridGroupDTOs; + return; } // 构建所有点 - for (GridDTO gridDTO : gridGroupDTOs) { + for (GridDTO gridDTO : gridDTOs) { List pointArray = new ArrayList<>(); for (GridPointDTO gridPointDTO : gridPointDTOs) { if (StringUtils.equals(gridDTO.getGridId(), gridPointDTO.getGridId())) { @@ -235,7 +260,6 @@ public class GridServiceImpl extends AbstractService implements IGridService { } gridDTO.setPointArray(pointArray); } - return gridGroupDTOs; } /**