From 25185405c3f765b0741b5d54fa3e8fb4ee88c7e4 Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Fri, 23 Oct 2020 18:05:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cm/plugin/map/dao/IGridDao.java | 28 ++++++++++++--- .../cm/plugin/map/service/IGridService.java | 16 +++++++-- .../map/service/impl/GridServiceImpl.java | 36 +++++++++++++++++-- .../resources/mybatis/mapper/grid-mapper.xml | 36 +++++++++++++++++++ 4 files changed, 106 insertions(+), 10 deletions(-) diff --git a/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/dao/IGridDao.java b/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/dao/IGridDao.java index d732edd..2d8431b 100644 --- a/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/dao/IGridDao.java +++ b/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/dao/IGridDao.java @@ -81,20 +81,38 @@ public interface IGridDao { List listGridRelation(Map params) throws SearchException; /** - * 获取网格列表(通过关联ID) + * 获取网格列表 * - * @param areaId + * @param relationId 关联ID * @return * @throws SearchException */ - List listGridByRelationId(String areaId) throws SearchException; + List listGridByRelationId(String relationId) throws SearchException; /** - * 获取网格点列表(通过网格ID) + * 获取网格点列表 * - * @param gridId + * @param gridId 网格ID * @return * @throws SearchException */ List listPointByGridId(String gridId) throws SearchException; + + /** + * 获取网格点列表 + * + * @param relationIds 关联ID列表 + * @return + * @throws SearchException + */ + List listGridByRelationIds(List relationIds) throws SearchException; + + /** + * 获取网格点列表 + * + * @param gridIds 网格ID列表 + * @return + * @throws SearchException + */ + List listPointByGridIds(List gridIds) throws SearchException; } 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 2b8ec44..c6345c7 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 @@ -48,10 +48,20 @@ public interface IGridService { List listGridRelationByRelationId(String relationId) throws SearchException; /** - * 获取网格列表(通过关联ID) - * @param areaId + * 获取网格列表 + * + * @param relationId 关联ID * @return * @throws SearchException */ - List listGridByRelationId(String areaId) throws SearchException; + List listGridByRelationId(String relationId) throws SearchException; + + /** + * 获取网格列表 + * + * @param relationIds 关联ID列表 + * @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 bfaa290..82f1b12 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 @@ -1,5 +1,6 @@ package com.cm.plugin.map.service.impl; +import com.alibaba.druid.util.StringUtils; import com.cm.common.base.AbstractService; import com.cm.common.exception.RemoveException; import com.cm.common.exception.SearchException; @@ -82,8 +83,8 @@ public class GridServiceImpl extends AbstractService implements IGridService { } @Override - public List listGridByRelationId(String areaId) throws SearchException { - List gridDTOs = gridDao.listGridByRelationId(areaId); + public List listGridByRelationId(String relationId) throws SearchException { + List gridDTOs = gridDao.listGridByRelationId(relationId); if (gridDTOs.isEmpty()) { return gridDTOs; } @@ -94,6 +95,37 @@ public class GridServiceImpl extends AbstractService implements IGridService { return gridDTOs; } + @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; + } + List gridIds = new ArrayList<>(); + for (GridDTO gridDTO : gridDTOs) { + gridIds.add(gridDTO.getGridId()); + } + // 获取所有点 + List gridPointDTOs = gridDao.listPointByGridIds(gridIds); + if (gridPointDTOs.isEmpty()) { + return gridDTOs; + } + // 构建所有点 + for (GridDTO gridDTO : gridDTOs) { + List pointArray = new ArrayList<>(); + for (GridPointDTO gridPointDTO : gridPointDTOs) { + if (StringUtils.equals(gridDTO.getGridId(), gridPointDTO.getGridId())) { + pointArray.add(gridPointDTO); + } + } + gridDTO.setPointArray(pointArray); + } + return gridDTOs; + } + /** * 保存关联关系 * diff --git a/cloud-common-plugin-map/src/main/resources/mybatis/mapper/grid-mapper.xml b/cloud-common-plugin-map/src/main/resources/mybatis/mapper/grid-mapper.xml index 717cba8..8c47965 100644 --- a/cloud-common-plugin-map/src/main/resources/mybatis/mapper/grid-mapper.xml +++ b/cloud-common-plugin-map/src/main/resources/mybatis/mapper/grid-mapper.xml @@ -137,6 +137,27 @@ t2.relation_id = #{_parameter} + + + + + \ No newline at end of file