feat(timeseries): unify element history queries
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"contracts": {
|
||||
"server": {
|
||||
"file": "server-v1.openapi.json",
|
||||
"sha256": "fb720e3009948c3cb2f37674d0bbdbb7b6136973223eccca89880475697435bc"
|
||||
"sha256": "b565d841061c9091f48ff3118bcc0cbb1b918b0cb8c2316d177570e8b2d8ba29"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+238
-357
@@ -982,6 +982,224 @@
|
||||
"title": "BurstLocationRequestRest",
|
||||
"type": "object"
|
||||
},
|
||||
"ElementHistoryQuery": {
|
||||
"properties": {
|
||||
"elements": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ElementHistoryTarget"
|
||||
},
|
||||
"maxItems": 200,
|
||||
"minItems": 1,
|
||||
"title": "Elements",
|
||||
"type": "array"
|
||||
},
|
||||
"end_time": {
|
||||
"format": "date-time",
|
||||
"title": "End Time",
|
||||
"type": "string"
|
||||
},
|
||||
"mode": {
|
||||
"$ref": "#/components/schemas/HistoryMode",
|
||||
"default": "observed"
|
||||
},
|
||||
"run_id": {
|
||||
"anyOf": [
|
||||
{
|
||||
"format": "uuid",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Run Id"
|
||||
},
|
||||
"start_time": {
|
||||
"format": "date-time",
|
||||
"title": "Start Time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"start_time",
|
||||
"end_time",
|
||||
"elements"
|
||||
],
|
||||
"title": "ElementHistoryQuery",
|
||||
"type": "object"
|
||||
},
|
||||
"ElementHistoryResponse": {
|
||||
"properties": {
|
||||
"series": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ElementHistorySeries"
|
||||
},
|
||||
"title": "Series",
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"series"
|
||||
],
|
||||
"title": "ElementHistoryResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"ElementHistorySeries": {
|
||||
"properties": {
|
||||
"device_id": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Device Id"
|
||||
},
|
||||
"display_unit": {
|
||||
"description": "Recommended UI display unit",
|
||||
"title": "Display Unit",
|
||||
"type": "string"
|
||||
},
|
||||
"element_id": {
|
||||
"title": "Element Id",
|
||||
"type": "string"
|
||||
},
|
||||
"element_type": {
|
||||
"$ref": "#/components/schemas/HistoryElementType"
|
||||
},
|
||||
"metric": {
|
||||
"$ref": "#/components/schemas/HistoryMetric"
|
||||
},
|
||||
"points": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/HistoryPoint"
|
||||
},
|
||||
"title": "Points",
|
||||
"type": "array"
|
||||
},
|
||||
"source": {
|
||||
"$ref": "#/components/schemas/HistorySource"
|
||||
},
|
||||
"source_unit": {
|
||||
"description": "Unit used by the returned point values",
|
||||
"title": "Source Unit",
|
||||
"type": "string"
|
||||
},
|
||||
"unit_inferred": {
|
||||
"default": false,
|
||||
"title": "Unit Inferred",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"element_id",
|
||||
"element_type",
|
||||
"metric",
|
||||
"source",
|
||||
"source_unit",
|
||||
"display_unit",
|
||||
"points"
|
||||
],
|
||||
"title": "ElementHistorySeries",
|
||||
"type": "object"
|
||||
},
|
||||
"ElementHistoryTarget": {
|
||||
"properties": {
|
||||
"device_ids": {
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"maxItems": 100,
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Device Ids"
|
||||
},
|
||||
"element_id": {
|
||||
"maxLength": 128,
|
||||
"minLength": 1,
|
||||
"title": "Element Id",
|
||||
"type": "string"
|
||||
},
|
||||
"element_type": {
|
||||
"$ref": "#/components/schemas/HistoryElementType"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"element_id",
|
||||
"element_type"
|
||||
],
|
||||
"title": "ElementHistoryTarget",
|
||||
"type": "object"
|
||||
},
|
||||
"HistoryElementType": {
|
||||
"enum": [
|
||||
"pipe",
|
||||
"junction"
|
||||
],
|
||||
"title": "HistoryElementType",
|
||||
"type": "string"
|
||||
},
|
||||
"HistoryMetric": {
|
||||
"enum": [
|
||||
"flow",
|
||||
"pressure"
|
||||
],
|
||||
"title": "HistoryMetric",
|
||||
"type": "string"
|
||||
},
|
||||
"HistoryMode": {
|
||||
"enum": [
|
||||
"observed",
|
||||
"realtime_comparison",
|
||||
"analysis_comparison"
|
||||
],
|
||||
"title": "HistoryMode",
|
||||
"type": "string"
|
||||
},
|
||||
"HistoryPoint": {
|
||||
"properties": {
|
||||
"time": {
|
||||
"format": "date-time",
|
||||
"title": "Time",
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Value"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"time",
|
||||
"value"
|
||||
],
|
||||
"title": "HistoryPoint",
|
||||
"type": "object"
|
||||
},
|
||||
"HistorySource": {
|
||||
"enum": [
|
||||
"scada_raw",
|
||||
"scada_cleaned",
|
||||
"realtime_simulation",
|
||||
"analysis_simulation"
|
||||
],
|
||||
"title": "HistorySource",
|
||||
"type": "string"
|
||||
},
|
||||
"JsonValue": {},
|
||||
"LeakageIdentifyRequestRest": {
|
||||
"properties": {
|
||||
@@ -2409,6 +2627,10 @@
|
||||
],
|
||||
"title": "Longitude"
|
||||
},
|
||||
"measurement_unit": {
|
||||
"title": "Measurement Unit",
|
||||
"type": "string"
|
||||
},
|
||||
"node_id": {
|
||||
"anyOf": [
|
||||
{
|
||||
@@ -2465,6 +2687,7 @@
|
||||
"required": [
|
||||
"device_id",
|
||||
"device_type",
|
||||
"measurement_unit",
|
||||
"transmission_mode",
|
||||
"transmission_frequency"
|
||||
],
|
||||
@@ -35146,58 +35369,10 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/timeseries/views/element-scada-readings": {
|
||||
"get": {
|
||||
"description": "获取link/node关联的SCADA监测值\n\n根据传入的link/node id,匹配SCADA信息,\n如果存在关联的SCADA device_id,获取实际的监测数据。\n\nArgs:\n element_id: 管网元素ID\n start_time: 查询开始时间\n end_time: 查询结束时间\n use_cleaned: 是否使用清洗后的数据,默认为False使用原始数据\n timescale_conn: TimescaleDB连接\n postgres_conn: PostgreSQL连接\n \nReturns:\n 管网元素关联的SCADA监测数据\n \nRaises:\n HTTPException: 当查询参数无效时返回400错误,未找到关联数据返回404错误",
|
||||
"operationId": "get_timeseries_views_element_scada_readings",
|
||||
"/api/v1/timeseries/views/element-history/query": {
|
||||
"post": {
|
||||
"operationId": "post_timeseries_views_element_history_query",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "管网元素ID(管道或节点)",
|
||||
"in": "query",
|
||||
"name": "element_id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"description": "管网元素ID(管道或节点)",
|
||||
"title": "Element Id",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "查询开始时间",
|
||||
"in": "query",
|
||||
"name": "start_time",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"description": "查询开始时间",
|
||||
"format": "date-time",
|
||||
"title": "Start Time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "查询结束时间",
|
||||
"in": "query",
|
||||
"name": "end_time",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"description": "查询结束时间",
|
||||
"format": "date-time",
|
||||
"title": "End Time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "是否使用清洗后的数据",
|
||||
"in": "query",
|
||||
"name": "use_cleaned",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"default": false,
|
||||
"description": "是否使用清洗后的数据",
|
||||
"title": "Use Cleaned",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "X-Project-Id",
|
||||
@@ -35208,12 +35383,22 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ElementHistoryQuery"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/JsonValue"
|
||||
"$ref": "#/components/schemas/ElementHistoryResponse"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -35285,311 +35470,7 @@
|
||||
"OAuth2PasswordBearer": []
|
||||
}
|
||||
],
|
||||
"summary": "获取管网元素关联的SCADA监测数据",
|
||||
"tags": [
|
||||
"TimescaleDB - Composite"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/timeseries/views/element-simulations": {
|
||||
"get": {
|
||||
"description": "获取link/node模拟值\n\n根据传入的featureInfos,找到关联的link/node,\n并根据对应的type,查询对应的模拟数据。支持查询实时或分析运行数据。\n\nArgs:\n start_time: 查询开始时间\n end_time: 查询结束时间\n feature_infos: 格式为 \"element_id1:type1,element_id2:type2\"\n 例如: \"P1:pipe,J1:junction\"\n run_id: 分析运行 ID,若为空则查询实时数据\n timescale_conn: TimescaleDB连接\n \nReturns:\n 管网元素的模拟数据\n \nRaises:\n HTTPException: 当feature_infos为空返回400错误,未找到数据返回404错误,其他错误返回400错误",
|
||||
"operationId": "get_timeseries_views_element_simulations",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "查询开始时间",
|
||||
"in": "query",
|
||||
"name": "start_time",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"description": "查询开始时间",
|
||||
"format": "date-time",
|
||||
"title": "Start Time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "查询结束时间",
|
||||
"in": "query",
|
||||
"name": "end_time",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"description": "查询结束时间",
|
||||
"format": "date-time",
|
||||
"title": "End Time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "特征信息,格式: id1:type1,id2:type2,type为pipe(管道)或junction(节点)",
|
||||
"in": "query",
|
||||
"name": "feature_infos",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"description": "特征信息,格式: id1:type1,id2:type2,type为pipe(管道)或junction(节点)",
|
||||
"title": "Feature Infos",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "分析运行 ID;为空时查询实时数据",
|
||||
"in": "query",
|
||||
"name": "run_id",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"format": "uuid",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "分析运行 ID;为空时查询实时数据",
|
||||
"title": "Run Id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "X-Project-Id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"title": "X-Project-Id",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/JsonValue"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Successful Response"
|
||||
},
|
||||
"401": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Authentication required"
|
||||
},
|
||||
"403": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Insufficient permission"
|
||||
},
|
||||
"404": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Resource not found"
|
||||
},
|
||||
"409": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Resource conflict"
|
||||
},
|
||||
"422": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Validation error"
|
||||
},
|
||||
"503": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Dependency unavailable"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"OAuth2PasswordBearer": []
|
||||
}
|
||||
],
|
||||
"summary": "获取管网元素的模拟数据",
|
||||
"tags": [
|
||||
"TimescaleDB - Composite"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/timeseries/views/scada-simulations": {
|
||||
"get": {
|
||||
"description": "获取SCADA关联的link/node模拟值\n\n根据传入的SCADA device_ids,找到关联的link/node,\n并根据对应的type,查询对应的模拟数据。支持查询实时或分析运行数据。\n\nArgs:\n start_time: 查询开始时间\n end_time: 查询结束时间\n device_ids: SCADA设备ID列表,用逗号分隔\n run_id: 分析运行 ID,若为空则查询实时数据\n timescale_conn: TimescaleDB连接\n postgres_conn: PostgreSQL连接\n \nReturns:\n SCADA关联的模拟数据\n \nRaises:\n HTTPException: 当查询参数无效时返回400错误,未找到数据时返回404错误",
|
||||
"operationId": "get_timeseries_views_scada_simulations",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "查询开始时间",
|
||||
"in": "query",
|
||||
"name": "start_time",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"description": "查询开始时间",
|
||||
"format": "date-time",
|
||||
"title": "Start Time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "查询结束时间",
|
||||
"in": "query",
|
||||
"name": "end_time",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"description": "查询结束时间",
|
||||
"format": "date-time",
|
||||
"title": "End Time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "SCADA设备ID列表,逗号分隔",
|
||||
"in": "query",
|
||||
"name": "device_ids",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"description": "SCADA设备ID列表,逗号分隔",
|
||||
"title": "Device Ids",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "分析运行 ID;为空时查询实时数据",
|
||||
"in": "query",
|
||||
"name": "run_id",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"format": "uuid",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "分析运行 ID;为空时查询实时数据",
|
||||
"title": "Run Id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "X-Project-Id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"title": "X-Project-Id",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/JsonValue"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Successful Response"
|
||||
},
|
||||
"401": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Authentication required"
|
||||
},
|
||||
"403": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Insufficient permission"
|
||||
},
|
||||
"404": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Resource not found"
|
||||
},
|
||||
"409": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Resource conflict"
|
||||
},
|
||||
"422": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Validation error"
|
||||
},
|
||||
"503": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Dependency unavailable"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"OAuth2PasswordBearer": []
|
||||
}
|
||||
],
|
||||
"summary": "获取SCADA关联的模拟数据",
|
||||
"summary": "批量查询管网元素历史数据",
|
||||
"tags": [
|
||||
"TimescaleDB - Composite"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user