feat: expose vehicle map data APIs

This commit is contained in:
lingniu
2026-08-03 19:55:38 +08:00
parent 3c4bece72c
commit 8539af13e6
8 changed files with 492 additions and 7 deletions

View File

@@ -45,6 +45,10 @@ Content-Type: application/json</pre>
<p class="note">查询日没有有效里程但此前存在有效累计里程时,日里程补 0累计总里程、来源协议和数据时间沿用最近有效统计updatedAt 显示上一个统计周期的计算时间。</p>
<h3><span class="method">POST</span>/api/v1/vehicles/total-mileage/query</h3>
<p>按 VIN 和北京时间查询不晚于指定时刻的最近一条总里程,返回实际采集协议、记录时间和时间差秒数。</p>
<h3><span class="method">POST</span>/api/v1/vehicles/realtime/query</h3>
<p>查询当前有效授权车辆的最新位置、在线及运动状态、速度、累计里程、实际协议和记录时间。请求体传 <code>{}</code> 返回全部授权车辆。</p>
<h3><span class="method">POST</span>/api/v1/hydrogen-stations/query</h3>
<p>只读查询资产管理库中有有效坐标的加氢站;可按 <code>province</code><code>city</code><code>cooperateOnly</code> 筛选。</p>
<h2>总里程协议口径</h2>
<table>
@@ -100,6 +104,15 @@ Content-Type: application/json</pre>
}'</pre>
<p class="note">下一页保持原请求参数不变,并传入上一页 nextCursor同一次分页查询的 snapshotId 保持不变。</p>
<h3>实时车辆与全部加氢站</h3>
<pre>curl -X POST 'https://your-host/api/v1/vehicles/realtime/query' \
-H 'Authorization: Bearer YOUR_32_CHARACTER_APP_KEY' \
-H 'Content-Type: application/json' -d '{}'
curl -X POST 'https://your-host/api/v1/hydrogen-stations/query' \
-H 'Authorization: Bearer YOUR_32_CHARACTER_APP_KEY' \
-H 'Content-Type: application/json' -d '{}'</pre>
<h2>响应示例</h2>
<h3>车辆单日里程</h3>
<pre>{

View File

@@ -1,11 +1,11 @@
openapi: 3.0.3
info:
title: 车辆数据开放平台 API
version: 1.5.0
version: 1.6.0
license:
name: Proprietary
description: |
向授权合作方开放车辆单日用氢量、单日里程、区间日里程指定时刻总里程。
向授权合作方开放车辆单日用氢量、单日里程、区间日里程指定时刻总里程、实时位置状态及加氢站地图点位
appKey 和逐车授权必须完整覆盖查询自然日。
servers:
- url: /
@@ -160,6 +160,67 @@ paths:
$ref: '#/components/responses/Forbidden'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/vehicles/realtime/query:
post:
tags: [合作方数据接口]
summary: 查询授权车辆实时位置与状态
description: |
plateNumbers 省略或传空数组时返回应用当前有效授权的全部车辆。
实时来源优先级为 GB32960 > YUTONG_MQTT > JT808所有来源超过10分钟时改按最新记录选择。
记录时间距当前不超过60秒视为在线在线且速度大于3km/h为行驶中否则为静止中。
operationId: queryRealtimeVehicles
security:
- AppKeyAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RealtimeVehicleQuery'
example: {}
responses:
'200':
description: 查询成功;没有实时记录的授权车辆以 NO_DATA 返回
content:
application/json:
schema:
$ref: '#/components/schemas/RealtimeVehicleQueryResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'500':
$ref: '#/components/responses/InternalError'
/api/v1/hydrogen-stations/query:
post:
tags: [合作方数据接口]
summary: 查询加氢站地图点位
description: 只读返回资产管理数据库内具有有效经纬度的加氢站,可按省、市和合作状态筛选;无需车辆授权但要求有效 appKey。
operationId: queryHydrogenStations
security:
- AppKeyAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/HydrogenStationQuery'
example: {}
responses:
'200':
description: 查询成功
content:
application/json:
schema:
$ref: '#/components/schemas/HydrogenStationQueryResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
/api/v2/open-platform/apps:
get:
tags: [开放平台管理]
@@ -430,6 +491,32 @@ components:
type: string
enum: [GB32960, YUTONG_MQTT, JT808]
description: 可选;只接受平台统一协议标识;不传时按 GB32960 > YUTONG_MQTT > JT808
RealtimeVehicleQuery:
type: object
additionalProperties: false
properties:
plateNumbers:
type: array
maxItems: 2000
uniqueItems: true
items:
type: string
minLength: 1
maxLength: 32
description: 可选;省略或传空数组时查询当前有效授权的全部车辆
HydrogenStationQuery:
type: object
additionalProperties: false
properties:
province:
type: string
maxLength: 32
city:
type: string
maxLength: 32
cooperateOnly:
type: boolean
description: true仅合作站false仅外部站省略则返回全部
HydrogenResult:
type: object
required: [plateNumber, date, hydrogenConsumptionKg, status]
@@ -614,6 +701,55 @@ components:
properties:
data:
$ref: '#/components/schemas/TotalMileageResult'
RealtimeVehicleResult:
type: object
required: [vin, plateNumber, online, motionStatus, locationAvailable, status]
properties:
vin: { type: string }
plateNumber: { type: string }
protocol: { type: string, enum: [GB32960, YUTONG_MQTT, JT808] }
longitude: { type: number, format: double, nullable: true }
latitude: { type: number, format: double, nullable: true }
speedKmh: { type: number, format: double, nullable: true }
totalMileageKm: { type: number, format: double, nullable: true }
recordTime: { type: string }
timeDifferenceSeconds: { type: integer, format: int64, minimum: 0 }
online: { type: boolean }
motionStatus: { type: string, enum: [driving, idle, offline] }
locationAvailable: { type: boolean }
status: { $ref: '#/components/schemas/DataStatus' }
RealtimeVehicleQueryResponse:
allOf:
- $ref: '#/components/schemas/SuccessEnvelope'
- type: object
required: [data]
properties:
data:
type: array
items: { $ref: '#/components/schemas/RealtimeVehicleResult' }
HydrogenStation:
type: object
required: [id, name, longitude, latitude, cooperative]
properties:
id: { type: string, description: 站点ID使用字符串避免JavaScript整数精度损失 }
name: { type: string }
shortName: { type: string }
address: { type: string }
longitude: { type: number, format: double }
latitude: { type: number, format: double }
province: { type: string }
city: { type: string }
district: { type: string }
cooperative: { type: boolean }
HydrogenStationQueryResponse:
allOf:
- $ref: '#/components/schemas/SuccessEnvelope'
- type: object
required: [data]
properties:
data:
type: array
items: { $ref: '#/components/schemas/HydrogenStation' }
SuccessEnvelope:
type: object
required: [code, message, traceId]