260710_1
This commit is contained in:
@@ -26,6 +26,7 @@ from B06_wf3_ProfileCross.B06_wf3_ProfileCross_Schema import (
|
||||
SectionSummaryResponse,
|
||||
)
|
||||
from common_util.common_util_storage import resolve_stored_project_path
|
||||
from common_util.common_util_workflow_state import complete_stage, fail_stage, start_stage
|
||||
from config.config_db import get_db_pool
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -51,7 +52,22 @@ async def generate_sections(
|
||||
"""확정 경로에서 종횡단을 생성·저장하고 DB에 기록한다."""
|
||||
pool = get_db_pool()
|
||||
try:
|
||||
params = {
|
||||
"route_id": request.route_id,
|
||||
"filter_key": request.filter_key,
|
||||
"method": request.method,
|
||||
"smooth": request.smooth,
|
||||
"station_interval_m": request.station_interval_m,
|
||||
"cross_half_width_m": request.cross_half_width_m,
|
||||
"cross_sample_interval_m": request.cross_sample_interval_m,
|
||||
"long_sample_interval_m": request.long_sample_interval_m,
|
||||
"crs": request.crs,
|
||||
}
|
||||
async with pool.acquire() as connection:
|
||||
async with connection.cursor() as cursor:
|
||||
await start_stage(cursor, str(project_id), 3, params)
|
||||
await connection.commit()
|
||||
|
||||
stored_path = await get_project_storage_relative_path(connection, project_id)
|
||||
project_root = Path(resolve_stored_project_path(stored_path))
|
||||
|
||||
@@ -91,6 +107,8 @@ async def generate_sections(
|
||||
route_id=request.route_id,
|
||||
sections=design["cross_sections"],
|
||||
)
|
||||
async with connection.cursor() as cursor:
|
||||
await complete_stage(cursor, str(project_id), 3)
|
||||
await connection.commit()
|
||||
except Exception:
|
||||
await connection.rollback()
|
||||
@@ -105,13 +123,25 @@ async def generate_sections(
|
||||
longitudinal_file_path=design["longitudinal"]["file_path"],
|
||||
)
|
||||
except LookupError as exc:
|
||||
async with pool.acquire() as connection, connection.cursor() as cursor:
|
||||
await fail_stage(cursor, str(project_id), 3, str(exc))
|
||||
await connection.commit()
|
||||
return JSONResponse(status_code=404, content={"status": "error", "message": str(exc)})
|
||||
except FileNotFoundError as exc:
|
||||
async with pool.acquire() as connection, connection.cursor() as cursor:
|
||||
await fail_stage(cursor, str(project_id), 3, str(exc))
|
||||
await connection.commit()
|
||||
return JSONResponse(status_code=404, content={"status": "error", "message": str(exc)})
|
||||
except (OSError, ValueError) as exc:
|
||||
async with pool.acquire() as connection, connection.cursor() as cursor:
|
||||
await fail_stage(cursor, str(project_id), 3, str(exc))
|
||||
await connection.commit()
|
||||
return JSONResponse(status_code=400, content={"status": "error", "message": str(exc)})
|
||||
except Exception:
|
||||
except Exception as exc:
|
||||
logger.exception("B06 종횡단 생성 실패: project_id=%s", project_id)
|
||||
async with pool.acquire() as connection, connection.cursor() as cursor:
|
||||
await fail_stage(cursor, str(project_id), 3, str(exc))
|
||||
await connection.commit()
|
||||
return JSONResponse(
|
||||
status_code=500,
|
||||
content={"status": "error", "message": "종횡단 생성 처리 중 오류가 발생했습니다."},
|
||||
@@ -137,7 +167,9 @@ async def get_sections(project_id: UUID, route_id: int) -> SectionSummaryRespons
|
||||
|
||||
|
||||
@router.post("/{project_id}/sections/{route_id}/confirm", response_model=SectionConfirmResponse)
|
||||
async def confirm_sections(project_id: UUID, route_id: int) -> SectionConfirmResponse | JSONResponse:
|
||||
async def confirm_sections(
|
||||
project_id: UUID, route_id: int
|
||||
) -> SectionConfirmResponse | JSONResponse:
|
||||
"""경로의 종횡단면을 확정(CONFIRMED)한다."""
|
||||
pool = get_db_pool()
|
||||
try:
|
||||
@@ -151,6 +183,8 @@ async def confirm_sections(project_id: UUID, route_id: int) -> SectionConfirmRes
|
||||
await connection.begin()
|
||||
try:
|
||||
await confirm_sections_for_route(connection, route_id)
|
||||
async with connection.cursor() as cursor:
|
||||
await complete_stage(cursor, str(project_id), 3)
|
||||
await connection.commit()
|
||||
except Exception:
|
||||
await connection.rollback()
|
||||
|
||||
Reference in New Issue
Block a user