feat(B09): 단가연결 즉시 금액(뒤에서 서버 셈) · [저장] 단추 · 옮길 때 물음(PLAN 702-3)
- 새 산근(로직 연결 · 입력값) = 연결 즉시 뒤에서 POST …/estimation/calc(화면 캐시로 셈 · 저장 안 함) · 차례 번호 · 옛 요청 끊기 · 오는 동안 그 줄 금액 칸만 「셈 중」 · 잠금 없음 (새 `B09_Estimation_UI_Live.ts`) · 기준 = payload.user(서버가 그 셈에 쓴 값) - 조작 중 셈 = 마지막 GET · [저장] 의 B08 원천 다시 씀(120 s · 0.6 → 0.15 s) · [저장] · GET 은 늘 새로 읽음 - [저장] 단추 = 왼쪽 아래 [초기화] 옆(B08 과 같은 부품 · 꼴) · 고침 없으면 알림만 - 단계 이동 · [>] = 저장 안 한 고침 있으면 공용 떠남 물음(취소 · 폐기 · 저장) — 옛 자동 저장 없앰 - 서고 사본 payload 의 user 받음(서버 기준) — 화면 캐시와 다른 로직 줄은 뒤에서 다시 셈 - 낡은 시험 고침: 481-2 · 298-2(자동 저장 → 물음 · [저장] 단추) · 184-3 · 304(단추 줄) · 204-2(user 받음) · 200-2(701-3 띠 · 702-1 펼침 뒤 셸 꼴) - 확인 = test_702_3 3 · B09 관련 312 통과 · typecheck 0 · 검증_sub5 T6 11 누름 · 연결 뒤 0.32~0.49 s 금액 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
POST /api/projects/{id}/estimation/prices {user?}
|
||||
[단가 갱신] — 수요 단가 전부를 지금 M01 값으로 새로 굳힘 · user = 화면 캐시(296 ·
|
||||
지운 줄 · 그 사본은 수요에서 뺌 · 저장은 안 함) · M01 원본이 지워진 줄 = 굳힌 값 그대로
|
||||
POST /api/projects/{id}/estimation/calc {user}
|
||||
조작 중 서버 셈(702-3 · 단가연결 즉시 금액) — 화면 캐시로 GET 꼴 셈 · 저장 안 함
|
||||
POST /api/projects/{id}/estimation/logic-preview {code, given, rate, picks}
|
||||
「운반 단가」 모달 계산 절차(253-3) — 그 로직 한 산근을 프로젝트 단가로 풀어 글 줄 · 단가 ·
|
||||
저장 안 함(`render_sangeun_text` 를 `Sangeun.Solver` 로) · `blocks` = 칸 나눔(277-2)
|
||||
@@ -38,6 +40,7 @@ import asyncio
|
||||
import copy
|
||||
import importlib
|
||||
import logging
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
@@ -80,6 +83,25 @@ except ImportError: # pragma: no cover
|
||||
router = APIRouter(prefix="/api/projects", tags=["B09 Estimation"])
|
||||
|
||||
|
||||
# 702-3 조작 중 셈 = 마지막 GET · [저장] 이 읽은 B08 원천 다시 씀(B08 은 B09 조작으로 안 바뀜)
|
||||
# ponytail: 시간 창만 봄 — 창 안에 남이 B08 을 고치면 미리보기만 옛 수량 · [저장] 은 늘 새로 읽음
|
||||
B08_REUSE_S = 120.0
|
||||
_b08_seen: dict[UUID, tuple[float, dict[str, Any], list[str]]] = {}
|
||||
|
||||
|
||||
async def _b08_for(project_id: UUID, notes: list[str], reuse: bool) -> dict[str, Any]:
|
||||
"""B08 원천 — reuse = 시간 창 안 마지막 값(사본) · 아니면 새로 읽고 남김."""
|
||||
seen = _b08_seen.get(project_id)
|
||||
if reuse and seen and time.monotonic() - seen[0] < B08_REUSE_S:
|
||||
notes.extend(seen[2])
|
||||
return copy.deepcopy(seen[1])
|
||||
mine: list[str] = []
|
||||
out = await _b08(project_id, mine)
|
||||
_b08_seen[project_id] = (time.monotonic(), copy.deepcopy(out), mine)
|
||||
notes.extend(mine)
|
||||
return out
|
||||
|
||||
|
||||
async def _b08(project_id: UUID, notes: list[str]) -> dict[str, Any]:
|
||||
"""B08 수량 원천 — 못 읽으면 빈칸 + 알림(B09 는 B08 를 고치지 않음)."""
|
||||
out: dict[str, Any] = {}
|
||||
@@ -170,10 +192,10 @@ async def _demand(root: Path, draft: dict[str, Any] | None = None) -> list[str]:
|
||||
|
||||
|
||||
async def payload(
|
||||
project_id: UUID, root: Path, draft: dict[str, Any] | None = None
|
||||
project_id: UUID, root: Path, draft: dict[str, Any] | None = None, reuse_b08: bool = False
|
||||
) -> dict[str, Any]:
|
||||
notes: list[str] = []
|
||||
b08 = await _b08(project_id, notes)
|
||||
b08 = await _b08_for(project_id, notes, reuse_b08)
|
||||
keys = await _demand(root, draft)
|
||||
if not keys:
|
||||
notes.append(
|
||||
@@ -182,7 +204,8 @@ async def payload(
|
||||
book = await asyncio.to_thread(store.read_book, root)
|
||||
inputs = await asyncio.to_thread(prices.build_inputs, book, keys, b08["materials"])
|
||||
hauls = await asyncio.to_thread(haul_routes, root)
|
||||
user = await asyncio.to_thread(store.read_user, root)
|
||||
# 702-3 draft = 화면 캐시로 셈(저장 안 함) · 없으면 저장 값
|
||||
user = await asyncio.to_thread(store.read_user, root) if draft is None else draft
|
||||
calc = await asyncio.to_thread(library.resolve_hauls, root, {**user, **haul_user(hauls)})
|
||||
inputs["bill"] = bill_items({**b08, **calc, "haul_routes": hauls})
|
||||
inputs["hopyo"] = hopyo_prices(root)
|
||||
@@ -276,6 +299,14 @@ async def refresh_prices(
|
||||
return await payload(project_id, root, draft)
|
||||
|
||||
|
||||
@router.post("/{project_id}/estimation/calc")
|
||||
async def calc_estimation(project_id: UUID, body: dict[str, Any] = Body(...)) -> dict[str, Any]:
|
||||
"""702-3 조작 중 서버 셈 — 화면 캐시(user)로 GET 꼴 셈 · 저장 안 함 · 단가 = 굳힌 책
|
||||
(없는 줄 = 지금 M01 · [저장] 때 책에 굳힘 → 같은 값)."""
|
||||
root = await _project_root(project_id)
|
||||
return await payload(project_id, root, store.clean_user(body.get("user")), reuse_b08=True)
|
||||
|
||||
|
||||
class PreviewBody(BaseModel):
|
||||
code: str = Field(min_length=1, max_length=40)
|
||||
given: dict[str, Any] = Field(default_factory=dict)
|
||||
|
||||
Reference in New Issue
Block a user