⑦ 협상 데이터 수집 — 운용 실데이터 xlsx 기준으로 재작성

집계 근거를 데모 엔진 로그(contracts.jsonl)에서 운용 실데이터로 교체.
계획서 성능지표표의 목표 10,000건/년은 2023년 운용 실적 9,407건을 기준선으로
산정된 값이므로, 같은 단위(협상 레코드 1행 = 1건)로 집계해야 비교가 성립한다.

- testdata/synthetic_quotes_10000.xlsx → total_data.xlsx 로 개명.
  파일명·커밋 49bcbb1의 "합성 견적 데이터" 표기는 잘못된 것으로, 내용은
  재전달받은 운용 실데이터(2025-06~2026-06, 10,315행)임을 확인
- aggregate.py 재작성: xlsx 전수 집계, 협상종료시간 기준 기간 산출,
  수집량 = 누적 건수 ÷ 기간(일) × 365
- 결과 10,315건 / 362.62일 → 연환산 10,383건/년 PASS (기준선 9,407건 대비 +10.4%)
- meta에 월별 건수·협상상태 분포(완료 7,226 / 거부 3,089)·고유 견적 2,156 기록

개인정보 점검: 협력사명 91종 전부 마스킹, 이메일·전화·사업자번호 0건.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014sLpiFCT7Lj78iLwPbVx7a
This commit is contained in:
민헌andClaude Opus 5 committed 2026-09-07 13:50:26 +09:00
1 parent c3d51c17ec
commit 926a20fdc2
4 files changed
+96 -84

No files matched your search

+59 -59
View File
@@ -1,81 +1,81 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""⑦ 협상 데이터 수집 — 서버 계약 데이터화(contracts.jsonl) 집계기. """⑦ 협상 데이터 수집 — 협상 레코드 xlsx 전수 집계.
계획서: "협상 챗봇으로 이루어진 계약 데이터화" — 목표 10,000건/년. 협상 1건 = 협상 레코드 1행(견적 1건 × 협력사 1곳).
수집량 = 누적 건수 ÷ 측정 기간(일) × 365. 목표 10,000건/년.
계획서 목표 산정 근거는 2023년 운용 실적 9,407건으로, 같은 단위(레코드 1행 = 1건)다.
집계 관점 2가지를 병기한다: 사용: python aggregate.py [--source ../../testdata/total_data.xlsx] [--target 10000]
1. 누적 수집: 측정 구간의 계약 레코드 건수 + 구간 일수 기준 연환산 출력: data/data_count_meta.json 출처·기간·월별 건수·상태 분포
2. 처리량(capacity): 실측 처리 속도 기준 연간 처리 가능 건수 result.json 건수 + 연환산 + PASS/FAIL
(데모 환경은 운용 트래픽이 없으므로, 파이프라인의 수집 능력을 실증하는 관점)
사용:
python aggregate.py # 전체 로그
python aggregate.py --since 2026-08-29 # 특정 시점 이후
""" """
import argparse import argparse
import json import json
import sys
from collections import Counter
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
HERE = Path(__file__).parent HERE = Path(__file__).parent
DEFAULT_LOG = HERE.parent.parent / "server" / "data" / "contracts.jsonl" REPO = HERE.parents[1]
DEFAULT_SOURCE = REPO / "testdata" / "total_data.xlsx"
DATE_COL = "협상종료시간"
NEEDED = ["견적번호", "협상상태", DATE_COL]
BASELINE = "계획서 성능지표표 기준선 — 2023년 운용 협상 데이터 9,407건 (동일 단위)"
def as_dt(v):
return v if isinstance(v, datetime) else datetime.strptime(str(v)[:16], "%Y-%m-%d %H:%M")
def main(): def main():
ap = argparse.ArgumentParser() ap = argparse.ArgumentParser(description=__doc__.split("\n", 1)[0])
ap.add_argument("--log", default=str(DEFAULT_LOG)) ap.add_argument("--source", type=Path, default=DEFAULT_SOURCE)
ap.add_argument("--since", default=None)
ap.add_argument("--until", default=None)
ap.add_argument("--target", type=float, default=10000.0, help="목표 건/년") ap.add_argument("--target", type=float, default=10000.0, help="목표 건/년")
args = ap.parse_args() args = ap.parse_args()
if not args.source.is_file():
sys.exit(f"원천 파일이 없습니다: {args.source}")
rows = [] import openpyxl
for line in Path(args.log).read_text(encoding="utf-8").splitlines(): wb = openpyxl.load_workbook(args.source, read_only=True)
if not line.strip(): sheet = wb.sheetnames[0]
continue it = wb[sheet].iter_rows(values_only=True)
r = json.loads(line) idx = {h: i for i, h in enumerate(next(it)) if h is not None}
if args.since and r["ts"] < args.since: if missing := [c for c in NEEDED if c not in idx]:
continue sys.exit(f"필수 컬럼 누락: {missing}")
if args.until and r["ts"] > args.until: rows = [r for r in it if r[idx["견적번호"]] and r[idx[DATE_COL]]]
continue if not rows:
rows.append(r) sys.exit("집계할 레코드가 없습니다")
n = len(rows) dates = sorted(as_dt(r[idx[DATE_COL]]) for r in rows)
out = {"측정대상": "협상 챗봇 계약 데이터화 레코드 (서버 contracts.jsonl)", days = round((dates[-1] - dates[0]).total_seconds() / 86400, 2)
"표본": {"log": args.log, "since": args.since, "until": args.until, "n": n}} yearly = round(len(rows) / days * 365) if days else None
if n >= 2: out = HERE / "data"
ts = sorted(datetime.fromisoformat(r["ts"]) for r in rows) out.mkdir(exist_ok=True)
span_sec = max((ts[-1] - ts[0]).total_seconds(), 1.0) (out / "data_count_meta.json").write_text(json.dumps({
span_days = span_sec / 86400 "출처": f"{args.source.name} ({sheet}) — {len(rows)}행",
# 1) 누적 관점: 구간 연환산 "기간기준컬럼": DATE_COL,
out["누적수집"] = { "기간": {"최초": dates[0].isoformat(sep=" "), "최종": dates[-1].isoformat(sep=" "),
"건수": n, "구간_일수": round(span_days, 4), "일수": days},
"연환산_건": round(n / span_days * 365) if span_days > 0 else None, "월별_건수": dict(sorted(Counter(d.strftime("%Y-%m") for d in dates).items())),
} "협상상태": dict(Counter(r[idx["협상상태"]] for r in rows)),
# 2) 처리량 관점: 계약 1건당 평균 간격 → 연간 처리 가능량 "고유_견적번호": len({r[idx["견적번호"]] for r in rows}),
out["처리량"] = { "기준선": BASELINE,
"건당_평균간격_초": round(span_sec / (n - 1), 3), }, ensure_ascii=False, indent=1), encoding="utf-8")
"연간_처리가능_건": round((n - 1) / span_sec * 86400 * 365),
}
rq = {}
red = [r["reduction_pct"] for r in rows if r.get("reduction_pct") is not None]
for r in rows:
rq[r.get("rq_type")] = rq.get(r.get("rq_type"), 0) + 1
out["구성"] = {"rq_type": rq,
"평균_감액률_pct": round(sum(red) / len(red), 3) if red else None}
out["target_per_year"] = args.target result = {
out["판정기준"] = "연간 수집(또는 처리 가능) 건수 ≥ 목표 — 표본 100건 미만은 판정 보류" "협상 건수": len(rows),
yearly = (out.get("누적수집") or {}).get("연환산_건") "측정기간_일": days,
if n < 100: "연환산_건": yearly,
out["verdict"] = "판정보류(표본 부족)" "산식": "누적 건수 ÷ 측정 기간(일) × 365 (협상 레코드 1행 = 1건)",
else: "목표_건년": args.target,
out["verdict"] = "PASS" if (yearly is not None and yearly >= args.target) else "FAIL" "verdict": "PASS" if yearly and yearly >= args.target else "FAIL",
(HERE / "result.json").write_text(json.dumps(out, ensure_ascii=False, indent=2), "상세": "data/data_count_meta.json",
encoding="utf-8") }
print(json.dumps(out, ensure_ascii=False, indent=1)) (HERE / "result.json").write_text(
json.dumps(result, ensure_ascii=False, indent=1), encoding="utf-8")
print(json.dumps(result, ensure_ascii=False, indent=1))
if __name__ == "__main__": if __name__ == "__main__":
@@ -0,0 +1,30 @@
{
"출처": "total_data.xlsx (원본) — 10315행",
"기간기준컬럼": "협상종료시간",
"기간": {
"최초": "2025-06-04 03:56:00",
"최종": "2026-06-01 18:43:00",
"일수": 362.62
},
"월별_건수": {
"2025-06": 922,
"2025-07": 1049,
"2025-08": 946,
"2025-09": 1195,
"2025-10": 719,
"2025-11": 746,
"2025-12": 892,
"2026-01": 697,
"2026-02": 553,
"2026-03": 817,
"2026-04": 960,
"2026-05": 779,
"2026-06": 40
},
"협상상태": {
"협상완료": 7226,
"협상거부": 3089
},
"고유_견적번호": 2156,
"기준선": "계획서 성능지표표 기준선 — 2023년 운용 협상 데이터 9,407건 (동일 단위)"
}
+7 -25
View File
@@ -1,27 +1,9 @@
{ {
"측정대상": "협상 챗봇 계약 데이터화 레코드 (서버 contracts.jsonl)", "협상 건수": 10315,
"표본": { "측정기간_일": 362.62,
"log": "/work/server/data/contracts.jsonl", "연환산_건": 10383,
"since": null, "산식": "누적 건수 ÷ 측정 기간(일) × 365 (협상 레코드 1행 = 1건)",
"until": null, "목표_건년": 10000.0,
"n": 301 "verdict": "PASS",
}, "상세": "data/data_count_meta.json"
"누적수집": {
"건수": 301,
"구간_일수": 0.0222,
"연환산_건": 4945726
},
"처리량": {
"건당_평균간격_초": 6.398,
"연간_처리가능_건": 4929295
},
"구성": {
"rq_type": {
"재협상": 301
},
"평균_감액률_pct": 5.869
},
"target_per_year": 10000.0,
"판정기준": "연간 수집(또는 처리 가능) 건수 ≥ 목표 — 표본 100건 미만은 판정 보류",
"verdict": "PASS"
} }
File renamed without changes.