|
@@ -33,6 +33,7 @@ public class TableDataSelectServiceImpl implements TableDataSelectService {
|
|
|
@Resource
|
|
|
private TableFiledMapper tableFiledMapper;
|
|
|
private final Integer SRID = 4525;
|
|
|
+ private final String Srid4326 = "SRID=4326;";
|
|
|
|
|
|
/**
|
|
|
* @param sourcePointWkt
|
|
@@ -49,6 +50,7 @@ public class TableDataSelectServiceImpl implements TableDataSelectService {
|
|
|
if (StringUtils.isEmpty(sourcePointWkt)) {
|
|
|
return retMapData;
|
|
|
}
|
|
|
+ sourcePointWkt = Srid4326 + sourcePointWkt;
|
|
|
if (StringUtils.isEmpty(sourceLayerId)) {
|
|
|
return retMapData;
|
|
|
}
|
|
@@ -162,7 +164,120 @@ public class TableDataSelectServiceImpl implements TableDataSelectService {
|
|
|
return retMapData;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map dataQueryByPolygon(String sourceDataId, String sourcePolygonWkt, String sourceLayerId, String sourceLayerType, String queryTableId) {
|
|
|
+ System.out.println("进入面数据查询");
|
|
|
+ Map<String, Object> retMapData = new HashMap<>();
|
|
|
+ retMapData.put("base", "无数据");
|
|
|
+ if (StringUtils.isEmpty(sourcePolygonWkt)) {
|
|
|
+ return retMapData;
|
|
|
+ }
|
|
|
+ sourcePolygonWkt = Srid4326 + sourcePolygonWkt;
|
|
|
+ if (StringUtils.isEmpty(sourceLayerId)) {
|
|
|
+ return retMapData;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(sourceLayerType)) {
|
|
|
+ return retMapData;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(queryTableId)) {
|
|
|
+ return retMapData;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询原始节点数据
|
|
|
+ QueryWrapper<TableLayerDTO> fromTableLayerWrapper = new QueryWrapper<>();
|
|
|
+ if ("0".equals(sourceLayerType)) {
|
|
|
+ fromTableLayerWrapper.eq("layer_id", sourceLayerId);
|
|
|
+ } else if ("1".equals(sourceLayerType)) {
|
|
|
+ fromTableLayerWrapper.eq("table_id", sourceLayerId);
|
|
|
+ } else {
|
|
|
+ return retMapData;
|
|
|
+ }
|
|
|
+ TableLayerDTO fromTableLayerDTO = tableLayerMapper.selectOne(fromTableLayerWrapper);
|
|
|
+ if (fromTableLayerDTO == null) {
|
|
|
+ return retMapData;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询查询节点数据
|
|
|
+ QueryWrapper<TableLayerDTO> queryTableLayerWrapper = new QueryWrapper<>();
|
|
|
+ queryTableLayerWrapper.eq("table_id", queryTableId);
|
|
|
+ TableLayerDTO queryTableLayerDTO = tableLayerMapper.selectOne(queryTableLayerWrapper);
|
|
|
+ if (queryTableLayerDTO == null) {
|
|
|
+ return retMapData;
|
|
|
+ }
|
|
|
+ retMapData.put("dataname", queryTableLayerDTO.getName());
|
|
|
+ //intersects 相交
|
|
|
+ //intersection 交集
|
|
|
+ String uid = StringUtils.getUUID();
|
|
|
+ //查询查询节点的是否有子集
|
|
|
+ QueryWrapper<TableLayerDTO> queryTableLayerPidWrapper = new QueryWrapper<>();
|
|
|
+ queryTableLayerPidWrapper.eq("pid", queryTableLayerDTO.getId());
|
|
|
+ List<TableLayerDTO> TableLayerDTOPid = tableLayerMapper.selectList(queryTableLayerPidWrapper);
|
|
|
+ List<String> tableDataIds = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(sourceDataId)) {
|
|
|
+ tableDataIds.add(sourceDataId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (TableLayerDTOPid == null || TableLayerDTOPid.size() == 0) {
|
|
|
+ if (fromTableLayerDTO.getId().equals(queryTableLayerDTO.getId())) {
|
|
|
+ List<List<TableDataVo>> retListData = new ArrayList<>();
|
|
|
+ //因为是面数据,所以直接进行切割
|
|
|
+ List<List<TableDataVo>> ret = queryIntersectionList(sourcePolygonWkt, tableDataIds, queryTableLayerDTO.getTableId());
|
|
|
+ retListData.addAll(ret);
|
|
|
+ insetDataHandleGroup(ret, queryTableLayerDTO.getGroupcolumn(), uid);
|
|
|
+ retMapData.put("data", retListData);
|
|
|
+ retMapData.put("datalist", tableLayerJgTempMapper.queryTableLayerJgTempList(uid));
|
|
|
+ } else {
|
|
|
+ List<List<TableDataVo>> retListData = new ArrayList<>();
|
|
|
+ //因为是面数据,所以直接进行切割
|
|
|
+ List<List<TableDataVo>> ret = queryIntersectionList(sourcePolygonWkt, null, queryTableLayerDTO.getTableId());
|
|
|
+ retListData.addAll(ret);
|
|
|
+ insetDataHandleGroup(ret, queryTableLayerDTO.getGroupcolumn(), uid);
|
|
|
+ retMapData.put("data", retListData);
|
|
|
+ retMapData.put("datalist", tableLayerJgTempMapper.queryTableLayerJgTempList(uid));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //因为是面数据,所以直接进行切割
|
|
|
+ List<List<TableDataVo>> ret = queryIntersectionList(sourcePolygonWkt, tableDataIds, fromTableLayerDTO.getTableId());
|
|
|
+ if (ret != null && ret.size() > 0) {
|
|
|
+ List child = new ArrayList();
|
|
|
+ for (TableLayerDTO layerDTO : TableLayerDTOPid) {
|
|
|
+ String v_uid = StringUtils.getUUID();
|
|
|
+ List<List<TableDataVo>> retListData = new ArrayList<>();
|
|
|
+ Map<String, Object> v_d01 = new HashMap<>();
|
|
|
+ v_d01.put("base", "无数据");
|
|
|
+ for (List<TableDataVo> mapData : ret) {
|
|
|
+ String geom = null;
|
|
|
+ for (TableDataVo d01_tableDataVo : mapData) {
|
|
|
+ if (d01_tableDataVo.getFiled().equals("geom")) {
|
|
|
+ geom = d01_tableDataVo.getData().toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(geom)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<List<TableDataVo>> child_ret = queryIntersectionList(geom, tableDataIds, layerDTO.getTableId());
|
|
|
+ if (child_ret != null && child_ret.size() > 0) {
|
|
|
+ retMapData.put("base", null);
|
|
|
+ v_d01.put("base", null);
|
|
|
+ insetDataHandleGroup(child_ret, layerDTO.getGroupcolumn(), v_uid);
|
|
|
+ retListData.addAll(child_ret);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ v_d01.put("dataname", layerDTO.getName());
|
|
|
+ v_d01.put("data", retListData);
|
|
|
+ v_d01.put("datalist", tableLayerJgTempMapper.queryTableLayerJgTempList(v_uid));
|
|
|
+ child.add(v_d01);
|
|
|
+ }
|
|
|
+ retMapData.put("child", child);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return retMapData;
|
|
|
+ }
|
|
|
+
|
|
|
private void insetDataHandleGroup(List<List<TableDataVo>> tableData, String groupColumn, String uid) {
|
|
|
+ if (tableData == null || tableData.size() <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (StringUtils.isEmpty(groupColumn)) {
|
|
|
return;
|
|
|
}
|
|
@@ -223,7 +338,6 @@ public class TableDataSelectServiceImpl implements TableDataSelectService {
|
|
|
return retDataList;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//取相交的函数
|
|
|
private List<List<TableDataVo>> queryIntersectsList(String eWkt, String tableId) {
|
|
|
List<List<TableDataVo>> retList = new ArrayList<>();
|
|
@@ -352,6 +466,55 @@ public class TableDataSelectServiceImpl implements TableDataSelectService {
|
|
|
return dataMapTransFormZh(from_jg, list);
|
|
|
}
|
|
|
|
|
|
+ //取并集的函数
|
|
|
+ private List<List<TableDataVo>> queryIntersectionList(String eWkt, List<String> tableDataIds, String tableId) {
|
|
|
+ List<List<TableDataVo>> retList = new ArrayList<>();
|
|
|
+ // 获取from_table_id
|
|
|
+ QueryWrapper<TableDTO> queryTableTableWrapper = new QueryWrapper<>();
|
|
|
+ queryTableTableWrapper.eq("id", tableId);
|
|
|
+ TableDTO v_table = tableMapper.selectOne(queryTableTableWrapper);
|
|
|
+ if (v_table == null) {
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+
|
|
|
+ IntersectsTableWktVo intersectsTableWktVo = new IntersectsTableWktVo();
|
|
|
+ intersectsTableWktVo.setEwkt(eWkt);
|
|
|
+ intersectsTableWktVo.setTableIds(tableDataIds);
|
|
|
+ intersectsTableWktVo.setTableName(v_table.getTableName());
|
|
|
+ List<String> from_kj_ids = httpAnalyseService.intersectsTableWkt(intersectsTableWktVo);
|
|
|
+ if (from_kj_ids == null || from_kj_ids.size() == 0) {
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+ List<TableFiledDTO> list = getFieldListByTableId(tableId, 0);
|
|
|
+ List<String> outputColumn = new ArrayList<>();
|
|
|
+ for (TableFiledDTO v_data : list) {
|
|
|
+ outputColumn.add(v_data.getFiledName());
|
|
|
+ }
|
|
|
+
|
|
|
+ IntersectionTableWktVo intersectionTableWktVo = new IntersectionTableWktVo();
|
|
|
+ intersectionTableWktVo.setEwkt(eWkt);
|
|
|
+ intersectionTableWktVo.setTableIds(from_kj_ids);
|
|
|
+ intersectionTableWktVo.setTableName(v_table.getTableName());
|
|
|
+ String from_kj_data = httpAnalyseService.intersectionTableWkt(intersectionTableWktVo);
|
|
|
+ if (StringUtils.isEmpty(from_kj_data)) {
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+
|
|
|
+ TargetTableVo targetTableVo = new TargetTableVo();
|
|
|
+ targetTableVo.setTargetTableName(from_kj_data);
|
|
|
+ targetTableVo.setColumns(outputColumn);
|
|
|
+ targetTableVo.setRawTableName(v_table.getTableName());
|
|
|
+ targetTableVo.setIsGeography(false);
|
|
|
+ targetTableVo.setSrid(SRID);
|
|
|
+ targetTableVo.setSiweiArea(true);
|
|
|
+
|
|
|
+ List<Map> from_jg = httpAnalyseService.targetTable(targetTableVo);
|
|
|
+ if (from_jg == null || from_jg.size() <= 0) {
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+ return dataMapTransFormZh(from_jg, list);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Map dataSelectByPoint(String pointEWkt, String bsm) {
|