diff --git a/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/pojo/vo/GridVO.java b/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/pojo/vo/GridVO.java index 15afacd..c969b72 100644 --- a/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/pojo/vo/GridVO.java +++ b/cloud-common-plugin-map/src/main/java/com/cm/plugin/map/pojo/vo/GridVO.java @@ -19,6 +19,8 @@ import java.util.List; @ApiModel public class GridVO { + @ApiModelProperty(name = "id", value = "网格ID") + private String id; @ApiModelProperty(name = "fillColor", value = "填充颜色") private String fillColor; @ApiModelProperty(name = "gridName", value = "网格名称") @@ -28,6 +30,14 @@ public class GridVO { @ApiModelProperty(name = "pointArray", value = "网格点列表") private List pointArray; + public String getId() { + return id == null ? "" : id.trim(); + } + + public void setId(String id) { + this.id = id; + } + public String getFillColor() { return fillColor == null ? "" : fillColor.trim(); } @@ -69,10 +79,12 @@ public class GridVO { @Override public String toString() { final StringBuilder sb = new StringBuilder("{"); - sb.append("\"fillColor\":\"") + sb.append("\"id\":\"") + .append(id).append('\"'); + sb.append(",\"fillColor\":\"") .append(fillColor).append('\"'); - sb.append(",\"gridName\":") - .append(gridName); + sb.append(",\"gridName\":\"") + .append(gridName).append('\"'); sb.append(",\"relationIdArray\":") .append(relationIdArray); sb.append(",\"pointArray\":") 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 c6345c7..083f95f 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 @@ -4,6 +4,7 @@ import com.cm.common.exception.RemoveException; import com.cm.common.exception.SearchException; import com.cm.plugin.map.pojo.dto.GridDTO; import com.cm.plugin.map.pojo.dto.GridRelationDTO; +import com.cm.plugin.map.pojo.vo.GridPointVO; import com.cm.plugin.map.pojo.vo.GridVO; import org.springframework.stereotype.Service; @@ -31,22 +32,48 @@ public interface IGridService { void saveGrid(GridVO gridVO) throws Exception; /** - * 通过关联关系删除网格 + * 更新网格数组 * - * @param relationId + * @param gridId 网格ID + * @param pointArray 点数组 + * @throws Exception + */ + void updateGridPointArrayByGridId(String gridId, List pointArray) throws Exception; + + /** + * 删除网格 + * + * @param relationId 关联关系 * @throws RemoveException */ void deleteGridByRelationId(String relationId) throws RemoveException; + /** + * 删除网格 + * + * @param gridIds 网格ID列表 + * @throws SearchException + */ + void deleteGridByGridIds(List gridIds) throws RemoveException; + /** * 获取网格关系列表 * - * @param relationId + * @param relationId 关联ID * @return * @throws SearchException */ List listGridRelationByRelationId(String relationId) throws SearchException; + /** + * 获取网格关系列表 + * + * @param relationIds 关联ID列表 + * @return + * @throws SearchException + */ + List listGridRelationByRelationIds(List relationIds) throws SearchException; + /** * 获取网格列表 * @@ -64,4 +91,5 @@ public interface IGridService { * @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 0448219..0745f3e 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 @@ -53,6 +53,20 @@ public class GridServiceImpl extends AbstractService implements IGridService { savePointArray(gridId, pointArray); } + @Override + public void updateGridPointArrayByGridId(String gridId, List pointArray) throws Exception { + // 删除原有网格数组 + Map params = getHashMap(2); + params.put("gridId", gridId); + gridDao.deleteGridPoint(params); + // 新增网格数组 + for(GridPointVO gridPointVO : pointArray) { + params = HashMapUtil.beanToMap(gridPointVO); + params.put("gridId", gridId); + gridDao.saveGridPoint(params); + } + } + @Override public void deleteGridByRelationId(String relationId) throws RemoveException { List gridRelationDTOs = listGridRelationByRelationId(relationId); @@ -75,6 +89,21 @@ public class GridServiceImpl extends AbstractService implements IGridService { gridDao.deleteGridRelation(params); } + @Override + public void deleteGridByGridIds(List gridIds) throws RemoveException { + if(gridIds.isEmpty()) { + return; + } + // 删除网格 + Map params = getHashMap(2); + params.put("gridIds", gridIds); + gridDao.deleteGrid(params); + // 删除点数组 + gridDao.deleteGridPoint(params); + // 删除关联 + gridDao.deleteGridRelation(params); + } + @Override public List listGridRelationByRelationId(String relationId) throws SearchException { Map params = getHashMap(2); @@ -82,6 +111,13 @@ public class GridServiceImpl extends AbstractService implements IGridService { return gridDao.listGridRelation(params); } + @Override + public List listGridRelationByRelationIds(List relationIds) throws SearchException { + Map params = getHashMap(2); + params.put("relationIds", relationIds); + return gridDao.listGridRelation(params); + } + @Override public List listGridByRelationId(String relationId) throws SearchException { List gridDTOs = gridDao.listGridByRelationId(relationId); 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 8c47965..74d199d 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 @@ -59,6 +59,9 @@ DELETE FROM map_grid WHERE + + grid_id = #{gridId} + grid_id IN @@ -72,6 +75,9 @@ DELETE FROM map_grid_point WHERE + + grid_id = #{gridId} + grid_id IN @@ -85,6 +91,15 @@ DELETE FROM map_grid_relation WHERE + + grid_id = #{gridId} + + + grid_id IN + + #{gridIds[${index}]} + + relation_id = #{relationId} @@ -116,6 +131,13 @@ AND relation_id = #{relationId} + + AND + relation_id IN + + #{relationIds[${index}]} + +