refactor(db)!: clean up business SQL access

- make realtime replacement and analysis result writes transactional\n- consolidate SCADA repositories and remove process-global project state\n- validate SCADA batches and use indexed GIS-backed business queries\n\nBREAKING CHANGE: remove the public analysis result writer and the pipeline-health network_name query parameter.
This commit is contained in:
2026-08-28 11:37:36 +08:00
parent b74799a39d
commit 9b095c7439
34 changed files with 859 additions and 921 deletions
+46 -122
View File
@@ -2340,6 +2340,48 @@
"title": "RunSimulationManuallyByDateRest",
"type": "object"
},
"ScadaReadingBatchItem": {
"properties": {
"cleaned_value": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Cleaned Value"
},
"device_id": {
"minLength": 1,
"title": "Device Id",
"type": "string"
},
"monitored_value": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Monitored Value"
},
"time": {
"format": "date-time",
"title": "Time",
"type": "string"
}
},
"required": [
"time",
"device_id"
],
"title": "ScadaReadingBatchItem",
"type": "object"
},
"SchedulingAnalysisRest": {
"properties": {
"pump_control": {
@@ -19116,7 +19158,7 @@
},
"/api/v1/pipeline-health-predictions": {
"get": {
"description": "预测管道健康状况\n\n根据管网名称和当前时间,查询管道信息和实时数据,\n使用随机生存森林模型预测管道的生存概率。\n\nArgs:\n query_time: 查询时间\n network_name: 管网名称(或数据库名称)\n timescale_conn: TimescaleDB连接\n\nReturns:\n 预测结果列表,每个元素包含 link_id 和对应的生存函数\n\nRaises:\n HTTPException: 当模型文件不存在返回404错误,其他错误返回400或500错误",
"description": "预测管道健康状况\n\n根据管网名称和当前时间,查询管道信息和实时数据,\n使用随机生存森林模型预测管道的生存概率。\n\nArgs:\n query_time: 查询时间\n timescale_conn: TimescaleDB连接\n\nReturns:\n 预测结果列表,每个元素包含 link_id 和对应的生存函数\n\nRaises:\n HTTPException: 当模型文件不存在返回404错误,其他错误返回400或500错误",
"operationId": "get_pipeline_health_predictions",
"parameters": [
{
@@ -33641,126 +33683,6 @@
]
}
},
"/api/v1/timeseries/analysis/runs/{run_id}/results": {
"post": {
"operationId": "post_timeseries_analysis_runs_run_id_results",
"parameters": [
{
"description": "分析运行 ID",
"in": "path",
"name": "run_id",
"required": true,
"schema": {
"description": "分析运行 ID",
"format": "uuid",
"title": "Run Id",
"type": "string"
}
},
{
"in": "header",
"name": "X-Project-Id",
"required": true,
"schema": {
"title": "X-Project-Id",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"title": "Payload",
"type": "object"
}
}
},
"required": true
},
"responses": {
"201": {
"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": "Store Analysis Results",
"tags": [
"TimescaleDB - Analysis"
]
}
},
"/api/v1/timeseries/analysis/runs/{run_id}/values": {
"get": {
"operationId": "get_timeseries_analysis_runs_run_id_values",
@@ -35526,8 +35448,10 @@
"schema": {
"description": "SCADA设备监测数据列表",
"items": {
"type": "object"
"$ref": "#/components/schemas/ScadaReadingBatchItem"
},
"maxItems": 10000,
"minItems": 1,
"title": "Data",
"type": "array"
}