新增了网格操作的一些接口

This commit is contained in:
WenG 2020-10-27 23:47:39 +08:00
parent 4fcf860189
commit 6fd1ded8ad
4 changed files with 104 additions and 6 deletions

View File

@ -19,6 +19,8 @@ import java.util.List;
@ApiModel @ApiModel
public class GridVO { public class GridVO {
@ApiModelProperty(name = "id", value = "网格ID")
private String id;
@ApiModelProperty(name = "fillColor", value = "填充颜色") @ApiModelProperty(name = "fillColor", value = "填充颜色")
private String fillColor; private String fillColor;
@ApiModelProperty(name = "gridName", value = "网格名称") @ApiModelProperty(name = "gridName", value = "网格名称")
@ -28,6 +30,14 @@ public class GridVO {
@ApiModelProperty(name = "pointArray", value = "网格点列表") @ApiModelProperty(name = "pointArray", value = "网格点列表")
private List<GridPointVO> pointArray; private List<GridPointVO> pointArray;
public String getId() {
return id == null ? "" : id.trim();
}
public void setId(String id) {
this.id = id;
}
public String getFillColor() { public String getFillColor() {
return fillColor == null ? "" : fillColor.trim(); return fillColor == null ? "" : fillColor.trim();
} }
@ -69,10 +79,12 @@ public class GridVO {
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("{"); final StringBuilder sb = new StringBuilder("{");
sb.append("\"fillColor\":\"") sb.append("\"id\":\"")
.append(id).append('\"');
sb.append(",\"fillColor\":\"")
.append(fillColor).append('\"'); .append(fillColor).append('\"');
sb.append(",\"gridName\":") sb.append(",\"gridName\":\"")
.append(gridName); .append(gridName).append('\"');
sb.append(",\"relationIdArray\":") sb.append(",\"relationIdArray\":")
.append(relationIdArray); .append(relationIdArray);
sb.append(",\"pointArray\":") sb.append(",\"pointArray\":")

View File

@ -4,6 +4,7 @@ import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SearchException; import com.cm.common.exception.SearchException;
import com.cm.plugin.map.pojo.dto.GridDTO; import com.cm.plugin.map.pojo.dto.GridDTO;
import com.cm.plugin.map.pojo.dto.GridRelationDTO; 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 com.cm.plugin.map.pojo.vo.GridVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -31,22 +32,48 @@ public interface IGridService {
void saveGrid(GridVO gridVO) throws Exception; void saveGrid(GridVO gridVO) throws Exception;
/** /**
* 通过关联关系删除网格 * 更新网格数组
* *
* @param relationId * @param gridId 网格ID
* @param pointArray 点数组
* @throws Exception
*/
void updateGridPointArrayByGridId(String gridId, List<GridPointVO> pointArray) throws Exception;
/**
* 删除网格
*
* @param relationId 关联关系
* @throws RemoveException * @throws RemoveException
*/ */
void deleteGridByRelationId(String relationId) throws RemoveException; void deleteGridByRelationId(String relationId) throws RemoveException;
/**
* 删除网格
*
* @param gridIds 网格ID列表
* @throws SearchException
*/
void deleteGridByGridIds(List<String> gridIds) throws RemoveException;
/** /**
* 获取网格关系列表 * 获取网格关系列表
* *
* @param relationId * @param relationId 关联ID
* @return * @return
* @throws SearchException * @throws SearchException
*/ */
List<GridRelationDTO> listGridRelationByRelationId(String relationId) throws SearchException; List<GridRelationDTO> listGridRelationByRelationId(String relationId) throws SearchException;
/**
* 获取网格关系列表
*
* @param relationIds 关联ID列表
* @return
* @throws SearchException
*/
List<GridRelationDTO> listGridRelationByRelationIds(List<String> relationIds) throws SearchException;
/** /**
* 获取网格列表 * 获取网格列表
* *
@ -64,4 +91,5 @@ public interface IGridService {
* @throws SearchException * @throws SearchException
*/ */
List<GridDTO> listGridByRelationIds(List<String> relationIds) throws SearchException; List<GridDTO> listGridByRelationIds(List<String> relationIds) throws SearchException;
} }

View File

@ -53,6 +53,20 @@ public class GridServiceImpl extends AbstractService implements IGridService {
savePointArray(gridId, pointArray); savePointArray(gridId, pointArray);
} }
@Override
public void updateGridPointArrayByGridId(String gridId, List<GridPointVO> pointArray) throws Exception {
// 删除原有网格数组
Map<String, Object> 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 @Override
public void deleteGridByRelationId(String relationId) throws RemoveException { public void deleteGridByRelationId(String relationId) throws RemoveException {
List<GridRelationDTO> gridRelationDTOs = listGridRelationByRelationId(relationId); List<GridRelationDTO> gridRelationDTOs = listGridRelationByRelationId(relationId);
@ -75,6 +89,21 @@ public class GridServiceImpl extends AbstractService implements IGridService {
gridDao.deleteGridRelation(params); gridDao.deleteGridRelation(params);
} }
@Override
public void deleteGridByGridIds(List<String> gridIds) throws RemoveException {
if(gridIds.isEmpty()) {
return;
}
// 删除网格
Map<String, Object> params = getHashMap(2);
params.put("gridIds", gridIds);
gridDao.deleteGrid(params);
// 删除点数组
gridDao.deleteGridPoint(params);
// 删除关联
gridDao.deleteGridRelation(params);
}
@Override @Override
public List<GridRelationDTO> listGridRelationByRelationId(String relationId) throws SearchException { public List<GridRelationDTO> listGridRelationByRelationId(String relationId) throws SearchException {
Map<String, Object> params = getHashMap(2); Map<String, Object> params = getHashMap(2);
@ -82,6 +111,13 @@ public class GridServiceImpl extends AbstractService implements IGridService {
return gridDao.listGridRelation(params); return gridDao.listGridRelation(params);
} }
@Override
public List<GridRelationDTO> listGridRelationByRelationIds(List<String> relationIds) throws SearchException {
Map<String, Object> params = getHashMap(2);
params.put("relationIds", relationIds);
return gridDao.listGridRelation(params);
}
@Override @Override
public List<GridDTO> listGridByRelationId(String relationId) throws SearchException { public List<GridDTO> listGridByRelationId(String relationId) throws SearchException {
List<GridDTO> gridDTOs = gridDao.listGridByRelationId(relationId); List<GridDTO> gridDTOs = gridDao.listGridByRelationId(relationId);

View File

@ -59,6 +59,9 @@
DELETE FROM DELETE FROM
map_grid map_grid
WHERE WHERE
<if test="gridId != null and gridId != ''">
grid_id = #{gridId}
</if>
<if test="gridIds != null and gridIds.size > 0"> <if test="gridIds != null and gridIds.size > 0">
grid_id IN grid_id IN
<foreach collection="gridIds" index="index" open="(" separator="," close=")"> <foreach collection="gridIds" index="index" open="(" separator="," close=")">
@ -72,6 +75,9 @@
DELETE FROM DELETE FROM
map_grid_point map_grid_point
WHERE WHERE
<if test="gridId != null and gridId != ''">
grid_id = #{gridId}
</if>
<if test="gridIds != null and gridIds.size > 0"> <if test="gridIds != null and gridIds.size > 0">
grid_id IN grid_id IN
<foreach collection="gridIds" index="index" open="(" separator="," close=")"> <foreach collection="gridIds" index="index" open="(" separator="," close=")">
@ -85,6 +91,15 @@
DELETE FROM DELETE FROM
map_grid_relation map_grid_relation
WHERE WHERE
<if test="gridId != null and gridId != ''">
grid_id = #{gridId}
</if>
<if test="gridIds != null and gridIds.size > 0">
grid_id IN
<foreach collection="gridIds" index="index" open="(" separator="," close=")">
#{gridIds[${index}]}
</foreach>
</if>
<if test="relationId != null and relationId != ''"> <if test="relationId != null and relationId != ''">
relation_id = #{relationId} relation_id = #{relationId}
</if> </if>
@ -116,6 +131,13 @@
AND AND
relation_id = #{relationId} relation_id = #{relationId}
</if> </if>
<if test="relationIds != null and relationIds.size > 0">
AND
relation_id IN
<foreach collection="relationIds" index="index" open="(" separator="," close=")">
#{relationIds[${index}]}
</foreach>
</if>
</select> </select>
<!-- 获取网格列表通过关联ID --> <!-- 获取网格列表通过关联ID -->