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; } /**