feat: extend operational investigation workflows
Generic Container CI/CD / test-build-publish (push) Successful in 3m53s
Server CI/CD v2 / build-test-publish-and-deploy (push) Successful in 3m52s

This commit is contained in:
2026-10-30 17:30:19 +08:00
parent 63af998045
commit 05183aff93
82 changed files with 4644 additions and 330 deletions
+5 -5
View File
@@ -1,4 +1,4 @@
"""Independent sample API for synthetic work orders and monitoring data."""
"""Project-scoped peripheral work orders, monitoring history and explicit test data."""
from typing import get_args
from uuid import UUID
@@ -34,8 +34,8 @@ async def store(request: Request, who: Identity = Depends(identity),
def create_app(settings: SampleSettings | None = None) -> FastAPI:
app = FastAPI(title="TJWater 外围系统模拟接入", version="1.0.0",
description="测试监测与核查反馈样板,不是正式工单平台或设备控制服务。")
app = FastAPI(title="TJWater 外围系统接入", version="1.0.0",
description="按项目管理业务工单与反馈、读取监测历史;测试数据保留独立来源标记。")
app.state.settings = settings or SampleSettings()
app.add_middleware(CORSMiddleware, allow_origins=app.state.settings.cors_origins,
allow_credentials=False, allow_methods=["GET", "POST", "PATCH", "DELETE"],
@@ -51,7 +51,7 @@ def create_app(settings: SampleSettings | None = None) -> FastAPI:
@app.get("/health")
def health():
return {"service": "peripheral-sample", "origin": "synthetic", "storage": "postgresql",
return {"service": "peripheral-sample", "origin": "system_data", "storage": "postgresql",
"status": "up", "storage_verified": False}
prefix = "/api/sample/v1"
@@ -59,7 +59,7 @@ def create_app(settings: SampleSettings | None = None) -> FastAPI:
@app.get(prefix + "/context", response_model=Context, responses=errors)
def context(request: Request, who: Identity = Depends(identity), db=Depends(store)):
return {"protocol_version": "tjwater-peripheral-sample@1", "origin": "synthetic",
return {"protocol_version": "tjwater-peripheral-sample@1", "origin": "system_data",
"project_id": who.project_id, "user_id": who.user_id, "can_write": who.can_write,
"scenarios": list(get_args(Scenario)) if request.app.state.settings.enable_faults else ["normal"],
"state_transitions": TRANSITIONS, "managed_resources": db.managed_resource_capabilities()}
+9 -3
View File
@@ -122,6 +122,7 @@ WorkOrderStatus = Literal[
]
Priority = Literal["low", "normal", "high", "urgent"]
WorkOrderType = Literal["general", "water_quality_complaint", "burst_report"]
WorkOrderOrigin = Literal["system_data"]
class CreateWorkOrder(Model):
request_id: UUID
title: Annotated[str, Field(min_length=1, max_length=200)]
@@ -131,6 +132,7 @@ class CreateWorkOrder(Model):
assignee: Annotated[str, Field(min_length=1, max_length=200)] | None = None
scheduled_at: WireDateTime | None = None
work_order_type: WorkOrderType = "general"
origin: WorkOrderOrigin = "system_data"
location: Annotated[str, Field(min_length=1, max_length=200)] | None = None
scenario_code: Annotated[str, Field(min_length=1, max_length=128)] | None = None
feedback_requirements: list[Text] = Field(default_factory=list)
@@ -193,7 +195,7 @@ class WorkOrder(Model):
priority: Priority
assignee: str | None
scheduled_at: WireDateTime | None
origin: Literal["synthetic"]
origin: WorkOrderOrigin
created_at: WireDateTime
updated_at: WireDateTime
created_by: str
@@ -208,7 +210,11 @@ class WorkOrder(Model):
@classmethod
def accept_legacy_document(cls, value):
if isinstance(value, dict):
return {key: item for key, item in value.items() if key != "subtasks"}
return {
key: "system_data" if key == "origin" else item
for key, item in value.items()
if key != "subtasks"
}
return value
@@ -314,7 +320,7 @@ class ManagedResourceCapabilities(Model):
class Context(Model):
protocol_version: Literal["tjwater-peripheral-sample@1"]
origin: Literal["synthetic"]
origin: Literal["system_data"]
project_id: UUID
user_id: UUID
can_write: StrictBool
+1 -1
View File
@@ -369,7 +369,7 @@ class PostgresStore:
now = datetime.now(timezone.utc).isoformat()
document = command.model_dump(mode="json", exclude={"request_id"}) | {
"work_order_id": str(uuid4()), "project_id": who.project_id, "revision": 1,
"origin": "synthetic", "created_at": now, "updated_at": now,
"origin": "system_data", "created_at": now, "updated_at": now,
"created_by": who.user_id, "updated_by": who.user_id,
"activity": [{"sequence": 1, "occurred_at": now, "actor": who.user_id,
"kind": "created", "title": "工单创建",