图层要素多条件查询(v2)
# 前言
相比于第一版本多条件查询升级了以下几点:
- 新增条件组查询,例如and,or 等自由组合的查询。
- 对接口的入参进行了语义化设置,并以前的一些字典值改成了中文。这样接口调试起来比较通俗易懂。
- 新增一系列异常捕获逻辑。让调用方知道自己接口出错错在哪儿。
- V2 不兼容 V1
postman调试api下载 (opens new window)
# (高级查询)单图层多条件查询
接口描述:
对该接口进行对接的时候请用写sql的思路来进行理解: 假如数据库的sql是如下:
select name,age from my_table where ( name is not null and name like "%CaiXuKun%" ) order by create_time
那么在该接口描述的伪代码就是:
select [distinctIs] <selectFieldName> from <fromTableId> where <wheres> order by <orders>
接口地址:/one-map-server/sys/geom/vector/v2/advancedQuery
请求方式:POST
请求数据类型:application/json
响应数据类型:*/*
请求示例:
{
"orders": [
{
"fieldName": "七级",
"condition": "升序"
}
],
"selectFieldName": [],
"resultFormat": "simple",
"fromTableId": "t_1876180138174562304",
"wheres": [
{
"andOr": "and",
"subWhere": [
{
"andOr": "and",
"value": "编码CS03",
"fieldName": "场所类别",
"operator": "全模糊匹配"
},
{
"andOr": "and",
"fieldName": "七级",
"value": "00690001",
"operator": "左模糊匹配"
}
]
},
{
"andOr": "or",
"subWhere": [
{
"andOr": "and",
"value": "重点目标",
"fieldName": "重点类型",
"operator": "等于"
},
{
"andOr": "or",
"value": "is not null ",
"fieldName": "重点等级",
"operator": "不为空"
}
]
}
]
}
请求参数:
| 参数名称 | 参数说明 | 默认值 | 是否必须 | 数据类型 |
|---|---|---|---|---|
| distinctIs | 是否对结果集去重 | false | false | boolean |
| resultFormat | 结果集的返回格式,可用值:{name: geojson;code: geojson},{name: simple;code: simple} | simple | false | string |
| fromTableId | 动态表id | true | string | |
| selectFieldName | 要查询的字段(不传就是查询全部字段) | false | array | |
| orders | 需要满足的排序信息 | false | array | |
| condition | 条件 ,高级查询查询条件可选值 | false | string | |
| fieldName | 字段名称 | false | string | |
| whereConditions | 需要满足的条件信息 | true | array | |
| andOr | 查询拼接条件,参见高级查询查询条件可选值 | 201 | false | string |
| fieldName | 字段名称 | false | string | |
| operator | 字段操作符 ,高级查询查询条件可选值 | false | string | |
| value | 要满足的值 | false | string |
响应参数:
| 参数名称 | 参数说明 | 类型 | schema |
|---|---|---|---|
| alertMsg | 提示消息 | string | |
| alertType | 提示消息类型 | integer(int32) | integer(int32) |
| code | 状态码 | integer(int32) | integer(int32) |
| data | 业务数据 | GtcPager«Map«string,object»» | GtcPager«Map«string,object»» |
| list | 业务数据 | Iterable«Map«string,object»» | Iterable«Map«string,object»» |
| pageNum | 当前页码 | integer(int32) | |
| pageParam | 分页参数 | GtcPageParam | GtcPageParam |
| pageNum | 当前页码 | integer | |
| pageSize | 总页数 | integer | |
| startRow | 游标开始行 | integer | |
| pageSize | 总页数 | integer(int32) | |
| startRow | 游标开始行 | integer(int64) | |
| total | 总条数 | integer(int64) | |
| location | 跳转地址 | string |
响应示例:
{
// 与<simpleQuery >的返回结果集一致
}
# 接口用于获取字段可选值
场景描述:
当你需要对一个字段获取到他在图层里面有哪些值的时候,可以用到这个接口
示例效果 
接口入参示例
{
"orders": [
{
"fieldName": "场所类别", // 如果有orderBy 的话,selectFieldName中必须和它一一对应
"condition": "升序"
}
],
"selectFieldName": ["场所类别"],
"resultFormat": "simple",
"distinctIs": true, // 必传!!!!!!
"fromTableId": "t_1876180138174562304",
"wheres": [
{
"andOr": "and",
"value": "编码CS03",
"fieldName": "场所类别",
"operator": "全模糊匹配"
}
]
}
返回结果示例
{
"code": 200,
"alertType": 0,
"alertMsg": null,
"data": {
"pageSize": 15,
"startRow": 15,
"pageNum": 1,
"pageParam": {
"pageSize": 15,
"startRow": 15,
"pageNum": 1
},
"total": 430,
"list": [
{
"名称": "红十月西一区"
},
{
"名称": null //这种null值也是存在的,你这边在进行下拉的时候注意过滤null值
},
{
"名称": "金鑫花园"
},
{
"名称": "自治区人民医院天池路59号院"
},
{
"名称": "汇玺小区"
},
{
"名称": "阳光雅润园二期"
},
{
"名称": "万和居"
},
{
"名称": "葛洲坝胜利路小区"
},
{
"名称": "新疆迎宾馆家属院"
},
{
"名称": "自治区妇联石泉巷家属院"
},
{
"名称": "胸科医院羊毛湖家属院"
},
{
"名称": "阿特兰特斯小区"
},
{
"名称": "吐曼金桥花园"
},
{
"名称": "达胜花园"
},
{
"名称": "八艺印刷厂家属院"
}
]
},
"location": null
}
# 接口直接返回geojson进行快速上图
场景描述:
当你需要在查询到要素的时候,不光列表能够看到,你的地图对象里面也能够马上看到地图 ,
这时候可以使用这种方式传参: 实现返回结果集为 geojson ,可以快速上图
示例效果 
接口入参示例
{
"orders": [
{
"fieldName": "七级",
"condition": "升序"
}
],
"selectFieldName": [],
"resultFormat": "simple",
"fromTableId": "t_1876180138174562304",
"wheres": [
// 。。。。。。。
]
}
返回结果示例
{
"code": 200,
"alertType": 0,
"alertMsg": null,
"data": {
"pageSize": 15,
"startRow": 15,
"pageNum": 1,
"pageParam": {
"pageSize": 15,
"startRow": 15,
"pageNum": 1
},
"total": 10,
"list": [ // 注意,这时候 list里面装的是一个 对象,geojson对象. 列表信息在geosjon的 features数组里面去拿
{
"features": [
{
"geometry": {
"coordinates": [
87.5946863575,
43.7735381466
],
"type": "Point"
},
"type": "Feature",
"properties": { // 要素信息
"gtc_id": "1797566524046766081"
// .....其他要素信息
}
}
// .... 其他属性信息
],
"type": "FeatureCollection"
}
]
},
"location": null
}
# 接口进行要素内容模糊查询的同时进行空间查询
场景描述:
当图层的BBox非常大的时候,你需要查询某一个小范围的数据
比如: 图层范围是全国 ,你想在乌鲁木齐范围内进行查询名称为 上沙河的小区的时候.
接口入参示例
{
"orders": [],
"selectFieldName": [],
"resultFormat": "simple",
"fromTableId": "t_1876180138174562304",
"wheres": [
{
"andOr": "and",
"value": "编码CS03",
"fieldName": "场所类别",
"operator": "全模糊匹配"
},
{
"andOr": "201",
"fieldName": "the_geom",
"operator": "501",
"value": "MULTIPOLYGON (......)"//需要过滤的面的wkt字符串
}
]
}
返回结果示例
//同上
# 多条件组合嵌套子查询
假如数据库的sql是如下:
select name,age from my_table
where
(
( name is not null and name like "%CaiXuKun%" )
and
(name is not null and name like "%CaiXuKun%" )
or
(name is not null and name like "%CaiXuKun%" )
)
and name is not null
场景描述:
像这种括号与子条件递归嵌套的查询,高级查询也能够支持. 具体参见下面的请求入参, 一定一定需要注意括号关系
这里我只能举例,因为我词穷,我实在不知道该如何语义化描述.
接口入参示例
{
"orderByConditions": [],
"selectFileld": [],
"tableId": "t_1836681087XXXX0",
"whereConditions": [
[{
"andor": "201",
"field": "the_geom",
"operator": "501",
"condition": "POLYGON ((........))"
}, {
"andor": "201",
"childConditionVos": [ // 主要是通过这个 子对象数组进行嵌套子条件
{
"andor": "201",
"childConditionVos": [{ // 这个子对象支持递归,理论上你往里面再塞个十级八级也行
"andor": "201",
"condition": "VA",
"field": "FA",
"operator": "103"
},
{
"andor": "201",
"condition": "VB",
"field": "FB",
"operator": "103"
}]
},
{
"andor": "201",
"childConditionVos": [{
"andor": "201",
"condition": "VC",
"field": "FC",
"operator": "103"
}, {
"andor": "201",
"condition": "VD",
"field": "FD",
"operator": "103"
}]
}
]
}]
]
}
上面的请求入参构建出来的查询sql将会是如下:
select *
FROM
"v_biz_183668108763XXXXXX0" AS T
WHERE
( ...... ) //空间范围过滤条件
AND ( ( "FA" = 'VA' AND "FB" = 'VB' ) AND ( "FC" = 'VC' AND "FD" = 'VD' ) )
上次更新: 2026/03/31, 15:42:55