新增网格操作接口
This commit is contained in:
parent
ccdddc41ec
commit
528951b779
@ -0,0 +1,16 @@
|
||||
package ink.wgink.interfaces.map;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: IGridDeleteAfterHandler
|
||||
* @Description: 网格删除后处理
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/12/23 10:28 AM
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IGridDeleteAfterHandler {
|
||||
|
||||
void handler(List<String> gridIds);
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package ink.wgink.interfaces.map;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: IGridPointRemoveAfterHandler
|
||||
* @Description: 网格点删除
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/12/23 10:37 AM
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IGridPointDeleteAfterHandler {
|
||||
|
||||
/**
|
||||
* 网格点删除
|
||||
*
|
||||
* @param gridIds
|
||||
*/
|
||||
void handle(List<String> gridIds);
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ink.wgink.interfaces.map;
|
||||
|
||||
/**
|
||||
* @ClassName: IGridPointSaveAfterHandler
|
||||
* @Description: 网格点新增后处理
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/12/23 10:29 AM
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IGridPointSaveAfterHandler {
|
||||
|
||||
/**
|
||||
* 网格点新增
|
||||
*
|
||||
* @param gridId 网格ID
|
||||
*/
|
||||
void handle(String gridId);
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package ink.wgink.interfaces.map;
|
||||
|
||||
/**
|
||||
* @ClassName: GridSaveAfterHandler
|
||||
* @Description: 网格新增后处理
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/12/23 10:25 AM
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IGridSaveAfterHandler {
|
||||
|
||||
/**
|
||||
* 新增网格
|
||||
*
|
||||
* @param gridId 网格ID
|
||||
* @param gridCode 网格编码
|
||||
* @param gridName 网格名称
|
||||
* @param fillColor 填充颜色
|
||||
* @param areaCode 区域编码
|
||||
* @param areaName 区域名称
|
||||
*/
|
||||
void handle(String gridId, String gridCode, String gridName, String fillColor, String areaCode, String areaName);
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package ink.wgink.interfaces.map;
|
||||
|
||||
/**
|
||||
* @ClassName: IGridUpdateAfterHandler
|
||||
* @Description: 网格更新后处理
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/12/23 10:26 AM
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IGridUpdateAfterHandler {
|
||||
|
||||
/**
|
||||
* 修改网格
|
||||
*
|
||||
* @param gridId 网格ID
|
||||
* @param gridName 网格名称
|
||||
* @param fillColor 填充颜色
|
||||
*/
|
||||
void handle(String gridId, String gridName, String fillColor);
|
||||
|
||||
}
|
@ -2,6 +2,8 @@ package ink.wgink.module.map.service.grid.impl;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.interfaces.map.IGridPointDeleteAfterHandler;
|
||||
import ink.wgink.interfaces.map.IGridPointSaveAfterHandler;
|
||||
import ink.wgink.module.map.dao.grid.IGridPointDao;
|
||||
import ink.wgink.module.map.pojo.dtos.grid.GridPointDTO;
|
||||
import ink.wgink.module.map.pojo.vos.grid.GridPointVO;
|
||||
@ -11,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -26,6 +29,10 @@ public class GridPointServiceImpl extends DefaultBaseService implements IGridPoi
|
||||
|
||||
@Autowired
|
||||
private IGridPointDao gridPointDao;
|
||||
@Autowired(required = false)
|
||||
private IGridPointSaveAfterHandler gridPointSaveAfterHandler;
|
||||
@Autowired(required = false)
|
||||
private IGridPointDeleteAfterHandler gridPointDeleteAfterHandler;
|
||||
|
||||
@Override
|
||||
public void save(String gridId, List<GridPointVO> pointArray) {
|
||||
@ -39,6 +46,9 @@ public class GridPointServiceImpl extends DefaultBaseService implements IGridPoi
|
||||
params.put("lat", gridPointVO.getLat());
|
||||
gridPointDao.save(params);
|
||||
}
|
||||
if (gridPointSaveAfterHandler != null) {
|
||||
gridPointSaveAfterHandler.handle(gridId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,6 +56,9 @@ public class GridPointServiceImpl extends DefaultBaseService implements IGridPoi
|
||||
List<String> gridIds = new ArrayList<>();
|
||||
gridIds.add(gridId);
|
||||
deleteByGridIds(gridIds);
|
||||
if (gridPointDeleteAfterHandler != null) {
|
||||
gridPointDeleteAfterHandler.handle(gridIds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,6 +66,9 @@ public class GridPointServiceImpl extends DefaultBaseService implements IGridPoi
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("gridIds", gridIds);
|
||||
gridPointDao.delete(params);
|
||||
if (gridPointDeleteAfterHandler != null) {
|
||||
gridPointDeleteAfterHandler.handle(gridIds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,12 +77,18 @@ public class GridPointServiceImpl extends DefaultBaseService implements IGridPoi
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("gridId", gridId);
|
||||
gridPointDao.delete(params);
|
||||
if (gridPointDeleteAfterHandler != null) {
|
||||
gridPointDeleteAfterHandler.handle(Arrays.asList(gridId));
|
||||
}
|
||||
// 新增网格数组
|
||||
for (GridPointVO gridPointVO : pointArray) {
|
||||
params = HashMapUtil.beanToMap(gridPointVO);
|
||||
params.put("gridId", gridId);
|
||||
gridPointDao.save(params);
|
||||
}
|
||||
if (gridPointSaveAfterHandler != null) {
|
||||
gridPointSaveAfterHandler.handle(gridId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,9 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.map.IGridDeleteAfterHandler;
|
||||
import ink.wgink.interfaces.map.IGridSaveAfterHandler;
|
||||
import ink.wgink.interfaces.map.IGridUpdateAfterHandler;
|
||||
import ink.wgink.module.map.dao.grid.IGridDao;
|
||||
import ink.wgink.module.map.pojo.dtos.grid.GridDTO;
|
||||
import ink.wgink.module.map.pojo.dtos.grid.GridPointDTO;
|
||||
@ -47,6 +50,12 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
|
||||
private IGridRelationService gridRelationService;
|
||||
@Autowired
|
||||
private IGridPointService gridPointService;
|
||||
@Autowired(required = false)
|
||||
private IGridSaveAfterHandler gridSaveAfterHandler;
|
||||
@Autowired(required = false)
|
||||
private IGridUpdateAfterHandler gridUpdateAfterHandler;
|
||||
@Autowired(required = false)
|
||||
private IGridDeleteAfterHandler gridDeleteAfterHandler;
|
||||
|
||||
@Override
|
||||
public void save(GridVO gridVO) throws Exception {
|
||||
@ -63,7 +72,8 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
|
||||
params.put("gridSquare", getSquare(pointArray));
|
||||
params.put("fillColor", gridVO.getGrid().getFillColor());
|
||||
GridPO areaLastPO = getAreaLastPO(gridVO.getAreaCode());
|
||||
params.put("gridCode", areaLastPO == null ? String.format("%s001", gridVO.getAreaCode().substring(0, 12)) : Long.valueOf(areaLastPO.getGridCode()) + 1);
|
||||
String areaCode = areaLastPO == null ? String.format("%s001", gridVO.getAreaCode().substring(0, 12)) : String.valueOf(Long.valueOf(areaLastPO.getGridCode()) + 1);
|
||||
params.put("gridCode", areaCode);
|
||||
params.put("gridId", gridId);
|
||||
params.remove("relationIdArray");
|
||||
params.remove("pointArray");
|
||||
@ -73,6 +83,9 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
|
||||
// 保存拓展属性
|
||||
gridRelationService.save(gridId, relationIdArray);
|
||||
gridPointService.save(gridId, pointArray);
|
||||
if (gridSaveAfterHandler != null) {
|
||||
gridSaveAfterHandler.handle(gridId, areaCode, gridVO.getGridName(), gridVO.getGrid().getFillColor(), gridVO.getAreaCode(), gridVO.getAreaName());
|
||||
}
|
||||
return gridId;
|
||||
}
|
||||
|
||||
@ -82,6 +95,9 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
|
||||
params.put("gridIds", ids);
|
||||
setUpdateInfo(params);
|
||||
gridDao.remove(params);
|
||||
if (gridDeleteAfterHandler != null) {
|
||||
gridDeleteAfterHandler.handler(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,6 +110,9 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
|
||||
params.put("gridIds", gridIds);
|
||||
// 删除网格
|
||||
gridDao.delete(params);
|
||||
if (gridDeleteAfterHandler != null) {
|
||||
gridDeleteAfterHandler.handler(gridIds);
|
||||
}
|
||||
// 删除网格点
|
||||
gridPointService.deleteByGridIds(gridIds);
|
||||
// 删除关联关系
|
||||
@ -109,6 +128,9 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("gridIds", gridIds);
|
||||
gridDao.delete(params);
|
||||
if (gridDeleteAfterHandler != null) {
|
||||
gridDeleteAfterHandler.handler(gridIds);
|
||||
}
|
||||
// 删除点数组
|
||||
gridPointService.deleteByGridIds(gridIds);
|
||||
// 删除关联
|
||||
@ -149,7 +171,9 @@ public class GridServiceImpl extends DefaultBaseService implements IGridService
|
||||
params.put("gridId", gridId);
|
||||
setUpdateInfo(params);
|
||||
gridDao.update(params);
|
||||
|
||||
if (gridUpdateAfterHandler != null) {
|
||||
gridUpdateAfterHandler.handle(gridId, gridVO.getGridName(), grid.getFillColor());
|
||||
}
|
||||
// 删除原有节点
|
||||
gridPointService.deleteByGridId(gridId);
|
||||
// 新增原有节点
|
||||
|
Loading…
Reference in New Issue
Block a user