|
@@ -1,10 +1,7 @@
|
|
|
package com.onemap.apply.service.impl.table;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.onemap.apply.domain.table.TableDTO;
|
|
|
-import com.onemap.apply.domain.table.TableDataVo;
|
|
|
-import com.onemap.apply.domain.table.TableFiledDTO;
|
|
|
-import com.onemap.apply.domain.table.TableResRuleDTO;
|
|
|
+import com.onemap.apply.domain.table.*;
|
|
|
import com.onemap.apply.mapper.table.*;
|
|
|
import com.onemap.apply.service.analyse.HttpAnalyseService;
|
|
|
import com.onemap.apply.service.table.TableDataSelectService;
|
|
@@ -24,6 +21,10 @@ public class TableDataSelectServiceImpl implements TableDataSelectService {
|
|
|
@Resource
|
|
|
private TableMapper tableMapper;
|
|
|
@Resource
|
|
|
+ private TableLayerMapper tableLayerMapper;
|
|
|
+ @Resource
|
|
|
+ private TableLayerJgTempMapper tableLayerJgTempMapper;
|
|
|
+ @Resource
|
|
|
private TableDataSelectMapper tableDataSelectMapper;
|
|
|
@Resource
|
|
|
private HttpAnalyseService httpAnalyseService;
|
|
@@ -33,6 +34,325 @@ public class TableDataSelectServiceImpl implements TableDataSelectService {
|
|
|
private TableFiledMapper tableFiledMapper;
|
|
|
private final Integer SRID = 4525;
|
|
|
|
|
|
+ /**
|
|
|
+ * @param sourcePointWkt
|
|
|
+ * @param sourceLayerId
|
|
|
+ * @param sourceLayerType 0图层ID 1数据库表id
|
|
|
+ * @param queryTableId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map dataQueryByPoint(String sourcePointWkt, String sourceLayerId, String sourceLayerType, String queryTableId) {
|
|
|
+ System.out.println("进入点数据查询");
|
|
|
+ Map<String, Object> retMapData = new HashMap<>();
|
|
|
+ retMapData.put("base", "无数据");
|
|
|
+ if (StringUtils.isEmpty(sourcePointWkt)) {
|
|
|
+ return retMapData;
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+
|
|
|
+
|
|
|
+ if (TableLayerDTOPid == null || TableLayerDTOPid.size() == 0) {
|
|
|
+ List<List<TableDataVo>> retListData = new ArrayList<>();
|
|
|
+ //判断查询节点和源数据节点是否一致,一致代表查询当前节点详情
|
|
|
+ if (fromTableLayerDTO.getId().equals(queryTableLayerDTO.getId())) {
|
|
|
+ List<List<TableDataVo>> ret = queryIntersectsList(sourcePointWkt, queryTableId);
|
|
|
+ if (ret != null && ret.size() > 0) {
|
|
|
+ retMapData.put("base", null);
|
|
|
+ insetDataHandleGroup(ret, queryTableLayerDTO.getGroupcolumn(), uid);
|
|
|
+ }
|
|
|
+ retListData.addAll(ret);
|
|
|
+ retMapData.put("data", retListData);
|
|
|
+ retMapData.put("datalist", tableLayerJgTempMapper.queryTableLayerJgTempList(uid));
|
|
|
+ } else {
|
|
|
+ //判断查询节点和源数据节点是否一致,不一致先查询原始节点图层,之后根据图层信息,查询要查询图层的数据
|
|
|
+ List<Map> retListMap = queryIntersectsByPoint(sourcePointWkt, fromTableLayerDTO.getTableId());
|
|
|
+ if (retListMap != null && retListMap.size() > 0) {
|
|
|
+ for (Map mapData : retListMap) {
|
|
|
+ String geom = (String) mapData.get("geom");
|
|
|
+ List<List<TableDataVo>> ret = queryIntersectionList(geom, queryTableLayerDTO.getTableId());
|
|
|
+ if (ret != null && ret.size() > 0) {
|
|
|
+ retMapData.put("base", null);
|
|
|
+ insetDataHandleGroup(ret, queryTableLayerDTO.getGroupcolumn(), uid);
|
|
|
+ }
|
|
|
+ retListData.addAll(ret);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ retMapData.put("data", retListData);
|
|
|
+ retMapData.put("datalist", tableLayerJgTempMapper.queryTableLayerJgTempList(uid));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //判断查询节点和源数据节点是否一致,一致代表查询当前节点详情
|
|
|
+ if (fromTableLayerDTO.getId().equals(queryTableLayerDTO.getId())) {
|
|
|
+// List<List<TableDataVo>> ret = queryIntersectsList(sourcePointWkt, queryTableId);
|
|
|
+// if (ret != null && ret.size() > 0) {
|
|
|
+// retMapData.put("base", null);
|
|
|
+// retMapData.put("datalist", insetDataHandleGroup(ret, queryTableLayerDTO.getGroupcolumn(), uid));
|
|
|
+// }
|
|
|
+// retMapData.put("data", ret);
|
|
|
+ } else {
|
|
|
+ //判断查询节点和源数据节点是否一致,不一致先查询原始节点图层,之后根据图层信息,查询要查询图层的数据
|
|
|
+ List<Map> retListMap = queryIntersectsByPoint(sourcePointWkt, fromTableLayerDTO.getTableId());
|
|
|
+ if (retListMap != null && retListMap.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 (Map mapData : retListMap) {
|
|
|
+ String geom = (String) mapData.get("geom");
|
|
|
+
|
|
|
+ List<List<TableDataVo>> ret = queryIntersectionList(geom, layerDTO.getTableId());
|
|
|
+ if (ret != null && ret.size() > 0) {
|
|
|
+ retMapData.put("base", null);
|
|
|
+ v_d01.put("base", null);
|
|
|
+ insetDataHandleGroup(ret, layerDTO.getGroupcolumn(), v_uid);
|
|
|
+ retListData.addAll(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 (StringUtils.isEmpty(groupColumn)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String[] groupColumns = groupColumn.split(",", -1);
|
|
|
+ if (groupColumns.length < 3) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String groupValue = groupColumns[0];
|
|
|
+ String sumValue = groupColumns[1];
|
|
|
+ String geomValue = groupColumns[2];
|
|
|
+ List<TableLayerJgTempDTO> retList = new ArrayList<>();
|
|
|
+ for (List<TableDataVo> dataVo : tableData) {
|
|
|
+ TableLayerJgTempDTO map = new TableLayerJgTempDTO();
|
|
|
+ map.setId(uid);
|
|
|
+ for (TableDataVo tableVo : dataVo) {
|
|
|
+ if (tableVo.getFiled().equals(groupValue)) {
|
|
|
+ map.setGroupvalue(tableVo.getData().toString());
|
|
|
+ } else if (tableVo.getFiled().equals(sumValue)) {
|
|
|
+ map.setSumvalue(tableVo.getData().toString());
|
|
|
+ } else if (tableVo.getFiled().equals(geomValue)) {
|
|
|
+ map.setGeomvalue(tableVo.getData().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ retList.add(map);
|
|
|
+ }
|
|
|
+ tableLayerJgTempMapper.insertTableLayerJgTempList(retList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //取相交的函数
|
|
|
+ private List<Map> queryIntersectsByPoint(String eWkt, String tableId) {
|
|
|
+ List<Map> 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.setTableName(v_table.getTableName());
|
|
|
+ List<String> from_kj_ids = httpAnalyseService.intersectsTableWkt(intersectsTableWktVo);
|
|
|
+ if (from_kj_ids == null || from_kj_ids.size() <= 0) {
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+
|
|
|
+ RawTableVo rawTableVo = new RawTableVo();
|
|
|
+ rawTableVo.setRawTableName(v_table.getTableName());
|
|
|
+ rawTableVo.setSrid(SRID);
|
|
|
+ rawTableVo.setIds(from_kj_ids);
|
|
|
+ rawTableVo.setIsGeography(false);
|
|
|
+ rawTableVo.setSiweiArea(true);
|
|
|
+ List<Map> retDataList = httpAnalyseService.rawTable(rawTableVo);
|
|
|
+ if (retDataList == null || retDataList.size() <= 0) {
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+ return retDataList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //取相交的函数
|
|
|
+ private List<List<TableDataVo>> queryIntersectsList(String eWkt, 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.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> filedlist = getFieldListByTableId(tableId, 0);
|
|
|
+ List<String> outputColumn = new ArrayList<>();
|
|
|
+ for (TableFiledDTO v_data : filedlist) {
|
|
|
+ outputColumn.add(v_data.getFiledName());
|
|
|
+ }
|
|
|
+ RawTableVo rawTableVo = new RawTableVo();
|
|
|
+ rawTableVo.setRawTableName(v_table.getTableName());
|
|
|
+ rawTableVo.setSrid(SRID);
|
|
|
+ rawTableVo.setIds(from_kj_ids);
|
|
|
+ rawTableVo.setIsGeography(false);
|
|
|
+ rawTableVo.setColumns(outputColumn);
|
|
|
+ rawTableVo.setSiweiArea(true);
|
|
|
+ List<Map> retDataList = httpAnalyseService.rawTable(rawTableVo);
|
|
|
+ if (retDataList == null || retDataList.size() <= 0) {
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+ return dataMapTransFormZh(retDataList, filedlist);
|
|
|
+ }
|
|
|
+
|
|
|
+ //取并集的函数
|
|
|
+ private List<Map> queryIntersectionByPoint(String eWkt, String tableId) {
|
|
|
+ List<Map> 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.setTableName(v_table.getTableName());
|
|
|
+ List<String> from_kj_ids = httpAnalyseService.intersectsTableWkt(intersectsTableWktVo);
|
|
|
+ if (from_kj_ids == null || from_kj_ids.size() == 0) {
|
|
|
+ return retList;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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.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 from_jg;
|
|
|
+ }
|
|
|
+
|
|
|
+ //取并集的函数
|
|
|
+ private List<List<TableDataVo>> queryIntersectionList(String eWkt, 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.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) {
|
|
|
Map retList = new LinkedHashMap<>();
|
|
@@ -319,26 +639,15 @@ public class TableDataSelectServiceImpl implements TableDataSelectService {
|
|
|
}
|
|
|
Object siweiarea = v_data.get("siweiarea");
|
|
|
if (StringUtils.isNotNull(siweiarea)) {
|
|
|
- boolean show = false;
|
|
|
- for (TableFiledDTO v_filed_data : filedList) {
|
|
|
- String v_filedName = v_filed_data.getFiledName();
|
|
|
- if (v_filedName.equals("siweiarea")) {
|
|
|
- show = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (show) {
|
|
|
- // 面积
|
|
|
- TableDataVo tableDataVo = new TableDataVo();
|
|
|
- tableDataVo.setData(new BigDecimal(String.valueOf(siweiarea)).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
- tableDataVo.setFiledZH("面积");
|
|
|
- tableDataVo.setFiled("siweiarea");
|
|
|
- v_dataList.add(tableDataVo);
|
|
|
- }
|
|
|
+ // 面积
|
|
|
+ TableDataVo tableDataVo = new TableDataVo();
|
|
|
+ tableDataVo.setData(new BigDecimal(String.valueOf(siweiarea)).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
+ tableDataVo.setFiledZH("空间面积(平方米)");
|
|
|
+ tableDataVo.setFiled("siweiarea");
|
|
|
+ v_dataList.add(tableDataVo);
|
|
|
}
|
|
|
retList.add(v_dataList);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
return retList;
|
|
|
}
|
|
|
|
|
@@ -346,4 +655,19 @@ public class TableDataSelectServiceImpl implements TableDataSelectService {
|
|
|
List<TableFiledDTO> list = tableFiledMapper.getFiledDTOByTableId(tableId, isDisplay);
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TableLayerDTO> dataQueryLayer(String defaultType, String layerId) {
|
|
|
+ QueryWrapper<TableLayerDTO> queryTableLayerWrapper = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotBlank(defaultType)) {
|
|
|
+ queryTableLayerWrapper.eq("default_type", defaultType);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(layerId)) {
|
|
|
+ queryTableLayerWrapper.or(wq -> wq.ne("layer_id", layerId).or().isNull("layer_id"));
|
|
|
+ }
|
|
|
+ queryTableLayerWrapper.eq("pid", "0");
|
|
|
+ queryTableLayerWrapper.orderByAsc("sort");
|
|
|
+ return tableLayerMapper.selectList(queryTableLayerWrapper);
|
|
|
+ }
|
|
|
}
|