[fix] 재협상 가격협상 흐름 정비 — 무한루프·카드 연출·요약카드
agent 가격협상 무한 루프 수정 + 선행 chat_server 의 가격협상 연출(카드 스크립트 + 협상지표 게이지) 복원, 버짓 확인 입력가 표시 버그, 요약카드 공급사 담당자/날짜 표시 정비. - agent: 가격협상 루프를 라운드 상한(MAX_ROUNDS)으로 종료(카드선택 실패해도 종료 보장 — 기존엔 카드소진에만 의존해 무한 입력). chat_server iteration>=3 동작 복원. - agent: 가격협상 턴에 선택 카드 스크립트(scripts_cards.json)를 script 로 렌더 + 협상지표(indicator.py, 1~99/PZ) 산출해 indicator_value/bot_chat_type 전달. Res_Chat 에 indicator/bot_chat_type, Req_Chat 에 item_price 추가. - agent: 가격협상_확인 멘트에 할인율(discount_rate) 표시, 가격협상_확인_버짓이 target 이 아니라 입력가(input_price)를 표시하도록 수정. - backend: item_price(기존 공급가) 를 agent 로 전달. 요약카드 공급사 담당자 정보를 supplier_users(빈 이메일) 대신 partner.suppliers.manager_* 에서 조회, ChatSummary.supplier_manager_phone 추가. - frontend: 요약카드 협상 개시/종료 시각을 "YYYY년 MM월 dd일 HH시 MM분 SS초"(KST) 로, 공급 계약 만료일(+1년) ISO 파싱, 우선협상 대상자에 공급사 연락처/이메일 표시. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1630b3d20c
commit
1d4e5816b2
12 files changed
+176
-41
No files matched your search
@@ -44,6 +44,7 @@ class AgentChatContext:
|
||||
rq_type: str = "재협상" # 재협상 | 재견적
|
||||
target_price: int = 0 # 갑 목표 매입가(원)
|
||||
anchor_price: int = 0 # 앵커링가(목표가보다 낮음). quotation_settings.anchoring_value 로 계산.
|
||||
item_price: int = 0 # 기존 공급가(품목 기준가). agent 가격협상_확인 인하율 산출용.
|
||||
# 핸드오프 #4: agent 의 RL 상태(state) 계산 입력.
|
||||
# partner_count 는 견적당 세션 수로 산출(실데이터). 나머지 3개는 우리 스키마에 데이터 소스가 없어
|
||||
# 기본값으로 보낸다 → agent 가 실제값을 받으려면 backend 스키마에 컬럼 추가 필요(HANDOFF.md ④).
|
||||
@@ -75,6 +76,7 @@ class HttpAgentClient(IAgentClient):
|
||||
"user_input": user_input,
|
||||
"target_price": ctx.target_price,
|
||||
"anchor_price": ctx.anchor_price,
|
||||
"item_price": ctx.item_price,
|
||||
# 핸드오프 #4: RL state 입력 (agent Req_Chat 이 받는 필드). 현재 기본값.
|
||||
"revenue_amount": ctx.revenue_amount,
|
||||
"distribution_code": ctx.distribution_code,
|
||||
|
||||
@@ -18,7 +18,7 @@ from fastapi import Depends
|
||||
from sqlalchemy import func, select
|
||||
|
||||
from common.database.db_session_manager import DB_SESSION_MNG
|
||||
from common.database.model.models import chats, items, quotation_settings, quotations, sessions, supplier_users, suppliers
|
||||
from common.database.model.models import chats, items, quotation_settings, quotations, sessions, suppliers
|
||||
from common.enums import ChatSender, DBWRType, DeliveryType, ErrorType, QuotationStatus, SessionStatus
|
||||
from common.logger import LOG
|
||||
from common.models.gmodel import UserInfo
|
||||
@@ -369,10 +369,12 @@ class ChatService:
|
||||
partner_count = await self._count_partners(sess)
|
||||
# revenue_amount / distribution_code / acceptance_ratio 는 현재 스키마에 데이터 소스가 없어
|
||||
# AgentChatContext 기본값으로 보낸다(HANDOFF #4 — 컬럼 추가/소스 합의 필요).
|
||||
# 기존 공급가(품목 기준가) — agent 가격협상_확인 인하율(discount_rate) 산출 입력.
|
||||
item_price = int(item.price) if item is not None and item.price else 0
|
||||
return AgentChatContext(
|
||||
tenant_id=tenant_id, rq_type=rq_type,
|
||||
target_price=target_price, anchor_price=anchor, partner_count=partner_count,
|
||||
client_step=client_step,
|
||||
item_price=item_price, client_step=client_step,
|
||||
)
|
||||
|
||||
async def _resolve_anchor_price(self, sess, target_price: int) -> int:
|
||||
@@ -499,24 +501,20 @@ class ChatService:
|
||||
async def _build_summary(self, sess, quote, item, final_price: Optional[int], last_price: Optional[int]) -> dict:
|
||||
"""협상 결과 요약 카드 데이터 조립(item + 견적 담당 MD + 공급사/담당자 + 최종 제시가).
|
||||
종료 스텝에서 1회만 호출. item/last_price 는 호출부(send)에서 1회 조회해 넘겨준다(중복 조회 제거)."""
|
||||
def _supplier_name(s):
|
||||
stmt = select(suppliers.name).where(suppliers.supplier_id == sess.supplier_id).limit(1)
|
||||
return DB_SESSION_MNG.execute(s, stmt)
|
||||
|
||||
err_type, rows = await DB_SESSION_MNG.execute_lambda(suppliers.DBType(), DBWRType.DB_READ.value, _supplier_name)
|
||||
supplier_name = rows[0] if err_type == ErrorType.SUCCESS and rows else ""
|
||||
|
||||
# 공급사 담당자(로그인 계정) 이름/이메일
|
||||
def _supplier_user(s):
|
||||
# 우선협상 대상자(공급사) + 담당자 정보. 담당자명/이메일/연락처는 partner.suppliers 에 영속된 값을 쓴다
|
||||
# (supplier_users 는 로그인 계정이라 이메일이 비어 있을 수 있어, 요약 카드엔 공급사 담당자 정보를 사용).
|
||||
def _supplier(s):
|
||||
stmt = (
|
||||
select(supplier_users.name, supplier_users.email)
|
||||
.where(supplier_users.supplier_id == sess.supplier_id, supplier_users.deleted == False) # noqa: E712
|
||||
.limit(1)
|
||||
select(suppliers.name, suppliers.manager_name, suppliers.manager_email, suppliers.manager_contact_number)
|
||||
.where(suppliers.supplier_id == sess.supplier_id).limit(1)
|
||||
)
|
||||
return DB_SESSION_MNG.execute(s, stmt)
|
||||
|
||||
err_type, su_rows = await DB_SESSION_MNG.execute_lambda(supplier_users.DBType(), DBWRType.DB_READ.value, _supplier_user)
|
||||
sup_mgr_name, sup_mgr_email = (su_rows[0][0], su_rows[0][1]) if err_type == ErrorType.SUCCESS and su_rows else ("", "")
|
||||
err_type, rows = await DB_SESSION_MNG.execute_lambda(suppliers.DBType(), DBWRType.DB_READ.value, _supplier)
|
||||
if err_type == ErrorType.SUCCESS and rows:
|
||||
supplier_name, sup_mgr_name, sup_mgr_email, sup_mgr_phone = rows[0]
|
||||
else:
|
||||
supplier_name = sup_mgr_name = sup_mgr_email = sup_mgr_phone = ""
|
||||
|
||||
# 최종 제시가: 가장 최근 유저 제시가(없으면 입찰가/목표가 폴백). last_price 는 호출부에서 전달.
|
||||
resolved_price = int(last_price if last_price else (final_price or 0))
|
||||
@@ -553,6 +551,7 @@ class ChatService:
|
||||
supplier_name=supplier_name or "",
|
||||
supplier_manager_name=sup_mgr_name or "",
|
||||
supplier_manager_email=sup_mgr_email or "",
|
||||
supplier_manager_phone=sup_mgr_phone or "",
|
||||
delivery_type=delivery_label,
|
||||
).model_dump()
|
||||
|
||||
|
||||
Reference in new issue
Block a user